refactor(modules): 使用IIFE包装模块增强隔离和安全性

- 在web主文件和所有模块文件中添加立即调用函数表达式(IIFE)
- 对模块作用域使用'use strict'提高代码规范性和错误检测
- 提升模块代码的封装性,防止全局变量污染
- 维护现有模块接口和导出方式不变
- 优化代码结构,提升可读性和维护性
This commit is contained in:
zhouyonggao 2025-12-17 10:02:07 +08:00
parent 913f93fabd
commit 37aef35f99
6 changed files with 30 additions and 0 deletions

View File

@ -3,6 +3,9 @@
* @description 使用模块化架构重构提升可读性和扩展性 * @description 使用模块化架构重构提升可读性和扩展性
*/ */
;(function() {
'use strict';
const { createApp, reactive } = Vue; const { createApp, reactive } = Vue;
// ==================== 模块引用 ==================== // ==================== 模块引用 ====================
@ -907,3 +910,5 @@ const app = createApp({
app.use(ElementPlus); app.use(ElementPlus);
app.mount('#app'); app.mount('#app');
})();

View File

@ -3,6 +3,9 @@
* @module api * @module api
*/ */
;(function() {
'use strict';
/** /**
* 获取 API 基础地址 * 获取 API 基础地址
* @returns {string} API 基础 URL * @returns {string} API 基础 URL
@ -427,3 +430,5 @@ window.ApiService = {
fetchYmtMerchants, fetchYmtMerchants,
fetchYmtActivities fetchYmtActivities
}; };
})();

View File

@ -3,6 +3,9 @@
* @module config * @module config
*/ */
;(function() {
'use strict';
// ==================== 系统常量 ==================== // ==================== 系统常量 ====================
/** /**
@ -319,3 +322,5 @@ window.AppConfig = {
// 默认值 // 默认值
getDefaultFields getDefaultFields
}; };
})();

View File

@ -3,6 +3,9 @@
* @module fields * @module fields
*/ */
;(function() {
'use strict';
// 依赖AppConfig // 依赖AppConfig
/** /**
@ -460,3 +463,5 @@ window.FieldsModule = {
TreeUtils, TreeUtils,
fieldsManager fieldsManager
}; };
})();

View File

@ -3,6 +3,9 @@
* @module state * @module state
*/ */
;(function() {
'use strict';
/** /**
* 创建模板表单初始状态 * 创建模板表单初始状态
* @param {string} [datasource='marketing'] - 数据源 * @param {string} [datasource='marketing'] - 数据源
@ -261,3 +264,5 @@ window.StateModule = {
resetExportForm, resetExportForm,
ValidationRules ValidationRules
}; };
})();

View File

@ -3,6 +3,9 @@
* @module utils * @module utils
*/ */
;(function() {
'use strict';
/** /**
* 显示消息提示 * 显示消息提示
* @param {string} text - 消息内容 * @param {string} text - 消息内容
@ -185,3 +188,5 @@ window.AppUtils = {
debounce, debounce,
throttle throttle
}; };
})();