mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-10-29 03:36:15 +08:00
- 清单 [[plugin.ui]]:五个挂载点、ab-plugin- 元素名与 web/ 入口校验
- GET /plugins/ui 列出已启用插件的挂载点;GET /plugins/{id}/web/{path} 提供静态资源(防路径穿越、JS MIME、需登录)
- SPA 文档加 CSP script-src 'self',内联深色模式脚本移到 theme-init.js
- webui/packages/plugin-ui:AbHost 类型、--ab-* 主题变量、Vite 库模式模板
- 设计文档第 0 节记录第一部分的调整
133 lines
3.3 KiB
TypeScript
133 lines
3.3 KiB
TypeScript
import { resolve } from 'node:path';
|
||
import UnoCSS from 'unocss/vite';
|
||
import { defineConfig } from 'vite';
|
||
import vue from '@vitejs/plugin-vue';
|
||
import AutoImport from 'unplugin-auto-import/vite';
|
||
import Components from 'unplugin-vue-components/vite';
|
||
import VueRouter from 'unplugin-vue-router/vite';
|
||
import { VueRouterAutoImports } from 'unplugin-vue-router';
|
||
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
||
import { VitePWA } from 'vite-plugin-pwa';
|
||
import VueJsx from '@vitejs/plugin-vue-jsx';
|
||
|
||
// 与后端给 SPA 文档加的响应头一致(backend/src/main.py)。只加在 preview:
|
||
// dev 服务器与 vite-plugin-pwa 的开发态会注入内联脚本,会被这个策略拦下
|
||
const headers = { 'Content-Security-Policy': "script-src 'self'" };
|
||
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig(({ mode }) => ({
|
||
base: './',
|
||
plugins: [
|
||
VueJsx(),
|
||
VueRouter({
|
||
dts: 'types/dts/router-type.d.ts',
|
||
}),
|
||
vue({
|
||
script: {
|
||
defineModel: true,
|
||
},
|
||
}),
|
||
UnoCSS(),
|
||
AutoImport({
|
||
imports: [
|
||
'vue',
|
||
'vitest',
|
||
'pinia',
|
||
{
|
||
'@vueuse/core': [
|
||
'createSharedComposable',
|
||
'useBreakpoints',
|
||
'usePreferredDark',
|
||
'useClipboard',
|
||
'useLocalStorage',
|
||
'useIntervalFn',
|
||
],
|
||
},
|
||
VueRouterAutoImports,
|
||
'vue-i18n',
|
||
],
|
||
dts: 'types/dts/auto-imports.d.ts',
|
||
dirs: ['src/api', 'src/store', 'src/hooks', 'src/utils'],
|
||
}),
|
||
Components({
|
||
dts: 'types/dts/components.d.ts',
|
||
dirs: [
|
||
'src/components',
|
||
'src/components/basic',
|
||
'src/components/layout',
|
||
'src/components/setting',
|
||
'src/components/setup',
|
||
],
|
||
}),
|
||
VueI18nPlugin({
|
||
include: resolve(__dirname, './src/i18n/**'),
|
||
}),
|
||
VitePWA({
|
||
injectRegister: false,
|
||
registerType: 'autoUpdate',
|
||
devOptions: {
|
||
enabled: true,
|
||
},
|
||
workbox: {
|
||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||
},
|
||
manifest: {
|
||
name: 'AutoBangumi',
|
||
display: 'standalone',
|
||
short_name: 'AutoBangumi',
|
||
description: 'Automated Bangumi Download Tool',
|
||
theme_color: '#ffffff',
|
||
icons: [
|
||
{
|
||
src: '/images/logo.svg',
|
||
sizes: 'any',
|
||
type: 'image/svg+xml',
|
||
purpose: 'any',
|
||
},
|
||
{
|
||
src: '/images/pwa-192.png',
|
||
sizes: '192x192',
|
||
type: 'image/png',
|
||
},
|
||
{
|
||
src: '/images/pwa-512.png',
|
||
sizes: '512x512',
|
||
type: 'image/png',
|
||
purpose: 'any',
|
||
},
|
||
],
|
||
},
|
||
}),
|
||
],
|
||
css: {
|
||
preprocessorOptions: {
|
||
scss: {
|
||
additionalData: '@import "./src/style/mixin.scss";',
|
||
},
|
||
},
|
||
},
|
||
esbuild: {
|
||
drop: mode === 'production' ? ['console', 'debugger'] : [],
|
||
},
|
||
build: {
|
||
cssCodeSplit: false,
|
||
},
|
||
resolve: {
|
||
alias: {
|
||
'~': resolve(__dirname, './'),
|
||
'@': resolve(__dirname, 'src'),
|
||
'#': resolve(__dirname, 'types'),
|
||
},
|
||
},
|
||
preview: { headers },
|
||
server: {
|
||
proxy: {
|
||
'^/api/.*': {
|
||
target: 'http://localhost:7892',
|
||
changeOrigin: false,
|
||
},
|
||
'^/posters/.*': 'http://localhost:7892',
|
||
},
|
||
},
|
||
}));
|