diff --git a/src/components/App.tsx b/src/components/App.tsx index a578cc8..1053527 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -59,7 +59,7 @@ function App() { > - + { diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 7b00006..0745f23 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -112,43 +112,7 @@ const Navbar: React.FC = ({ ? 'ic:round-light-mode' : 'ic:round-contrast' } - />, - window.open('https://discord.gg/SDbbn3hT4b', '_blank')} - style={{ cursor: 'pointer' }} - fontSize={30} - icon={'ic:baseline-discord'} - />, - , - + /> ]; const drawerList = ( diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 5934f90..ca01ef0 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -47,7 +47,7 @@ i18n escapeValue: false // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape }, backend: { - loadPath: '/locales/{{lng}}/{{ns}}.json' + loadPath: `${import.meta.env.BASE_URL}locales/{{lng}}/{{ns}}.json` }, detection: { lookupLocalStorage: 'lang', diff --git a/src/lib/ffmpeg.ts b/src/lib/ffmpeg.ts index 5957e70..7d2de30 100644 --- a/src/lib/ffmpeg.ts +++ b/src/lib/ffmpeg.ts @@ -1,8 +1,9 @@ import { FFmpeg } from '@ffmpeg/ffmpeg'; import { toBlobURL } from '@ffmpeg/util'; -const CORE_VERSION = '0.12.6'; -const BASE_URL = `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/esm`; +// ffmpeg 内核(@ffmpeg/core 0.12.6,MIT)放在 public/ffmpeg/ 自托管。 +// 原来从 unpkg 下载,国内网络慢或不通,且首次使用要拉 32MB。 +const BASE_URL = `${import.meta.env.BASE_URL}ffmpeg`; let ffmpegInstance: FFmpeg | null = null; let loadingPromise: Promise | null = null; diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index c65d24f..42fec41 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -16,7 +16,7 @@ export default function Home() { lg: 5 }} sx={{ - background: `url(/assets/${ + background: `url(${import.meta.env.BASE_URL}assets/${ theme.palette.mode === 'dark' ? 'background-dark.png' : 'background.svg' diff --git a/vite.config.ts b/vite.config.ts index 92f32f7..d498c28 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,6 +9,8 @@ const commitHash = execSync('git rev-parse --short HEAD').toString().trim(); // https://vitejs.dev/config https://vitest.dev/config export default defineConfig({ + // 站点部署在子路径(如 /tools/omni/)时用 BASE_URL 指定,默认仍是根路径 + base: process.env.BASE_URL ?? '/', plugins: [react(), tsconfigPaths()], define: { 'process.env': {},