diff --git a/build/vite/index.ts b/build/vite/index.ts index 40033551..585759f5 100644 --- a/build/vite/index.ts +++ b/build/vite/index.ts @@ -11,10 +11,10 @@ import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import viteCompression from 'vite-plugin-compression' +import topLevelAwait from 'vite-plugin-top-level-await' import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import UnoCSS from 'unocss/vite' -import topLevelAwait from 'vite-plugin-top-level-await' export function createVitePlugins() { const root = process.cwd() @@ -31,7 +31,6 @@ export function createVitePlugins() { progress(), PurgeIcons(), ElementPlus({}), - topLevelAwait(), AutoImport({ include: [ /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx @@ -89,6 +88,13 @@ export function createVitePlugins() { ext: '.gz', // 生成的压缩包后缀 deleteOriginFile: false //压缩后是否删除源文件 }), - ViteEjsPlugin() + ViteEjsPlugin(), + topLevelAwait({ + // https://juejin.cn/post/7152191742513512485 + // The export name of top-level await promise for each chunk module + promiseExportName: '__tla', + // The function to generate import names of top-level await promise in each chunk module + promiseImportName: (i) => `__tla_${i}` + }) ] } diff --git a/src/views/system/mail/template/template.data.ts b/src/views/system/mail/template/template.data.ts index e43f50e0..e68f875a 100644 --- a/src/views/system/mail/template/template.data.ts +++ b/src/views/system/mail/template/template.data.ts @@ -4,12 +4,7 @@ import { TableColumn } from '@/types/table' import * as MailAccountApi from '@/api/system/mail/account' // 邮箱账号的列表 -let accountList: any[] = [] - -// 初始化账号列表 -const initAccountList = async () => { - accountList = await MailAccountApi.getSimpleMailAccountList() -} +const accountList = await MailAccountApi.getSimpleMailAccountList() // 表单校验 export const rules = reactive({ @@ -59,12 +54,7 @@ const crudSchemas = reactive([ search: { show: true, component: 'Select', - api: async () => { - if (accountList.length === 0) { - await initAccountList() - } - return accountList - }, + api: () => accountList, componentProps: { optionsAlias: { labelField: 'mail', @@ -74,12 +64,7 @@ const crudSchemas = reactive([ }, form: { component: 'Select', - api: async () => { - if (accountList.length === 0) { - await initAccountList() - } - return accountList - }, + api: () => accountList, componentProps: { optionsAlias: { labelField: 'mail', diff --git a/vite.config.ts b/vite.config.ts index 015d9431..8cba9150 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -65,16 +65,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { minify: 'terser', outDir: env.VITE_OUT_DIR || 'dist', sourcemap: env.VITE_SOURCEMAP === 'true' ? 'inline' : false, - chunkSizeWarningLimit: 1500, - rollupOptions: { - output: { - manualChunks: { - 'element-plus': ['element-plus'], - 'vue-vendor': ['vue', 'vue-router', 'pinia'], - 'echarts': ['echarts', 'echarts-wordcloud'] - } - } - }, + // brotliSize: false, terserOptions: { compress: { drop_debugger: env.VITE_DROP_DEBUGGER === 'true', @@ -82,18 +73,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { } } }, - optimizeDeps: { - include, - exclude, - esbuildOptions: { - target: 'es2020' - } - }, - // 添加对 SDK 文件的特殊处理 - define: { - 'process.env': {}, - 'global': 'window', - 'require': 'window.require' - } + optimizeDeps: { include, exclude } } }