20765efe62
- 实现移动端响应式适配:抽屉式侧边栏、触摸优化、Safe Area 支持 - 添加 PWA 支持:vite-plugin-pwa、manifest、Service Worker 缓存 - 优化移动端输入体验:防缩放、最小触摸目标、键盘适配
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['icon.svg'],
|
|
manifest: {
|
|
name: 'AI Terminal Assistant',
|
|
short_name: 'AI Assistant',
|
|
description: 'Your intelligent coding companion',
|
|
theme_color: '#111827',
|
|
background_color: '#111827',
|
|
display: 'standalone',
|
|
orientation: 'portrait-primary',
|
|
scope: '/',
|
|
start_url: '/',
|
|
icons: [
|
|
{
|
|
src: '/icon.svg',
|
|
sizes: 'any',
|
|
type: 'image/svg+xml',
|
|
purpose: 'any maskable',
|
|
},
|
|
],
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: /\/api\//i,
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'api-cache',
|
|
expiration: {
|
|
maxEntries: 50,
|
|
maxAgeSeconds: 60 * 60, // 1 hour
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
devOptions: {
|
|
enabled: false, // 开发模式下禁用 PWA
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3000',
|
|
changeOrigin: true,
|
|
ws: true,
|
|
},
|
|
'/health': {
|
|
target: 'http://localhost:3000',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
});
|