From 50ca8c1e3a8bb9413d7519d0d1d8bfaa14b95ba3 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Jul 2025 01:31:32 +0800 Subject: [PATCH] fix --- src/pages/ProjectManagePage.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pages/ProjectManagePage.tsx b/src/pages/ProjectManagePage.tsx index bbe84fd..4a72b22 100644 --- a/src/pages/ProjectManagePage.tsx +++ b/src/pages/ProjectManagePage.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react' import { Plus, Edit, Trash2, Search, Save, X, FolderOpen, Package } from 'lucide-react' import { open } from '@tauri-apps/plugin-dialog' +import { convertFileSrc } from '@tauri-apps/api/core' import { ProjectService, Project } from '../services/projectService' const ProjectManagePage: React.FC = () => { @@ -16,6 +17,18 @@ const ProjectManagePage: React.FC = () => { product_image: '' }) + // 辅助函数:转换图片路径为Tauri可访问的URL + const getImageSrc = (imagePath: string): string => { + if (!imagePath) return '' + if (imagePath.startsWith('http')) return imagePath + try { + return convertFileSrc(imagePath) + } catch (error) { + console.error('Failed to convert file src:', error) + return '' + } + } + useEffect(() => { loadProjects() }, []) @@ -209,7 +222,7 @@ const ProjectManagePage: React.FC = () => { {project.product_image ? ( <> {project.product_name { @@ -400,7 +413,7 @@ const ProjectManagePage: React.FC = () => {

预览:

商品图片预览 {