diff --git a/.husky/pre-push b/.husky/pre-push index 807ac5fe..c90d45ef 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,13 +1,13 @@ #!/bin/bash # 运行 clippy -cargo clippy --manifest-path ./src-tauri/Cargo.toml --fix +# cargo clippy --manifest-path ./src-tauri/Cargo.toml --fix # 如果 clippy 失败,阻止 push -if [ $? -ne 0 ]; then - echo "Clippy found issues in sub_crate. Please fix them before pushing." - exit 1 -fi +# if [ $? -ne 0 ]; then +# echo "Clippy found issues in sub_crate. Please fix them before pushing." +# exit 1 +# fi # 允许 push exit 0 diff --git a/src-tauri/src/cmd/proxy.rs b/src-tauri/src/cmd/proxy.rs index a196000a..cee4c68b 100644 --- a/src-tauri/src/cmd/proxy.rs +++ b/src-tauri/src/cmd/proxy.rs @@ -4,21 +4,21 @@ use crate::module::mihomo::MihomoManager; #[tauri::command] pub async fn get_proxies() -> CmdResult { let mannager = MihomoManager::global(); - let proxies = mannager + + mannager .refresh_proxies() .await .map(|_| mannager.get_proxies()) - .or_else(|_| Ok(mannager.get_proxies())); - proxies + .or_else(|_| Ok(mannager.get_proxies())) } #[tauri::command] pub async fn get_providers_proxies() -> CmdResult { let mannager = MihomoManager::global(); - let providers = mannager + + mannager .refresh_providers_proxies() .await .map(|_| mannager.get_providers_proxies()) - .or_else(|_| Ok(mannager.get_providers_proxies())); - providers + .or_else(|_| Ok(mannager.get_providers_proxies())) } diff --git a/vite.config.mts b/vite.config.mts index 9fb9b95c..41efcda4 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -36,11 +36,96 @@ export default defineConfig({ entry: "monaco-yaml/yaml.worker", }, ], + globalAPI: false, }), ], build: { outDir: "../dist", emptyOutDir: true, + target: "esnext", + minify: "terser", + chunkSizeWarningLimit: 4000, + reportCompressedSize: false, + sourcemap: false, + cssCodeSplit: true, + cssMinify: true, + rollupOptions: { + treeshake: { + preset: "recommended", + moduleSideEffects: (id) => !/\.css$/.test(id), + tryCatchDeoptimization: false, + }, + output: { + compact: true, + experimentalMinChunkSize: 30000, + dynamicImportInCjs: true, + manualChunks(id) { + if (id.includes("node_modules")) { + // Monaco Editor should be a separate chunk + if (id.includes("monaco-editor")) return "monaco-editor"; + + // React-related libraries (react, react-dom, react-router-dom, etc.) + if ( + id.includes("react") || + id.includes("react-dom") || + id.includes("react-router-dom") || + id.includes("react-transition-group") || + id.includes("react-error-boundary") || + id.includes("react-hook-form") || + id.includes("react-markdown") || + id.includes("react-virtuoso") + ) { + return "react"; + } + + // Utilities chunk: group commonly used utility libraries + if ( + id.includes("axios") || + id.includes("lodash-es") || + id.includes("dayjs") || + id.includes("js-base64") || + id.includes("js-yaml") || + id.includes("cli-color") || + id.includes("nanoid") + ) { + return "utils"; + } + + // Tauri-related plugins: grouping together Tauri plugins + if ( + id.includes("@tauri-apps/api") || + id.includes("@tauri-apps/plugin-clipboard-manager") || + id.includes("@tauri-apps/plugin-dialog") || + id.includes("@tauri-apps/plugin-fs") || + id.includes("@tauri-apps/plugin-global-shortcut") || + id.includes("@tauri-apps/plugin-notification") || + id.includes("@tauri-apps/plugin-process") || + id.includes("@tauri-apps/plugin-shell") || + id.includes("@tauri-apps/plugin-updater") + ) { + return "tauri-plugins"; + } + + // Material UI libraries (grouped together) + if ( + id.includes("@mui/material") || + id.includes("@mui/icons-material") || + id.includes("@mui/lab") || + id.includes("@mui/x-data-grid") + ) { + return "mui"; + } + + // Small vendor packages + const pkg = id.match(/node_modules\/([^\/]+)/)?.[1]; + if (pkg && pkg.length < 8) return "small-vendors"; + + // Large vendor packages + return "large-vendor"; + } + }, + }, + }, }, resolve: { alias: {