fix(service-party-app): fix TypeScript compilation errors
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
88370691d1
commit
fcaa57605a
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ interface ShareItem {
|
|||
};
|
||||
}
|
||||
|
||||
export function Home() {
|
||||
export default function Home() {
|
||||
const navigate = useNavigate();
|
||||
const [shares, setShares] = useState<ShareItem[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 || '获取会话状态失败');
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<CreateSessionResult>;
|
||||
|
|
@ -104,9 +117,9 @@ interface ElectronAPI {
|
|||
testConnection: (url: string) => Promise<TestConnectionResult>;
|
||||
};
|
||||
storage: {
|
||||
listShares: () => Promise<ShareEntry[]>;
|
||||
listShares: () => Promise<ListSharesResult>;
|
||||
getShare: (id: string, password: string) => Promise<ShareEntry | null>;
|
||||
exportShare: (id: string, password: string) => Promise<{ success: boolean; filePath?: string; error?: string }>;
|
||||
exportShare: (id: string, password: string) => Promise<ExportShareResult>;
|
||||
importShare: (filePath: string, password: string) => Promise<{ success: boolean; share?: ShareEntry; error?: string }>;
|
||||
deleteShare: (id: string) => Promise<{ success: boolean; error?: string }>;
|
||||
getSettings: () => Promise<Settings | null>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue