From fcaa57605a97ad4cb3a26115ce017b33c01f6175 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 28 Dec 2025 07:27:12 -0800 Subject: [PATCH] fix(service-party-app): fix TypeScript compilation errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix import/export consistency (use default exports) - Add CSS module type declarations - Fix ElectronAPI type definitions (ListSharesResult, ExportShareResult) - Fix null checks for sessionInfo and session - Change build script to use npx tsc 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../services/service-party-app/package.json | 2 +- .../services/service-party-app/src/App.tsx | 12 ++++++------ .../service-party-app/src/components/Layout.tsx | 2 +- .../service-party-app/src/pages/Home.tsx | 2 +- .../service-party-app/src/pages/Join.tsx | 2 +- .../service-party-app/src/pages/Session.tsx | 2 +- .../service-party-app/src/types/css.d.ts | 10 ++++++++++ .../service-party-app/src/types/electron.d.ts | 17 +++++++++++++++-- 8 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 backend/mpc-system/services/service-party-app/src/types/css.d.ts diff --git a/backend/mpc-system/services/service-party-app/package.json b/backend/mpc-system/services/service-party-app/package.json index a00ad2eb..a3d86109 100644 --- a/backend/mpc-system/services/service-party-app/package.json +++ b/backend/mpc-system/services/service-party-app/package.json @@ -7,7 +7,7 @@ "dev": "concurrently \"npm run dev:vite\" \"npm run dev:electron\"", "dev:vite": "vite", "dev:electron": "wait-on http://localhost:5173 && electron .", - "build": "tsc && vite build && electron-builder", + "build": "npx tsc && vite build && electron-builder", "build:win": "npm run build -- --win", "build:mac": "npm run build -- --mac", "build:linux": "npm run build -- --linux", diff --git a/backend/mpc-system/services/service-party-app/src/App.tsx b/backend/mpc-system/services/service-party-app/src/App.tsx index b227c7f2..f1b2f1c6 100644 --- a/backend/mpc-system/services/service-party-app/src/App.tsx +++ b/backend/mpc-system/services/service-party-app/src/App.tsx @@ -1,10 +1,10 @@ import { Routes, Route, Navigate } from 'react-router-dom'; -import { Layout } from './components/Layout'; -import { Home } from './pages/Home'; -import { Join } from './pages/Join'; -import { Create } from './pages/Create'; -import { Session } from './pages/Session'; -import { Settings } from './pages/Settings'; +import Layout from './components/Layout'; +import Home from './pages/Home'; +import Join from './pages/Join'; +import Create from './pages/Create'; +import Session from './pages/Session'; +import Settings from './pages/Settings'; function App() { return ( diff --git a/backend/mpc-system/services/service-party-app/src/components/Layout.tsx b/backend/mpc-system/services/service-party-app/src/components/Layout.tsx index 5432d224..7b481868 100644 --- a/backend/mpc-system/services/service-party-app/src/components/Layout.tsx +++ b/backend/mpc-system/services/service-party-app/src/components/Layout.tsx @@ -13,7 +13,7 @@ const navItems = [ { path: '/settings', label: '设置', icon: '⚙️' }, ]; -export function Layout({ children }: LayoutProps) { +export default function Layout({ children }: LayoutProps) { const location = useLocation(); return ( diff --git a/backend/mpc-system/services/service-party-app/src/pages/Home.tsx b/backend/mpc-system/services/service-party-app/src/pages/Home.tsx index ccfc2685..5466d5fc 100644 --- a/backend/mpc-system/services/service-party-app/src/pages/Home.tsx +++ b/backend/mpc-system/services/service-party-app/src/pages/Home.tsx @@ -14,7 +14,7 @@ interface ShareItem { }; } -export function Home() { +export default function Home() { const navigate = useNavigate(); const [shares, setShares] = useState([]); const [loading, setLoading] = useState(true); diff --git a/backend/mpc-system/services/service-party-app/src/pages/Join.tsx b/backend/mpc-system/services/service-party-app/src/pages/Join.tsx index e057de21..37c1474b 100644 --- a/backend/mpc-system/services/service-party-app/src/pages/Join.tsx +++ b/backend/mpc-system/services/service-party-app/src/pages/Join.tsx @@ -40,7 +40,7 @@ export default function Join() { try { // 解析邀请码获取会话信息 const result = await window.electronAPI.grpc.validateInviteCode(codeToValidate); - if (result.success) { + if (result.success && result.sessionInfo) { setSessionInfo(result.sessionInfo); setStep('confirm'); } else { diff --git a/backend/mpc-system/services/service-party-app/src/pages/Session.tsx b/backend/mpc-system/services/service-party-app/src/pages/Session.tsx index 02123113..84c70734 100644 --- a/backend/mpc-system/services/service-party-app/src/pages/Session.tsx +++ b/backend/mpc-system/services/service-party-app/src/pages/Session.tsx @@ -34,7 +34,7 @@ export default function Session() { try { const result = await window.electronAPI.grpc.getSessionStatus(sessionId); - if (result.success) { + if (result.success && result.session) { setSession(result.session); } else { setError(result.error || '获取会话状态失败'); diff --git a/backend/mpc-system/services/service-party-app/src/types/css.d.ts b/backend/mpc-system/services/service-party-app/src/types/css.d.ts new file mode 100644 index 00000000..36b8affb --- /dev/null +++ b/backend/mpc-system/services/service-party-app/src/types/css.d.ts @@ -0,0 +1,10 @@ +// CSS 模块类型声明 +declare module '*.module.css' { + const classes: { [key: string]: string }; + export default classes; +} + +declare module '*.css' { + const content: string; + export default content; +} diff --git a/backend/mpc-system/services/service-party-app/src/types/electron.d.ts b/backend/mpc-system/services/service-party-app/src/types/electron.d.ts index ee122c8f..f6ab7044 100644 --- a/backend/mpc-system/services/service-party-app/src/types/electron.d.ts +++ b/backend/mpc-system/services/service-party-app/src/types/electron.d.ts @@ -94,6 +94,19 @@ interface SessionEvent { error?: string; } +interface ListSharesResult { + success: boolean; + data?: ShareEntry[]; + error?: string; +} + +interface ExportShareResult { + success: boolean; + data?: ArrayBuffer; + filePath?: string; + error?: string; +} + interface ElectronAPI { grpc: { createSession: (params: CreateSessionParams) => Promise; @@ -104,9 +117,9 @@ interface ElectronAPI { testConnection: (url: string) => Promise; }; storage: { - listShares: () => Promise; + listShares: () => Promise; getShare: (id: string, password: string) => Promise; - exportShare: (id: string, password: string) => Promise<{ success: boolean; filePath?: string; error?: string }>; + exportShare: (id: string, password: string) => Promise; importShare: (filePath: string, password: string) => Promise<{ success: boolean; share?: ShareEntry; error?: string }>; deleteShare: (id: string) => Promise<{ success: boolean; error?: string }>; getSettings: () => Promise;