fix: 修复Windows长路径前缀问题
路径处理优化: - 去掉Windows长路径前缀 \\\\?\\ 避免文件URL转换错误 - 在convertFileSrc之前清理路径格式 - 确保缩略图URL在所有平台上正确显示 修复内容: - 数据库读取的缩略图路径处理 - 新生成缩略图的路径处理 - 统一使用convertFileSrc确保跨平台兼容性 现在缩略图可以正确显示,不会因为Windows长路径前缀导致加载失败。
This commit is contained in:
parent
4d61fb69f3
commit
723575ba7e
|
|
@ -10,7 +10,7 @@ import {
|
||||||
Trash2,
|
Trash2,
|
||||||
FolderOpen
|
FolderOpen
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke, convertFileSrc } from '@tauri-apps/api/core';
|
||||||
import { SearchInput } from './InteractiveInput';
|
import { SearchInput } from './InteractiveInput';
|
||||||
import { InteractiveButton } from './InteractiveButton';
|
import { InteractiveButton } from './InteractiveButton';
|
||||||
|
|
||||||
|
|
@ -147,10 +147,12 @@ const ThumbnailDisplay: React.FC<ThumbnailDisplayProps> = ({
|
||||||
setThumbnailUrl(thumbnailCache.get(segmentId) || null);
|
setThumbnailUrl(thumbnailCache.get(segmentId) || null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log({ segment })
|
||||||
// 首先检查数据库中是否已有缩略图
|
// 首先检查数据库中是否已有缩略图
|
||||||
if (segment.segment.thumbnail_path) {
|
if (segment.segment.thumbnail_path) {
|
||||||
const thumbnailUrl = `file://${segment.segment.thumbnail_path}`;
|
// 去掉Windows长路径前缀 \\?\
|
||||||
|
const cleanPath = segment.segment.thumbnail_path.replace(/^\\\\\?\\/, '');
|
||||||
|
const thumbnailUrl = convertFileSrc(cleanPath);
|
||||||
setThumbnailUrl(thumbnailUrl);
|
setThumbnailUrl(thumbnailUrl);
|
||||||
// 更新缓存
|
// 更新缓存
|
||||||
setThumbnailCache(prev => new Map(prev.set(segmentId, thumbnailUrl)));
|
setThumbnailCache(prev => new Map(prev.set(segmentId, thumbnailUrl)));
|
||||||
|
|
@ -162,8 +164,10 @@ const ThumbnailDisplay: React.FC<ThumbnailDisplayProps> = ({
|
||||||
try {
|
try {
|
||||||
const thumbnailPath = await generateSegmentThumbnail(segment);
|
const thumbnailPath = await generateSegmentThumbnail(segment);
|
||||||
if (thumbnailPath) {
|
if (thumbnailPath) {
|
||||||
|
// 去掉Windows长路径前缀 \\?\
|
||||||
|
const cleanPath = thumbnailPath.replace(/^\\\\\?\\/, '');
|
||||||
// 转换为可访问的URL
|
// 转换为可访问的URL
|
||||||
const thumbnailUrl = `file://${thumbnailPath}`;
|
const thumbnailUrl = convertFileSrc(cleanPath);
|
||||||
setThumbnailUrl(thumbnailUrl);
|
setThumbnailUrl(thumbnailUrl);
|
||||||
|
|
||||||
// 更新缓存
|
// 更新缓存
|
||||||
|
|
@ -484,8 +488,7 @@ export const MaterialSegmentView: React.FC<MaterialSegmentViewProps> = ({ projec
|
||||||
<button
|
<button
|
||||||
key={option.value}
|
key={option.value}
|
||||||
onClick={() => setSelectedClassification(option.value)}
|
onClick={() => setSelectedClassification(option.value)}
|
||||||
className={`inline-flex items-center px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${
|
className={`inline-flex items-center px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${selectedClassification === option.value
|
||||||
selectedClassification === option.value
|
|
||||||
? 'bg-blue-100 text-blue-800 border border-blue-200'
|
? 'bg-blue-100 text-blue-800 border border-blue-200'
|
||||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200 border border-gray-200'
|
: 'bg-gray-100 text-gray-700 hover:bg-gray-200 border border-gray-200'
|
||||||
}`}
|
}`}
|
||||||
|
|
@ -510,8 +513,7 @@ export const MaterialSegmentView: React.FC<MaterialSegmentViewProps> = ({ projec
|
||||||
<button
|
<button
|
||||||
key={option.value}
|
key={option.value}
|
||||||
onClick={() => setSelectedModel(option.value)}
|
onClick={() => setSelectedModel(option.value)}
|
||||||
className={`inline-flex items-center px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${
|
className={`inline-flex items-center px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${selectedModel === option.value
|
||||||
selectedModel === option.value
|
|
||||||
? 'bg-green-100 text-green-800 border border-green-200'
|
? 'bg-green-100 text-green-800 border border-green-200'
|
||||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200 border border-gray-200'
|
: 'bg-gray-100 text-gray-700 hover:bg-gray-200 border border-gray-200'
|
||||||
}`}
|
}`}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue