perf: 优化依赖与首屏加载

This commit is contained in:
zhanjunhao
2026-10-28 11:37:15 +08:00
parent e91077a7f2
commit a2e5f6ef0e
11 changed files with 541 additions and 504 deletions
+106 -212
View File
@@ -55,7 +55,6 @@
}, },
"devDependencies": { "devDependencies": {
"@douyinfe/vite-plugin-semi": "^2.74.0-alpha.6", "@douyinfe/vite-plugin-semi": "^2.74.0-alpha.6",
"@so1ve/prettier-config": "^3.1.0",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.21", "autoprefixer": "^10.4.21",
"eslint": "8.57.0", "eslint": "8.57.0",
@@ -67,7 +66,7 @@
"postcss": "^8.5.3", "postcss": "^8.5.3",
"prettier": "^3.0.0", "prettier": "^3.0.0",
"tailwindcss": "^3", "tailwindcss": "^3",
"vite": "5.1.0" "vite": "5.4.21"
}, },
"engines": { "engines": {
"node": ">=22.13.0", "node": ">=22.13.0",
@@ -197,13 +196,6 @@
"url": "https://github.com/sponsors/antfu" "url": "https://github.com/sponsors/antfu"
} }
}, },
"node_modules/@astrojs/compiler": {
"version": "2.13.1",
"resolved": "https://registry.npmmirror.com/@astrojs/compiler/-/compiler-2.13.1.tgz",
"integrity": "sha512-f3FN83d2G/v32ipNClRKgYv30onQlMZX1vCeZMjPsMMPl1mDpmbl0+N5BYo4S/ofzqJyS5hvwacEo0CCVDn/Qg==",
"dev": true,
"license": "MIT"
},
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
"version": "7.29.7", "version": "7.29.7",
"resolved": "https://registry.npmmirror.com/@babel/code-frame/-/code-frame-7.29.7.tgz", "resolved": "https://registry.npmmirror.com/@babel/code-frame/-/code-frame-7.29.7.tgz",
@@ -962,9 +954,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
"integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==", "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==",
"cpu": [ "cpu": [
"ppc64" "ppc64"
], ],
@@ -979,9 +971,9 @@
} }
}, },
"node_modules/@esbuild/android-arm": { "node_modules/@esbuild/android-arm": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz",
"integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==", "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==",
"cpu": [ "cpu": [
"arm" "arm"
], ],
@@ -996,9 +988,9 @@
} }
}, },
"node_modules/@esbuild/android-arm64": { "node_modules/@esbuild/android-arm64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz",
"integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==", "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1013,9 +1005,9 @@
} }
}, },
"node_modules/@esbuild/android-x64": { "node_modules/@esbuild/android-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz",
"integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==", "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1030,9 +1022,9 @@
} }
}, },
"node_modules/@esbuild/darwin-arm64": { "node_modules/@esbuild/darwin-arm64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz",
"integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==", "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1047,9 +1039,9 @@
} }
}, },
"node_modules/@esbuild/darwin-x64": { "node_modules/@esbuild/darwin-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz",
"integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==", "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1064,9 +1056,9 @@
} }
}, },
"node_modules/@esbuild/freebsd-arm64": { "node_modules/@esbuild/freebsd-arm64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz",
"integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==", "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1081,9 +1073,9 @@
} }
}, },
"node_modules/@esbuild/freebsd-x64": { "node_modules/@esbuild/freebsd-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz",
"integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==", "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1098,9 +1090,9 @@
} }
}, },
"node_modules/@esbuild/linux-arm": { "node_modules/@esbuild/linux-arm": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz",
"integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==", "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==",
"cpu": [ "cpu": [
"arm" "arm"
], ],
@@ -1115,9 +1107,9 @@
} }
}, },
"node_modules/@esbuild/linux-arm64": { "node_modules/@esbuild/linux-arm64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz",
"integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==", "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1132,9 +1124,9 @@
} }
}, },
"node_modules/@esbuild/linux-ia32": { "node_modules/@esbuild/linux-ia32": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz",
"integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==", "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -1149,9 +1141,9 @@
} }
}, },
"node_modules/@esbuild/linux-loong64": { "node_modules/@esbuild/linux-loong64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz",
"integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==", "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==",
"cpu": [ "cpu": [
"loong64" "loong64"
], ],
@@ -1166,9 +1158,9 @@
} }
}, },
"node_modules/@esbuild/linux-mips64el": { "node_modules/@esbuild/linux-mips64el": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz",
"integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==", "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==",
"cpu": [ "cpu": [
"mips64el" "mips64el"
], ],
@@ -1183,9 +1175,9 @@
} }
}, },
"node_modules/@esbuild/linux-ppc64": { "node_modules/@esbuild/linux-ppc64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz",
"integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==", "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==",
"cpu": [ "cpu": [
"ppc64" "ppc64"
], ],
@@ -1200,9 +1192,9 @@
} }
}, },
"node_modules/@esbuild/linux-riscv64": { "node_modules/@esbuild/linux-riscv64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz",
"integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==", "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==",
"cpu": [ "cpu": [
"riscv64" "riscv64"
], ],
@@ -1217,9 +1209,9 @@
} }
}, },
"node_modules/@esbuild/linux-s390x": { "node_modules/@esbuild/linux-s390x": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz",
"integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==", "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==",
"cpu": [ "cpu": [
"s390x" "s390x"
], ],
@@ -1234,9 +1226,9 @@
} }
}, },
"node_modules/@esbuild/linux-x64": { "node_modules/@esbuild/linux-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz",
"integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==", "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1251,9 +1243,9 @@
} }
}, },
"node_modules/@esbuild/netbsd-x64": { "node_modules/@esbuild/netbsd-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz",
"integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==", "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1268,9 +1260,9 @@
} }
}, },
"node_modules/@esbuild/openbsd-x64": { "node_modules/@esbuild/openbsd-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz",
"integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==", "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1285,9 +1277,9 @@
} }
}, },
"node_modules/@esbuild/sunos-x64": { "node_modules/@esbuild/sunos-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz",
"integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==", "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -1302,9 +1294,9 @@
} }
}, },
"node_modules/@esbuild/win32-arm64": { "node_modules/@esbuild/win32-arm64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz",
"integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==", "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -1319,9 +1311,9 @@
} }
}, },
"node_modules/@esbuild/win32-ia32": { "node_modules/@esbuild/win32-ia32": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz",
"integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==", "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -1336,9 +1328,9 @@
} }
}, },
"node_modules/@esbuild/win32-x64": { "node_modules/@esbuild/win32-x64": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz",
"integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==", "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -3767,31 +3759,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/@so1ve/prettier-config": {
"version": "3.26.0",
"resolved": "https://registry.npmmirror.com/@so1ve/prettier-config/-/prettier-config-3.26.0.tgz",
"integrity": "sha512-DWiWczVdwbolZy/BKlFqsWWLkxarGAhtcyoS7K2u6BUXBFZg6V+87laCvs/UC/kHiucx/IvZXdf3CQtZfoYxxw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@so1ve/prettier-plugin-toml": "3.26.0",
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-jsdoc": "^1.8.0"
},
"peerDependencies": {
"prettier": "^3.7.4"
}
},
"node_modules/@so1ve/prettier-plugin-toml": {
"version": "3.26.0",
"resolved": "https://registry.npmmirror.com/@so1ve/prettier-plugin-toml/-/prettier-plugin-toml-3.26.0.tgz",
"integrity": "sha512-iFJpSndNdIMnzNKbdXXRqyA2rrLsVqePhX3m+ongWip3BFxmRpfW9pon2FTm7qsZrslu39wQ7wPvIuxbmXZe2g==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"prettier": "^3.7.4"
}
},
"node_modules/@splinetool/runtime": { "node_modules/@splinetool/runtime": {
"version": "0.9.526", "version": "0.9.526",
"resolved": "https://registry.npmmirror.com/@splinetool/runtime/-/runtime-0.9.526.tgz", "resolved": "https://registry.npmmirror.com/@splinetool/runtime/-/runtime-0.9.526.tgz",
@@ -6402,13 +6369,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/binary-searching": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/binary-searching/-/binary-searching-2.0.5.tgz",
"integrity": "sha512-v4N2l3RxL+m4zDxyxz3Ne2aTmiPn8ZUpKFpdPtO+ItW1NcTCXA7JeHG5GMBSvoKSkQZ9ycS+EouDVxYB9ufKWA==",
"dev": true,
"license": "MIT"
},
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "1.1.21", "version": "1.1.21",
"resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.21.tgz", "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.21.tgz",
@@ -6852,16 +6812,6 @@
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/comment-parser": {
"version": "1.4.9",
"resolved": "https://registry.npmmirror.com/comment-parser/-/comment-parser-1.4.9.tgz",
"integrity": "sha512-+2AvZKjJaNq9GQljm3tr0utwrig5BL+jgJGvz5rDpGKNIp+ojcRXWUwBbh/sGIi1QCprR6PsKFakub+w1v+4hQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 12.0.0"
}
},
"node_modules/compute-scroll-into-view": { "node_modules/compute-scroll-into-view": {
"version": "1.0.20", "version": "1.0.20",
"resolved": "https://registry.npmmirror.com/compute-scroll-into-view/-/compute-scroll-into-view-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/compute-scroll-into-view/-/compute-scroll-into-view-1.0.20.tgz",
@@ -8195,9 +8145,9 @@
} }
}, },
"node_modules/esbuild": { "node_modules/esbuild": {
"version": "0.19.12", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.19.12.tgz", "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz",
"integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==", "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
@@ -8208,29 +8158,29 @@
"node": ">=12" "node": ">=12"
}, },
"optionalDependencies": { "optionalDependencies": {
"@esbuild/aix-ppc64": "0.19.12", "@esbuild/aix-ppc64": "0.21.5",
"@esbuild/android-arm": "0.19.12", "@esbuild/android-arm": "0.21.5",
"@esbuild/android-arm64": "0.19.12", "@esbuild/android-arm64": "0.21.5",
"@esbuild/android-x64": "0.19.12", "@esbuild/android-x64": "0.21.5",
"@esbuild/darwin-arm64": "0.19.12", "@esbuild/darwin-arm64": "0.21.5",
"@esbuild/darwin-x64": "0.19.12", "@esbuild/darwin-x64": "0.21.5",
"@esbuild/freebsd-arm64": "0.19.12", "@esbuild/freebsd-arm64": "0.21.5",
"@esbuild/freebsd-x64": "0.19.12", "@esbuild/freebsd-x64": "0.21.5",
"@esbuild/linux-arm": "0.19.12", "@esbuild/linux-arm": "0.21.5",
"@esbuild/linux-arm64": "0.19.12", "@esbuild/linux-arm64": "0.21.5",
"@esbuild/linux-ia32": "0.19.12", "@esbuild/linux-ia32": "0.21.5",
"@esbuild/linux-loong64": "0.19.12", "@esbuild/linux-loong64": "0.21.5",
"@esbuild/linux-mips64el": "0.19.12", "@esbuild/linux-mips64el": "0.21.5",
"@esbuild/linux-ppc64": "0.19.12", "@esbuild/linux-ppc64": "0.21.5",
"@esbuild/linux-riscv64": "0.19.12", "@esbuild/linux-riscv64": "0.21.5",
"@esbuild/linux-s390x": "0.19.12", "@esbuild/linux-s390x": "0.21.5",
"@esbuild/linux-x64": "0.19.12", "@esbuild/linux-x64": "0.21.5",
"@esbuild/netbsd-x64": "0.19.12", "@esbuild/netbsd-x64": "0.21.5",
"@esbuild/openbsd-x64": "0.19.12", "@esbuild/openbsd-x64": "0.21.5",
"@esbuild/sunos-x64": "0.19.12", "@esbuild/sunos-x64": "0.21.5",
"@esbuild/win32-arm64": "0.19.12", "@esbuild/win32-arm64": "0.21.5",
"@esbuild/win32-ia32": "0.19.12", "@esbuild/win32-ia32": "0.21.5",
"@esbuild/win32-x64": "0.19.12" "@esbuild/win32-x64": "0.21.5"
} }
}, },
"node_modules/escalade": { "node_modules/escalade": {
@@ -13635,39 +13585,6 @@
"url": "https://github.com/prettier/prettier?sponsor=1" "url": "https://github.com/prettier/prettier?sponsor=1"
} }
}, },
"node_modules/prettier-plugin-astro": {
"version": "0.14.1",
"resolved": "https://registry.npmmirror.com/prettier-plugin-astro/-/prettier-plugin-astro-0.14.1.tgz",
"integrity": "sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@astrojs/compiler": "^2.9.1",
"prettier": "^3.0.0",
"sass-formatter": "^0.7.6"
},
"engines": {
"node": "^14.15.0 || >=16.0.0"
}
},
"node_modules/prettier-plugin-jsdoc": {
"version": "1.8.1",
"resolved": "https://registry.npmmirror.com/prettier-plugin-jsdoc/-/prettier-plugin-jsdoc-1.8.1.tgz",
"integrity": "sha512-XuMqBWTc3b/8eCOe+OlZlFy9Z413a7WOmF4i5hDGtjbtIFOdvRrVtGjXR2Feye3TrLWhkkkHheNXPTyYKxw3nA==",
"dev": true,
"license": "MIT",
"dependencies": {
"binary-searching": "^2.0.5",
"comment-parser": "^1.4.0",
"mdast-util-from-markdown": "^2.0.0"
},
"engines": {
"node": ">=14.13.1 || >=16.0.0"
},
"peerDependencies": {
"prettier": "^3.0.0"
}
},
"node_modules/pretty-ms": { "node_modules/pretty-ms": {
"version": "9.3.1", "version": "9.3.1",
"resolved": "https://registry.npmmirror.com/pretty-ms/-/pretty-ms-9.3.1.tgz", "resolved": "https://registry.npmmirror.com/pretty-ms/-/pretty-ms-9.3.1.tgz",
@@ -15616,13 +15533,6 @@
"integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==",
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/s.color": {
"version": "0.0.15",
"resolved": "https://registry.npmmirror.com/s.color/-/s.color-0.0.15.tgz",
"integrity": "sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==",
"dev": true,
"license": "MIT"
},
"node_modules/safe-array-concat": { "node_modules/safe-array-concat": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmmirror.com/safe-array-concat/-/safe-array-concat-1.1.4.tgz", "resolved": "https://registry.npmmirror.com/safe-array-concat/-/safe-array-concat-1.1.4.tgz",
@@ -15739,16 +15649,6 @@
"@parcel/watcher": "^2.4.1" "@parcel/watcher": "^2.4.1"
} }
}, },
"node_modules/sass-formatter": {
"version": "0.7.9",
"resolved": "https://registry.npmmirror.com/sass-formatter/-/sass-formatter-0.7.9.tgz",
"integrity": "sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==",
"dev": true,
"license": "MIT",
"dependencies": {
"suf-log": "^2.5.3"
}
},
"node_modules/sax": { "node_modules/sax": {
"version": "1.6.1", "version": "1.6.1",
"resolved": "https://registry.npmmirror.com/sax/-/sax-1.6.1.tgz", "resolved": "https://registry.npmmirror.com/sax/-/sax-1.6.1.tgz",
@@ -16511,16 +16411,6 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/suf-log": {
"version": "2.5.3",
"resolved": "https://registry.npmmirror.com/suf-log/-/suf-log-2.5.3.tgz",
"integrity": "sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==",
"dev": true,
"license": "MIT",
"dependencies": {
"s.color": "0.0.15"
}
},
"node_modules/supports-color": { "node_modules/supports-color": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz", "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz",
@@ -17347,15 +17237,15 @@
} }
}, },
"node_modules/vite": { "node_modules/vite": {
"version": "5.1.0", "version": "5.4.21",
"resolved": "https://registry.npmmirror.com/vite/-/vite-5.1.0.tgz", "resolved": "https://registry.npmmirror.com/vite/-/vite-5.4.21.tgz",
"integrity": "sha512-STmSFzhY4ljuhz14bg9LkMTk3d98IO6DIArnTY6MeBwiD1Za2StcQtz7fzOUnRCqrHSD5+OS2reg4HOz1eoLnw==", "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"esbuild": "^0.19.3", "esbuild": "^0.21.3",
"postcss": "^8.4.35", "postcss": "^8.4.43",
"rollup": "^4.2.0" "rollup": "^4.20.0"
}, },
"bin": { "bin": {
"vite": "bin/vite.js" "vite": "bin/vite.js"
@@ -17374,6 +17264,7 @@
"less": "*", "less": "*",
"lightningcss": "^1.21.0", "lightningcss": "^1.21.0",
"sass": "*", "sass": "*",
"sass-embedded": "*",
"stylus": "*", "stylus": "*",
"sugarss": "*", "sugarss": "*",
"terser": "^5.4.0" "terser": "^5.4.0"
@@ -17391,6 +17282,9 @@
"sass": { "sass": {
"optional": true "optional": true
}, },
"sass-embedded": {
"optional": true
},
"stylus": { "stylus": {
"optional": true "optional": true
}, },
+7 -3
View File
@@ -78,7 +78,6 @@
}, },
"devDependencies": { "devDependencies": {
"@douyinfe/vite-plugin-semi": "^2.74.0-alpha.6", "@douyinfe/vite-plugin-semi": "^2.74.0-alpha.6",
"@so1ve/prettier-config": "^3.1.0",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.21", "autoprefixer": "^10.4.21",
"eslint": "8.57.0", "eslint": "8.57.0",
@@ -90,12 +89,17 @@
"postcss": "^8.5.3", "postcss": "^8.5.3",
"prettier": "^3.0.0", "prettier": "^3.0.0",
"tailwindcss": "^3", "tailwindcss": "^3",
"vite": "5.1.0" "vite": "5.4.21"
}, },
"proxy": "http://localhost:3000", "proxy": "http://localhost:3000",
"engines": { "engines": {
"node": ">=22.13.0", "node": ">=22.13.0",
"npm": ">=10" "npm": ">=10"
}, },
"packageManager": "npm@10.9.9" "packageManager": "npm@10.9.9",
"overrides": {
"@douyinfe/vite-plugin-semi": {
"vite": "$vite"
}
}
} }
+164
View File
@@ -0,0 +1,164 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Avatar } from '@douyinfe/semi-ui';
import { Bot as FastGPT, Image as Jimeng } from 'lucide-react';
import OpenAI from '@lobehub/icons/es/OpenAI';
import Claude from '@lobehub/icons/es/Claude';
import Gemini from '@lobehub/icons/es/Gemini';
import Moonshot from '@lobehub/icons/es/Moonshot';
import Zhipu from '@lobehub/icons/es/Zhipu';
import Qwen from '@lobehub/icons/es/Qwen';
import DeepSeek from '@lobehub/icons/es/DeepSeek';
import Minimax from '@lobehub/icons/es/Minimax';
import Wenxin from '@lobehub/icons/es/Wenxin';
import Spark from '@lobehub/icons/es/Spark';
import Midjourney from '@lobehub/icons/es/Midjourney';
import Hunyuan from '@lobehub/icons/es/Hunyuan';
import Cohere from '@lobehub/icons/es/Cohere';
import Cloudflare from '@lobehub/icons/es/Cloudflare';
import Ai360 from '@lobehub/icons/es/Ai360';
import Yi from '@lobehub/icons/es/Yi';
import Jina from '@lobehub/icons/es/Jina';
import Mistral from '@lobehub/icons/es/Mistral';
import XAI from '@lobehub/icons/es/XAI';
import Ollama from '@lobehub/icons/es/Ollama';
import Doubao from '@lobehub/icons/es/Doubao';
import Suno from '@lobehub/icons/es/Suno';
import Xinference from '@lobehub/icons/es/Xinference';
import OpenRouter from '@lobehub/icons/es/OpenRouter';
import Dify from '@lobehub/icons/es/Dify';
import Coze from '@lobehub/icons/es/Coze';
import SiliconCloud from '@lobehub/icons/es/SiliconCloud';
import Kling from '@lobehub/icons/es/Kling';
import Perplexity from '@lobehub/icons/es/Perplexity';
import Replicate from '@lobehub/icons/es/Replicate';
const LobeIconsMap = {
OpenAI,
Claude,
Gemini,
Moonshot,
Zhipu,
Qwen,
DeepSeek,
Minimax,
Wenxin,
Spark,
Midjourney,
Hunyuan,
Cohere,
Cloudflare,
Ai360,
Yi,
Jina,
Mistral,
XAI,
Ollama,
Doubao,
Suno,
Xinference,
OpenRouter,
Dify,
Coze,
SiliconCloud,
FastGPT,
Kling,
Jimeng,
Perplexity,
Replicate,
};
export default function LobeHubIcon({ iconName, size = 14 }) {
if (typeof iconName === 'string') iconName = iconName.trim();
// 如果没有图标名称,返回 Avatar
if (!iconName) {
return <Avatar size='extra-extra-small'>?</Avatar>;
}
// 解析组件路径与点号链式属性
const segments = String(iconName).split('.');
const baseKey = segments[0];
const BaseIcon = LobeIconsMap[baseKey];
let IconComponent = undefined;
let propStartIndex = 1;
if (BaseIcon && segments.length > 1 && BaseIcon[segments[1]]) {
IconComponent = BaseIcon[segments[1]];
propStartIndex = 2;
} else {
IconComponent = LobeIconsMap[baseKey];
propStartIndex = 1;
}
// 失败兜底
if (
!IconComponent ||
(typeof IconComponent !== 'function' && typeof IconComponent !== 'object')
) {
const firstLetter = String(iconName).charAt(0).toUpperCase();
return <Avatar size='extra-extra-small'>{firstLetter}</Avatar>;
}
// 解析点号链式属性,形如:key={...}、key='...'、key="..."、key=123、key、key=true/false
const props = {};
const parseValue = (raw) => {
if (raw == null) return true;
let v = String(raw).trim();
// 去除一层花括号包裹
if (v.startsWith('{') && v.endsWith('}')) {
v = v.slice(1, -1).trim();
}
// 去除引号
if (
(v.startsWith('"') && v.endsWith('"')) ||
(v.startsWith("'") && v.endsWith("'"))
) {
return v.slice(1, -1);
}
// 布尔
if (v === 'true') return true;
if (v === 'false') return false;
// 数字
if (/^-?\d+(?:\.\d+)?$/.test(v)) return Number(v);
// 其他原样返回字符串
return v;
};
for (let i = propStartIndex; i < segments.length; i++) {
const seg = segments[i];
if (!seg) continue;
const eqIdx = seg.indexOf('=');
if (eqIdx === -1) {
props[seg.trim()] = true;
continue;
}
const key = seg.slice(0, eqIdx).trim();
const valRaw = seg.slice(eqIdx + 1).trim();
props[key] = parseValue(valRaw);
}
// 兼容第二参数 size,若字符串中未显式指定 size,则使用函数入参
if (props.size == null && size != null) props.size = size;
return <IconComponent {...props} />;
}
+85
View File
@@ -0,0 +1,85 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { runInNewContext } from 'node:vm';
import test from 'node:test';
import React from 'react';
import { transformWithEsbuild } from 'vite';
const filename = new URL('./LobeHubIcon.jsx', import.meta.url);
const { code } = await transformWithEsbuild(
await readFile(filename, 'utf8'),
filename.pathname,
{ loader: 'jsx', format: 'cjs', jsx: 'transform', target: 'node22' },
);
const Mono = () => null;
const Color = () => null;
const Avatar = () => null;
const module = { exports: {} };
runInNewContext(code, {
module,
exports: module.exports,
require(name) {
if (name === 'react') return React;
if (name === '@douyinfe/semi-ui') return { Avatar: 'avatar' };
if (name === 'lucide-react') return { Bot: Mono, Image: Mono };
assert.ok(name.startsWith('@lobehub/icons/es/'), name);
return Object.assign(Mono, { Color, Avatar });
},
});
const render = module.exports.default;
test('brand icon keeps the selected variant and configured props', () => {
const icon = render({
iconName: "OpenAI.Avatar.type={'platform'}.shape='square'.size=24",
size: 14,
});
assert.equal(icon.type, Avatar);
assert.equal(icon.props.type, 'platform');
assert.equal(icon.props.shape, 'square');
assert.equal(icon.props.size, 24);
});
test('brand icon preserves color and default size', () => {
const icon = render({ iconName: 'Claude.Color' });
assert.equal(icon.type, Color);
assert.equal(icon.props.size, 14);
});
test('empty and unknown brand names preserve the fallback avatar', () => {
for (const [iconName, letter] of [
[null, '?'],
['', '?'],
['UnknownBrand', 'U'],
]) {
const icon = render({ iconName });
assert.equal(icon.type, 'avatar');
assert.equal(icon.props.children, letter);
}
});
test('base icons and lucide compatibility brands remain supported', () => {
for (const iconName of ['OpenAI', 'FastGPT', 'Jimeng']) {
const icon = render({ iconName, size: 20 });
assert.equal(icon.type, Mono);
assert.equal(icon.props.size, 20);
}
});
+28 -18
View File
@@ -17,9 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com For commercial licensing, please contact support@quantumnous.com
*/ */
import HeaderBar from './headerbar';
import { Layout } from '@douyinfe/semi-ui'; import { Layout } from '@douyinfe/semi-ui';
import SiderBar from './SiderBar';
import App from '../../App'; import App from '../../App';
import { ToastContainer } from 'react-toastify'; import { ToastContainer } from 'react-toastify';
import React, { import React, {
@@ -49,7 +47,11 @@ import { useLocation } from 'react-router-dom';
import { applyTheme, setPresetOverrides } from '../../helpers/theme'; import { applyTheme, setPresetOverrides } from '../../helpers/theme';
// 用户问卷功能已禁用 // 用户问卷功能已禁用
// import UserSurveyModal from '../common/modals/UserSurveyModal'; // import UserSurveyModal from '../common/modals/UserSurveyModal';
import NewUserGiftModal from '../common/modals/NewUserGiftModal'; const HeaderBar = lazy(() => import('./headerbar'));
const SiderBar = lazy(() => import('./SiderBar'));
const NewUserGiftModal = lazy(
() => import('../common/modals/NewUserGiftModal'),
);
// 懒加载客服浮窗组件 - 非核心功能,延迟加载 // 懒加载客服浮窗组件 - 非核心功能,延迟加载
const CustomerServiceFloat = lazy(() => import('../customer-service')); const CustomerServiceFloat = lazy(() => import('../customer-service'));
@@ -355,10 +357,12 @@ const PageLayout = () => {
zIndex: 100, zIndex: 100,
}} }}
> >
<HeaderBar <Suspense fallback={null}>
onMobileMenuToggle={() => setDrawerOpen((prev) => !prev)} <HeaderBar
drawerOpen={drawerOpen} onMobileMenuToggle={() => setDrawerOpen((prev) => !prev)}
/> drawerOpen={drawerOpen}
/>
</Suspense>
{/* 跑马灯公告 - 固定在导航栏正下方;认证页不展示(与 hasMarquee 的高度计算保持一致) */} {/* 跑马灯公告 - 固定在导航栏正下方;认证页不展示(与 hasMarquee 的高度计算保持一致) */}
{!isAuthPage && <Marquee />} {!isAuthPage && <Marquee />}
</Header> </Header>
@@ -406,12 +410,14 @@ const PageLayout = () => {
: undefined, : undefined,
}} }}
> >
<SiderBar <Suspense fallback={null}>
forceExpanded={siderForceExpanded} <SiderBar
onNavigate={() => { forceExpanded={siderForceExpanded}
if (isMobile) setDrawerOpen(false); onNavigate={() => {
}} if (isMobile) setDrawerOpen(false);
/> }}
/>
</Suspense>
</Sider> </Sider>
)} )}
<Layout <Layout
@@ -470,11 +476,15 @@ const PageLayout = () => {
/> */} /> */}
{/* 新用户注册赠送额度弹窗 */} {/* 新用户注册赠送额度弹窗 */}
<NewUserGiftModal {showGiftModal && (
visible={showGiftModal} <Suspense fallback={null}>
onClose={() => setShowGiftModal(false)} <NewUserGiftModal
quota={giftQuota} visible={showGiftModal}
/> onClose={() => setShowGiftModal(false)}
quota={giftQuota}
/>
</Suspense>
)}
</Layout> </Layout>
); );
}; };
@@ -18,7 +18,6 @@ For commercial licensing, please contact support@quantumnous.com
*/ */
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import * as XLSX from 'xlsx';
import { Modal, Button, Checkbox, Radio, RadioGroup } from '@douyinfe/semi-ui'; import { Modal, Button, Checkbox, Radio, RadioGroup } from '@douyinfe/semi-ui';
import { CheckSquare, Eraser, FileSpreadsheet, X } from 'lucide-react'; import { CheckSquare, Eraser, FileSpreadsheet, X } from 'lucide-react';
import { import {
@@ -232,7 +231,7 @@ const UsageLogsExportModal = ({
// 不用可能过期的 logCount 来禁用按钮(避免编辑筛选未查询时被误禁用) // 不用可能过期的 logCount 来禁用按钮(避免编辑筛选未查询时被误禁用)
const pageNoData = scope === 'page' && pageCount === 0; const pageNoData = scope === 'page' && pageCount === 0;
const buildSheet = (rows, fields, header) => { const buildSheet = (XLSX, rows, fields, header) => {
const aoa = [header, ...rows.map((r) => fields.map((f) => f.value(r, t)))]; const aoa = [header, ...rows.map((r) => fields.map((f) => f.value(r, t)))];
const ws = XLSX.utils.aoa_to_sheet(aoa); const ws = XLSX.utils.aoa_to_sheet(aoa);
ws['!cols'] = fields.map((f) => ({ wch: f.width || 14 })); ws['!cols'] = fields.map((f) => ({ wch: f.width || 14 }));
@@ -267,10 +266,11 @@ const UsageLogsExportModal = ({
return; return;
} }
const header = fields.map((f) => t(f.label)); const header = fields.map((f) => t(f.label));
const XLSX = await import('xlsx');
const wb = XLSX.utils.book_new(); const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet( XLSX.utils.book_append_sheet(
wb, wb,
buildSheet(rows, fields, header), buildSheet(XLSX, rows, fields, header),
t('消耗明细'), t('消耗明细'),
); );
XLSX.writeFile(wb, buildExportFilename()); XLSX.writeFile(wb, buildExportFilename());
+80 -180
View File
@@ -17,81 +17,46 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com For commercial licensing, please contact support@quantumnous.com
*/ */
import React, { lazy, Suspense } from 'react';
import i18next from 'i18next'; import i18next from 'i18next';
// React 18-compatible LobeHub icons lack these brands; use generic icons. // React 18-compatible LobeHub icons lack these brands; use generic icons.
import { Lock, Bot as FastGPT, Image as Jimeng } from 'lucide-react'; import { Lock, Bot as FastGPT, Image as Jimeng } from 'lucide-react';
import { Modal, Tag, Typography, Avatar } from '@douyinfe/semi-ui'; import { Modal, Tag, Typography } from '@douyinfe/semi-ui';
import { copy, getCurrencySymbol, showSuccess } from './utils'; import { copy, getCurrencySymbol, showSuccess } from './utils';
import { visit } from 'unist-util-visit'; import { visit } from 'unist-util-visit';
import { import OpenAI from '@lobehub/icons/es/OpenAI/components/Mono';
OpenAI, import Claude from '@lobehub/icons/es/Claude/components/Color';
Claude, import Gemini from '@lobehub/icons/es/Gemini/components/Color';
Gemini, import Moonshot from '@lobehub/icons/es/Moonshot/components/Mono';
Moonshot, import Zhipu from '@lobehub/icons/es/Zhipu/components/Color';
Zhipu, import Qwen from '@lobehub/icons/es/Qwen/components/Color';
Qwen, import DeepSeek from '@lobehub/icons/es/DeepSeek/components/Color';
DeepSeek, import Minimax from '@lobehub/icons/es/Minimax/components/Color';
Minimax, import Wenxin from '@lobehub/icons/es/Wenxin/components/Color';
Wenxin, import Spark from '@lobehub/icons/es/Spark/components/Color';
Spark, import Midjourney from '@lobehub/icons/es/Midjourney/components/Mono';
Midjourney, import Hunyuan from '@lobehub/icons/es/Hunyuan/components/Color';
Hunyuan, import Cohere from '@lobehub/icons/es/Cohere/components/Color';
Cohere, import Cloudflare from '@lobehub/icons/es/Cloudflare/components/Color';
Cloudflare, import Ai360 from '@lobehub/icons/es/Ai360/components/Color';
Ai360, import Yi from '@lobehub/icons/es/Yi/components/Color';
Yi, import Jina from '@lobehub/icons/es/Jina/components/Mono';
Jina, import Mistral from '@lobehub/icons/es/Mistral/components/Color';
Mistral, import XAI from '@lobehub/icons/es/XAI/components/Mono';
XAI, import Ollama from '@lobehub/icons/es/Ollama/components/Mono';
Ollama, import Doubao from '@lobehub/icons/es/Doubao/components/Color';
Doubao, import Suno from '@lobehub/icons/es/Suno/components/Mono';
Suno, import Xinference from '@lobehub/icons/es/Xinference/components/Color';
Xinference, import OpenRouter from '@lobehub/icons/es/OpenRouter/components/Mono';
OpenRouter, import Dify from '@lobehub/icons/es/Dify/components/Color';
Dify, import Coze from '@lobehub/icons/es/Coze/components/Mono';
Coze, import SiliconCloud from '@lobehub/icons/es/SiliconCloud/components/Color';
SiliconCloud, import Kling from '@lobehub/icons/es/Kling/components/Color';
Kling, import Perplexity from '@lobehub/icons/es/Perplexity/components/Color';
Perplexity, import Replicate from '@lobehub/icons/es/Replicate/components/Mono';
Replicate,
} from '@lobehub/icons';
// 创建图标映射表,避免使用 import * 导致整个库被打包 // Full Avatar/Text/Combine variants are loaded only when configured icons render.
// 只包含实际在库中存在的图标 const LobeHubIcon = lazy(() => import('../components/common/LobeHubIcon'));
const LobeIconsMap = {
OpenAI,
Claude,
Gemini,
Moonshot,
Zhipu,
Qwen,
DeepSeek,
Minimax,
Wenxin,
Spark,
Midjourney,
Hunyuan,
Cohere,
Cloudflare,
Ai360,
Yi,
Jina,
Mistral,
XAI,
Ollama,
Doubao,
Suno,
Xinference,
OpenRouter,
Dify,
Coze,
SiliconCloud,
FastGPT,
Kling,
Jimeng,
Perplexity,
Replicate,
};
import { import {
LayoutDashboard, LayoutDashboard,
@@ -205,12 +170,12 @@ export const getModelCategories = (() => {
}, },
anthropic: { anthropic: {
label: 'Anthropic', label: 'Anthropic',
icon: <Claude.Color />, icon: <Claude />,
filter: (model) => model.model_name.toLowerCase().includes('claude'), filter: (model) => model.model_name.toLowerCase().includes('claude'),
}, },
gemini: { gemini: {
label: 'Gemini', label: 'Gemini',
icon: <Gemini.Color />, icon: <Gemini />,
filter: (model) => filter: (model) =>
model.model_name.toLowerCase().includes('gemini') || model.model_name.toLowerCase().includes('gemini') ||
model.model_name.toLowerCase().includes('gemma') || model.model_name.toLowerCase().includes('gemma') ||
@@ -230,7 +195,7 @@ export const getModelCategories = (() => {
}, },
zhipu: { zhipu: {
label: t('智谱'), label: t('智谱'),
icon: <Zhipu.Color />, icon: <Zhipu />,
filter: (model) => filter: (model) =>
model.model_name.toLowerCase().includes('chatglm') || model.model_name.toLowerCase().includes('chatglm') ||
model.model_name.toLowerCase().includes('glm-') || model.model_name.toLowerCase().includes('glm-') ||
@@ -239,29 +204,29 @@ export const getModelCategories = (() => {
}, },
qwen: { qwen: {
label: t('通义千问'), label: t('通义千问'),
icon: <Qwen.Color />, icon: <Qwen />,
filter: (model) => model.model_name.toLowerCase().includes('qwen'), filter: (model) => model.model_name.toLowerCase().includes('qwen'),
}, },
deepseek: { deepseek: {
label: 'DeepSeek', label: 'DeepSeek',
icon: <DeepSeek.Color />, icon: <DeepSeek />,
filter: (model) => model.model_name.toLowerCase().includes('deepseek'), filter: (model) => model.model_name.toLowerCase().includes('deepseek'),
}, },
minimax: { minimax: {
label: 'MiniMax', label: 'MiniMax',
icon: <Minimax.Color />, icon: <Minimax />,
filter: (model) => filter: (model) =>
model.model_name.toLowerCase().includes('abab') || model.model_name.toLowerCase().includes('abab') ||
model.model_name.toLowerCase().includes('minimax'), model.model_name.toLowerCase().includes('minimax'),
}, },
baidu: { baidu: {
label: t('文心一言'), label: t('文心一言'),
icon: <Wenxin.Color />, icon: <Wenxin />,
filter: (model) => model.model_name.toLowerCase().includes('ernie'), filter: (model) => model.model_name.toLowerCase().includes('ernie'),
}, },
xunfei: { xunfei: {
label: t('讯飞星火'), label: t('讯飞星火'),
icon: <Spark.Color />, icon: <Spark />,
filter: (model) => model.model_name.toLowerCase().includes('spark'), filter: (model) => model.model_name.toLowerCase().includes('spark'),
}, },
midjourney: { midjourney: {
@@ -271,12 +236,12 @@ export const getModelCategories = (() => {
}, },
tencent: { tencent: {
label: t('腾讯混元'), label: t('腾讯混元'),
icon: <Hunyuan.Color />, icon: <Hunyuan />,
filter: (model) => model.model_name.toLowerCase().includes('hunyuan'), filter: (model) => model.model_name.toLowerCase().includes('hunyuan'),
}, },
cohere: { cohere: {
label: 'Cohere', label: 'Cohere',
icon: <Cohere.Color />, icon: <Cohere />,
filter: (model) => filter: (model) =>
model.model_name.toLowerCase().includes('command') || model.model_name.toLowerCase().includes('command') ||
model.model_name.toLowerCase().includes('c4ai-') || model.model_name.toLowerCase().includes('c4ai-') ||
@@ -284,12 +249,12 @@ export const getModelCategories = (() => {
}, },
cloudflare: { cloudflare: {
label: 'Cloudflare', label: 'Cloudflare',
icon: <Cloudflare.Color />, icon: <Cloudflare />,
filter: (model) => model.model_name.toLowerCase().includes('@cf/'), filter: (model) => model.model_name.toLowerCase().includes('@cf/'),
}, },
ai360: { ai360: {
label: t('360智脑'), label: t('360智脑'),
icon: <Ai360.Color />, icon: <Ai360 />,
filter: (model) => model.model_name.toLowerCase().includes('360'), filter: (model) => model.model_name.toLowerCase().includes('360'),
}, },
jina: { jina: {
@@ -299,7 +264,7 @@ export const getModelCategories = (() => {
}, },
mistral: { mistral: {
label: 'Mistral AI', label: 'Mistral AI',
icon: <Mistral.Color />, icon: <Mistral />,
filter: (model) => filter: (model) =>
model.model_name.toLowerCase().includes('mistral') || model.model_name.toLowerCase().includes('mistral') ||
model.model_name.toLowerCase().includes('codestral') || model.model_name.toLowerCase().includes('codestral') ||
@@ -319,12 +284,12 @@ export const getModelCategories = (() => {
}, },
doubao: { doubao: {
label: t('豆包'), label: t('豆包'),
icon: <Doubao.Color />, icon: <Doubao />,
filter: (model) => model.model_name.toLowerCase().includes('doubao'), filter: (model) => model.model_name.toLowerCase().includes('doubao'),
}, },
yi: { yi: {
label: t('零一万物'), label: t('零一万物'),
icon: <Yi.Color />, icon: <Yi />,
filter: (model) => model.model_name.toLowerCase().includes('yi'), filter: (model) => model.model_name.toLowerCase().includes('yi'),
}, },
}; };
@@ -355,64 +320,64 @@ export function getChannelIcon(channelType) {
return <Ollama size={iconSize} />; return <Ollama size={iconSize} />;
case 14: // Anthropic Claude case 14: // Anthropic Claude
case 33: // AWS Claude case 33: // AWS Claude
return <Claude.Color size={iconSize} />; return <Claude size={iconSize} />;
case 41: // Vertex AI case 41: // Vertex AI
return <Gemini.Color size={iconSize} />; return <Gemini size={iconSize} />;
case 34: // Cohere case 34: // Cohere
return <Cohere.Color size={iconSize} />; return <Cohere size={iconSize} />;
case 39: // Cloudflare case 39: // Cloudflare
return <Cloudflare.Color size={iconSize} />; return <Cloudflare size={iconSize} />;
case 43: // DeepSeek case 43: // DeepSeek
return <DeepSeek.Color size={iconSize} />; return <DeepSeek size={iconSize} />;
case 15: // 百度文心千帆 case 15: // 百度文心千帆
case 46: // 百度文心千帆V2 case 46: // 百度文心千帆V2
return <Wenxin.Color size={iconSize} />; return <Wenxin size={iconSize} />;
case 17: // 阿里通义千问 case 17: // 阿里通义千问
return <Qwen.Color size={iconSize} />; return <Qwen size={iconSize} />;
case 18: // 讯飞星火认知 case 18: // 讯飞星火认知
return <Spark.Color size={iconSize} />; return <Spark size={iconSize} />;
case 16: // 智谱 ChatGLM case 16: // 智谱 ChatGLM
case 26: // 智谱 GLM-4V case 26: // 智谱 GLM-4V
return <Zhipu.Color size={iconSize} />; return <Zhipu size={iconSize} />;
case 24: // Google Gemini case 24: // Google Gemini
case 11: // Google PaLM2 case 11: // Google PaLM2
return <Gemini.Color size={iconSize} />; return <Gemini size={iconSize} />;
case 47: // Xinference case 47: // Xinference
return <Xinference.Color size={iconSize} />; return <Xinference size={iconSize} />;
case 25: // Moonshot case 25: // Moonshot
return <Moonshot size={iconSize} />; return <Moonshot size={iconSize} />;
case 27: // Perplexity case 27: // Perplexity
return <Perplexity.Color size={iconSize} />; return <Perplexity size={iconSize} />;
case 20: // OpenRouter case 20: // OpenRouter
return <OpenRouter size={iconSize} />; return <OpenRouter size={iconSize} />;
case 19: // 360 智脑 case 19: // 360 智脑
return <Ai360.Color size={iconSize} />; return <Ai360 size={iconSize} />;
case 23: // 腾讯混元 case 23: // 腾讯混元
return <Hunyuan.Color size={iconSize} />; return <Hunyuan size={iconSize} />;
case 31: // 零一万物 case 31: // 零一万物
return <Yi.Color size={iconSize} />; return <Yi size={iconSize} />;
case 35: // MiniMax case 35: // MiniMax
return <Minimax.Color size={iconSize} />; return <Minimax size={iconSize} />;
case 37: // Dify case 37: // Dify
return <Dify.Color size={iconSize} />; return <Dify size={iconSize} />;
case 38: // Jina case 38: // Jina
return <Jina size={iconSize} />; return <Jina size={iconSize} />;
case 40: // SiliconCloud case 40: // SiliconCloud
return <SiliconCloud.Color size={iconSize} />; return <SiliconCloud size={iconSize} />;
case 42: // Mistral AI case 42: // Mistral AI
return <Mistral.Color size={iconSize} />; return <Mistral size={iconSize} />;
case 45: // 字节火山方舟、豆包通用 case 45: // 字节火山方舟、豆包通用
return <Doubao.Color size={iconSize} />; return <Doubao size={iconSize} />;
case 48: // xAI case 48: // xAI
return <XAI size={iconSize} />; return <XAI size={iconSize} />;
case 49: // Coze case 49: // Coze
return <Coze size={iconSize} />; return <Coze size={iconSize} />;
case 50: // 可灵 Kling case 50: // 可灵 Kling
return <Kling.Color size={iconSize} />; return <Kling size={iconSize} />;
case 51: // 即梦 Jimeng case 51: // 即梦 Jimeng
return <Jimeng size={iconSize} />; return <Jimeng size={iconSize} />;
case 54: // 豆包视频 Doubao Video case 54: // 豆包视频 Doubao Video
return <Doubao.Color size={iconSize} />; return <Doubao size={iconSize} />;
case 56: // Replicate case 56: // Replicate
return <Replicate size={iconSize} />; return <Replicate size={iconSize} />;
case 8: // 自定义渠道 case 8: // 自定义渠道
@@ -436,80 +401,15 @@ export function getChannelIcon(channelType) {
* @returns {JSX.Element} - 对应的图标组件或 Avatar * @returns {JSX.Element} - 对应的图标组件或 Avatar
*/ */
export function getLobeHubIcon(iconName, size = 14) { export function getLobeHubIcon(iconName, size = 14) {
if (typeof iconName === 'string') iconName = iconName.trim(); return (
// 如果没有图标名称,返回 Avatar <Suspense
if (!iconName) { fallback={
return <Avatar size='extra-extra-small'>?</Avatar>; <span style={{ display: 'inline-block', width: size, height: size }} />
} }
>
// 解析组件路径与点号链式属性 <LobeHubIcon iconName={iconName} size={size} />
const segments = String(iconName).split('.'); </Suspense>
const baseKey = segments[0]; );
const BaseIcon = LobeIconsMap[baseKey];
let IconComponent = undefined;
let propStartIndex = 1;
if (BaseIcon && segments.length > 1 && BaseIcon[segments[1]]) {
IconComponent = BaseIcon[segments[1]];
propStartIndex = 2;
} else {
IconComponent = LobeIconsMap[baseKey];
propStartIndex = 1;
}
// 失败兜底
if (
!IconComponent ||
(typeof IconComponent !== 'function' && typeof IconComponent !== 'object')
) {
const firstLetter = String(iconName).charAt(0).toUpperCase();
return <Avatar size='extra-extra-small'>{firstLetter}</Avatar>;
}
// 解析点号链式属性,形如:key={...}、key='...'、key="..."、key=123、key、key=true/false
const props = {};
const parseValue = (raw) => {
if (raw == null) return true;
let v = String(raw).trim();
// 去除一层花括号包裹
if (v.startsWith('{') && v.endsWith('}')) {
v = v.slice(1, -1).trim();
}
// 去除引号
if (
(v.startsWith('"') && v.endsWith('"')) ||
(v.startsWith("'") && v.endsWith("'"))
) {
return v.slice(1, -1);
}
// 布尔
if (v === 'true') return true;
if (v === 'false') return false;
// 数字
if (/^-?\d+(?:\.\d+)?$/.test(v)) return Number(v);
// 其他原样返回字符串
return v;
};
for (let i = propStartIndex; i < segments.length; i++) {
const seg = segments[i];
if (!seg) continue;
const eqIdx = seg.indexOf('=');
if (eqIdx === -1) {
props[seg.trim()] = true;
continue;
}
const key = seg.slice(0, eqIdx).trim();
const valRaw = seg.slice(eqIdx + 1).trim();
props[key] = parseValue(valRaw);
}
// 兼容第二参数 size,若字符串中未显式指定 size,则使用函数入参
if (props.size == null && size != null) props.size = size;
return <IconComponent {...props} />;
} }
// 颜色列表 // 颜色列表
+19 -21
View File
@@ -31,18 +31,16 @@ import { useActualTheme } from '../../context/Theme';
import { marked } from 'marked'; import { marked } from 'marked';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Link, useNavigate } from 'react-router-dom'; import { Link, useNavigate } from 'react-router-dom';
import { import Moonshot from '@lobehub/icons/es/Moonshot/components/Mono';
Moonshot, import OpenAI from '@lobehub/icons/es/OpenAI/components/Mono';
OpenAI, import Zhipu from '@lobehub/icons/es/Zhipu/components/Color';
Zhipu, import Claude from '@lobehub/icons/es/Claude/components/Color';
Claude, import Gemini from '@lobehub/icons/es/Gemini/components/Color';
Gemini, import Wenxin from '@lobehub/icons/es/Wenxin/components/Color';
Wenxin, import Spark from '@lobehub/icons/es/Spark/components/Color';
Spark, import DeepSeek from '@lobehub/icons/es/DeepSeek/components/Color';
DeepSeek, import Qwen from '@lobehub/icons/es/Qwen/components/Color';
Qwen, import Midjourney from '@lobehub/icons/es/Midjourney/components/Mono';
Midjourney,
} from '@lobehub/icons';
import { import {
Cpu, Cpu,
Server, Server,
@@ -299,15 +297,15 @@ const Home = () => {
// 模型列表 // 模型列表
const modelIcons = [ const modelIcons = [
{ Icon: OpenAI, name: 'OpenAI' }, { Icon: OpenAI, name: 'OpenAI' },
{ Icon: Claude.Color, name: 'Claude' }, { Icon: Claude, name: 'Claude' },
{ Icon: Gemini.Color, name: 'Gemini' }, { Icon: Gemini, name: 'Gemini' },
{ Icon: Midjourney, name: 'Midjourney' }, { Icon: Midjourney, name: 'Midjourney' },
{ Icon: Qwen.Color, name: 'Qwen' }, { Icon: Qwen, name: 'Qwen' },
{ Icon: DeepSeek.Color, name: 'DeepSeek' }, { Icon: DeepSeek, name: 'DeepSeek' },
{ Icon: Zhipu.Color, name: 'ChatGLM' }, { Icon: Zhipu, name: 'ChatGLM' },
{ Icon: Moonshot, name: 'Moonshot' }, { Icon: Moonshot, name: 'Moonshot' },
{ Icon: Spark.Color, name: 'Spark' }, { Icon: Spark, name: 'Spark' },
{ Icon: Wenxin.Color, name: 'Wenxin' }, { Icon: Wenxin, name: 'Wenxin' },
]; ];
// Enterprise Style CSS // Enterprise Style CSS
@@ -498,10 +496,10 @@ const Home = () => {
<OpenAI size={24} /> <OpenAI size={24} />
</div> </div>
<div className='w-12 h-12 rounded-xl bg-white dark:bg-slate-800 flex items-center justify-center shadow-md border border-slate-200 dark:border-slate-700 hover:scale-110 transition-transform'> <div className='w-12 h-12 rounded-xl bg-white dark:bg-slate-800 flex items-center justify-center shadow-md border border-slate-200 dark:border-slate-700 hover:scale-110 transition-transform'>
<Claude.Color size={24} /> <Claude size={24} />
</div> </div>
<div className='w-12 h-12 rounded-xl bg-white dark:bg-slate-800 flex items-center justify-center shadow-md border border-slate-200 dark:border-slate-700 hover:scale-110 transition-transform'> <div className='w-12 h-12 rounded-xl bg-white dark:bg-slate-800 flex items-center justify-center shadow-md border border-slate-200 dark:border-slate-700 hover:scale-110 transition-transform'>
<Gemini.Color size={24} /> <Gemini size={24} />
</div> </div>
</div> </div>
</div> </div>
+4 -4
View File
@@ -18,7 +18,6 @@ For commercial licensing, please contact support@quantumnous.com
*/ */
import React, { useEffect, useState, useMemo, useCallback } from 'react'; import React, { useEffect, useState, useMemo, useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import * as XLSX from 'xlsx';
import { import {
RefreshCw, RefreshCw,
Receipt, Receipt,
@@ -161,7 +160,7 @@ const EXPORT_FIELDS = [
]; ];
// 将选中字段组装成一个 worksheet(含表头、列宽) // 将选中字段组装成一个 worksheet(含表头、列宽)
function buildWorksheet(rows, fields, header) { function buildWorksheet(XLSX, rows, fields, header) {
const aoa = [header, ...rows.map((r) => fields.map((f) => f.value(r)))]; const aoa = [header, ...rows.map((r) => fields.map((f) => f.value(r)))];
const ws = XLSX.utils.aoa_to_sheet(aoa); const ws = XLSX.utils.aoa_to_sheet(aoa);
ws['!cols'] = fields.map((f) => ({ wch: f.width || 14 })); ws['!cols'] = fields.map((f) => ({ wch: f.width || 14 }));
@@ -455,6 +454,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
} }
const header = fields.map((f) => t(f.label)); const header = fields.map((f) => t(f.label));
const XLSX = await import('xlsx');
const wb = XLSX.utils.book_new(); const wb = XLSX.utils.book_new();
if (exportMode === 'perUser') { if (exportMode === 'perUser') {
@@ -535,7 +535,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
); );
for (const { name, rows } of groups.values()) { for (const { name, rows } of groups.values()) {
const ws = buildWorksheet(rows, fields, header); const ws = buildWorksheet(XLSX, rows, fields, header);
XLSX.utils.book_append_sheet( XLSX.utils.book_append_sheet(
wb, wb,
ws, ws,
@@ -544,7 +544,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
} }
} else { } else {
// 汇总:所有记录放在一个 sheet 页 // 汇总:所有记录放在一个 sheet 页
const ws = buildWorksheet(allLogs, fields, header); const ws = buildWorksheet(XLSX, allLogs, fields, header);
XLSX.utils.book_append_sheet( XLSX.utils.book_append_sheet(
wb, wb,
ws, ws,
+45
View File
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
import assert from 'node:assert/strict'; import assert from 'node:assert/strict';
import { mkdtemp, readFile, writeFile, rm } from 'node:fs/promises'; import { mkdtemp, readFile, writeFile, rm } from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
import { createServer as createHttpServer } from 'node:http';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import test from 'node:test'; import test from 'node:test';
import { loadConfigFromFile, loadEnv, createServer } from 'vite'; import { loadConfigFromFile, loadEnv, createServer } from 'vite';
@@ -123,6 +124,7 @@ test('checked-in defaults preserve same-origin behavior and disable analytics',
test('development server transforms the HTML and runtime configuration modules', async () => { test('development server transforms the HTML and runtime configuration modules', async () => {
const server = await createServer({ const server = await createServer({
root, root,
cacheDir: path.join(root, '.cache/vite-environment-test'),
server: { middlewareMode: true }, server: { middlewareMode: true },
optimizeDeps: { noDiscovery: true, include: [] }, optimizeDeps: { noDiscovery: true, include: [] },
}); });
@@ -144,3 +146,46 @@ test('development server transforms the HTML and runtime configuration modules',
await server.close(); await server.close();
} }
}); });
test('Vite proxies API requests on Node 22 without DEP0060', async () => {
const upstream = createHttpServer((request, response) => {
response.setHeader('Content-Type', 'application/json');
response.end(JSON.stringify({ path: request.url }));
});
await new Promise((resolve) => upstream.listen(0, '127.0.0.1', resolve));
const warnings = [];
const onWarning = (warning) => warnings.push(warning.code);
process.on('warning', onWarning);
let server;
try {
server = await createServer({
configFile: false,
root,
cacheDir: path.join(root, '.cache/vite-proxy-test'),
optimizeDeps: { noDiscovery: true, include: [] },
server: {
host: '127.0.0.1',
port: 0,
proxy: {
'/api': {
target: `http://127.0.0.1:${upstream.address().port}`,
changeOrigin: true,
},
},
},
});
await server.listen();
const response = await fetch(
`http://127.0.0.1:${server.httpServer.address().port}/api/status`,
{ headers: { Connection: 'close' } },
);
assert.equal(response.status, 200);
assert.deepEqual(await response.json(), { path: '/api/status' });
await new Promise((resolve) => setImmediate(resolve));
assert.ok(!warnings.includes('DEP0060'));
} finally {
process.off('warning', onWarning);
await server?.close();
await new Promise((resolve) => upstream.close(resolve));
}
});
-63
View File
@@ -38,61 +38,6 @@ const DEV_PROXY_TARGET = 'http://134.175.227.134:13000';
*/ */
const JSX_IN_JS_RE = /src\/.*\.js$/; const JSX_IN_JS_RE = /src\/.*\.js$/;
/**
* 手动分包规则,数组顺序即匹配优先级:首个命中的分组拥有该模块。
*
* 每条规则只负责把 node_modules 下的第三方库归入固定 chunk;
* 未命中的模块返回 undefined,仍交回 Rollup 的默认分包策略。
*/
const VENDOR_CHUNK_RULES = [
// React 运行时核心
['react-core', ['react/', 'react-dom/', 'react-router-dom/', 'scheduler/']],
// Semi UI:图标与组件分开,避免图标变动连带组件 chunk 失效
['semi-icons', ['@douyinfe/semi-icons']],
['semi-ui', ['@douyinfe/semi-ui', '@douyinfe/semi-foundation']],
// 图表库,体积较大
['vchart', ['@visactor/']],
// Mermaid 及其布局引擎,体积最大
['mermaid', ['mermaid/', 'dagre-d3', 'cytoscape', 'elkjs']],
// Markdown 渲染链路
['markdown', ['react-markdown/', 'remark-', 'rehype-', 'unified/', 'unist-']],
// KaTeX 数学公式
['katex', ['katex/']],
// 代码高亮
['highlight', ['highlight.js/']],
// 图标库
['lobe-icons', ['@lobehub/icons']],
['lucide-icons', ['lucide-react/']],
// 国际化
['i18n', ['i18next', 'react-i18next/']],
// 基础工具库
['utils', ['axios/', 'dayjs/', 'clsx/']],
// 独立的 React 生态第三方组件
[
'react-components',
[
'react-dropzone/',
'react-toastify/',
'react-telegram-login/',
'react-turnstile/',
],
],
// 二维码生成
['qrcode', ['qrcode']],
];
/**
* 解析模块应归属的第三方 chunk。
*
* @param {string} id 模块的绝对路径
* @returns {string | undefined} chunk 名;无匹配时返回 undefined
*/
function resolveVendorChunk(id) {
return VENDOR_CHUNK_RULES.find(([, packages]) =>
packages.some((name) => id.includes(`node_modules/${name}`)),
)?.[0];
}
/** /**
* 让 JSX_IN_JS_RE 命中的 .js 按 JSX 语法解析。 * 让 JSX_IN_JS_RE 命中的 .js 按 JSX 语法解析。
* *
@@ -175,8 +120,6 @@ export default defineConfig(({ mode }) => {
analyticsPlugin(env), analyticsPlugin(env),
], ],
optimizeDeps: { optimizeDeps: {
// 强制重新预构建,避免依赖变更后命中陈旧的依赖缓存
force: true,
esbuildOptions: { esbuildOptions: {
loader: { loader: {
'.js': 'jsx', '.js': 'jsx',
@@ -195,18 +138,12 @@ export default defineConfig(({ mode }) => {
target: 'es2015', target: 'es2015',
// 生产环境不需要 sourcemap // 生产环境不需要 sourcemap
sourcemap: false, sourcemap: false,
// esbuild 压缩选项:移除调试语句与版权注释
esbuild: {
drop: ['console', 'debugger'],
legalComments: 'none',
},
rollupOptions: { rollupOptions: {
output: { output: {
// 文件名带内容 hash,便于浏览器长期缓存与增量更新 // 文件名带内容 hash,便于浏览器长期缓存与增量更新
chunkFileNames: 'assets/[name]-[hash].js', chunkFileNames: 'assets/[name]-[hash].js',
entryFileNames: 'assets/[name]-[hash].js', entryFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]', assetFileNames: 'assets/[name]-[hash].[ext]',
manualChunks: resolveVendorChunk,
}, },
}, },
}, },