feat: complete stage 4 cleanup and code formatting
This commit completes stage 4 of the refactoring plan, focusing on cleanup and optimization of the modernized codebase. ## Key Changes ### Code Cleanup - Remove legacy `src/lib/styles.ts` (no longer needed) - Remove old modal components (`ImportProgressModal.tsx`, `ProviderList.tsx`) - Streamline `src/lib/tauri-api.ts` from 712 lines to 17 lines (-97.6%) - Remove global `window.api` pollution - Keep only event listeners (`tauriEvents.onProviderSwitched`) - All API calls now use modular `@/lib/api/*` layer ### Type System - Clean up `src/vite-env.d.ts` (remove 156 lines of outdated types) - Remove obsolete global type declarations - All TypeScript checks pass with zero errors ### Code Formatting - Format all source files with Prettier (82 files) - Fix formatting issues in 15 files: - App.tsx and core components - MCP management components - Settings module components - Provider management components - UI components ### Documentation Updates - Update `REFACTORING_CHECKLIST.md` with stage 4 progress - Mark completed tasks in `REFACTORING_MASTER_PLAN.md` ## Impact **Code Reduction:** - Total: -1,753 lines, +384 lines (net -1,369 lines) - tauri-api.ts: 712 → 17 lines (-97.6%) - Removed styles.ts: -82 lines - Removed vite-env.d.ts declarations: -156 lines **Quality Improvements:** - ✅ Zero TypeScript errors - ✅ Zero TODO/FIXME comments - ✅ 100% Prettier compliant - ✅ Zero `window.api` references - ✅ Fully modular API layer ## Testing - [x] TypeScript compilation passes - [x] Code formatting validated - [x] No linting errors Stage 4 completion: 100% Ready for stage 5 (testing and bug fixes)
This commit is contained in:
25
src/App.tsx
25
src/App.tsx
@@ -11,7 +11,12 @@ import {
|
||||
useDeleteProviderMutation,
|
||||
useSwitchProviderMutation,
|
||||
} from "@/lib/query";
|
||||
import { providersApi, type AppType } from "@/lib/api";
|
||||
import {
|
||||
providersApi,
|
||||
settingsApi,
|
||||
type AppType,
|
||||
type ProviderSwitchEvent,
|
||||
} from "@/lib/api";
|
||||
import { extractErrorMessage } from "@/utils/errorUtils";
|
||||
import { AppSwitcher } from "@/components/AppSwitcher";
|
||||
import { ModeToggle } from "@/components/mode-toggle";
|
||||
@@ -25,11 +30,6 @@ import UsageScriptModal from "@/components/UsageScriptModal";
|
||||
import McpPanel from "@/components/mcp/McpPanel";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
interface ProviderSwitchEvent {
|
||||
appType: string;
|
||||
providerId: string;
|
||||
}
|
||||
|
||||
function App() {
|
||||
const { t } = useTranslation();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -56,7 +56,7 @@ function App() {
|
||||
|
||||
const setupListener = async () => {
|
||||
try {
|
||||
unsubscribe = await window.api.onProviderSwitched(
|
||||
unsubscribe = await providersApi.onSwitched(
|
||||
async (event: ProviderSwitchEvent) => {
|
||||
if (event.appType === activeApp) {
|
||||
await refetch();
|
||||
@@ -89,7 +89,7 @@ function App() {
|
||||
const handleOpenWebsite = useCallback(
|
||||
async (url: string) => {
|
||||
try {
|
||||
await window.api.openExternal(url);
|
||||
await settingsApi.openExternal(url);
|
||||
} catch (error) {
|
||||
const detail =
|
||||
extractErrorMessage(error) ||
|
||||
@@ -127,13 +127,13 @@ function App() {
|
||||
if (activeApp !== "claude") return;
|
||||
|
||||
try {
|
||||
const settings = await window.api.getSettings();
|
||||
const settings = await settingsApi.get();
|
||||
if (!settings?.enableClaudePluginIntegration) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isOfficial = provider.category === "official";
|
||||
await window.api.applyClaudePluginConfig({ official: isOfficial });
|
||||
await settingsApi.applyClaudePluginConfig({ official: isOfficial });
|
||||
|
||||
toast.success(
|
||||
isOfficial
|
||||
@@ -249,10 +249,7 @@ function App() {
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<AppSwitcher activeApp={activeApp} onSwitch={setActiveApp} />
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setIsMcpOpen(true)}
|
||||
>
|
||||
<Button variant="outline" onClick={() => setIsMcpOpen(true)}>
|
||||
MCP
|
||||
</Button>
|
||||
<Button onClick={() => setIsAddOpen(true)}>
|
||||
|
||||
Reference in New Issue
Block a user