提交 f1134147 authored 作者: kxjia's avatar kxjia

修改打包问题

上级 a76b863c
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
.app-loading .app-loading-logo { .app-loading .app-loading-logo {
display: block; display: block;
width: 180px; width: 90px;
margin: 0 auto; margin: 0 auto;
margin-bottom: 20px; margin-bottom: 20px;
} }
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
</style> </style>
<div class="app-loading"> <div class="app-loading">
<div class="app-loading-wrap"> <div class="app-loading-wrap">
<img src="<%= basePublicPath %>/resource/img/logo.png" class="app-loading-logo" alt="Logo"/> <img src="<%= basePublicPath %>/resource/img/logo.png" class="app-loading-logo" alt="Logo" />
<div class="app-loading-dots"> <div class="app-loading-dots">
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span> <span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
</div> </div>
......
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
"dependencies": { "dependencies": {
"@ant-design/colors": "^7.2.1", "@ant-design/colors": "^7.2.1",
"@ant-design/icons-vue": "^7.0.1", "@ant-design/icons-vue": "^7.0.1",
"@form-create/ant-design-vue": "^2.6.3", "@form-create/ant-design-vue": "3.1.12",
"@form-create/antd-designer": "^3.4.0", "@form-create/antd-designer": "^3.4.0",
"@form-create/core": "^2.6.3",
"@iconify/iconify": "^3.1.1", "@iconify/iconify": "^3.1.1",
"@jeecg/aiflow": "3.9.0-beta2", "@jeecg/aiflow": "3.9.0-beta2",
"@jeecg/online": "3.9.0-beta2", "@jeecg/online": "3.9.0-beta2",
...@@ -37,14 +36,13 @@ ...@@ -37,14 +36,13 @@
"@tinymce/tinymce-vue": "4.0.7", "@tinymce/tinymce-vue": "4.0.7",
"@traptitech/markdown-it-katex": "^3.6.0", "@traptitech/markdown-it-katex": "^3.6.0",
"@vant/area-data": "^1.5.2", "@vant/area-data": "^1.5.2",
"@vue/compat": "^3.5.27",
"@vue/shared": "^3.5.22", "@vue/shared": "^3.5.22",
"@vueuse/core": "^10.11.1", "@vueuse/core": "^10.11.1",
"@vxe-ui/core": "^4.2.21",
"@zxcvbn-ts/core": "^3.0.4", "@zxcvbn-ts/core": "^3.0.4",
"ant-design-vue": "^4.2.6", "ant-design-vue": "^4.2.6",
"axios": "^1.12.2", "axios": "^1.12.2",
"bpmn-js": "^18.10.1", "bpmn-js": "7.0.0",
"bpmn-js-properties-panel": "0.37.6",
"china-area-data": "^5.0.1", "china-area-data": "^5.0.1",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"codemirror": "^5.65.20", "codemirror": "^5.65.20",
...@@ -76,13 +74,11 @@ ...@@ -76,13 +74,11 @@
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"qs": "^6.14.0", "qs": "^6.14.0",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"sass-embedded": "^1.97.2",
"showdown": "^2.1.0", "showdown": "^2.1.0",
"sortablejs": "^1.15.6", "sortablejs": "^1.15.6",
"swagger-ui-dist": "^5.29.3", "swagger-ui-dist": "^5.29.3",
"tinymce": "6.6.2", "tinymce": "6.6.2",
"vditor": "^3.11.2", "vditor": "^3.11.2",
"vkbeautify": "^0.99.3",
"vue": "^3.5.22", "vue": "^3.5.22",
"vue-cropper": "^0.6.5", "vue-cropper": "^0.6.5",
"vue-cropperjs": "^5.0.0", "vue-cropperjs": "^5.0.0",
...@@ -103,8 +99,6 @@ ...@@ -103,8 +99,6 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^18.6.1", "@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.3", "@commitlint/config-conventional": "^18.6.3",
"@form-create/data": "^2.6.2",
"@form-create/utils": "^2.6.3",
"@iconify/json": "^2.2.394", "@iconify/json": "^2.2.394",
"@purge-icons/generated": "^0.10.0", "@purge-icons/generated": "^0.10.0",
"@rys-fe/vite-plugin-theme": "^0.8.6", "@rys-fe/vite-plugin-theme": "^0.8.6",
...@@ -162,6 +156,7 @@ ...@@ -162,6 +156,7 @@
"rimraf": "^5.0.10", "rimraf": "^5.0.10",
"rollup": "4.52.5", "rollup": "4.52.5",
"rollup-plugin-visualizer": "5.14.0", "rollup-plugin-visualizer": "5.14.0",
"sass-embedded": "^1.97.3",
"stylelint": "^16.25.0", "stylelint": "^16.25.0",
"stylelint-config-prettier": "^9.0.5", "stylelint-config-prettier": "^9.0.5",
"stylelint-config-recommended": "^14.0.1", "stylelint-config-recommended": "^14.0.1",
......
...@@ -113,29 +113,14 @@ function registerPromiseErrorHandler() { ...@@ -113,29 +113,14 @@ function registerPromiseErrorHandler() {
'unhandledrejection', 'unhandledrejection',
function (event) { function (event) {
const errorLogStore = useErrorLogStoreWithOut(); const errorLogStore = useErrorLogStoreWithOut();
// 获取更详细的错误信息
let message = 'Unknown Promise Error';
let stack = 'No stack trace available';
if (event.reason instanceof Error) {
message = event.reason.message;
stack = event.reason.stack || stack;
} else if (typeof event.reason === 'string') {
message = event.reason;
} else if (event.reason) {
// 处理其他类型的错误原因
message = JSON.stringify(event.reason);
}
errorLogStore.addErrorLogInfo({ errorLogStore.addErrorLogInfo({
type: ErrorTypeEnum.PROMISE, type: ErrorTypeEnum.PROMISE,
name: 'Unhandled Promise Rejection', name: 'Promise Error!',
file: 'none', file: 'none',
detail: 'Unhandled promise rejection occurred', detail: 'promise error!',
url: window.location.href, url: window.location.href,
stack: stack, stack: 'promise error!',
message: message, message: event.reason,
}); });
}, },
true true
......
...@@ -45,6 +45,8 @@ main(); ...@@ -45,6 +45,8 @@ main();
async function bootstrap(props?: MainAppProps) { async function bootstrap(props?: MainAppProps) {
// 创建应用实例 // 创建应用实例
const app = createApp(App); const app = createApp(App);
// 【QQYUN-6329】
window['JAppRootInstance'] = app;
// 创建路由 // 创建路由
createRouter(); createRouter();
......
...@@ -103,18 +103,13 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { ...@@ -103,18 +103,13 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
function dynamicImport(dynamicViewsModules: Record<string, () => Promise<Recordable>>, component: string) { function dynamicImport(dynamicViewsModules: Record<string, () => Promise<Recordable>>, component: string) {
const keys = Object.keys(dynamicViewsModules); const keys = Object.keys(dynamicViewsModules);
// 标准化组件路径
let normalizedComponent = component;
if (normalizedComponent.startsWith('/')) {
normalizedComponent = normalizedComponent.slice(1);
}
if (normalizedComponent.endsWith('.vue') || normalizedComponent.endsWith('.tsx')) {
normalizedComponent = normalizedComponent.replace(/\.(vue|tsx)$/, '');
}
const matchKeys = keys.filter((key) => { const matchKeys = keys.filter((key) => {
const k = key.replace('../../views/', '').replace(/\.(vue|tsx)$/, ''); const k = key.replace('../../views', '');
return k === normalizedComponent; const startFlag = component.startsWith('/');
const endFlag = component.endsWith('.vue') || component.endsWith('.tsx');
const startIndex = startFlag ? 0 : 1;
const lastIndex = endFlag ? k.length : k.lastIndexOf('.');
return k.substring(startIndex, lastIndex) === component;
}); });
if (matchKeys?.length === 1) { if (matchKeys?.length === 1) {
const matchKey = matchKeys[0]; const matchKey = matchKeys[0];
...@@ -123,12 +118,7 @@ function dynamicImport(dynamicViewsModules: Record<string, () => Promise<Recorda ...@@ -123,12 +118,7 @@ function dynamicImport(dynamicViewsModules: Record<string, () => Promise<Recorda
warn( warn(
'Please do not create `.vue` and `.TSX` files with the same file name in the same hierarchical directory under the views folder. This will cause dynamic introduction failure' 'Please do not create `.vue` and `.TSX` files with the same file name in the same hierarchical directory under the views folder. This will cause dynamic introduction failure'
); );
return EXCEPTION_COMPONENT; return;
} else {
warn(
`Failed to find dynamic import component: ${component}`
);
return EXCEPTION_COMPONENT;
} }
} }
......
...@@ -201,9 +201,6 @@ export class VAxios { ...@@ -201,9 +201,6 @@ export class VAxios {
} }
request<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> { request<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
if(!config.timeout) {
config.timeout = 10000
}
let conf: CreateAxiosOptions = cloneDeep(config); let conf: CreateAxiosOptions = cloneDeep(config);
const transform = this.getTransform(); const transform = this.getTransform();
......
...@@ -172,7 +172,9 @@ const transform: AxiosTransform = { ...@@ -172,7 +172,9 @@ const transform: AxiosTransform = {
config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token; config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token;
config.headers[ConfigEnum.TOKEN] = token; config.headers[ConfigEnum.TOKEN] = token;
// 将签名和时间戳,添加在请求接口 Header
//config.headers[ConfigEnum.TIMESTAMP] = signMd5Utils.getTimestamp();
//config.headers[ConfigEnum.Sign] = signMd5Utils.getSign(config.url, config.params);
if (!tenantId) { if (!tenantId) {
tenantId = 0; tenantId = 0;
} }
...@@ -190,12 +192,13 @@ const transform: AxiosTransform = { ...@@ -190,12 +192,13 @@ const transform: AxiosTransform = {
// ======================================================================================== // ========================================================================================
// 代码逻辑说明: 添加低代码应用ID // 代码逻辑说明: 添加低代码应用ID
const { appId, lowAppFilter } = router.currentRoute.value.params; let routeParams = router.currentRoute.value.params;
if (appId) { if (routeParams.appId) {
config.headers[ConfigEnum.X_LOW_APP_ID] = appId; config.headers[ConfigEnum.X_LOW_APP_ID] = routeParams.appId;
// lowApp自定义筛选条件 // lowApp自定义筛选条件
if (lowAppFilter) { if (routeParams.lowAppFilter) {
config.params = { ...config.params, ...JSON.parse(lowAppFilter as string) }; config.params = { ...config.params, ...JSON.parse(routeParams.lowAppFilter as string) };
delete routeParams.lowAppFilter;
} }
} }
// ======================================================================================== // ========================================================================================
......
...@@ -40,13 +40,12 @@ export function isNull(val: unknown): val is null { ...@@ -40,13 +40,12 @@ export function isNull(val: unknown): val is null {
return val === null; return val === null;
} }
export function isNullOrUnDef(val: unknown): val is null | undefined { export function isNullAndUnDef(val: unknown): val is null | undefined {
return isUnDef(val) || isNull(val); return isUnDef(val) && isNull(val);
} }
// 保持向后兼容 export function isNullOrUnDef(val: unknown): val is null | undefined {
export function isNullAndUnDef(val: unknown): val is null | undefined { return isUnDef(val) || isNull(val);
return isNullOrUnDef(val);
} }
export function isNumber(val: unknown): val is number { export function isNumber(val: unknown): val is number {
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
<script setup> <script setup>
import {ref, watch} from "vue"; import {ref, watch} from "vue";
import formCreate from "@form-create/ant-design-vue"; // import formCreate from "@form-create/ant-design-vue";
// import { default as formCreate } from '@form-create/ant-design-vue'
import * as formCreate from '@form-create/ant-design-vue'
const option = ref([]); const option = ref([]);
const rule = ref([]); const rule = ref([]);
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
<script setup> <script setup>
import {ref, watch} from "vue"; import {ref, watch} from "vue";
import formCreate from "@form-create/ant-design-vue"; //import formCreate from "@form-create/ant-design-vue";
// import { default as formCreate } from '@form-create/ant-design-vue'
import * as formCreate from '@form-create/ant-design-vue'
const option = ref([]); const option = ref([]);
const rule = ref([]); const rule = ref([]);
......
...@@ -45,20 +45,21 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -45,20 +45,21 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
console.log('[init] Start Port: ', VITE_PORT); console.log('[init] Start Port: ', VITE_PORT);
console.debug('[init] Vite Proxy Config: ', VITE_PROXY); console.debug('[init] Vite Proxy Config: ', VITE_PROXY);
return { return {
base: isQiankunMicro ? VITE_GLOB_QIANKUN_MICRO_APP_ENTRY : VITE_PUBLIC_PATH, base: isQiankunMicro ? VITE_GLOB_QIANKUN_MICRO_APP_ENTRY : VITE_PUBLIC_PATH,
root, root,
resolve: { resolve: {
alias: [ alias: [
// 修复 Vue 导入问题
{
find: 'vue',
replacement: resolve(__dirname, 'node_modules/vue/dist/vue.esm-bundler.js'),
},
{ {
find: 'vue-i18n', find: 'vue-i18n',
replacement: 'vue-i18n/dist/vue-i18n.cjs.js', replacement: 'vue-i18n/dist/vue-i18n.cjs.js',
}, },
// 添加 Vue 别名,确保使用正确的版本
{
find: 'vue',
replacement: 'vue/dist/vue.esm-bundler.js',
},
// /@/xxxx => src/xxxx // /@/xxxx => src/xxxx
{ {
find: /\/@\//, find: /\/@\//,
...@@ -99,45 +100,14 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -99,45 +100,14 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
rollupOptions: { rollupOptions: {
// 关闭除屑优化,防止删除重要代码,导致打包后功能出现异常 // 关闭除屑优化,防止删除重要代码,导致打包后功能出现异常
treeshake: false, treeshake: false,
// 添加外部依赖配置
external: [
'vkbeautify',
'@form-create/antd-designer',
'@vxe-ui/core'
],
// 添加插件修复 form-create 的导入问题
plugins: [
{
name: 'fix-form-create-import',
transform(code, id) {
if (id.includes('@form-create/ant-design-vue')) {
// 修复 Vue 导入方式
code = code.replace(
/import\s+(\w+)\s+from\s+['"]vue['"]/g,
'import * as $1 from "vue"'
);
// 添加默认导出支持
code = code.replace(
/import\s+\*\s+as\s+(\w+)\s+from\s+['"]vue['"]/,
'import * as $1 from "vue";\nconst Vue = { ...$1, default: $1 };'
);
return code;
}
}
}
],
output: { output: {
chunkFileNames: 'js/[name]-[hash].js', // 提供命名导出,解决默认导出问题
entryFileNames: 'js/[name]-[hash].js',
// 处理模块兼容性
globals: {
'vue': 'Vue'
},
interop: 'auto',
// 确保正确处理默认导出
exports: 'named', exports: 'named',
// manualChunks配置 chunkFileNames: 'js/[name]-[hash].js', // 引入文件名的名称
entryFileNames: 'js/[name]-[hash].js', // 包的入口文件名称
// manualChunks配置 (依赖包从大到小排列)
manualChunks: { manualChunks: {
// vue vue-router合并打包
'vue-vendor': ['vue', 'vue-router'], 'vue-vendor': ['vue', 'vue-router'],
'antd-vue-vendor': ['ant-design-vue','@ant-design/icons-vue','@ant-design/colors'], 'antd-vue-vendor': ['ant-design-vue','@ant-design/icons-vue','@ant-design/colors'],
'vxe-table-vendor': ['vxe-table','vxe-table-plugin-antd','xe-utils'], 'vxe-table-vendor': ['vxe-table','vxe-table-plugin-antd','xe-utils'],
...@@ -146,13 +116,27 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -146,13 +116,27 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
}, },
}, },
}, },
// 关闭brotliSize显示可以稍微减少打包时间
reportCompressedSize: false, reportCompressedSize: false,
// 提高超大静态资源警告大小
chunkSizeWarningLimit: 2000, chunkSizeWarningLimit: 2000,
// 添加 CommonJS 配置
commonjsOptions: {
transformMixedEsModules: true,
include: [/node_modules/],
// 特别处理 form-create 的依赖
requireReturnsDefault: 'auto',
// 忽略导入检查
ignoreTryCatch: false,
},
}, },
esbuild: { esbuild: {
//清除全局的console.log和debug
drop: isBuild ? ['console', 'debugger'] : [], drop: isBuild ? ['console', 'debugger'] : [],
}, },
define: { define: {
// setting vue-i18-next
// Suppress warning
__INTLIFY_PROD_DEVTOOLS__: false, __INTLIFY_PROD_DEVTOOLS__: false,
__APP_INFO__: JSON.stringify(__APP_INFO__), __APP_INFO__: JSON.stringify(__APP_INFO__),
}, },
...@@ -165,59 +149,36 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -165,59 +149,36 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
}, },
}, },
// 修改插件配置,将修复插件放在最前面 // The vite plugin used by the project. The quantity is large, so it is separately extracted and managed
plugins: [ // 预加载构建配置(首屏性能)
// 先添加修复插件 plugins: createVitePlugins(viteEnv, isBuild, isQiankunMicro),
{
name: 'fix-form-create-import',
enforce: 'pre', // 确保在其他插件之前执行
transform(code, id) {
if (id.includes('@form-create/ant-design-vue') && id.includes('form-create.esm.js')) {
console.log('修复 form-create 导入...');
// 方法1:只修改导入语句
code = code.replace(
/import\s+I\s+from\s+['"]vue['"]/g,
'import * as I from "vue";'
);
// 方法2:如果上面不行,使用更保守的替换
// 只替换第22行的 import I from "vue";
const lines = code.split('\n');
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes('import I from "vue"')) {
lines[i] = 'import * as I from "vue";';
break;
}
}
code = lines.join('\n');
return code;
}
return code;
}
},
// 然后添加其他插件
...createVitePlugins(viteEnv, isBuild, isQiankunMicro)
],
optimizeDeps: { optimizeDeps: {
esbuildOptions: { esbuildOptions: {
target: 'es2020', target: 'es2020',
// 添加 define 来兼容 // 为 ES 模块添加支持
define: { supported: {
'process.env.NODE_ENV': '"development"' 'dynamic-import': true,
} 'import-meta': true,
},
// 解决默认导出问题
banner: 'import { createRequire } from "module"; const require = createRequire(import.meta.url);',
}, },
exclude: [ exclude: [
//升级vite4后,需要排除online依赖
'@jeecg/online', '@jeecg/online',
'@jeecg/aiflow', '@jeecg/aiflow',
'vkbeautify',
'@form-create/antd-designer',
'@vxe-ui/core',
'@form-create/ant-design-vue'
], ],
include: ['vue'] // 明确包含可能需要预构建的依赖
include: [
'vue',
'vue-router',
'ant-design-vue',
'@ant-design/icons-vue',
'moment',
'dayjs',
// 尝试包含 form-create
'@form-create/ant-design-vue'
]
}, },
}; };
}; };
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论