inl-ui 0.1.174 → 0.1.175
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/dist/components/index.cjs +122 -41
- package/dist/components/index.js +122 -41
- package/dist/index.cjs +123 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.js +123 -42
- package/package.json +1 -1
|
@@ -7210,62 +7210,138 @@ const PageContent = vue.defineComponent({
|
|
|
7210
7210
|
};
|
|
7211
7211
|
const activeMenu = useActiveMenu(() => props.menu, props.extraPages, false, false, extraIframeList);
|
|
7212
7212
|
let interval = null;
|
|
7213
|
+
const minute = 60 * 1e3;
|
|
7214
|
+
const retryDelay = 5 * 1e3;
|
|
7215
|
+
const getRecordKey = item => {
|
|
7216
|
+
if (!item) return "";
|
|
7217
|
+
if (item.isExtra || item.isExtraTab) {
|
|
7218
|
+
return `extra:${item.key ?? item.id ?? ""}:${item.uniqueKey ?? ""}`;
|
|
7219
|
+
}
|
|
7220
|
+
return `menu:${item.id ?? item.key ?? item.url ?? ""}`;
|
|
7221
|
+
};
|
|
7222
|
+
const sendRecord = async (obj, fun) => {
|
|
7223
|
+
let userInfo = {};
|
|
7224
|
+
try {
|
|
7225
|
+
userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
7226
|
+
} catch {}
|
|
7227
|
+
const payload = {
|
|
7228
|
+
...obj,
|
|
7229
|
+
userId: userInfo.userId,
|
|
7230
|
+
userName: userInfo.userName,
|
|
7231
|
+
menuName: obj.name,
|
|
7232
|
+
type: 1
|
|
7233
|
+
};
|
|
7234
|
+
try {
|
|
7235
|
+
await axios__default["default"].post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", payload, {
|
|
7236
|
+
headers: {
|
|
7237
|
+
token: sessionStorage.getItem("token") || ""
|
|
7238
|
+
}
|
|
7239
|
+
});
|
|
7240
|
+
return true;
|
|
7241
|
+
} catch {
|
|
7242
|
+
return false;
|
|
7243
|
+
}
|
|
7244
|
+
};
|
|
7245
|
+
const buildRecordPayload = (entry, sendTime = entry.sendTime) => ({
|
|
7246
|
+
...entry.menu,
|
|
7247
|
+
uuid: entry.uuid,
|
|
7248
|
+
inUse: entry.inUse,
|
|
7249
|
+
sendTime,
|
|
7250
|
+
leaveTime: entry.leaveTime
|
|
7251
|
+
});
|
|
7252
|
+
const ensureInserted = entry => {
|
|
7253
|
+
if (entry.inserted) return Promise.resolve(true);
|
|
7254
|
+
if (entry.insertPromise) return entry.insertPromise;
|
|
7255
|
+
entry.insertPromise = sendRecord(buildRecordPayload(entry, entry.sendTime), "insert").then(success => {
|
|
7256
|
+
if (success) {
|
|
7257
|
+
entry.inserted = true;
|
|
7258
|
+
entry.insertPromise = void 0;
|
|
7259
|
+
} else {
|
|
7260
|
+
entry.insertPromise = void 0;
|
|
7261
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
7262
|
+
}
|
|
7263
|
+
return success;
|
|
7264
|
+
});
|
|
7265
|
+
return entry.insertPromise;
|
|
7266
|
+
};
|
|
7267
|
+
const queueUpdate = (entry, force = false) => {
|
|
7268
|
+
if (entry.updateQueued) return;
|
|
7269
|
+
if (!force && entry.sendTime <= 0) return;
|
|
7270
|
+
if (entry.retryAt > Date.now()) return;
|
|
7271
|
+
entry.updateQueued = true;
|
|
7272
|
+
entry.requestChain = entry.requestChain.catch(() => false).then(async () => {
|
|
7273
|
+
if (!(await ensureInserted(entry))) return false;
|
|
7274
|
+
const sendTime = entry.sendTime;
|
|
7275
|
+
if (!force && sendTime <= 0) return true;
|
|
7276
|
+
const success = await sendRecord(buildRecordPayload(entry, sendTime), "update");
|
|
7277
|
+
if (success && sendTime > 0) {
|
|
7278
|
+
entry.sendTime = Math.max(0, entry.sendTime - sendTime);
|
|
7279
|
+
} else if (!success) {
|
|
7280
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
7281
|
+
}
|
|
7282
|
+
return success;
|
|
7283
|
+
}).finally(() => {
|
|
7284
|
+
entry.updateQueued = false;
|
|
7285
|
+
});
|
|
7286
|
+
};
|
|
7213
7287
|
vue.onMounted(() => {
|
|
7214
7288
|
interval = setInterval(() => {
|
|
7215
|
-
historyArr.forEach(
|
|
7216
|
-
if (
|
|
7217
|
-
|
|
7218
|
-
if (
|
|
7219
|
-
|
|
7220
|
-
item.sendTime = 0;
|
|
7289
|
+
historyArr.forEach(entry => {
|
|
7290
|
+
if (entry.inUse) {
|
|
7291
|
+
entry.sendTime += 1e3;
|
|
7292
|
+
if (entry.sendTime >= minute) {
|
|
7293
|
+
queueUpdate(entry);
|
|
7221
7294
|
}
|
|
7222
7295
|
}
|
|
7223
|
-
if (
|
|
7224
|
-
|
|
7296
|
+
if (entry.leaveTime > 0) {
|
|
7297
|
+
entry.leaveTime += 1e3;
|
|
7298
|
+
if (entry.sendTime > 0) {
|
|
7299
|
+
queueUpdate(entry);
|
|
7300
|
+
}
|
|
7225
7301
|
}
|
|
7226
7302
|
});
|
|
7227
|
-
historyArr = historyArr.filter(
|
|
7303
|
+
historyArr = historyArr.filter(entry => entry.leaveTime <= minute || entry.sendTime > 0 || entry.updateQueued || !!entry.insertPromise);
|
|
7228
7304
|
}, 1e3);
|
|
7229
7305
|
});
|
|
7230
7306
|
let historyArr = [];
|
|
7231
|
-
const sendRecord = async (obj, fun) => {
|
|
7232
|
-
const userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
7233
|
-
obj.userId = userInfo.userId;
|
|
7234
|
-
obj.userName = userInfo.userName;
|
|
7235
|
-
obj.menuName = obj.name;
|
|
7236
|
-
obj.type = 1;
|
|
7237
|
-
await axios__default["default"].post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", obj, {
|
|
7238
|
-
headers: {
|
|
7239
|
-
token: sessionStorage.getItem("token") || ""
|
|
7240
|
-
}
|
|
7241
|
-
});
|
|
7242
|
-
};
|
|
7243
7307
|
vue.watch(activeMenu, (val, oldVal) => {
|
|
7308
|
+
const oldRecordKey = getRecordKey(oldVal);
|
|
7309
|
+
const recordKey = getRecordKey(val);
|
|
7244
7310
|
if (oldVal) {
|
|
7245
|
-
const
|
|
7246
|
-
if (
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7311
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === oldRecordKey);
|
|
7312
|
+
if (historyEntry && oldRecordKey !== recordKey) {
|
|
7313
|
+
historyEntry.inUse = false;
|
|
7314
|
+
historyEntry.leaveTime = 1e3;
|
|
7315
|
+
queueUpdate(historyEntry);
|
|
7250
7316
|
}
|
|
7251
7317
|
}
|
|
7252
7318
|
if (val) {
|
|
7253
|
-
const
|
|
7254
|
-
if (
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7319
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === recordKey);
|
|
7320
|
+
if (historyEntry) {
|
|
7321
|
+
historyEntry.menu = {
|
|
7322
|
+
...historyEntry.menu,
|
|
7323
|
+
...val
|
|
7324
|
+
};
|
|
7325
|
+
historyEntry.leaveTime = 0;
|
|
7326
|
+
historyEntry.inUse = true;
|
|
7327
|
+
queueUpdate(historyEntry, oldRecordKey !== recordKey);
|
|
7262
7328
|
} else {
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7329
|
+
const entry = {
|
|
7330
|
+
recordKey,
|
|
7331
|
+
menu: {
|
|
7332
|
+
...val
|
|
7333
|
+
},
|
|
7334
|
+
uuid: UUID(),
|
|
7335
|
+
leaveTime: 0,
|
|
7336
|
+
sendTime: 0,
|
|
7337
|
+
inUse: true,
|
|
7338
|
+
inserted: false,
|
|
7339
|
+
requestChain: Promise.resolve(true),
|
|
7340
|
+
updateQueued: false,
|
|
7341
|
+
retryAt: 0
|
|
7342
|
+
};
|
|
7343
|
+
historyArr.push(entry);
|
|
7344
|
+
ensureInserted(entry);
|
|
7269
7345
|
}
|
|
7270
7346
|
}
|
|
7271
7347
|
handleMenuChange(val);
|
|
@@ -7367,6 +7443,11 @@ const PageContent = vue.defineComponent({
|
|
|
7367
7443
|
};
|
|
7368
7444
|
vue.onBeforeUnmount(() => {
|
|
7369
7445
|
clearInterval(interval);
|
|
7446
|
+
historyArr.forEach(entry => {
|
|
7447
|
+
entry.inUse = false;
|
|
7448
|
+
entry.leaveTime = minute + 1;
|
|
7449
|
+
queueUpdate(entry);
|
|
7450
|
+
});
|
|
7370
7451
|
for (const app of loadAppList.value) {
|
|
7371
7452
|
app.app.unmount();
|
|
7372
7453
|
}
|
package/dist/components/index.js
CHANGED
|
@@ -7181,62 +7181,138 @@ const PageContent = defineComponent({
|
|
|
7181
7181
|
};
|
|
7182
7182
|
const activeMenu = useActiveMenu(() => props.menu, props.extraPages, false, false, extraIframeList);
|
|
7183
7183
|
let interval = null;
|
|
7184
|
+
const minute = 60 * 1e3;
|
|
7185
|
+
const retryDelay = 5 * 1e3;
|
|
7186
|
+
const getRecordKey = item => {
|
|
7187
|
+
if (!item) return "";
|
|
7188
|
+
if (item.isExtra || item.isExtraTab) {
|
|
7189
|
+
return `extra:${item.key ?? item.id ?? ""}:${item.uniqueKey ?? ""}`;
|
|
7190
|
+
}
|
|
7191
|
+
return `menu:${item.id ?? item.key ?? item.url ?? ""}`;
|
|
7192
|
+
};
|
|
7193
|
+
const sendRecord = async (obj, fun) => {
|
|
7194
|
+
let userInfo = {};
|
|
7195
|
+
try {
|
|
7196
|
+
userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
7197
|
+
} catch {}
|
|
7198
|
+
const payload = {
|
|
7199
|
+
...obj,
|
|
7200
|
+
userId: userInfo.userId,
|
|
7201
|
+
userName: userInfo.userName,
|
|
7202
|
+
menuName: obj.name,
|
|
7203
|
+
type: 1
|
|
7204
|
+
};
|
|
7205
|
+
try {
|
|
7206
|
+
await axios$3.post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", payload, {
|
|
7207
|
+
headers: {
|
|
7208
|
+
token: sessionStorage.getItem("token") || ""
|
|
7209
|
+
}
|
|
7210
|
+
});
|
|
7211
|
+
return true;
|
|
7212
|
+
} catch {
|
|
7213
|
+
return false;
|
|
7214
|
+
}
|
|
7215
|
+
};
|
|
7216
|
+
const buildRecordPayload = (entry, sendTime = entry.sendTime) => ({
|
|
7217
|
+
...entry.menu,
|
|
7218
|
+
uuid: entry.uuid,
|
|
7219
|
+
inUse: entry.inUse,
|
|
7220
|
+
sendTime,
|
|
7221
|
+
leaveTime: entry.leaveTime
|
|
7222
|
+
});
|
|
7223
|
+
const ensureInserted = entry => {
|
|
7224
|
+
if (entry.inserted) return Promise.resolve(true);
|
|
7225
|
+
if (entry.insertPromise) return entry.insertPromise;
|
|
7226
|
+
entry.insertPromise = sendRecord(buildRecordPayload(entry, entry.sendTime), "insert").then(success => {
|
|
7227
|
+
if (success) {
|
|
7228
|
+
entry.inserted = true;
|
|
7229
|
+
entry.insertPromise = void 0;
|
|
7230
|
+
} else {
|
|
7231
|
+
entry.insertPromise = void 0;
|
|
7232
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
7233
|
+
}
|
|
7234
|
+
return success;
|
|
7235
|
+
});
|
|
7236
|
+
return entry.insertPromise;
|
|
7237
|
+
};
|
|
7238
|
+
const queueUpdate = (entry, force = false) => {
|
|
7239
|
+
if (entry.updateQueued) return;
|
|
7240
|
+
if (!force && entry.sendTime <= 0) return;
|
|
7241
|
+
if (entry.retryAt > Date.now()) return;
|
|
7242
|
+
entry.updateQueued = true;
|
|
7243
|
+
entry.requestChain = entry.requestChain.catch(() => false).then(async () => {
|
|
7244
|
+
if (!(await ensureInserted(entry))) return false;
|
|
7245
|
+
const sendTime = entry.sendTime;
|
|
7246
|
+
if (!force && sendTime <= 0) return true;
|
|
7247
|
+
const success = await sendRecord(buildRecordPayload(entry, sendTime), "update");
|
|
7248
|
+
if (success && sendTime > 0) {
|
|
7249
|
+
entry.sendTime = Math.max(0, entry.sendTime - sendTime);
|
|
7250
|
+
} else if (!success) {
|
|
7251
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
7252
|
+
}
|
|
7253
|
+
return success;
|
|
7254
|
+
}).finally(() => {
|
|
7255
|
+
entry.updateQueued = false;
|
|
7256
|
+
});
|
|
7257
|
+
};
|
|
7184
7258
|
onMounted(() => {
|
|
7185
7259
|
interval = setInterval(() => {
|
|
7186
|
-
historyArr.forEach(
|
|
7187
|
-
if (
|
|
7188
|
-
|
|
7189
|
-
if (
|
|
7190
|
-
|
|
7191
|
-
item.sendTime = 0;
|
|
7260
|
+
historyArr.forEach(entry => {
|
|
7261
|
+
if (entry.inUse) {
|
|
7262
|
+
entry.sendTime += 1e3;
|
|
7263
|
+
if (entry.sendTime >= minute) {
|
|
7264
|
+
queueUpdate(entry);
|
|
7192
7265
|
}
|
|
7193
7266
|
}
|
|
7194
|
-
if (
|
|
7195
|
-
|
|
7267
|
+
if (entry.leaveTime > 0) {
|
|
7268
|
+
entry.leaveTime += 1e3;
|
|
7269
|
+
if (entry.sendTime > 0) {
|
|
7270
|
+
queueUpdate(entry);
|
|
7271
|
+
}
|
|
7196
7272
|
}
|
|
7197
7273
|
});
|
|
7198
|
-
historyArr = historyArr.filter(
|
|
7274
|
+
historyArr = historyArr.filter(entry => entry.leaveTime <= minute || entry.sendTime > 0 || entry.updateQueued || !!entry.insertPromise);
|
|
7199
7275
|
}, 1e3);
|
|
7200
7276
|
});
|
|
7201
7277
|
let historyArr = [];
|
|
7202
|
-
const sendRecord = async (obj, fun) => {
|
|
7203
|
-
const userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
7204
|
-
obj.userId = userInfo.userId;
|
|
7205
|
-
obj.userName = userInfo.userName;
|
|
7206
|
-
obj.menuName = obj.name;
|
|
7207
|
-
obj.type = 1;
|
|
7208
|
-
await axios$3.post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", obj, {
|
|
7209
|
-
headers: {
|
|
7210
|
-
token: sessionStorage.getItem("token") || ""
|
|
7211
|
-
}
|
|
7212
|
-
});
|
|
7213
|
-
};
|
|
7214
7278
|
watch(activeMenu, (val, oldVal) => {
|
|
7279
|
+
const oldRecordKey = getRecordKey(oldVal);
|
|
7280
|
+
const recordKey = getRecordKey(val);
|
|
7215
7281
|
if (oldVal) {
|
|
7216
|
-
const
|
|
7217
|
-
if (
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7282
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === oldRecordKey);
|
|
7283
|
+
if (historyEntry && oldRecordKey !== recordKey) {
|
|
7284
|
+
historyEntry.inUse = false;
|
|
7285
|
+
historyEntry.leaveTime = 1e3;
|
|
7286
|
+
queueUpdate(historyEntry);
|
|
7221
7287
|
}
|
|
7222
7288
|
}
|
|
7223
7289
|
if (val) {
|
|
7224
|
-
const
|
|
7225
|
-
if (
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7290
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === recordKey);
|
|
7291
|
+
if (historyEntry) {
|
|
7292
|
+
historyEntry.menu = {
|
|
7293
|
+
...historyEntry.menu,
|
|
7294
|
+
...val
|
|
7295
|
+
};
|
|
7296
|
+
historyEntry.leaveTime = 0;
|
|
7297
|
+
historyEntry.inUse = true;
|
|
7298
|
+
queueUpdate(historyEntry, oldRecordKey !== recordKey);
|
|
7233
7299
|
} else {
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7300
|
+
const entry = {
|
|
7301
|
+
recordKey,
|
|
7302
|
+
menu: {
|
|
7303
|
+
...val
|
|
7304
|
+
},
|
|
7305
|
+
uuid: UUID(),
|
|
7306
|
+
leaveTime: 0,
|
|
7307
|
+
sendTime: 0,
|
|
7308
|
+
inUse: true,
|
|
7309
|
+
inserted: false,
|
|
7310
|
+
requestChain: Promise.resolve(true),
|
|
7311
|
+
updateQueued: false,
|
|
7312
|
+
retryAt: 0
|
|
7313
|
+
};
|
|
7314
|
+
historyArr.push(entry);
|
|
7315
|
+
ensureInserted(entry);
|
|
7240
7316
|
}
|
|
7241
7317
|
}
|
|
7242
7318
|
handleMenuChange(val);
|
|
@@ -7338,6 +7414,11 @@ const PageContent = defineComponent({
|
|
|
7338
7414
|
};
|
|
7339
7415
|
onBeforeUnmount(() => {
|
|
7340
7416
|
clearInterval(interval);
|
|
7417
|
+
historyArr.forEach(entry => {
|
|
7418
|
+
entry.inUse = false;
|
|
7419
|
+
entry.leaveTime = minute + 1;
|
|
7420
|
+
queueUpdate(entry);
|
|
7421
|
+
});
|
|
7341
7422
|
for (const app of loadAppList.value) {
|
|
7342
7423
|
app.app.unmount();
|
|
7343
7424
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -45,7 +45,7 @@ var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
|
45
45
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
46
46
|
var mqtt__default = /*#__PURE__*/_interopDefaultLegacy(mqtt);
|
|
47
47
|
|
|
48
|
-
var version = "0.1.
|
|
48
|
+
var version = "0.1.174";
|
|
49
49
|
|
|
50
50
|
const setTheme = theme => {
|
|
51
51
|
if (theme === "dark") {
|
|
@@ -8357,62 +8357,138 @@ const PageContent = vue.defineComponent({
|
|
|
8357
8357
|
};
|
|
8358
8358
|
const activeMenu = useActiveMenu(() => props.menu, props.extraPages, false, false, extraIframeList);
|
|
8359
8359
|
let interval = null;
|
|
8360
|
+
const minute = 60 * 1e3;
|
|
8361
|
+
const retryDelay = 5 * 1e3;
|
|
8362
|
+
const getRecordKey = item => {
|
|
8363
|
+
if (!item) return "";
|
|
8364
|
+
if (item.isExtra || item.isExtraTab) {
|
|
8365
|
+
return `extra:${item.key ?? item.id ?? ""}:${item.uniqueKey ?? ""}`;
|
|
8366
|
+
}
|
|
8367
|
+
return `menu:${item.id ?? item.key ?? item.url ?? ""}`;
|
|
8368
|
+
};
|
|
8369
|
+
const sendRecord = async (obj, fun) => {
|
|
8370
|
+
let userInfo = {};
|
|
8371
|
+
try {
|
|
8372
|
+
userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
8373
|
+
} catch {}
|
|
8374
|
+
const payload = {
|
|
8375
|
+
...obj,
|
|
8376
|
+
userId: userInfo.userId,
|
|
8377
|
+
userName: userInfo.userName,
|
|
8378
|
+
menuName: obj.name,
|
|
8379
|
+
type: 1
|
|
8380
|
+
};
|
|
8381
|
+
try {
|
|
8382
|
+
await axios__default["default"].post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", payload, {
|
|
8383
|
+
headers: {
|
|
8384
|
+
token: sessionStorage.getItem("token") || ""
|
|
8385
|
+
}
|
|
8386
|
+
});
|
|
8387
|
+
return true;
|
|
8388
|
+
} catch {
|
|
8389
|
+
return false;
|
|
8390
|
+
}
|
|
8391
|
+
};
|
|
8392
|
+
const buildRecordPayload = (entry, sendTime = entry.sendTime) => ({
|
|
8393
|
+
...entry.menu,
|
|
8394
|
+
uuid: entry.uuid,
|
|
8395
|
+
inUse: entry.inUse,
|
|
8396
|
+
sendTime,
|
|
8397
|
+
leaveTime: entry.leaveTime
|
|
8398
|
+
});
|
|
8399
|
+
const ensureInserted = entry => {
|
|
8400
|
+
if (entry.inserted) return Promise.resolve(true);
|
|
8401
|
+
if (entry.insertPromise) return entry.insertPromise;
|
|
8402
|
+
entry.insertPromise = sendRecord(buildRecordPayload(entry, entry.sendTime), "insert").then(success => {
|
|
8403
|
+
if (success) {
|
|
8404
|
+
entry.inserted = true;
|
|
8405
|
+
entry.insertPromise = void 0;
|
|
8406
|
+
} else {
|
|
8407
|
+
entry.insertPromise = void 0;
|
|
8408
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
8409
|
+
}
|
|
8410
|
+
return success;
|
|
8411
|
+
});
|
|
8412
|
+
return entry.insertPromise;
|
|
8413
|
+
};
|
|
8414
|
+
const queueUpdate = (entry, force = false) => {
|
|
8415
|
+
if (entry.updateQueued) return;
|
|
8416
|
+
if (!force && entry.sendTime <= 0) return;
|
|
8417
|
+
if (entry.retryAt > Date.now()) return;
|
|
8418
|
+
entry.updateQueued = true;
|
|
8419
|
+
entry.requestChain = entry.requestChain.catch(() => false).then(async () => {
|
|
8420
|
+
if (!(await ensureInserted(entry))) return false;
|
|
8421
|
+
const sendTime = entry.sendTime;
|
|
8422
|
+
if (!force && sendTime <= 0) return true;
|
|
8423
|
+
const success = await sendRecord(buildRecordPayload(entry, sendTime), "update");
|
|
8424
|
+
if (success && sendTime > 0) {
|
|
8425
|
+
entry.sendTime = Math.max(0, entry.sendTime - sendTime);
|
|
8426
|
+
} else if (!success) {
|
|
8427
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
8428
|
+
}
|
|
8429
|
+
return success;
|
|
8430
|
+
}).finally(() => {
|
|
8431
|
+
entry.updateQueued = false;
|
|
8432
|
+
});
|
|
8433
|
+
};
|
|
8360
8434
|
vue.onMounted(() => {
|
|
8361
8435
|
interval = setInterval(() => {
|
|
8362
|
-
historyArr.forEach(
|
|
8363
|
-
if (
|
|
8364
|
-
|
|
8365
|
-
if (
|
|
8366
|
-
|
|
8367
|
-
item.sendTime = 0;
|
|
8436
|
+
historyArr.forEach(entry => {
|
|
8437
|
+
if (entry.inUse) {
|
|
8438
|
+
entry.sendTime += 1e3;
|
|
8439
|
+
if (entry.sendTime >= minute) {
|
|
8440
|
+
queueUpdate(entry);
|
|
8368
8441
|
}
|
|
8369
8442
|
}
|
|
8370
|
-
if (
|
|
8371
|
-
|
|
8443
|
+
if (entry.leaveTime > 0) {
|
|
8444
|
+
entry.leaveTime += 1e3;
|
|
8445
|
+
if (entry.sendTime > 0) {
|
|
8446
|
+
queueUpdate(entry);
|
|
8447
|
+
}
|
|
8372
8448
|
}
|
|
8373
8449
|
});
|
|
8374
|
-
historyArr = historyArr.filter(
|
|
8450
|
+
historyArr = historyArr.filter(entry => entry.leaveTime <= minute || entry.sendTime > 0 || entry.updateQueued || !!entry.insertPromise);
|
|
8375
8451
|
}, 1e3);
|
|
8376
8452
|
});
|
|
8377
8453
|
let historyArr = [];
|
|
8378
|
-
const sendRecord = async (obj, fun) => {
|
|
8379
|
-
const userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
8380
|
-
obj.userId = userInfo.userId;
|
|
8381
|
-
obj.userName = userInfo.userName;
|
|
8382
|
-
obj.menuName = obj.name;
|
|
8383
|
-
obj.type = 1;
|
|
8384
|
-
await axios__default["default"].post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", obj, {
|
|
8385
|
-
headers: {
|
|
8386
|
-
token: sessionStorage.getItem("token") || ""
|
|
8387
|
-
}
|
|
8388
|
-
});
|
|
8389
|
-
};
|
|
8390
8454
|
vue.watch(activeMenu, (val, oldVal) => {
|
|
8455
|
+
const oldRecordKey = getRecordKey(oldVal);
|
|
8456
|
+
const recordKey = getRecordKey(val);
|
|
8391
8457
|
if (oldVal) {
|
|
8392
|
-
const
|
|
8393
|
-
if (
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8458
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === oldRecordKey);
|
|
8459
|
+
if (historyEntry && oldRecordKey !== recordKey) {
|
|
8460
|
+
historyEntry.inUse = false;
|
|
8461
|
+
historyEntry.leaveTime = 1e3;
|
|
8462
|
+
queueUpdate(historyEntry);
|
|
8397
8463
|
}
|
|
8398
8464
|
}
|
|
8399
8465
|
if (val) {
|
|
8400
|
-
const
|
|
8401
|
-
if (
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8466
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === recordKey);
|
|
8467
|
+
if (historyEntry) {
|
|
8468
|
+
historyEntry.menu = {
|
|
8469
|
+
...historyEntry.menu,
|
|
8470
|
+
...val
|
|
8471
|
+
};
|
|
8472
|
+
historyEntry.leaveTime = 0;
|
|
8473
|
+
historyEntry.inUse = true;
|
|
8474
|
+
queueUpdate(historyEntry, oldRecordKey !== recordKey);
|
|
8409
8475
|
} else {
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8476
|
+
const entry = {
|
|
8477
|
+
recordKey,
|
|
8478
|
+
menu: {
|
|
8479
|
+
...val
|
|
8480
|
+
},
|
|
8481
|
+
uuid: UUID(),
|
|
8482
|
+
leaveTime: 0,
|
|
8483
|
+
sendTime: 0,
|
|
8484
|
+
inUse: true,
|
|
8485
|
+
inserted: false,
|
|
8486
|
+
requestChain: Promise.resolve(true),
|
|
8487
|
+
updateQueued: false,
|
|
8488
|
+
retryAt: 0
|
|
8489
|
+
};
|
|
8490
|
+
historyArr.push(entry);
|
|
8491
|
+
ensureInserted(entry);
|
|
8416
8492
|
}
|
|
8417
8493
|
}
|
|
8418
8494
|
handleMenuChange(val);
|
|
@@ -8514,6 +8590,11 @@ const PageContent = vue.defineComponent({
|
|
|
8514
8590
|
};
|
|
8515
8591
|
vue.onBeforeUnmount(() => {
|
|
8516
8592
|
clearInterval(interval);
|
|
8593
|
+
historyArr.forEach(entry => {
|
|
8594
|
+
entry.inUse = false;
|
|
8595
|
+
entry.leaveTime = minute + 1;
|
|
8596
|
+
queueUpdate(entry);
|
|
8597
|
+
});
|
|
8517
8598
|
for (const app of loadAppList.value) {
|
|
8518
8599
|
app.app.unmount();
|
|
8519
8600
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Key } from 'ant-design-vue/lib/table/interface';
|
|
|
11
11
|
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
12
12
|
import * as _ant_design_icons_vue_lib_components_IconFont from '@ant-design/icons-vue/lib/components/IconFont';
|
|
13
13
|
|
|
14
|
-
var version = "0.1.
|
|
14
|
+
var version = "0.1.174";
|
|
15
15
|
|
|
16
16
|
declare const _default$p: {
|
|
17
17
|
set(theme: string): void;
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { XPopup, CommentBlock, setAxiosOption } from '@sszj-temp/mobile';
|
|
|
14
14
|
import { marked } from 'marked';
|
|
15
15
|
import '@sszj-temp/mobile/style.css';
|
|
16
16
|
|
|
17
|
-
var version = "0.1.
|
|
17
|
+
var version = "0.1.174";
|
|
18
18
|
|
|
19
19
|
const setTheme = theme => {
|
|
20
20
|
if (theme === "dark") {
|
|
@@ -8326,62 +8326,138 @@ const PageContent = defineComponent({
|
|
|
8326
8326
|
};
|
|
8327
8327
|
const activeMenu = useActiveMenu(() => props.menu, props.extraPages, false, false, extraIframeList);
|
|
8328
8328
|
let interval = null;
|
|
8329
|
+
const minute = 60 * 1e3;
|
|
8330
|
+
const retryDelay = 5 * 1e3;
|
|
8331
|
+
const getRecordKey = item => {
|
|
8332
|
+
if (!item) return "";
|
|
8333
|
+
if (item.isExtra || item.isExtraTab) {
|
|
8334
|
+
return `extra:${item.key ?? item.id ?? ""}:${item.uniqueKey ?? ""}`;
|
|
8335
|
+
}
|
|
8336
|
+
return `menu:${item.id ?? item.key ?? item.url ?? ""}`;
|
|
8337
|
+
};
|
|
8338
|
+
const sendRecord = async (obj, fun) => {
|
|
8339
|
+
let userInfo = {};
|
|
8340
|
+
try {
|
|
8341
|
+
userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
8342
|
+
} catch {}
|
|
8343
|
+
const payload = {
|
|
8344
|
+
...obj,
|
|
8345
|
+
userId: userInfo.userId,
|
|
8346
|
+
userName: userInfo.userName,
|
|
8347
|
+
menuName: obj.name,
|
|
8348
|
+
type: 1
|
|
8349
|
+
};
|
|
8350
|
+
try {
|
|
8351
|
+
await axios$3.post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", payload, {
|
|
8352
|
+
headers: {
|
|
8353
|
+
token: sessionStorage.getItem("token") || ""
|
|
8354
|
+
}
|
|
8355
|
+
});
|
|
8356
|
+
return true;
|
|
8357
|
+
} catch {
|
|
8358
|
+
return false;
|
|
8359
|
+
}
|
|
8360
|
+
};
|
|
8361
|
+
const buildRecordPayload = (entry, sendTime = entry.sendTime) => ({
|
|
8362
|
+
...entry.menu,
|
|
8363
|
+
uuid: entry.uuid,
|
|
8364
|
+
inUse: entry.inUse,
|
|
8365
|
+
sendTime,
|
|
8366
|
+
leaveTime: entry.leaveTime
|
|
8367
|
+
});
|
|
8368
|
+
const ensureInserted = entry => {
|
|
8369
|
+
if (entry.inserted) return Promise.resolve(true);
|
|
8370
|
+
if (entry.insertPromise) return entry.insertPromise;
|
|
8371
|
+
entry.insertPromise = sendRecord(buildRecordPayload(entry, entry.sendTime), "insert").then(success => {
|
|
8372
|
+
if (success) {
|
|
8373
|
+
entry.inserted = true;
|
|
8374
|
+
entry.insertPromise = void 0;
|
|
8375
|
+
} else {
|
|
8376
|
+
entry.insertPromise = void 0;
|
|
8377
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
8378
|
+
}
|
|
8379
|
+
return success;
|
|
8380
|
+
});
|
|
8381
|
+
return entry.insertPromise;
|
|
8382
|
+
};
|
|
8383
|
+
const queueUpdate = (entry, force = false) => {
|
|
8384
|
+
if (entry.updateQueued) return;
|
|
8385
|
+
if (!force && entry.sendTime <= 0) return;
|
|
8386
|
+
if (entry.retryAt > Date.now()) return;
|
|
8387
|
+
entry.updateQueued = true;
|
|
8388
|
+
entry.requestChain = entry.requestChain.catch(() => false).then(async () => {
|
|
8389
|
+
if (!(await ensureInserted(entry))) return false;
|
|
8390
|
+
const sendTime = entry.sendTime;
|
|
8391
|
+
if (!force && sendTime <= 0) return true;
|
|
8392
|
+
const success = await sendRecord(buildRecordPayload(entry, sendTime), "update");
|
|
8393
|
+
if (success && sendTime > 0) {
|
|
8394
|
+
entry.sendTime = Math.max(0, entry.sendTime - sendTime);
|
|
8395
|
+
} else if (!success) {
|
|
8396
|
+
entry.retryAt = Date.now() + retryDelay;
|
|
8397
|
+
}
|
|
8398
|
+
return success;
|
|
8399
|
+
}).finally(() => {
|
|
8400
|
+
entry.updateQueued = false;
|
|
8401
|
+
});
|
|
8402
|
+
};
|
|
8329
8403
|
onMounted(() => {
|
|
8330
8404
|
interval = setInterval(() => {
|
|
8331
|
-
historyArr.forEach(
|
|
8332
|
-
if (
|
|
8333
|
-
|
|
8334
|
-
if (
|
|
8335
|
-
|
|
8336
|
-
item.sendTime = 0;
|
|
8405
|
+
historyArr.forEach(entry => {
|
|
8406
|
+
if (entry.inUse) {
|
|
8407
|
+
entry.sendTime += 1e3;
|
|
8408
|
+
if (entry.sendTime >= minute) {
|
|
8409
|
+
queueUpdate(entry);
|
|
8337
8410
|
}
|
|
8338
8411
|
}
|
|
8339
|
-
if (
|
|
8340
|
-
|
|
8412
|
+
if (entry.leaveTime > 0) {
|
|
8413
|
+
entry.leaveTime += 1e3;
|
|
8414
|
+
if (entry.sendTime > 0) {
|
|
8415
|
+
queueUpdate(entry);
|
|
8416
|
+
}
|
|
8341
8417
|
}
|
|
8342
8418
|
});
|
|
8343
|
-
historyArr = historyArr.filter(
|
|
8419
|
+
historyArr = historyArr.filter(entry => entry.leaveTime <= minute || entry.sendTime > 0 || entry.updateQueued || !!entry.insertPromise);
|
|
8344
8420
|
}, 1e3);
|
|
8345
8421
|
});
|
|
8346
8422
|
let historyArr = [];
|
|
8347
|
-
const sendRecord = async (obj, fun) => {
|
|
8348
|
-
const userInfo = JSON.parse(sessionStorage.getItem("userinfo") || "{}");
|
|
8349
|
-
obj.userId = userInfo.userId;
|
|
8350
|
-
obj.userName = userInfo.userName;
|
|
8351
|
-
obj.menuName = obj.name;
|
|
8352
|
-
obj.type = 1;
|
|
8353
|
-
await axios$3.post(fun === "insert" ? "/api/common/v1/menu-usage/record" : "/api/common/v1/menu-usage/update-duration", obj, {
|
|
8354
|
-
headers: {
|
|
8355
|
-
token: sessionStorage.getItem("token") || ""
|
|
8356
|
-
}
|
|
8357
|
-
});
|
|
8358
|
-
};
|
|
8359
8423
|
watch(activeMenu, (val, oldVal) => {
|
|
8424
|
+
const oldRecordKey = getRecordKey(oldVal);
|
|
8425
|
+
const recordKey = getRecordKey(val);
|
|
8360
8426
|
if (oldVal) {
|
|
8361
|
-
const
|
|
8362
|
-
if (
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8427
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === oldRecordKey);
|
|
8428
|
+
if (historyEntry && oldRecordKey !== recordKey) {
|
|
8429
|
+
historyEntry.inUse = false;
|
|
8430
|
+
historyEntry.leaveTime = 1e3;
|
|
8431
|
+
queueUpdate(historyEntry);
|
|
8366
8432
|
}
|
|
8367
8433
|
}
|
|
8368
8434
|
if (val) {
|
|
8369
|
-
const
|
|
8370
|
-
if (
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8435
|
+
const historyEntry = historyArr.find(entry => entry.recordKey === recordKey);
|
|
8436
|
+
if (historyEntry) {
|
|
8437
|
+
historyEntry.menu = {
|
|
8438
|
+
...historyEntry.menu,
|
|
8439
|
+
...val
|
|
8440
|
+
};
|
|
8441
|
+
historyEntry.leaveTime = 0;
|
|
8442
|
+
historyEntry.inUse = true;
|
|
8443
|
+
queueUpdate(historyEntry, oldRecordKey !== recordKey);
|
|
8378
8444
|
} else {
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8445
|
+
const entry = {
|
|
8446
|
+
recordKey,
|
|
8447
|
+
menu: {
|
|
8448
|
+
...val
|
|
8449
|
+
},
|
|
8450
|
+
uuid: UUID(),
|
|
8451
|
+
leaveTime: 0,
|
|
8452
|
+
sendTime: 0,
|
|
8453
|
+
inUse: true,
|
|
8454
|
+
inserted: false,
|
|
8455
|
+
requestChain: Promise.resolve(true),
|
|
8456
|
+
updateQueued: false,
|
|
8457
|
+
retryAt: 0
|
|
8458
|
+
};
|
|
8459
|
+
historyArr.push(entry);
|
|
8460
|
+
ensureInserted(entry);
|
|
8385
8461
|
}
|
|
8386
8462
|
}
|
|
8387
8463
|
handleMenuChange(val);
|
|
@@ -8483,6 +8559,11 @@ const PageContent = defineComponent({
|
|
|
8483
8559
|
};
|
|
8484
8560
|
onBeforeUnmount(() => {
|
|
8485
8561
|
clearInterval(interval);
|
|
8562
|
+
historyArr.forEach(entry => {
|
|
8563
|
+
entry.inUse = false;
|
|
8564
|
+
entry.leaveTime = minute + 1;
|
|
8565
|
+
queueUpdate(entry);
|
|
8566
|
+
});
|
|
8486
8567
|
for (const app of loadAppList.value) {
|
|
8487
8568
|
app.app.unmount();
|
|
8488
8569
|
}
|