diff --git a/build/vite/index.ts b/build/vite/index.ts index 585759f5..2e48231d 100644 --- a/build/vite/index.ts +++ b/build/vite/index.ts @@ -11,7 +11,6 @@ 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' @@ -88,13 +87,6 @@ export function createVitePlugins() { ext: '.gz', // 生成的压缩包后缀 deleteOriginFile: false //压缩后是否删除源文件 }), - 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}` - }) + ViteEjsPlugin() ] } diff --git a/src/views/system/mail/template/template.data.ts b/src/views/system/mail/template/template.data.ts index e68f875a..e43f50e0 100644 --- a/src/views/system/mail/template/template.data.ts +++ b/src/views/system/mail/template/template.data.ts @@ -4,7 +4,12 @@ import { TableColumn } from '@/types/table' import * as MailAccountApi from '@/api/system/mail/account' // 邮箱账号的列表 -const accountList = await MailAccountApi.getSimpleMailAccountList() +let accountList: any[] = [] + +// 初始化账号列表 +const initAccountList = async () => { + accountList = await MailAccountApi.getSimpleMailAccountList() +} // 表单校验 export const rules = reactive({ @@ -54,7 +59,12 @@ const crudSchemas = reactive([ search: { show: true, component: 'Select', - api: () => accountList, + api: async () => { + if (accountList.length === 0) { + await initAccountList() + } + return accountList + }, componentProps: { optionsAlias: { labelField: 'mail', @@ -64,7 +74,12 @@ const crudSchemas = reactive([ }, form: { component: 'Select', - api: () => accountList, + api: async () => { + if (accountList.length === 0) { + await initAccountList() + } + return accountList + }, componentProps: { optionsAlias: { labelField: 'mail', diff --git a/vite.config.ts b/vite.config.ts index 8cba9150..015d9431 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -65,7 +65,16 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { minify: 'terser', outDir: env.VITE_OUT_DIR || 'dist', sourcemap: env.VITE_SOURCEMAP === 'true' ? 'inline' : false, - // brotliSize: false, + chunkSizeWarningLimit: 1500, + rollupOptions: { + output: { + manualChunks: { + 'element-plus': ['element-plus'], + 'vue-vendor': ['vue', 'vue-router', 'pinia'], + 'echarts': ['echarts', 'echarts-wordcloud'] + } + } + }, terserOptions: { compress: { drop_debugger: env.VITE_DROP_DEBUGGER === 'true', @@ -73,6 +82,18 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { } } }, - optimizeDeps: { include, exclude } + optimizeDeps: { + include, + exclude, + esbuildOptions: { + target: 'es2020' + } + }, + // 添加对 SDK 文件的特殊处理 + define: { + 'process.env': {}, + 'global': 'window', + 'require': 'window.require' + } } }