generated from kevisual/vite-react-template
feat: 添加 PWA 插件支持,更新环境变量处理,优化可见性选项
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
"react-dom": "^19.2.4",
|
||||
"react-hook-form": "^7.71.2",
|
||||
"sonner": "^2.0.7",
|
||||
"vite-plugin-pwa": "^1.2.0",
|
||||
"zod": "^4.3.6",
|
||||
"zustand": "^5.0.12"
|
||||
},
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
"registry": ""
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"auth": "ev sync clone -l -i https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/public/auth.json"
|
||||
},
|
||||
"sync": {
|
||||
"AGENTS.md": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/AGENTS.md",
|
||||
"vite.config.ts": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/vite.config.ts",
|
||||
"src/main.tsx": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/main.tsx",
|
||||
"src/agents/app.ts": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/agents/app.ts",
|
||||
"public/auth.json": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/public/auth.json",
|
||||
"src/agents/index.ts": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/agents/index.ts",
|
||||
"src/modules/basename.ts": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/modules/basename.ts",
|
||||
"src/modules/query.ts": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/modules/query.ts",
|
||||
"src/pages/page.tsx": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/pages/page.tsx",
|
||||
"src/routes/__root.tsx": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/routes/__root.tsx",
|
||||
"src/routes/demo.tsx": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/routes/demo.tsx",
|
||||
"src/routes/index.tsx": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/routes/index.tsx",
|
||||
"src/routes/login.tsx": "https://kevisual.cn/root/ai/kevisual/frontend/vite-react-template/src/routes/login.tsx",
|
||||
|
||||
@@ -19,4 +19,14 @@ export const getDynamicBasename = (): string => {
|
||||
}
|
||||
// 默认使用构建时的 basename
|
||||
return basename
|
||||
}
|
||||
|
||||
export const openLink = (path: string, target: string = '_self') => {
|
||||
if (path.startsWith('http://') || path.startsWith('https://')) {
|
||||
window.open(path, target);
|
||||
return;
|
||||
}
|
||||
const url = new URL(path, window.location.origin);
|
||||
url.pathname = wrapBasename(url.pathname);
|
||||
window.open(url.toString(), target);
|
||||
}
|
||||
@@ -83,7 +83,6 @@ export const BaseHeader = (props: { main?: React.ComponentType | null }) => {
|
||||
{meInfo}
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export function CreateRepoDialog({ open, onOpenChange }: CreateRepoDialogProps)
|
||||
path: '',
|
||||
license: '',
|
||||
description: '',
|
||||
visibility: 'public'
|
||||
visibility: 'Public'
|
||||
})
|
||||
}
|
||||
}, [open, reset])
|
||||
@@ -104,16 +104,16 @@ export function CreateRepoDialog({ open, onOpenChange }: CreateRepoDialogProps)
|
||||
<Controller
|
||||
name="visibility"
|
||||
control={control}
|
||||
defaultValue="public"
|
||||
render={({ field }) => (
|
||||
<Select {...field}>
|
||||
defaultValue="Public"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<Select onValueChange={onChange} value={value}>
|
||||
<SelectTrigger id="visibility">
|
||||
<SelectValue placeholder="选择可见性" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="public">公开 (public)</SelectItem>
|
||||
<SelectItem value="private">私有 (private)</SelectItem>
|
||||
<SelectItem value="protected">保护 (protected)</SelectItem>
|
||||
<SelectItem value="Public">公开 (public)</SelectItem>
|
||||
<SelectItem value="Private">私有 (private)</SelectItem>
|
||||
<SelectItem value="Protected">保护 (protected)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
|
||||
@@ -4,12 +4,14 @@ import path from 'path';
|
||||
import pkgs from './package.json';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
||||
import 'dotenv/config';
|
||||
import dotenv from 'dotenv';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const env = dotenv.config().parsed || {};
|
||||
const isDev = env.NODE_ENV === 'development' || process.env.NODE_ENV === 'development';
|
||||
const basename = isDev ? '/' : pkgs?.basename || '/';
|
||||
|
||||
let target = process.env.VITE_API_URL || 'http://localhost:51515';
|
||||
let target = env.VITE_API_URL || process.env.API_URL || 'http://localhost:51515';
|
||||
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
|
||||
let proxy = {
|
||||
'/root/': apiProxy,
|
||||
@@ -27,7 +29,10 @@ export default defineConfig({
|
||||
autoCodeSplitting: true,
|
||||
}),
|
||||
react(),
|
||||
tailwindcss()
|
||||
tailwindcss(),
|
||||
VitePWA({
|
||||
injectRegister: 'auto',
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
|
||||
Reference in New Issue
Block a user