mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
- 在vite.config.mts中添加__BUILD_TIME__常量以记录构建时间 - 在AboutView.vue中显示构建时间及其相对时间 - 在ReadDanmaku.vue中重构语音合成状态管理,优化礼物合并逻辑 - 更新相关类型定义,增强代码可读性和可维护性
108 lines
2.9 KiB
TypeScript
108 lines
2.9 KiB
TypeScript
// vite.config.ts
|
||
import vue from '@vitejs/plugin-vue';
|
||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||
import path from 'path';
|
||
import AutoImport from 'unplugin-auto-import/vite';
|
||
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
|
||
import Components from 'unplugin-vue-components/vite';
|
||
import Markdown from 'unplugin-vue-markdown/vite';
|
||
import { defineConfig } from 'vite';
|
||
import oxlintPlugin from 'vite-plugin-oxlint';
|
||
import svgLoader from 'vite-svg-loader';
|
||
import { VineVitePlugin } from 'vue-vine/vite';
|
||
|
||
// 自定义SVGO插件,删除所有名称以sodipodi:和inkscape:开头的元素
|
||
const removeSodipodiInkscape = {
|
||
name: 'removeSodipodiInkscape',
|
||
description: '删除所有名称以sodipodi:和inkscape:开头的元素',
|
||
fn: () => {
|
||
return {
|
||
element: {
|
||
enter: (node, parentNode) => {
|
||
// 检查元素名称是否以sodipodi:或inkscape:开头
|
||
if (node.name && (node.name.startsWith('sodipodi:') || node.name.startsWith('inkscape:'))) {
|
||
// 从父节点的children数组中过滤掉当前节点
|
||
parentNode.children = parentNode.children.filter(child => child !== node);
|
||
}
|
||
},
|
||
},
|
||
};
|
||
},
|
||
};
|
||
|
||
export default defineConfig({
|
||
plugins: [
|
||
vue({
|
||
script: { propsDestructure: true, defineModel: true },
|
||
include: [/\.vue$/, /\.md$/],
|
||
template: {
|
||
compilerOptions: {
|
||
isCustomElement: (tag) => {
|
||
return tag.includes(':') || tag.startsWith('yt-');
|
||
}
|
||
}
|
||
}
|
||
}),
|
||
vueJsx(),
|
||
svgLoader({
|
||
svgoConfig: {
|
||
plugins: [
|
||
{
|
||
name: 'preset-default',
|
||
params: {
|
||
overrides: {
|
||
removeEditorsNSData: false,
|
||
}
|
||
}
|
||
},
|
||
removeSodipodiInkscape,
|
||
"convertStyleToAttrs",
|
||
"removeUselessDefs",
|
||
"removeUselessStrokeAndFill",
|
||
"removeUnusedNS",
|
||
"removeEmptyText",
|
||
"removeEmptyContainers",
|
||
"removeViewBox",
|
||
"cleanupIds",
|
||
]
|
||
}
|
||
}),
|
||
Markdown({
|
||
/* options */
|
||
}),
|
||
AutoImport({
|
||
imports: ['vue', 'vue-router', '@vueuse/core', 'pinia', 'date-fns', {
|
||
'naive-ui': [
|
||
'useDialog',
|
||
'useMessage',
|
||
'useNotification',
|
||
'useLoadingBar'
|
||
]
|
||
}],
|
||
dts: 'src/auto-imports.d.ts'
|
||
}),
|
||
Components({
|
||
resolvers: [NaiveUiResolver()],
|
||
dts: 'src/components.d.ts',
|
||
extensions: ['vue', 'md'],
|
||
|
||
include: [/\.vue$/, /\.vue\?vue/, /\.md$/, /\.vine$/],
|
||
}),
|
||
oxlintPlugin(),
|
||
VineVitePlugin(),
|
||
],
|
||
server: { port: 51000 },
|
||
resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
|
||
define: {
|
||
'process.env': {},
|
||
global: 'window',
|
||
__BUILD_TIME__: JSON.stringify(new Date().toISOString())
|
||
},
|
||
optimizeDeps: {
|
||
include: ['@vicons/fluent', '@vicons/ionicons5', 'vue', 'vue-router']
|
||
},
|
||
build: {
|
||
sourcemap: true,
|
||
},
|
||
});
|