@fmdeui/fmui 1.0.2 → 1.0.4
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/es/api/index.d.ts +0 -1
- package/es/components/query-condition/index.d.ts +6 -6
- package/es/components/query-condition/src/index.vue.d.ts +2 -2
- package/es/index.d.ts +7 -7
- package/es/packages/api/index.mjs +0 -1
- package/es/packages/utils/index.mjs +1 -0
- package/index.js +259 -259
- package/index.min.js +3 -3
- package/index.min.mjs +3 -3
- package/index.mjs +256 -256
- package/lib/api/index.d.ts +0 -1
- package/lib/components/query-condition/index.d.ts +6 -6
- package/lib/components/query-condition/src/index.vue.d.ts +2 -2
- package/lib/index.d.ts +7 -7
- package/lib/packages/api/index.js +0 -17
- package/lib/packages/utils/index.js +17 -0
- package/locale/en.js +1 -1
- package/locale/en.min.js +1 -1
- package/locale/en.min.mjs +1 -1
- package/locale/en.mjs +1 -1
- package/locale/zh-cn.js +1 -1
- package/locale/zh-cn.min.js +1 -1
- package/locale/zh-cn.min.mjs +1 -1
- package/locale/zh-cn.mjs +1 -1
- package/package.json +1 -1
- /package/es/{component.css → defaults.css} +0 -0
- /package/lib/{component.css → make-installer.css} +0 -0
package/es/api/index.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare const FQueryCondition: {
|
|
|
35
35
|
readonly labelPosition: "top" | "left" | "right";
|
|
36
36
|
} & {
|
|
37
37
|
readonly reset: boolean;
|
|
38
|
-
readonly isFooter: boolean;
|
|
39
38
|
readonly loading: boolean;
|
|
39
|
+
readonly isFooter: boolean;
|
|
40
40
|
readonly boolEnter: boolean;
|
|
41
41
|
readonly isShowOpen: boolean;
|
|
42
42
|
readonly isExpansion: boolean;
|
|
@@ -63,8 +63,8 @@ export declare const FQueryCondition: {
|
|
|
63
63
|
reset: boolean;
|
|
64
64
|
labelPosition: "top" | "left" | "right";
|
|
65
65
|
labelWidth: string;
|
|
66
|
-
isFooter: boolean;
|
|
67
66
|
loading: boolean;
|
|
67
|
+
isFooter: boolean;
|
|
68
68
|
moreCheckList: any[];
|
|
69
69
|
opts: Record<string, any>;
|
|
70
70
|
btnCheckBind: Record<string, any>;
|
|
@@ -120,8 +120,8 @@ export declare const FQueryCondition: {
|
|
|
120
120
|
readonly labelPosition: "top" | "left" | "right";
|
|
121
121
|
} & {
|
|
122
122
|
readonly reset: boolean;
|
|
123
|
-
readonly isFooter: boolean;
|
|
124
123
|
readonly loading: boolean;
|
|
124
|
+
readonly isFooter: boolean;
|
|
125
125
|
readonly boolEnter: boolean;
|
|
126
126
|
readonly isShowOpen: boolean;
|
|
127
127
|
readonly isExpansion: boolean;
|
|
@@ -142,8 +142,8 @@ export declare const FQueryCondition: {
|
|
|
142
142
|
reset: boolean;
|
|
143
143
|
labelPosition: "top" | "left" | "right";
|
|
144
144
|
labelWidth: string;
|
|
145
|
-
isFooter: boolean;
|
|
146
145
|
loading: boolean;
|
|
146
|
+
isFooter: boolean;
|
|
147
147
|
moreCheckList: any[];
|
|
148
148
|
opts: Record<string, any>;
|
|
149
149
|
btnCheckBind: Record<string, any>;
|
|
@@ -196,8 +196,8 @@ export declare const FQueryCondition: {
|
|
|
196
196
|
readonly labelPosition: "top" | "left" | "right";
|
|
197
197
|
} & {
|
|
198
198
|
readonly reset: boolean;
|
|
199
|
-
readonly isFooter: boolean;
|
|
200
199
|
readonly loading: boolean;
|
|
200
|
+
readonly isFooter: boolean;
|
|
201
201
|
readonly boolEnter: boolean;
|
|
202
202
|
readonly isShowOpen: boolean;
|
|
203
203
|
readonly isExpansion: boolean;
|
|
@@ -224,8 +224,8 @@ export declare const FQueryCondition: {
|
|
|
224
224
|
reset: boolean;
|
|
225
225
|
labelPosition: "top" | "left" | "right";
|
|
226
226
|
labelWidth: string;
|
|
227
|
-
isFooter: boolean;
|
|
228
227
|
loading: boolean;
|
|
228
|
+
isFooter: boolean;
|
|
229
229
|
moreCheckList: any[];
|
|
230
230
|
opts: Record<string, any>;
|
|
231
231
|
btnCheckBind: Record<string, any>;
|
|
@@ -29,8 +29,8 @@ declare const __VLS_component: DefineComponent<FQueryConditionProps, {
|
|
|
29
29
|
readonly labelPosition: "top" | "left" | "right";
|
|
30
30
|
} & {
|
|
31
31
|
readonly reset: boolean;
|
|
32
|
-
readonly isFooter: boolean;
|
|
33
32
|
readonly loading: boolean;
|
|
33
|
+
readonly isFooter: boolean;
|
|
34
34
|
readonly boolEnter: boolean;
|
|
35
35
|
readonly isShowOpen: boolean;
|
|
36
36
|
readonly isExpansion: boolean;
|
|
@@ -63,8 +63,8 @@ declare const __VLS_component: DefineComponent<FQueryConditionProps, {
|
|
|
63
63
|
reset: boolean;
|
|
64
64
|
labelPosition: "top" | "left" | "right";
|
|
65
65
|
labelWidth: string;
|
|
66
|
-
isFooter: boolean;
|
|
67
66
|
loading: boolean;
|
|
67
|
+
isFooter: boolean;
|
|
68
68
|
moreCheckList: any[];
|
|
69
69
|
opts: Record<string, any>;
|
|
70
70
|
btnCheckBind: Record<string, any>;
|
package/es/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { default as installer } from './defaults';
|
|
2
2
|
import { App } from 'vue';
|
|
3
|
-
export * from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
export * from '
|
|
7
|
-
export * from '
|
|
8
|
-
export * from '
|
|
9
|
-
export * from '
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './api';
|
|
5
|
+
export * from './utils';
|
|
6
|
+
export * from './stores';
|
|
7
|
+
export * from './hooks';
|
|
8
|
+
export * from './router';
|
|
9
|
+
export * from './locale';
|
|
10
10
|
export { version } from './version';
|
|
11
11
|
export declare const install: (app: App) => void;
|
|
12
12
|
export default installer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { useApi, useBaseApi } from './base/index.mjs';
|
|
2
2
|
export { feature, useSysApi } from './sys/index.mjs';
|
|
3
|
-
export { accessTokenKey, axiosInstance, cancelAllRequest, cancelRequest, clearAccessTokens, clearTokens, decryptJWT, getHeader, getJWTDate, getToken, reLoadLoginAccessToken, refreshAccessTokenKey, request2, default as service, sleep, tansParams } from '../utils/request.mjs';
|
|
4
3
|
|
|
5
4
|
var AccountTypeEnum = /* @__PURE__ */ ((AccountTypeEnum2) => {
|
|
6
5
|
AccountTypeEnum2[AccountTypeEnum2["NUMBER_666"] = 666] = "NUMBER_666";
|
|
@@ -14,6 +14,7 @@ export { StringToObj } from './json-utils.mjs';
|
|
|
14
14
|
export { NextLoading } from './loading.mjs';
|
|
15
15
|
import './md5Signature.mjs';
|
|
16
16
|
import './mitt.mjs';
|
|
17
|
+
export { accessTokenKey, axiosInstance, cancelAllRequest, cancelRequest, clearAccessTokens, clearTokens, decryptJWT, getHeader, getJWTDate, getToken, reLoadLoginAccessToken, refreshAccessTokenKey, request2, default as service, sleep, tansParams } from './request.mjs';
|
|
17
18
|
export { saulVModel } from './saulVModel.mjs';
|
|
18
19
|
export { setCssCdn, setJsCdn } from './setIconfont.mjs';
|
|
19
20
|
export { Local, Session } from './storage.mjs';
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! fmdeui-fmui v1.0.
|
|
1
|
+
/*! fmdeui-fmui v1.0.4 */
|
|
2
2
|
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('pinia'), require('crypto-js'), require('xlsx-js-style'), require('element-plus'), require('vue'), require('@element-plus/icons-vue'), require('mitt'), require('
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports', 'pinia', 'crypto-js', 'xlsx-js-style', 'element-plus', 'vue', '@element-plus/icons-vue', 'mitt', '
|
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fmdeuifmui = {}, global.Pinia, global.CryptoJS, global.XLSX, global.ElementPlus, global.Vue, global.ElementPlusIconsVue, global.mitt, global.
|
|
6
|
-
})(this, (function (exports, pinia$1, CryptoJS, XLSXS, elementPlus, vue, svg, mitt,
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('pinia'), require('crypto-js'), require('xlsx-js-style'), require('element-plus'), require('vue'), require('@element-plus/icons-vue'), require('mitt'), require('axios'), require('js-cookie'), require('vxe-table'), require('@vxe-ui/plugin-render-element'), require('@vxe-ui/plugin-export-xlsx'), require('vxe-pc-ui'), require('vue-i18n'), require('exceljs'), require('lodash-es'), require('@vueuse/core'), require('vue-router'), require('nprogress')) :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(['exports', 'pinia', 'crypto-js', 'xlsx-js-style', 'element-plus', 'vue', '@element-plus/icons-vue', 'mitt', 'axios', 'js-cookie', 'vxe-table', '@vxe-ui/plugin-render-element', '@vxe-ui/plugin-export-xlsx', 'vxe-pc-ui', 'vue-i18n', 'exceljs', 'lodash-es', '@vueuse/core', 'vue-router', 'nprogress'], factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fmdeuifmui = {}, global.Pinia, global.CryptoJS, global.XLSX, global.ElementPlus, global.Vue, global.ElementPlusIconsVue, global.mitt, global.axios, global.Cookies, global.VxeUITable, global.VxeUIPluginRenderElement, global.VxeUIPluginExportXLSX, global.VxeUIExport, global.vueI18n, global.ExcelJS, global._, global.VueUse, global.vueRouter, global.NProgress));
|
|
6
|
+
})(this, (function (exports, pinia$1, CryptoJS, XLSXS, elementPlus, vue, svg, mitt, axios, Cookies, VxeUITable, VxeUIPluginRenderElement, VxeUIPluginExportXLSX, VxeUI, vueI18n, ExcelJS, lodashEs, core, vueRouter, NProgress) { 'use strict';
|
|
7
7
|
|
|
8
8
|
const pinia = pinia$1.createPinia();
|
|
9
9
|
|
|
@@ -1165,50 +1165,6 @@
|
|
|
1165
1165
|
|
|
1166
1166
|
mitt();
|
|
1167
1167
|
|
|
1168
|
-
const saulVModel = (props, propName, emit) => {
|
|
1169
|
-
return vue.computed({
|
|
1170
|
-
get() {
|
|
1171
|
-
if (typeof props[propName] === "object") {
|
|
1172
|
-
return new Proxy(props[propName], {
|
|
1173
|
-
set(obj, name, val) {
|
|
1174
|
-
emit(`update:${String(propName)}`, { ...obj, [name]: val });
|
|
1175
|
-
return true;
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
return props[propName];
|
|
1180
|
-
},
|
|
1181
|
-
set(val) {
|
|
1182
|
-
emit(`update:${String(propName)}`, val);
|
|
1183
|
-
}
|
|
1184
|
-
});
|
|
1185
|
-
};
|
|
1186
|
-
|
|
1187
|
-
const cssCdnUrlList = [
|
|
1188
|
-
// 调整为从本地引入,注释下面的 url
|
|
1189
|
-
// '//at.alicdn.com/t/c/font_2298093_rnp72ifj3ba.css',
|
|
1190
|
-
// '//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
|
|
1191
|
-
];
|
|
1192
|
-
const jsCdnUrlList = [];
|
|
1193
|
-
function setCssCdn() {
|
|
1194
|
-
if (cssCdnUrlList.length <= 0) return false;
|
|
1195
|
-
cssCdnUrlList.map((v) => {
|
|
1196
|
-
let link = document.createElement("link");
|
|
1197
|
-
link.rel = "stylesheet";
|
|
1198
|
-
link.href = v;
|
|
1199
|
-
link.crossOrigin = "anonymous";
|
|
1200
|
-
document.getElementsByTagName("head")[0].appendChild(link);
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
function setJsCdn() {
|
|
1204
|
-
if (jsCdnUrlList.length <= 0) return false;
|
|
1205
|
-
jsCdnUrlList.map((v) => {
|
|
1206
|
-
let link = document.createElement("script");
|
|
1207
|
-
link.src = v;
|
|
1208
|
-
document.body.appendChild(link);
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
1168
|
const Local = {
|
|
1213
1169
|
// 查看 v2.4.3版本更新日志
|
|
1214
1170
|
setKey(key) {
|
|
@@ -1260,6 +1216,260 @@
|
|
|
1260
1216
|
}
|
|
1261
1217
|
};
|
|
1262
1218
|
|
|
1219
|
+
const abortControllerMap = /* @__PURE__ */ new Map();
|
|
1220
|
+
const service = axios.create({
|
|
1221
|
+
baseURL: window.__env__.VITE_API_URL,
|
|
1222
|
+
timeout: 1e3 * 60 * 10
|
|
1223
|
+
// 设置超时,默认 10 分钟
|
|
1224
|
+
// headers: { 'Content-Type': 'application/json' },
|
|
1225
|
+
});
|
|
1226
|
+
const accessTokenKey = "access-token";
|
|
1227
|
+
const refreshAccessTokenKey = `x-${accessTokenKey}`;
|
|
1228
|
+
const getToken = () => {
|
|
1229
|
+
return Local.get(accessTokenKey);
|
|
1230
|
+
};
|
|
1231
|
+
const getHeader = () => {
|
|
1232
|
+
return { authorization: "Bearer " + getToken() };
|
|
1233
|
+
};
|
|
1234
|
+
const clearAccessTokens = () => {
|
|
1235
|
+
clearTokens();
|
|
1236
|
+
if (window.location.hash.startsWith("#/login")) {
|
|
1237
|
+
window.location.hash = window.location.hash.replace(/([?&])token=[^&]*&?/, "$1").replace(/&$/, "");
|
|
1238
|
+
} else {
|
|
1239
|
+
window.location.reload();
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
const clearTokens = () => {
|
|
1243
|
+
Local.remove(accessTokenKey);
|
|
1244
|
+
Local.remove(refreshAccessTokenKey);
|
|
1245
|
+
Session.clear();
|
|
1246
|
+
};
|
|
1247
|
+
const axiosInstance = axios;
|
|
1248
|
+
service.interceptors.request.use(
|
|
1249
|
+
(config) => {
|
|
1250
|
+
var _a;
|
|
1251
|
+
const controller = new AbortController();
|
|
1252
|
+
config.signal = controller.signal;
|
|
1253
|
+
const url = config.url || "";
|
|
1254
|
+
abortControllerMap.set(url, controller);
|
|
1255
|
+
const accessToken = Local.get(accessTokenKey);
|
|
1256
|
+
if (accessToken) {
|
|
1257
|
+
config.headers["Authorization"] = `Bearer ${accessToken}`;
|
|
1258
|
+
const jwt = decryptJWT(accessToken);
|
|
1259
|
+
const exp = getJWTDate(jwt.exp);
|
|
1260
|
+
if (/* @__PURE__ */ new Date() >= exp) {
|
|
1261
|
+
const refreshAccessToken = Local.get(refreshAccessTokenKey);
|
|
1262
|
+
if (refreshAccessToken) {
|
|
1263
|
+
config.headers["X-Authorization"] = `Bearer ${refreshAccessToken}`;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if (((_a = config.method) == null ? void 0 : _a.toLowerCase()) === "get" && config.data) {
|
|
1267
|
+
let url2 = config.url + "?" + tansParams(config.data);
|
|
1268
|
+
url2 = url2.slice(0, -1);
|
|
1269
|
+
config.data = {};
|
|
1270
|
+
config.url = url2;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
return config;
|
|
1274
|
+
},
|
|
1275
|
+
(error) => {
|
|
1276
|
+
return Promise.reject(error);
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
service.interceptors.response.use(
|
|
1280
|
+
(res) => {
|
|
1281
|
+
const url = res.config.url || "";
|
|
1282
|
+
abortControllerMap.delete(url);
|
|
1283
|
+
var status = res.status;
|
|
1284
|
+
var serve = res.data;
|
|
1285
|
+
if (status === 401) {
|
|
1286
|
+
clearAccessTokens();
|
|
1287
|
+
}
|
|
1288
|
+
if (status >= 400) {
|
|
1289
|
+
throw new Error(res.statusText || "Request Error.");
|
|
1290
|
+
}
|
|
1291
|
+
if (serve && serve.hasOwnProperty("errors") && serve.errors) {
|
|
1292
|
+
throw new Error(JSON.stringify(serve.errors || "Request Error."));
|
|
1293
|
+
}
|
|
1294
|
+
var accessToken = res.headers[accessTokenKey];
|
|
1295
|
+
var refreshAccessToken = res.headers[refreshAccessTokenKey];
|
|
1296
|
+
if (accessToken === "invalid_token") {
|
|
1297
|
+
clearAccessTokens();
|
|
1298
|
+
} else if (refreshAccessToken && accessToken && accessToken !== "invalid_token") {
|
|
1299
|
+
Local.set(accessTokenKey, accessToken);
|
|
1300
|
+
Local.set(refreshAccessTokenKey, refreshAccessToken);
|
|
1301
|
+
}
|
|
1302
|
+
if (serve.code === 401) {
|
|
1303
|
+
clearAccessTokens();
|
|
1304
|
+
} else if (serve.code === void 0) {
|
|
1305
|
+
return Promise.resolve(res);
|
|
1306
|
+
} else if (serve.code !== 200) {
|
|
1307
|
+
let message = handleResponse(serve.message, 5);
|
|
1308
|
+
elementPlus.ElMessage.error({ dangerouslyUseHTMLString: true, message });
|
|
1309
|
+
throw new Error(serve.message);
|
|
1310
|
+
}
|
|
1311
|
+
return res;
|
|
1312
|
+
},
|
|
1313
|
+
(error) => {
|
|
1314
|
+
if (error.response) {
|
|
1315
|
+
if (error.response.status === 401) {
|
|
1316
|
+
clearAccessTokens();
|
|
1317
|
+
} else if (error.response.statusCode === 404) {
|
|
1318
|
+
elementPlus.ElMessage.error("\u63A5\u53E3\u5F02\u5E38\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458");
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (error.message.indexOf("timeout") != -1) {
|
|
1322
|
+
elementPlus.ElMessage.error("\u7F51\u7EDC\u8D85\u65F6");
|
|
1323
|
+
} else if (error.message == "Network Error") {
|
|
1324
|
+
elementPlus.ElMessage.error("\u7F51\u7EDC\u8FDE\u63A5\u9519\u8BEF");
|
|
1325
|
+
} else {
|
|
1326
|
+
if (error.response.data) elementPlus.ElMessage.error(error.response.statusText);
|
|
1327
|
+
else elementPlus.ElMessage.error("\u63A5\u53E3\u8DEF\u5F84\u627E\u4E0D\u5230");
|
|
1328
|
+
}
|
|
1329
|
+
return Promise.reject(error);
|
|
1330
|
+
}
|
|
1331
|
+
);
|
|
1332
|
+
const handleResponse = (input, col = 5) => {
|
|
1333
|
+
const messageList = [];
|
|
1334
|
+
const errorCodeRegex = /^\[[A-Za-z0-9_]+\]\s*/;
|
|
1335
|
+
function process(value) {
|
|
1336
|
+
if (value == null) return;
|
|
1337
|
+
if (typeof value === "string") {
|
|
1338
|
+
const clean = value.replace(errorCodeRegex, "");
|
|
1339
|
+
if (clean.trim()) messageList.push(clean.trim());
|
|
1340
|
+
} else if (Array.isArray(value)) {
|
|
1341
|
+
value.forEach((item) => process(item));
|
|
1342
|
+
} else if (typeof value === "object") {
|
|
1343
|
+
Object.values(value).forEach((val) => process(val));
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
try {
|
|
1347
|
+
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
1348
|
+
process(parsed);
|
|
1349
|
+
} catch (e) {
|
|
1350
|
+
process(input);
|
|
1351
|
+
}
|
|
1352
|
+
col = col < 4 ? 4 : col;
|
|
1353
|
+
return messageList.reduce((rows, msg, i) => {
|
|
1354
|
+
if (i % col === 0) rows.push([]);
|
|
1355
|
+
rows[rows.length - 1].push(msg);
|
|
1356
|
+
return rows;
|
|
1357
|
+
}, []).map((row) => row.join("; ")).join("<br/>");
|
|
1358
|
+
};
|
|
1359
|
+
const cancelRequest = (url) => {
|
|
1360
|
+
var _a;
|
|
1361
|
+
const urlList = Array.isArray(url) ? url : [url];
|
|
1362
|
+
for (const _url of urlList) {
|
|
1363
|
+
(_a = abortControllerMap.get(_url)) == null ? void 0 : _a.abort();
|
|
1364
|
+
abortControllerMap.delete(_url);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
const cancelAllRequest = () => {
|
|
1368
|
+
for (const [_, controller] of abortControllerMap) {
|
|
1369
|
+
controller.abort();
|
|
1370
|
+
}
|
|
1371
|
+
abortControllerMap.clear();
|
|
1372
|
+
};
|
|
1373
|
+
function tansParams(params) {
|
|
1374
|
+
let result = "";
|
|
1375
|
+
for (const propName of Object.keys(params)) {
|
|
1376
|
+
const value = params[propName];
|
|
1377
|
+
var part = encodeURIComponent(propName) + "=";
|
|
1378
|
+
if (value !== null && value !== "" && typeof value !== "undefined") {
|
|
1379
|
+
if (typeof value === "object") {
|
|
1380
|
+
for (const key of Object.keys(value)) {
|
|
1381
|
+
if (value[key] !== null && value[key] !== "" && typeof value[key] !== "undefined") {
|
|
1382
|
+
let params2 = propName + "[" + key + "]";
|
|
1383
|
+
var subPart = encodeURIComponent(params2) + "=";
|
|
1384
|
+
result += subPart + encodeURIComponent(value[key]) + "&";
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
} else {
|
|
1388
|
+
result += part + encodeURIComponent(value) + "&";
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return result;
|
|
1393
|
+
}
|
|
1394
|
+
function decryptJWT(token) {
|
|
1395
|
+
token = token.replace(/_/g, "/").replace(/-/g, "+");
|
|
1396
|
+
var json = decodeURIComponent(escape(window.atob(token.split(".")[1])));
|
|
1397
|
+
return JSON.parse(json);
|
|
1398
|
+
}
|
|
1399
|
+
function getJWTDate(timestamp) {
|
|
1400
|
+
return new Date(timestamp * 1e3);
|
|
1401
|
+
}
|
|
1402
|
+
function request2(config) {
|
|
1403
|
+
return new Promise((resolve, reject) => {
|
|
1404
|
+
service(config).then((res) => {
|
|
1405
|
+
if (res.data.type == "success") {
|
|
1406
|
+
resolve(res.data.result);
|
|
1407
|
+
} else {
|
|
1408
|
+
elementPlus.ElMessage.success(res.data.message);
|
|
1409
|
+
}
|
|
1410
|
+
}).catch((res) => {
|
|
1411
|
+
elementPlus.ElMessage.error(res);
|
|
1412
|
+
reject(res);
|
|
1413
|
+
});
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
function reLoadLoginAccessToken(accessInfo) {
|
|
1417
|
+
if ((accessInfo == null ? void 0 : accessInfo.accessToken) && (accessInfo == null ? void 0 : accessInfo.refreshToken)) {
|
|
1418
|
+
Local.remove("tagsViewList");
|
|
1419
|
+
Session.set("token", accessInfo.accessToken);
|
|
1420
|
+
Local.set(accessTokenKey, accessInfo.accessToken);
|
|
1421
|
+
Local.set(refreshAccessTokenKey, accessInfo.refreshToken);
|
|
1422
|
+
setTimeout(() => location.href = "/", 500);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
function sleep(delay) {
|
|
1426
|
+
return new Promise((resolve) => setTimeout(resolve, delay));
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
const saulVModel = (props, propName, emit) => {
|
|
1430
|
+
return vue.computed({
|
|
1431
|
+
get() {
|
|
1432
|
+
if (typeof props[propName] === "object") {
|
|
1433
|
+
return new Proxy(props[propName], {
|
|
1434
|
+
set(obj, name, val) {
|
|
1435
|
+
emit(`update:${String(propName)}`, { ...obj, [name]: val });
|
|
1436
|
+
return true;
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
return props[propName];
|
|
1441
|
+
},
|
|
1442
|
+
set(val) {
|
|
1443
|
+
emit(`update:${String(propName)}`, val);
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
};
|
|
1447
|
+
|
|
1448
|
+
const cssCdnUrlList = [
|
|
1449
|
+
// 调整为从本地引入,注释下面的 url
|
|
1450
|
+
// '//at.alicdn.com/t/c/font_2298093_rnp72ifj3ba.css',
|
|
1451
|
+
// '//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
|
|
1452
|
+
];
|
|
1453
|
+
const jsCdnUrlList = [];
|
|
1454
|
+
function setCssCdn() {
|
|
1455
|
+
if (cssCdnUrlList.length <= 0) return false;
|
|
1456
|
+
cssCdnUrlList.map((v) => {
|
|
1457
|
+
let link = document.createElement("link");
|
|
1458
|
+
link.rel = "stylesheet";
|
|
1459
|
+
link.href = v;
|
|
1460
|
+
link.crossOrigin = "anonymous";
|
|
1461
|
+
document.getElementsByTagName("head")[0].appendChild(link);
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
function setJsCdn() {
|
|
1465
|
+
if (jsCdnUrlList.length <= 0) return false;
|
|
1466
|
+
jsCdnUrlList.map((v) => {
|
|
1467
|
+
let link = document.createElement("script");
|
|
1468
|
+
link.src = v;
|
|
1469
|
+
document.body.appendChild(link);
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1263
1473
|
function useChangeColor() {
|
|
1264
1474
|
const hexToRgb = (str) => {
|
|
1265
1475
|
let hexs = "";
|
|
@@ -1651,216 +1861,6 @@
|
|
|
1651
1861
|
}
|
|
1652
1862
|
});
|
|
1653
1863
|
|
|
1654
|
-
const abortControllerMap = /* @__PURE__ */ new Map();
|
|
1655
|
-
const service = axios.create({
|
|
1656
|
-
baseURL: window.__env__.VITE_API_URL,
|
|
1657
|
-
timeout: 1e3 * 60 * 10
|
|
1658
|
-
// 设置超时,默认 10 分钟
|
|
1659
|
-
// headers: { 'Content-Type': 'application/json' },
|
|
1660
|
-
});
|
|
1661
|
-
const accessTokenKey = "access-token";
|
|
1662
|
-
const refreshAccessTokenKey = `x-${accessTokenKey}`;
|
|
1663
|
-
const getToken = () => {
|
|
1664
|
-
return Local.get(accessTokenKey);
|
|
1665
|
-
};
|
|
1666
|
-
const getHeader = () => {
|
|
1667
|
-
return { authorization: "Bearer " + getToken() };
|
|
1668
|
-
};
|
|
1669
|
-
const clearAccessTokens = () => {
|
|
1670
|
-
clearTokens();
|
|
1671
|
-
if (window.location.hash.startsWith("#/login")) {
|
|
1672
|
-
window.location.hash = window.location.hash.replace(/([?&])token=[^&]*&?/, "$1").replace(/&$/, "");
|
|
1673
|
-
} else {
|
|
1674
|
-
window.location.reload();
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
const clearTokens = () => {
|
|
1678
|
-
Local.remove(accessTokenKey);
|
|
1679
|
-
Local.remove(refreshAccessTokenKey);
|
|
1680
|
-
Session.clear();
|
|
1681
|
-
};
|
|
1682
|
-
const axiosInstance = axios;
|
|
1683
|
-
service.interceptors.request.use(
|
|
1684
|
-
(config) => {
|
|
1685
|
-
var _a;
|
|
1686
|
-
const controller = new AbortController();
|
|
1687
|
-
config.signal = controller.signal;
|
|
1688
|
-
const url = config.url || "";
|
|
1689
|
-
abortControllerMap.set(url, controller);
|
|
1690
|
-
const accessToken = Local.get(accessTokenKey);
|
|
1691
|
-
if (accessToken) {
|
|
1692
|
-
config.headers["Authorization"] = `Bearer ${accessToken}`;
|
|
1693
|
-
const jwt = decryptJWT(accessToken);
|
|
1694
|
-
const exp = getJWTDate(jwt.exp);
|
|
1695
|
-
if (/* @__PURE__ */ new Date() >= exp) {
|
|
1696
|
-
const refreshAccessToken = Local.get(refreshAccessTokenKey);
|
|
1697
|
-
if (refreshAccessToken) {
|
|
1698
|
-
config.headers["X-Authorization"] = `Bearer ${refreshAccessToken}`;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
if (((_a = config.method) == null ? void 0 : _a.toLowerCase()) === "get" && config.data) {
|
|
1702
|
-
let url2 = config.url + "?" + tansParams(config.data);
|
|
1703
|
-
url2 = url2.slice(0, -1);
|
|
1704
|
-
config.data = {};
|
|
1705
|
-
config.url = url2;
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
return config;
|
|
1709
|
-
},
|
|
1710
|
-
(error) => {
|
|
1711
|
-
return Promise.reject(error);
|
|
1712
|
-
}
|
|
1713
|
-
);
|
|
1714
|
-
service.interceptors.response.use(
|
|
1715
|
-
(res) => {
|
|
1716
|
-
const url = res.config.url || "";
|
|
1717
|
-
abortControllerMap.delete(url);
|
|
1718
|
-
var status = res.status;
|
|
1719
|
-
var serve = res.data;
|
|
1720
|
-
if (status === 401) {
|
|
1721
|
-
clearAccessTokens();
|
|
1722
|
-
}
|
|
1723
|
-
if (status >= 400) {
|
|
1724
|
-
throw new Error(res.statusText || "Request Error.");
|
|
1725
|
-
}
|
|
1726
|
-
if (serve && serve.hasOwnProperty("errors") && serve.errors) {
|
|
1727
|
-
throw new Error(JSON.stringify(serve.errors || "Request Error."));
|
|
1728
|
-
}
|
|
1729
|
-
var accessToken = res.headers[accessTokenKey];
|
|
1730
|
-
var refreshAccessToken = res.headers[refreshAccessTokenKey];
|
|
1731
|
-
if (accessToken === "invalid_token") {
|
|
1732
|
-
clearAccessTokens();
|
|
1733
|
-
} else if (refreshAccessToken && accessToken && accessToken !== "invalid_token") {
|
|
1734
|
-
Local.set(accessTokenKey, accessToken);
|
|
1735
|
-
Local.set(refreshAccessTokenKey, refreshAccessToken);
|
|
1736
|
-
}
|
|
1737
|
-
if (serve.code === 401) {
|
|
1738
|
-
clearAccessTokens();
|
|
1739
|
-
} else if (serve.code === void 0) {
|
|
1740
|
-
return Promise.resolve(res);
|
|
1741
|
-
} else if (serve.code !== 200) {
|
|
1742
|
-
let message = handleResponse(serve.message, 5);
|
|
1743
|
-
elementPlus.ElMessage.error({ dangerouslyUseHTMLString: true, message });
|
|
1744
|
-
throw new Error(serve.message);
|
|
1745
|
-
}
|
|
1746
|
-
return res;
|
|
1747
|
-
},
|
|
1748
|
-
(error) => {
|
|
1749
|
-
if (error.response) {
|
|
1750
|
-
if (error.response.status === 401) {
|
|
1751
|
-
clearAccessTokens();
|
|
1752
|
-
} else if (error.response.statusCode === 404) {
|
|
1753
|
-
elementPlus.ElMessage.error("\u63A5\u53E3\u5F02\u5E38\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458");
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
if (error.message.indexOf("timeout") != -1) {
|
|
1757
|
-
elementPlus.ElMessage.error("\u7F51\u7EDC\u8D85\u65F6");
|
|
1758
|
-
} else if (error.message == "Network Error") {
|
|
1759
|
-
elementPlus.ElMessage.error("\u7F51\u7EDC\u8FDE\u63A5\u9519\u8BEF");
|
|
1760
|
-
} else {
|
|
1761
|
-
if (error.response.data) elementPlus.ElMessage.error(error.response.statusText);
|
|
1762
|
-
else elementPlus.ElMessage.error("\u63A5\u53E3\u8DEF\u5F84\u627E\u4E0D\u5230");
|
|
1763
|
-
}
|
|
1764
|
-
return Promise.reject(error);
|
|
1765
|
-
}
|
|
1766
|
-
);
|
|
1767
|
-
const handleResponse = (input, col = 5) => {
|
|
1768
|
-
const messageList = [];
|
|
1769
|
-
const errorCodeRegex = /^\[[A-Za-z0-9_]+\]\s*/;
|
|
1770
|
-
function process(value) {
|
|
1771
|
-
if (value == null) return;
|
|
1772
|
-
if (typeof value === "string") {
|
|
1773
|
-
const clean = value.replace(errorCodeRegex, "");
|
|
1774
|
-
if (clean.trim()) messageList.push(clean.trim());
|
|
1775
|
-
} else if (Array.isArray(value)) {
|
|
1776
|
-
value.forEach((item) => process(item));
|
|
1777
|
-
} else if (typeof value === "object") {
|
|
1778
|
-
Object.values(value).forEach((val) => process(val));
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
try {
|
|
1782
|
-
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
1783
|
-
process(parsed);
|
|
1784
|
-
} catch (e) {
|
|
1785
|
-
process(input);
|
|
1786
|
-
}
|
|
1787
|
-
col = col < 4 ? 4 : col;
|
|
1788
|
-
return messageList.reduce((rows, msg, i) => {
|
|
1789
|
-
if (i % col === 0) rows.push([]);
|
|
1790
|
-
rows[rows.length - 1].push(msg);
|
|
1791
|
-
return rows;
|
|
1792
|
-
}, []).map((row) => row.join("; ")).join("<br/>");
|
|
1793
|
-
};
|
|
1794
|
-
const cancelRequest = (url) => {
|
|
1795
|
-
var _a;
|
|
1796
|
-
const urlList = Array.isArray(url) ? url : [url];
|
|
1797
|
-
for (const _url of urlList) {
|
|
1798
|
-
(_a = abortControllerMap.get(_url)) == null ? void 0 : _a.abort();
|
|
1799
|
-
abortControllerMap.delete(_url);
|
|
1800
|
-
}
|
|
1801
|
-
};
|
|
1802
|
-
const cancelAllRequest = () => {
|
|
1803
|
-
for (const [_, controller] of abortControllerMap) {
|
|
1804
|
-
controller.abort();
|
|
1805
|
-
}
|
|
1806
|
-
abortControllerMap.clear();
|
|
1807
|
-
};
|
|
1808
|
-
function tansParams(params) {
|
|
1809
|
-
let result = "";
|
|
1810
|
-
for (const propName of Object.keys(params)) {
|
|
1811
|
-
const value = params[propName];
|
|
1812
|
-
var part = encodeURIComponent(propName) + "=";
|
|
1813
|
-
if (value !== null && value !== "" && typeof value !== "undefined") {
|
|
1814
|
-
if (typeof value === "object") {
|
|
1815
|
-
for (const key of Object.keys(value)) {
|
|
1816
|
-
if (value[key] !== null && value[key] !== "" && typeof value[key] !== "undefined") {
|
|
1817
|
-
let params2 = propName + "[" + key + "]";
|
|
1818
|
-
var subPart = encodeURIComponent(params2) + "=";
|
|
1819
|
-
result += subPart + encodeURIComponent(value[key]) + "&";
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
} else {
|
|
1823
|
-
result += part + encodeURIComponent(value) + "&";
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
return result;
|
|
1828
|
-
}
|
|
1829
|
-
function decryptJWT(token) {
|
|
1830
|
-
token = token.replace(/_/g, "/").replace(/-/g, "+");
|
|
1831
|
-
var json = decodeURIComponent(escape(window.atob(token.split(".")[1])));
|
|
1832
|
-
return JSON.parse(json);
|
|
1833
|
-
}
|
|
1834
|
-
function getJWTDate(timestamp) {
|
|
1835
|
-
return new Date(timestamp * 1e3);
|
|
1836
|
-
}
|
|
1837
|
-
function request2(config) {
|
|
1838
|
-
return new Promise((resolve, reject) => {
|
|
1839
|
-
service(config).then((res) => {
|
|
1840
|
-
if (res.data.type == "success") {
|
|
1841
|
-
resolve(res.data.result);
|
|
1842
|
-
} else {
|
|
1843
|
-
elementPlus.ElMessage.success(res.data.message);
|
|
1844
|
-
}
|
|
1845
|
-
}).catch((res) => {
|
|
1846
|
-
elementPlus.ElMessage.error(res);
|
|
1847
|
-
reject(res);
|
|
1848
|
-
});
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
function reLoadLoginAccessToken(accessInfo) {
|
|
1852
|
-
if ((accessInfo == null ? void 0 : accessInfo.accessToken) && (accessInfo == null ? void 0 : accessInfo.refreshToken)) {
|
|
1853
|
-
Local.remove("tagsViewList");
|
|
1854
|
-
Session.set("token", accessInfo.accessToken);
|
|
1855
|
-
Local.set(accessTokenKey, accessInfo.accessToken);
|
|
1856
|
-
Local.set(refreshAccessTokenKey, accessInfo.refreshToken);
|
|
1857
|
-
setTimeout(() => location.href = "/", 500);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
function sleep(delay) {
|
|
1861
|
-
return new Promise((resolve) => setTimeout(resolve, delay));
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
1864
|
const useBaseApi = (module, options = {}) => {
|
|
1865
1865
|
const baseUrl = `/api/${module}/`;
|
|
1866
1866
|
const request = (config, cancel = false) => {
|