@infly/libs 2.0.44 → 2.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -5
- package/adapters/vue2/module/Permission.js +1 -1
- package/{module → adapters/vue2/module}/REST.js +3 -3
- package/{module → adapters/vue2/module}/TokenService.js +1 -1
- package/adapters/vue2/module/file-export.js +18 -0
- package/adapters/vue2/project-preview.js +6 -2
- package/adapters/vue2/script-config.js +1 -1
- package/adapters/vue2/store/modules/user.js +1 -1
- package/adapters/vue2/vite/index.js +95 -0
- package/adapters/vue2/vite/jest.config.js +11 -0
- package/adapters/vue2/{build/webpack5 → webpack5}/webpack.base.js +0 -55
- package/build/build-dist/index.js +2 -2
- package/{script/build → build/build-utils}/command.js +13 -4
- package/{script/build → build/build-utils}/git.js +6 -4
- package/{script/build → build/build-utils}/preview.js +4 -1
- package/module/Uts.js +47 -443
- package/package.json +18 -15
- package/script/git-automation/git-configure.js +29 -0
- package/script/git-automation/index.js +0 -14
- package/script/git-automation/submodule-status.js +113 -0
- package/script/git-automation/submodule-utils.js +18 -0
- package/tools/concurrency.js +30 -0
- package/tools/progress.js +63 -0
- package/tools/project-command.js +5 -1
- package/tools/workspace-config.js +145 -0
- package/adapters/vue2/build/webpack5/remove-legacy-assets-plugin.js +0 -84
- package/build/webpack5/inline-runtime-plugin.js +0 -1
- package/build/webpack5/remove-legacy-assets-plugin.js +0 -1
- package/build/webpack5/webpack.base.js +0 -1
- package/module/Permission.js +0 -1
- package/module/cjs/deep-merge.cjs +0 -38
- package/store/index.js +0 -1
- package/store/modules/user.js +0 -1
- package/tools/file-export.js +0 -167
- /package/{module → adapters/vue2/module}/Router.js +0 -0
- /package/adapters/vue2/{build/webpack5 → webpack5}/inline-runtime-plugin.js +0 -0
- /package/{script/build → build/build-utils}/deps.js +0 -0
- /package/{script/build → build/build-utils}/env.js +0 -0
- /package/{script/webhook/webhook.js → build/build-utils/webhook-single.js} +0 -0
- /package/{script/build → build/build-utils}/webhook.js +0 -0
- /package/module/cjs/{page-config.cjs → page-config.js} +0 -0
- /package/module/cjs/{request-url-rules.cjs → request-url-rules.js} +0 -0
- /package/module/cjs/{rest-error-rules.cjs → rest-error-rules.js} +0 -0
package/tools/file-export.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 统一文件导出函数
|
|
3
|
-
* @param {Object} config - 配置对象
|
|
4
|
-
* @param {string} config.url - 请求文件的 URL
|
|
5
|
-
* @param {string} config.fileName - 导出文件的基础名称
|
|
6
|
-
* @param {Object} [config.params={}] - 请求参数
|
|
7
|
-
* @param {string} [config.suffix=".csv"] - 文件后缀名
|
|
8
|
-
* @param {Object} config.request - 请求封装实例 (如 axios 实例)
|
|
9
|
-
* @param {string} [config.reqMethod="get"] - 请求方法 ('get' 或 'post')
|
|
10
|
-
* @param {Object} [config.Message={}] - Element UI Message 组件实例
|
|
11
|
-
* @param {Object} [config.MessageBox={}] - Element UI MessageBox 组件实例
|
|
12
|
-
* @param {Object} [config.Loading={}] - Element UI Loading 组件实例
|
|
13
|
-
*/
|
|
14
|
-
const isFn = (v) => typeof v === "function";
|
|
15
|
-
|
|
16
|
-
async function exportFile(config) {
|
|
17
|
-
// 1. 参数解构与默认值,并进行基本校验
|
|
18
|
-
const {
|
|
19
|
-
url,
|
|
20
|
-
fileName,
|
|
21
|
-
params = {},
|
|
22
|
-
suffix = ".csv",
|
|
23
|
-
request,
|
|
24
|
-
reqMethod = "get",
|
|
25
|
-
Message = {},
|
|
26
|
-
MessageBox = {},
|
|
27
|
-
Loading = {},
|
|
28
|
-
hideConfirm = false,
|
|
29
|
-
confirmConfig = { message: "导出筛选后的所有文件, 是否继续?" }
|
|
30
|
-
} = config || {};
|
|
31
|
-
|
|
32
|
-
if (!url || !request) {
|
|
33
|
-
console.error("exportFile: 缺少必要的参数 (url, fileName, request)");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let loadingInstance = null;
|
|
38
|
-
|
|
39
|
-
// 辅助函数:显示消息
|
|
40
|
-
const showMessage = (type, msg) => {
|
|
41
|
-
if (Message && isFn(Message[type])) {
|
|
42
|
-
Message[type](msg);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// 辅助函数:显示加载
|
|
47
|
-
const showLoading = () => {
|
|
48
|
-
if (Loading && isFn(Loading.service)) {
|
|
49
|
-
loadingInstance = Loading.service({
|
|
50
|
-
text: "文件正在下载中,请等候...",
|
|
51
|
-
spinner: "el-icon-loading",
|
|
52
|
-
background: "rgba(0, 0, 0, 0.7)"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// 辅助函数:隐藏加载
|
|
58
|
-
const hideLoading = () => {
|
|
59
|
-
if (loadingInstance && isFn(loadingInstance.close)) {
|
|
60
|
-
loadingInstance.close();
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// 辅助函数:处理文件下载
|
|
65
|
-
const handleDownload = (blob, fullFileName) => {
|
|
66
|
-
if ("download" in document.createElement("a")) {
|
|
67
|
-
const elink = document.createElement("a");
|
|
68
|
-
elink.style.display = "none";
|
|
69
|
-
elink.href = URL.createObjectURL(blob);
|
|
70
|
-
elink.download = fullFileName;
|
|
71
|
-
document.body.appendChild(elink);
|
|
72
|
-
elink.click();
|
|
73
|
-
URL.revokeObjectURL(elink.href);
|
|
74
|
-
document.body.removeChild(elink);
|
|
75
|
-
} else {
|
|
76
|
-
// IE10+下载
|
|
77
|
-
navigator.msSaveBlob(blob, fullFileName);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
// 2. 确认框
|
|
83
|
-
if (MessageBox && isFn(MessageBox.confirm) && !hideConfirm) {
|
|
84
|
-
await MessageBox.confirm(confirmConfig?.message, "提示", {
|
|
85
|
-
confirmButtonText: "确定",
|
|
86
|
-
cancelButtonText: "取消",
|
|
87
|
-
type: "warning"
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
showLoading(); // 显示加载
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
// 3. 请求文件流
|
|
95
|
-
const requestConfig = {
|
|
96
|
-
responseType: "arraybuffer",
|
|
97
|
-
timeout: 0
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
let res;
|
|
101
|
-
if (reqMethod === "get") {
|
|
102
|
-
res = await request.get(url, { ...params, ...requestConfig });
|
|
103
|
-
} else if (reqMethod === "post") {
|
|
104
|
-
res = await request.post(url, params, requestConfig);
|
|
105
|
-
} else {
|
|
106
|
-
console.warn(`exportFile: 不支持的请求方法 '${reqMethod}'`);
|
|
107
|
-
showMessage("error", "导出失败:不支持的请求方法!");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const { code, message } = res || {};
|
|
111
|
-
if (code && (code != 0 || code != 200)) {
|
|
112
|
-
showMessage("error", message || "导出失败!");
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const blob = new Blob([res], { type: "application/octet-stream" });
|
|
117
|
-
const fullFileName = `${fileName}_${new Date().toISOString().slice(0, 10)}${suffix}`;
|
|
118
|
-
|
|
119
|
-
handleDownload(blob, fullFileName); // 处理文件下载
|
|
120
|
-
showMessage("success", "文件导出成功!");
|
|
121
|
-
} catch (err) {
|
|
122
|
-
console.error("导出错误:", err);
|
|
123
|
-
const { response, message: errMsg } = err || {};
|
|
124
|
-
const { status, statusText, message = errMsg } = response || {};
|
|
125
|
-
|
|
126
|
-
if (status === 403 || statusText === "Forbidden") {
|
|
127
|
-
showMessage("error", "无操作权限!");
|
|
128
|
-
} else if (status === 404) {
|
|
129
|
-
showMessage("error", "导出地址未找到!");
|
|
130
|
-
} else if (message && message.includes("timeout")) {
|
|
131
|
-
showMessage("error", "导出超时,请稍后再试!");
|
|
132
|
-
} else {
|
|
133
|
-
showMessage("error", message || "导出异常,请稍后再试!");
|
|
134
|
-
}
|
|
135
|
-
} finally {
|
|
136
|
-
hideLoading(); // 隐藏加载
|
|
137
|
-
}
|
|
138
|
-
} catch (err) {
|
|
139
|
-
// 捕获 MessageBox.confirm 的取消操作
|
|
140
|
-
if (err === "cancel") {
|
|
141
|
-
showMessage("info", "已取消导出");
|
|
142
|
-
} else {
|
|
143
|
-
console.error("导出流程中断:", err);
|
|
144
|
-
showMessage("error", "导出流程异常中断!");
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// 创建 Vue mixin 对象
|
|
150
|
-
const fileExportMixin = {
|
|
151
|
-
methods: {
|
|
152
|
-
async $exportFile(config) {
|
|
153
|
-
// 自动注入 ElementUI 组件
|
|
154
|
-
const enhancedConfig = {
|
|
155
|
-
...config,
|
|
156
|
-
Message: this.$message || Message,
|
|
157
|
-
MessageBox: this.$msgbox || MessageBox,
|
|
158
|
-
Loading: this.$loading || Loading,
|
|
159
|
-
request: config.request || this.$axios
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
return await exportFile(enhancedConfig);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export { exportFile, fileExportMixin };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|