@whyshu/argent 0.1.26 → 0.2.0
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 +16 -65
- package/cordis.patch.yml +6 -0
- package/dist/client.js +691 -0
- package/mcp/billing-upload.mjs +77 -0
- package/mcp/erp-server.mjs +296 -0
- package/mcp/gateway.mjs +336 -0
- package/mcp/meter.mjs +101 -0
- package/mcp/vault.mjs +78 -0
- package/mcp/vendor/account-token.mjs +37 -0
- package/mcp/vendor/redact.mjs +34 -0
- package/package.json +28 -18
- package/src/account-token.mjs +40 -0
- package/src/actions.mjs +114 -0
- package/src/config.mjs +47 -0
- package/src/error-log.mjs +56 -0
- package/src/fulfillment-result.mjs +84 -0
- package/src/health.mjs +231 -0
- package/src/index.js +231 -0
- package/src/kernel.mjs +111 -0
- package/src/lease.mjs +90 -0
- package/src/llm-whyshu.mjs +155 -0
- package/src/office-runtime.js +1102 -0
- package/src/skuflow-runner.mjs +57 -0
- package/src/timer-status.mjs +160 -0
- package/src/whyshu-auth.mjs +277 -0
- package/bin/argent.mjs +0 -385
- package/lib/index.mjs +0 -604
- package/runner/argent-runner.mjs +0 -223
package/dist/client.js
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* argent client bundle(DSH browser bundle 格式,手写维护)
|
|
3
|
+
*
|
|
4
|
+
* 桌宠(2026-10-29):
|
|
5
|
+
* - 注册官方 `shell.overlay` 槽(与 dsh-pet 同一机制),右下角浮一个 Argent 星宠;
|
|
6
|
+
* - 5s 轮询宿主 `/api/argent/health`(与 check-argent.mjs 同一套判据);
|
|
7
|
+
* - 红/黄/绿光晕 + 待处理数徽标;点击展开检查清单;“重新检查”强制重跑 ziniao doctor;
|
|
8
|
+
* - 可拖拽,位置存 localStorage;页面隐藏时暂停轮询。
|
|
9
|
+
*
|
|
10
|
+
* ⚠️ id 必须是**整包名**(与 package.json#name 一致),否则客户端拒绝加载。
|
|
11
|
+
*/
|
|
12
|
+
window.__ModuleLoader__.load({
|
|
13
|
+
id: "@whyshu/argent",
|
|
14
|
+
factory: (require) => {
|
|
15
|
+
var module = { exports: {} };
|
|
16
|
+
var exports = module.exports;
|
|
17
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
var React = require("react");
|
|
19
|
+
var h = React.createElement;
|
|
20
|
+
|
|
21
|
+
var HEALTH_URL = "/api/argent/health";
|
|
22
|
+
var POS_KEY = "argent.pet.pos";
|
|
23
|
+
var COLORS = { ok: "#34d399", warn: "#fbbf24", error: "#f87171", unknown: "#a78bfa" };
|
|
24
|
+
|
|
25
|
+
// 桌宠形象:问述小蘑菇(矢量,随包内联;源文件见 ip-logo-2026-10-29/whyshu/desktop-pet)
|
|
26
|
+
var PET_SVG = "<svg viewBox=\"304 251 836 1061\" xmlns=\"http://www.w3.org/2000/svg\" style=\"width:100%;height:100%;display:block;overflow:visible\"><g class=\"awp-all\"><polygon points=\"752,889 716,887 673,876 650,864 630,846 616,822 607,789 608,758 612,747 618,739 650,712 696,686 738,670 786,659 820,655 859,655 893,659 928,669 952,683 959,691 965,706 970,743 983,782 979,802 968,823 962,825 946,818 924,812 898,809 868,811 842,817 818,827 793,843 768,867 752,889\" fill=\"rgb(253,247,239)\"/><polygon points=\"766,1284 756,1282 759,1270 758,1258 753,1241 745,1225 732,1206 695,1163 684,1142 679,1120 678,1090 681,1062 687,1041 658,1014 642,986 638,969 641,918 637,901 629,887 604,866 586,845 579,828 573,802 566,817 557,827 547,827 545,818 551,803 561,789 626,725 661,700 702,679 749,663 804,653 862,652 930,662 956,670 972,678 992,694 1001,711 1000,722 994,731 984,735 971,734 968,726 966,708 960,691 952,682 930,669 892,658 853,654 826,654 790,657 756,664 732,671 694,686 662,703 634,723 616,740 608,756 606,785 610,807 620,832 631,848 652,866 669,875 692,883 718,888 765,890 749,926 747,945 804,968 822,981 832,993 838,1009 838,1032 832,1046 822,1057 800,1071 790,1074 769,1075 775,1084 796,1104 829,1123 864,1133 903,1134 938,1125 958,1115 977,1101 989,1089 1005,1066 987,1055 981,1048 976,1035 976,1020 979,1009 990,990 1001,979 1015,970 1023,951 1022,930 1036,938 1045,948 1052,959 1059,977 1062,992 1062,1013 1056,1036 1050,1049 1042,1058 1042,1093 1037,1120 1024,1153 976,1228 953,1248 936,1257 918,1264 890,1269 862,1269 842,1266 834,1272 818,1277 766,1284\" fill=\"rgb(136,109,222)\"/><g class=\"awp-cap\"><polygon points=\"718,1286 652,1282 619,1276 596,1269 570,1257 552,1245 532,1226 519,1208 508,1186 501,1161 499,1144 501,1108 510,1074 538,1016 557,968 570,915 572,885 526,884 468,874 431,861 391,837 365,811 345,776 336,750 332,730 330,685 333,656 342,618 364,557 383,519 407,479 446,424 475,390 503,362 539,333 559,320 592,303 646,285 680,279 722,277 754,279 788,284 820,292 860,307 894,323 936,349 988,392 1012,416 1046,455 1086,513 1099,539 1110,574 1114,599 1114,631 1110,656 1103,678 1091,704 1075,728 1054,751 1036,766 1016,779 990,790 991,782 979,748 977,736 988,734 997,728 1001,719 1001,711 995,698 984,686 973,678 956,670 908,654 859,647 820,647 774,653 738,662 704,674 659,697 622,724 608,739 604,748 573,776 552,801 545,816 546,826 550,828 557,827 566,817 573,802 579,828 586,845 593,855 617,875 633,893 641,918 638,969 642,986 658,1014 679,1036 687,1041 681,1062 678,1090 678,1111 682,1136 695,1163 732,1206 745,1225 753,1241 759,1265 756,1284 718,1286\" fill=\"rgb(38,38,77)\"/></g><g class=\"awp-eyes\"><polygon points=\"726,815 714,815 704,810 697,802 693,791 693,774 698,762 708,751 720,747 728,748 736,752 743,760 748,774 748,790 745,800 737,810 726,815\" fill=\"rgb(38,38,77)\"/><polygon points=\"910,786 900,786 892,782 885,775 880,760 880,748 884,735 893,725 900,722 908,722 916,725 926,738 929,748 929,762 927,770 924,776 917,783 910,786\" fill=\"rgb(38,38,77)\"/><polygon points=\"808,803 805,802 805,798 811,791 817,788 824,788 834,795 834,800 832,801 824,798 816,798 808,803\" fill=\"rgb(38,38,77)\"/></g><g class=\"awp-eyes-closed\"><rect x=\"673\" y=\"784\" width=\"95\" height=\"30\" rx=\"15\" fill=\"rgb(38,38,77)\"/><rect x=\"860\" y=\"757\" width=\"89\" height=\"30\" rx=\"15\" fill=\"rgb(38,38,77)\"/></g><g class=\"awp-prop\"><polygon points=\"1046,972 1045,985 1044,998 1041,1011 1037,1024 1032,1036 1025,1048 1018,1060 1010,1070 1001,1080 991,1089 981,1097 969,1105 957,1111 945,1116 932,1120 919,1123 906,1125 893,1125 879,1125 866,1123 853,1120 840,1116 828,1111 816,1105 805,1097 794,1089 784,1080 775,1070 767,1060 760,1048 753,1036 748,1024 744,1011 741,998 740,985 739,972 740,958 741,945 744,932 748,919 753,907 760,895 767,884 775,873 784,863 794,854 805,846 816,839 828,832 840,827 853,823 866,820 879,819 893,818 906,819 919,820 932,823 945,827 957,832 969,839 981,846 991,854 1001,863 1010,873 1018,884 1025,895 1032,907 1037,919 1041,932 1044,945 1045,958\" fill=\"rgb(203,184,251)\"/><polygon points=\"877,916 877,920 877,923 876,926 875,929 874,932 872,935 871,937 869,940 866,942 864,945 862,947 859,948 856,950 853,951 850,952 847,953 844,953 840,953 837,953 834,953 831,952 828,951 825,950 822,948 819,947 817,945 814,942 812,940 810,937 808,935 807,932 806,929 805,926 804,923 804,920 804,916 804,913 804,910 805,907 806,904 807,901 808,898 810,895 812,893 814,890 817,888 819,886 822,884 825,883 828,882 831,881 834,880 837,880 840,880 844,880 847,880 850,881 853,882 856,883 859,884 862,886 864,888 866,890 869,893 871,895 872,898 874,901 875,904 876,907 877,910 877,913\" fill=\"rgb(249,241,231)\"/></g><g class=\"awp-hands\"><polygon points=\"782,1075 780,1075 771,1065 756,1040 745,1012 741,990 740,966 743,942 750,917 761,895 749,926 747,945 794,963 816,976 828,987 838,1009 838,1032 828,1051 808,1067 794,1073 782,1075\" fill=\"rgb(136,109,222)\"/><polygon points=\"982,1097 1005,1065 991,1058 981,1048 976,1035 976,1020 979,1009 990,990 1001,979 1015,970 1023,951 1021,931 1023,930 1036,938 1044,948 1046,981 1043,1003 1037,1024 1024,1052 1005,1077 982,1097\" fill=\"rgb(136,109,222)\"/></g></g></svg>";
|
|
27
|
+
var PET_MUSH_CSS = "\n.awp-mush{display:block;width:100%;height:100%;background:transparent;overflow:visible;\n filter:drop-shadow(0 4px 10px rgba(0,0,0,.35))}\n.awp-mush .awp-all{transform-origin:50% 92%;animation:awp-breathe 3.2s ease-in-out infinite}\n.awp-mush .awp-cap{transform-origin:50% 55%;animation:awp-cap 4.6s ease-in-out infinite}\n.awp-mush .awp-eyes{animation:awp-blink 5.4s ease-in-out infinite}\n.awp-mush .awp-eyes-closed{opacity:0}\n.awp-mush .awp-prop{animation:awp-bob 3.2s ease-in-out infinite}\n.awp-mush .awp-hands{animation:awp-hands 3.2s ease-in-out infinite}\n@keyframes awp-breathe{0%,100%{transform:scale(1,1)}50%{transform:scale(1.012,.988)}}\n@keyframes awp-cap{0%,100%{transform:rotate(-.9deg)}50%{transform:rotate(1deg)}}\n@keyframes awp-blink{0%,90%,100%{opacity:1}92%,95%{opacity:0}}\n@keyframes awp-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}\n@keyframes awp-hands{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}\n.awp-mush.awp-alert .awp-cap{animation:awp-alert 1.6s ease-in-out infinite}\n@keyframes awp-alert{0%,100%{transform:rotate(-3deg)}50%{transform:rotate(4deg)}}\n.awp-dot{position:absolute;right:-2px;bottom:2px;width:10px;height:10px;border-radius:50%;\n box-shadow:0 0 0 2px var(--dsw-alias-bg-layer-1, #18181f)}\n@media (prefers-reduced-motion: reduce){.awp-mush .awp-all,.awp-mush .awp-cap,.awp-mush .awp-eyes,.awp-mush .awp-prop,.awp-mush .awp-hands{animation:none !important}}\n";
|
|
28
|
+
|
|
29
|
+
function loadPos() {
|
|
30
|
+
try {
|
|
31
|
+
var raw = JSON.parse(localStorage.getItem(POS_KEY) || "null");
|
|
32
|
+
if (raw && Number.isFinite(raw.right) && Number.isFinite(raw.bottom)) {
|
|
33
|
+
return { right: Math.max(8, raw.right), bottom: Math.max(8, raw.bottom) };
|
|
34
|
+
}
|
|
35
|
+
} catch { /* noop */ }
|
|
36
|
+
return { right: 24, bottom: 132 };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function savePos(p) {
|
|
40
|
+
try { localStorage.setItem(POS_KEY, JSON.stringify(p)); } catch { /* noop */ }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function fmtTime(iso) {
|
|
44
|
+
try { return new Date(iso).toLocaleTimeString("zh-CN", { hour12: false }); } catch { return ""; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 日报定时器(2026-10-30):日期+时间("10-30 14:05")与"周几 + 时刻"("周五 11:05")
|
|
48
|
+
function fmtDateTime(iso) {
|
|
49
|
+
try {
|
|
50
|
+
return new Date(iso).toLocaleString("zh-CN", { month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: false });
|
|
51
|
+
} catch { return ""; }
|
|
52
|
+
}
|
|
53
|
+
function fmtDue(iso) {
|
|
54
|
+
try {
|
|
55
|
+
var d = new Date(iso);
|
|
56
|
+
var now = new Date();
|
|
57
|
+
var tomorrow = new Date();
|
|
58
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
59
|
+
var sameDay = function (a, b) { return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate(); };
|
|
60
|
+
var day = sameDay(d, now) ? "今天" : sameDay(d, tomorrow) ? "明天" : d.toLocaleDateString("zh-CN", { month: "2-digit", day: "2-digit" });
|
|
61
|
+
return day + " " + d.toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit", hour12: false });
|
|
62
|
+
} catch { return ""; }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function postJson(url, body) {
|
|
66
|
+
return fetch(url, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
cache: "no-store",
|
|
69
|
+
credentials: "same-origin",
|
|
70
|
+
headers: body ? { "content-type": "application/json" } : undefined,
|
|
71
|
+
body: body ? JSON.stringify(body) : undefined
|
|
72
|
+
}).then(function (res) {
|
|
73
|
+
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
74
|
+
return res.json();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function ArgentPet() {
|
|
79
|
+
var healthState = React.useState(null);
|
|
80
|
+
var health = healthState[0];
|
|
81
|
+
var setHealth = healthState[1];
|
|
82
|
+
var openState = React.useState(false);
|
|
83
|
+
var open = openState[0];
|
|
84
|
+
var setOpen = openState[1];
|
|
85
|
+
var hoverState = React.useState(false);
|
|
86
|
+
var hover = hoverState[0];
|
|
87
|
+
var setHover = hoverState[1];
|
|
88
|
+
var busyState = React.useState(false);
|
|
89
|
+
var busy = busyState[0];
|
|
90
|
+
var setBusy = busyState[1];
|
|
91
|
+
var posState = React.useState(loadPos);
|
|
92
|
+
var pos = posState[0];
|
|
93
|
+
var setPos = posState[1];
|
|
94
|
+
var accountState = React.useState(null);
|
|
95
|
+
var account = accountState[0];
|
|
96
|
+
var setAccount = accountState[1];
|
|
97
|
+
var loginState = React.useState(null);
|
|
98
|
+
var login = loginState[0];
|
|
99
|
+
var setLogin = loginState[1];
|
|
100
|
+
var authBusyState = React.useState(false);
|
|
101
|
+
var authBusy = authBusyState[0];
|
|
102
|
+
var setAuthBusy = authBusyState[1];
|
|
103
|
+
var authErrState = React.useState("");
|
|
104
|
+
var authErr = authErrState[0];
|
|
105
|
+
var setAuthErr = authErrState[1];
|
|
106
|
+
|
|
107
|
+
// 2026-10-29:右键菜单 / 动画开关 / 隐藏(都持久化到 localStorage)
|
|
108
|
+
var menuState = React.useState(null);
|
|
109
|
+
var menu = menuState[0];
|
|
110
|
+
var setMenu = menuState[1];
|
|
111
|
+
var animState = React.useState(function () { return localStorage.getItem("argent.pet.anim") !== "0"; });
|
|
112
|
+
var anim = animState[0];
|
|
113
|
+
var setAnim = animState[1];
|
|
114
|
+
var hiddenState = React.useState(function () { return localStorage.getItem("argent.pet.hidden") === "1"; });
|
|
115
|
+
var hidden = hiddenState[0];
|
|
116
|
+
var setHidden = hiddenState[1];
|
|
117
|
+
var sizeState = React.useState(function () {
|
|
118
|
+
var v = parseInt(localStorage.getItem("argent.pet.size") || "", 10);
|
|
119
|
+
return Number.isFinite(v) && v >= 64 && v <= 220 ? v : 120; // 默认 120px ≈ dsh-pet 那档
|
|
120
|
+
});
|
|
121
|
+
var petSize = sizeState[0];
|
|
122
|
+
var setPetSize = sizeState[1];
|
|
123
|
+
var popState = React.useState(false);
|
|
124
|
+
var pop = popState[0];
|
|
125
|
+
var setPop = popState[1];
|
|
126
|
+
var sayState = React.useState("");
|
|
127
|
+
var say = sayState[0];
|
|
128
|
+
var setSay = sayState[1];
|
|
129
|
+
|
|
130
|
+
var alive = React.useRef(true);
|
|
131
|
+
var busyRef = React.useRef(false);
|
|
132
|
+
var authBusyRef = React.useRef(false);
|
|
133
|
+
var pollRef = React.useRef(null);
|
|
134
|
+
var dragRef = React.useRef({ active: false, moved: false, startX: 0, startY: 0, right: 0, bottom: 0 });
|
|
135
|
+
var posRef = React.useRef(pos);
|
|
136
|
+
posRef.current = pos;
|
|
137
|
+
|
|
138
|
+
function load(refresh) {
|
|
139
|
+
if (busyRef.current) return;
|
|
140
|
+
busyRef.current = true;
|
|
141
|
+
setBusy(true);
|
|
142
|
+
var url = HEALTH_URL + (refresh ? "?refresh=1" : "");
|
|
143
|
+
fetch(url, { cache: "no-store", credentials: "same-origin" })
|
|
144
|
+
.then(function (res) {
|
|
145
|
+
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
146
|
+
return res.json();
|
|
147
|
+
})
|
|
148
|
+
.then(function (json) {
|
|
149
|
+
if (alive.current) setHealth(json);
|
|
150
|
+
})
|
|
151
|
+
.catch(function (e) {
|
|
152
|
+
if (!alive.current) return;
|
|
153
|
+
setHealth({
|
|
154
|
+
level: "error",
|
|
155
|
+
summary: "无法读取插件状态",
|
|
156
|
+
machineId: "",
|
|
157
|
+
at: new Date().toISOString(),
|
|
158
|
+
checks: [{ id: "route", label: "状态接口", level: "error", detail: String((e && e.message) || e) }]
|
|
159
|
+
});
|
|
160
|
+
})
|
|
161
|
+
.finally(function () {
|
|
162
|
+
busyRef.current = false;
|
|
163
|
+
if (alive.current) setBusy(false);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
React.useEffect(function () {
|
|
168
|
+
alive.current = true;
|
|
169
|
+
load(false);
|
|
170
|
+
loadAccount();
|
|
171
|
+
var timer = setInterval(function () {
|
|
172
|
+
if (document.visibilityState !== "hidden") load(false);
|
|
173
|
+
}, 5000);
|
|
174
|
+
return function () {
|
|
175
|
+
alive.current = false;
|
|
176
|
+
clearInterval(timer);
|
|
177
|
+
stopPoll();
|
|
178
|
+
};
|
|
179
|
+
}, []);
|
|
180
|
+
|
|
181
|
+
React.useEffect(function () {
|
|
182
|
+
if (open) loadAccount();
|
|
183
|
+
}, [open]);
|
|
184
|
+
|
|
185
|
+
function loadAccount() {
|
|
186
|
+
fetch("/api/argent/auth/status", { cache: "no-store", credentials: "same-origin" })
|
|
187
|
+
.then(function (res) { return res.ok ? res.json() : null; })
|
|
188
|
+
.then(function (json) { if (alive.current && json) setAccount(json); })
|
|
189
|
+
.catch(function () { /* 状态失败不影响健康检查 */ });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function stopPoll() {
|
|
193
|
+
if (pollRef.current) {
|
|
194
|
+
clearInterval(pollRef.current);
|
|
195
|
+
pollRef.current = null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function openAuthUrl(url) {
|
|
200
|
+
return postJson("/api/argent/auth/open", { url: url }).catch(function () { /* 用户可点面板里的按钮 */ });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function startPoll(deviceCode, intervalSec, expiresIn) {
|
|
204
|
+
stopPoll();
|
|
205
|
+
var deadline = Date.now() + Math.max(60, Number(expiresIn) || 600) * 1000;
|
|
206
|
+
var every = Math.max(3, Number(intervalSec) || 5) * 1000;
|
|
207
|
+
pollRef.current = setInterval(function () {
|
|
208
|
+
if (!alive.current) return;
|
|
209
|
+
if (Date.now() > deadline) {
|
|
210
|
+
stopPoll();
|
|
211
|
+
setLogin(null);
|
|
212
|
+
setAuthErr("授权超时,请重试");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
postJson("/api/argent/auth/poll", { device_code: deviceCode })
|
|
216
|
+
.then(function (j) {
|
|
217
|
+
if (j.status === "approved") {
|
|
218
|
+
stopPoll();
|
|
219
|
+
setLogin(null);
|
|
220
|
+
setAuthErr("");
|
|
221
|
+
setAccount(j.account || { loggedIn: true });
|
|
222
|
+
load(false);
|
|
223
|
+
} else if (j.status === "denied" || j.status === "error") {
|
|
224
|
+
stopPoll();
|
|
225
|
+
setLogin(null);
|
|
226
|
+
setAuthErr(j.error || "授权失败");
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
.catch(function () { /* 下一轮重试 */ });
|
|
230
|
+
}, every);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function startLogin() {
|
|
234
|
+
if (authBusyRef.current) return;
|
|
235
|
+
authBusyRef.current = true;
|
|
236
|
+
setAuthBusy(true);
|
|
237
|
+
setAuthErr("");
|
|
238
|
+
postJson("/api/argent/auth/device")
|
|
239
|
+
.then(function (j) {
|
|
240
|
+
if (!j.ok) throw new Error(j.error || "启动设备授权失败");
|
|
241
|
+
var info = {
|
|
242
|
+
device_code: j.device_code,
|
|
243
|
+
user_code: j.user_code,
|
|
244
|
+
url: j.verification_uri_complete,
|
|
245
|
+
interval: j.interval || 5
|
|
246
|
+
};
|
|
247
|
+
setLogin(info);
|
|
248
|
+
openAuthUrl(info.url);
|
|
249
|
+
startPoll(info.device_code, info.interval, j.expires_in);
|
|
250
|
+
})
|
|
251
|
+
.catch(function (e) { setAuthErr(String((e && e.message) || e)); })
|
|
252
|
+
.finally(function () {
|
|
253
|
+
authBusyRef.current = false;
|
|
254
|
+
if (alive.current) setAuthBusy(false);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function cancelLogin() {
|
|
259
|
+
stopPoll();
|
|
260
|
+
setLogin(null);
|
|
261
|
+
setAuthErr("");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function logout() {
|
|
265
|
+
postJson("/api/argent/auth/logout")
|
|
266
|
+
.then(function () {
|
|
267
|
+
setAccount({ loggedIn: false });
|
|
268
|
+
load(false);
|
|
269
|
+
})
|
|
270
|
+
.catch(function (e) { setAuthErr(String((e && e.message) || e)); });
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function onPointerDown(e) {
|
|
274
|
+
if (e.button !== undefined && e.button !== 0) return;
|
|
275
|
+
var g = dragRef.current;
|
|
276
|
+
g.active = true;
|
|
277
|
+
g.moved = false;
|
|
278
|
+
g.startX = e.clientX;
|
|
279
|
+
g.startY = e.clientY;
|
|
280
|
+
g.right = posRef.current.right;
|
|
281
|
+
g.bottom = posRef.current.bottom;
|
|
282
|
+
try { e.currentTarget.setPointerCapture(e.pointerId); } catch { /* noop */ }
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function onPointerMove(e) {
|
|
286
|
+
var g = dragRef.current;
|
|
287
|
+
if (!g.active) return;
|
|
288
|
+
var dx = e.clientX - g.startX;
|
|
289
|
+
var dy = e.clientY - g.startY;
|
|
290
|
+
if (!g.moved && Math.abs(dx) < 4 && Math.abs(dy) < 4) return;
|
|
291
|
+
g.moved = true;
|
|
292
|
+
var right = Math.max(8, Math.min(window.innerWidth - petSize - 8, g.right - dx));
|
|
293
|
+
var bottom = Math.max(8, Math.min(window.innerHeight - petSize - 8, g.bottom - dy));
|
|
294
|
+
setPos({ right: right, bottom: bottom });
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function onPointerUp(e) {
|
|
298
|
+
var g = dragRef.current;
|
|
299
|
+
if (!g.active) return;
|
|
300
|
+
g.active = false;
|
|
301
|
+
try { e.currentTarget.releasePointerCapture(e.pointerId); } catch { /* noop */ }
|
|
302
|
+
if (g.moved) { savePos(posRef.current); return; }
|
|
303
|
+
// 左键点一下 = 互动:弹一下 + 冒个话;不开面板(面板走右键菜单)
|
|
304
|
+
setPop(true);
|
|
305
|
+
setTimeout(function () { alive.current && setPop(false); }, 520);
|
|
306
|
+
var lines = ["嗯?", "在的", "我在听", "问吧", "伞伞在"];
|
|
307
|
+
setSay(lines[Math.floor(Math.random() * lines.length)]);
|
|
308
|
+
setTimeout(function () { alive.current && setSay(""); }, 1400);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
var level = (health && health.level) || "ok";
|
|
312
|
+
var color = COLORS[level] || COLORS.unknown;
|
|
313
|
+
var checks = (health && health.checks) || [];
|
|
314
|
+
var issues = checks.filter(function (c) { return c && c.level !== "ok"; }).length;
|
|
315
|
+
var summary = (health && health.summary) || (busy ? "检查中…" : "伞伞");
|
|
316
|
+
|
|
317
|
+
var rootStyle = {
|
|
318
|
+
position: "fixed",
|
|
319
|
+
right: pos.right + "px",
|
|
320
|
+
bottom: pos.bottom + "px",
|
|
321
|
+
zIndex: 2147483000,
|
|
322
|
+
display: "flex",
|
|
323
|
+
flexDirection: "column",
|
|
324
|
+
alignItems: "flex-end",
|
|
325
|
+
gap: "8px",
|
|
326
|
+
pointerEvents: "none",
|
|
327
|
+
fontFamily: "var(--dsw-font-family, system-ui, -apple-system, sans-serif)"
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
var bubble = h("div", {
|
|
331
|
+
style: {
|
|
332
|
+
pointerEvents: "none",
|
|
333
|
+
maxWidth: "240px",
|
|
334
|
+
padding: "6px 10px",
|
|
335
|
+
borderRadius: "10px",
|
|
336
|
+
background: "var(--dsw-alias-bg-layer-1, rgba(24,24,32,.92))",
|
|
337
|
+
border: "1px solid " + color,
|
|
338
|
+
color: "var(--dsw-alias-label-primary, #f4f4f5)",
|
|
339
|
+
fontSize: "11px",
|
|
340
|
+
lineHeight: 1.5,
|
|
341
|
+
boxShadow: "0 6px 20px rgba(0,0,0,.28)",
|
|
342
|
+
opacity: open ? 0 : (hover || level !== "ok" ? 1 : 0),
|
|
343
|
+
transform: open ? "translateY(4px)" : "translateY(0)",
|
|
344
|
+
transition: "opacity .15s ease, transform .15s ease"
|
|
345
|
+
}
|
|
346
|
+
}, say || "伞伞");
|
|
347
|
+
|
|
348
|
+
var pet = h("button", {
|
|
349
|
+
type: "button",
|
|
350
|
+
"aria-label": "伞伞(左键拖动/互动,右键菜单)",
|
|
351
|
+
title: "伞伞" + (issues ? " · " + issues + " 项待处理" : ""),
|
|
352
|
+
onPointerDown: onPointerDown,
|
|
353
|
+
onPointerMove: onPointerMove,
|
|
354
|
+
onPointerUp: onPointerUp,
|
|
355
|
+
onPointerCancel: onPointerUp,
|
|
356
|
+
onContextMenu: function (e) {
|
|
357
|
+
e.preventDefault();
|
|
358
|
+
e.stopPropagation();
|
|
359
|
+
setMenu({ x: Math.min(e.clientX, window.innerWidth - 168), y: Math.min(e.clientY, window.innerHeight - 190) });
|
|
360
|
+
},
|
|
361
|
+
onMouseEnter: function () { setHover(true); },
|
|
362
|
+
onMouseLeave: function () { setHover(false); },
|
|
363
|
+
style: {
|
|
364
|
+
position: "relative",
|
|
365
|
+
pointerEvents: "auto",
|
|
366
|
+
width: petSize + "px",
|
|
367
|
+
height: petSize + "px",
|
|
368
|
+
padding: Math.round(petSize * 0.07) + "px",
|
|
369
|
+
borderRadius: "12px",
|
|
370
|
+
border: "none",
|
|
371
|
+
background: "transparent",
|
|
372
|
+
color: "#fff",
|
|
373
|
+
fontSize: "26px",
|
|
374
|
+
overflow: "visible",
|
|
375
|
+
lineHeight: 1,
|
|
376
|
+
cursor: dragRef.current.active ? "grabbing" : "grab",
|
|
377
|
+
userSelect: "none",
|
|
378
|
+
touchAction: "none",
|
|
379
|
+
transform: hover ? "translateY(-2px) scale(1.03)" : "translateY(0)",
|
|
380
|
+
transition: "transform .12s ease, box-shadow .12s ease"
|
|
381
|
+
}
|
|
382
|
+
}, h("span", {
|
|
383
|
+
"aria-hidden": "true",
|
|
384
|
+
className: "awp-mush" + (issues > 0 ? " awp-alert" : "") + (pop ? " awp-pop" : "") + (anim ? "" : " awp-paused"),
|
|
385
|
+
dangerouslySetInnerHTML: { __html: PET_SVG }
|
|
386
|
+
}),
|
|
387
|
+
h("span", { className: "awp-dot", style: { background: color } }),
|
|
388
|
+
issues > 0 ? h("span", {
|
|
389
|
+
style: {
|
|
390
|
+
position: "absolute", top: "-4px", right: "-4px",
|
|
391
|
+
minWidth: "18px", height: "18px", padding: "0 4px",
|
|
392
|
+
borderRadius: "9px", background: COLORS.error, color: "#111",
|
|
393
|
+
fontSize: "10px", fontWeight: 700, lineHeight: "18px", textAlign: "center"
|
|
394
|
+
}
|
|
395
|
+
}, String(issues)) : null);
|
|
396
|
+
|
|
397
|
+
var btnStyle = {
|
|
398
|
+
height: "26px", padding: "0 10px", borderRadius: "8px",
|
|
399
|
+
border: "1px solid var(--dsw-alias-border-l2, #34343f)",
|
|
400
|
+
background: "transparent",
|
|
401
|
+
color: "var(--dsw-alias-label-primary, #f4f4f5)",
|
|
402
|
+
fontSize: "11px", cursor: "pointer"
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
var accountBlock = h("div", {
|
|
406
|
+
style: {
|
|
407
|
+
borderBottom: "1px solid var(--dsw-alias-border-l2, #34343f)",
|
|
408
|
+
padding: "0 0 10px", marginBottom: "10px"
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
h("div", { style: { display: "flex", alignItems: "center", gap: "6px" } },
|
|
412
|
+
h("div", { style: { fontSize: "11px", fontWeight: 600 } }, "问述账号"),
|
|
413
|
+
h("div", { style: { marginLeft: "auto", fontSize: "10px", color: "var(--dsw-alias-label-secondary, #9b95b0)" } },
|
|
414
|
+
login ? "等待授权" : (account && account.loggedIn ? "已登录" : "未登录"))),
|
|
415
|
+
login ? h("div", { style: { marginTop: "6px" } },
|
|
416
|
+
h("div", { style: { fontSize: "12px", fontWeight: 700, letterSpacing: "2px" } }, login.user_code || ""),
|
|
417
|
+
h("div", { style: { fontSize: "10px", color: "var(--dsw-alias-label-secondary, #9b95b0)", marginTop: "2px" } },
|
|
418
|
+
"已打开问述授权页;没弹窗就点下面按钮"),
|
|
419
|
+
h("div", { style: { display: "flex", gap: "6px", marginTop: "6px" } },
|
|
420
|
+
h("button", { type: "button", onClick: function () { openAuthUrl(login.url); }, style: btnStyle }, "打开授权页"),
|
|
421
|
+
h("button", { type: "button", onClick: cancelLogin, style: btnStyle }, "取消")))
|
|
422
|
+
: (account && account.loggedIn ? h("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "6px" } },
|
|
423
|
+
h("div", { style: { fontSize: "12px" } },
|
|
424
|
+
(account.nickname || "已登录") + (account.daysLeft != null ? " · 剩余 " + account.daysLeft + " 天" : "")),
|
|
425
|
+
h("button", { type: "button", onClick: logout, style: Object.assign({}, btnStyle, { marginLeft: "auto" }) }, "退出"))
|
|
426
|
+
: h("div", { style: { marginTop: "6px" } },
|
|
427
|
+
h("div", { style: { fontSize: "10px", color: "var(--dsw-alias-label-secondary, #9b95b0)" } },
|
|
428
|
+
account && (account.expired || account.invalid) ? "登录已过期,请重新授权" : "登录后可用问述积分选择「问述代理」模型"),
|
|
429
|
+
h("div", { style: { display: "flex", gap: "6px", marginTop: "6px", alignItems: "center" } },
|
|
430
|
+
h("button", { type: "button", onClick: startLogin, disabled: authBusy, style: Object.assign({}, btnStyle, { opacity: authBusy ? 0.6 : 1 }) },
|
|
431
|
+
authBusy ? "启动中…" : "一键登录"),
|
|
432
|
+
authErr ? h("div", { style: { fontSize: "10px", color: COLORS.error } }, authErr) : null))));
|
|
433
|
+
|
|
434
|
+
// 日报定时器卡片:状态 = 引擎状态文件 + LaunchAgent 在册(判据在宿主 health.mjs,⛔ 前端不重算)
|
|
435
|
+
var timer = health && health.timer;
|
|
436
|
+
var timerBlock = null;
|
|
437
|
+
if (timer) {
|
|
438
|
+
var tColor = COLORS[timer.level] || COLORS.unknown;
|
|
439
|
+
var timerLine = (timer.lastRunAt ? "上次运行 " + fmtDateTime(timer.lastRunAt) : "还没有运行记录")
|
|
440
|
+
+ (timer.lastPushAt ? " · 推送 " + fmtDateTime(timer.lastPushAt) : " · 未推送");
|
|
441
|
+
var missedNames = (timer.pending || []).slice(0, 3).map(function (p) {
|
|
442
|
+
var days = (p && p.missed) || [];
|
|
443
|
+
return (p.store || "") + (days.length ? "(" + days[days.length - 1] + ")" : "");
|
|
444
|
+
}).join(";");
|
|
445
|
+
timerBlock = h("div", {
|
|
446
|
+
style: {
|
|
447
|
+
marginTop: "10px",
|
|
448
|
+
padding: "9px 10px",
|
|
449
|
+
borderRadius: "10px",
|
|
450
|
+
border: "1px solid var(--dsw-alias-border-l2, #34343f)",
|
|
451
|
+
background: "var(--dsw-alias-bg-layer-2, #22222c)"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
h("div", { style: { display: "flex", alignItems: "center", gap: "7px" } },
|
|
455
|
+
h("div", { style: { width: "7px", height: "7px", borderRadius: "50%", background: tColor, flex: "none" } }),
|
|
456
|
+
h("div", { style: { fontSize: "12px", fontWeight: 600 } }, "美客多日报"),
|
|
457
|
+
h("div", { style: { marginLeft: "auto", fontSize: "10px", color: "var(--dsw-alias-label-secondary, #9b95b0)" } }, "每小时 :05"),
|
|
458
|
+
),
|
|
459
|
+
h("div", { style: { fontSize: "11px", color: "var(--dsw-alias-label-secondary, #9b95b0)", marginTop: "4px", lineHeight: 1.5, wordBreak: "break-word" } },
|
|
460
|
+
timerLine,
|
|
461
|
+
timer.nextDueAt ? h("span", null, " · 下次 " + fmtDue(timer.nextDueAt)) : null),
|
|
462
|
+
timer.missedTotal > 0 ? h("div", { style: { fontSize: "11px", color: COLORS.warn, marginTop: "3px" } },
|
|
463
|
+
"缺 " + timer.missedTotal + " 天未推送" + (missedNames ? ":" + missedNames : "")) : null,
|
|
464
|
+
timer.level === "error" ? h("div", { style: { fontSize: "11px", color: COLORS.error, marginTop: "3px" } }, timer.detail || "定时器异常") : null);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// 积分/余额(P3:从 argent-core 搬进伞伞;数据来自 /api/argent/account)
|
|
468
|
+
var acctState = React.useState(null);
|
|
469
|
+
var acct = acctState[0], setAcct = acctState[1];
|
|
470
|
+
React.useEffect(function () {
|
|
471
|
+
if (!open) return;
|
|
472
|
+
var alive = true;
|
|
473
|
+
function tick() {
|
|
474
|
+
fetch("/api/argent/account", { headers: { accept: "application/json" } })
|
|
475
|
+
.then(function (r) { return r.json() })
|
|
476
|
+
.then(function (j) { if (alive) setAcct(j || null) })
|
|
477
|
+
.catch(function () { if (alive) setAcct({ ok: false, message: "取不到积分" }) })
|
|
478
|
+
}
|
|
479
|
+
tick();
|
|
480
|
+
var id = setInterval(tick, 60000);
|
|
481
|
+
return function () { alive = false; clearInterval(id) };
|
|
482
|
+
}, [open]);
|
|
483
|
+
var pointsBlock = h("div", {
|
|
484
|
+
style: { padding: "8px 10px", borderRadius: "10px", background: "rgba(127,127,127,0.10)", marginBottom: "10px" }
|
|
485
|
+
},
|
|
486
|
+
h("div", { style: { display: "flex", alignItems: "baseline", gap: "8px" } },
|
|
487
|
+
h("div", { style: { fontSize: "11px", opacity: 0.7 } }, "问述积分"),
|
|
488
|
+
h("div", { style: { fontSize: "16px", fontWeight: 700 } }, acct && acct.points != null ? String(acct.points) : "—"),
|
|
489
|
+
acct && acct.plan ? h("div", { style: { marginLeft: "auto", fontSize: "10px", opacity: 0.6 } }, acct.plan) : null),
|
|
490
|
+
h("div", { style: { fontSize: "10px", opacity: 0.6, marginTop: "2px" } },
|
|
491
|
+
acct && acct.ok === false ? (acct.message || "未登录") :
|
|
492
|
+
acct && acct.spentPoints != null
|
|
493
|
+
? ("近 30 天 " + acct.spentPoints + " 分 · ¥" + acct.spentYuan + (acct.calls ? (" · " + acct.calls + " 次") : ""))
|
|
494
|
+
: "统计中…"))
|
|
495
|
+
|
|
496
|
+
var panel = open ? h("div", {
|
|
497
|
+
className: "awp-panel",
|
|
498
|
+
style: {
|
|
499
|
+
pointerEvents: "auto",
|
|
500
|
+
width: "340px",
|
|
501
|
+
maxWidth: "calc(100vw - 32px)",
|
|
502
|
+
maxHeight: "min(60vh, 520px)",
|
|
503
|
+
overflowY: "auto",
|
|
504
|
+
background: "var(--dsw-alias-bg-layer-1, #181820)",
|
|
505
|
+
border: "1px solid var(--dsw-alias-border-l2, #34343f)",
|
|
506
|
+
borderRadius: "14px",
|
|
507
|
+
boxShadow: "0 16px 48px rgba(0,0,0,.42)",
|
|
508
|
+
color: "var(--dsw-alias-label-primary, #f4f4f5)",
|
|
509
|
+
padding: "12px"
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
h("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "8px" } },
|
|
513
|
+
h("div", { style: { width: "10px", height: "10px", borderRadius: "50%", background: color, flex: "none" } }),
|
|
514
|
+
h("div", { style: { fontWeight: 700, fontSize: "13px" } }, "伞伞"),
|
|
515
|
+
h("div", { style: { marginLeft: "auto", display: "flex", gap: "6px" } },
|
|
516
|
+
h("button", {
|
|
517
|
+
type: "button",
|
|
518
|
+
onClick: function () { load(true); },
|
|
519
|
+
disabled: busy,
|
|
520
|
+
style: {
|
|
521
|
+
height: "26px", padding: "0 10px", borderRadius: "8px",
|
|
522
|
+
border: "1px solid var(--dsw-alias-border-l2, #34343f)",
|
|
523
|
+
background: "var(--dsw-alias-bg-layer-2, #22222c)",
|
|
524
|
+
color: "var(--dsw-alias-label-primary, #f4f4f5)",
|
|
525
|
+
fontSize: "11px", cursor: busy ? "default" : "pointer",
|
|
526
|
+
opacity: busy ? 0.6 : 1
|
|
527
|
+
}
|
|
528
|
+
}, busy ? "检查中…" : "重新检查"),
|
|
529
|
+
h("button", {
|
|
530
|
+
type: "button",
|
|
531
|
+
onClick: function () { setOpen(false); },
|
|
532
|
+
style: {
|
|
533
|
+
width: "26px", height: "26px", borderRadius: "8px",
|
|
534
|
+
border: "1px solid var(--dsw-alias-border-l2, #34343f)",
|
|
535
|
+
background: "transparent", color: "var(--dsw-alias-label-secondary, #9b95b0)",
|
|
536
|
+
fontSize: "15px", lineHeight: 1, cursor: "pointer"
|
|
537
|
+
}
|
|
538
|
+
}, "×"))),
|
|
539
|
+
h("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "9px 0 10px", borderBottom: "1px solid var(--dsw-alias-border-l2, #34343f)", marginBottom: "10px" } },
|
|
540
|
+
h("div", { style: { width: "7px", height: "7px", borderRadius: "50%", background: color, flex: "none" } }),
|
|
541
|
+
h("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-primary, #f4f4f5)", fontWeight: 500, minWidth: 0 } }, summary)),
|
|
542
|
+
accountBlock,
|
|
543
|
+
pointsBlock,
|
|
544
|
+
timerBlock,
|
|
545
|
+
checks.length === 0 ? h("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary, #9b95b0)", padding: "8px 0" } }, "还没有检查结果。")
|
|
546
|
+
: h("div", { style: { display: "flex", flexDirection: "column" } },
|
|
547
|
+
checks.map(function (c, i) {
|
|
548
|
+
var cc = COLORS[c.level] || COLORS.unknown;
|
|
549
|
+
return h("div", { key: c.id, style: { display: "flex", alignItems: "flex-start", gap: "9px", padding: "9px 0", borderTop: i ? "1px solid var(--dsw-alias-border-l2, #34343f)" : "none" } },
|
|
550
|
+
h("div", { style: { width: "7px", height: "7px", borderRadius: "50%", background: cc, marginTop: "5px", flex: "none" } }),
|
|
551
|
+
h("div", { style: { minWidth: 0 } },
|
|
552
|
+
h("div", { style: { fontSize: "12px", fontWeight: 600 } }, c.label || c.id),
|
|
553
|
+
c.detail ? h("div", { style: { fontSize: "11px", color: "var(--dsw-alias-label-secondary, #9b95b0)", lineHeight: 1.5, wordBreak: "break-word" } }, c.detail) : null));
|
|
554
|
+
})),
|
|
555
|
+
h("div", { style: { marginTop: "10px", paddingTop: "9px", borderTop: "1px solid var(--dsw-alias-border-l2, #34343f)", fontSize: "10px", color: "var(--dsw-alias-label-secondary, #9b95b0)" } },
|
|
556
|
+
(health && health.machineId ? health.machineId + " · " : "") + (health && health.at ? fmtTime(health.at) : "")))
|
|
557
|
+
: null;
|
|
558
|
+
|
|
559
|
+
// 点面板外部/按 Esc 关闭检查清单(2026-11-04:此前只能点右上角 ×)
|
|
560
|
+
React.useEffect(function () {
|
|
561
|
+
if (!open) return;
|
|
562
|
+
function onDown(e) {
|
|
563
|
+
var t = e && e.target;
|
|
564
|
+
if (!t || !t.closest) return;
|
|
565
|
+
if (t.closest(".awp-panel") || t.closest(".awp-menu") || t.closest(".awp-mush") || t.closest(".awp-hidden-dot")) return;
|
|
566
|
+
setOpen(false);
|
|
567
|
+
}
|
|
568
|
+
function onKey(e) { if (e.key === "Escape") setOpen(false); }
|
|
569
|
+
window.addEventListener("pointerdown", onDown, true);
|
|
570
|
+
window.addEventListener("keydown", onKey);
|
|
571
|
+
return function () {
|
|
572
|
+
window.removeEventListener("pointerdown", onDown, true);
|
|
573
|
+
window.removeEventListener("keydown", onKey);
|
|
574
|
+
};
|
|
575
|
+
}, [open]);
|
|
576
|
+
|
|
577
|
+
React.useEffect(function () {
|
|
578
|
+
if (menu === null) return;
|
|
579
|
+
function close(e) {
|
|
580
|
+
var t = e && e.target;
|
|
581
|
+
if (t && t.closest && t.closest(".awp-menu")) return; // 点在菜单内不关
|
|
582
|
+
setMenu(null);
|
|
583
|
+
}
|
|
584
|
+
function onKey(e) { if (e.key === "Escape") setMenu(null); }
|
|
585
|
+
window.addEventListener("pointerdown", close, true);
|
|
586
|
+
window.addEventListener("keydown", onKey);
|
|
587
|
+
return function () {
|
|
588
|
+
window.removeEventListener("pointerdown", close, true);
|
|
589
|
+
window.removeEventListener("keydown", onKey);
|
|
590
|
+
};
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
var menuEl = menu === null ? null : h("div", {
|
|
594
|
+
className: "awp-menu",
|
|
595
|
+
style: { left: menu.x + "px", top: menu.y + "px" },
|
|
596
|
+
onPointerDown: function (e) { e.stopPropagation(); },
|
|
597
|
+
onContextMenu: function (e) { e.preventDefault(); }
|
|
598
|
+
},
|
|
599
|
+
h("div", { className: "awp-menu-dim" }, "伞伞"),
|
|
600
|
+
h("button", { type: "button", onClick: function () { setOpen(true); setMenu(null); } }, "检查清单"),
|
|
601
|
+
h("button", { type: "button", onClick: function () { load(true); setMenu(null); } }, "重新检查"),
|
|
602
|
+
h("div", { className: "awp-menu-sep" }),
|
|
603
|
+
h("div", { className: "awp-menu-dim" }, "大小"),
|
|
604
|
+
h("div", { className: "awp-menu-row" },
|
|
605
|
+
[88, 120, 160].map(function (s) {
|
|
606
|
+
return h("button", {
|
|
607
|
+
key: s,
|
|
608
|
+
type: "button",
|
|
609
|
+
className: petSize === s ? "on" : "",
|
|
610
|
+
onClick: function () {
|
|
611
|
+
setPetSize(s);
|
|
612
|
+
try { localStorage.setItem("argent.pet.size", String(s)); } catch { /* noop */ }
|
|
613
|
+
}
|
|
614
|
+
}, String(s));
|
|
615
|
+
})),
|
|
616
|
+
h("div", { className: "awp-menu-sep" }),
|
|
617
|
+
h("button", {
|
|
618
|
+
type: "button",
|
|
619
|
+
onClick: function () {
|
|
620
|
+
var v = !anim;
|
|
621
|
+
setAnim(v);
|
|
622
|
+
try { localStorage.setItem("argent.pet.anim", v ? "1" : "0"); } catch { /* noop */ }
|
|
623
|
+
setMenu(null);
|
|
624
|
+
}
|
|
625
|
+
}, anim ? "暂停动画" : "播放动画"),
|
|
626
|
+
h("button", { type: "button", onClick: function () { window.open("https://whyshu.com", "_blank", "noopener"); setMenu(null); } }, "关于伞伞"),
|
|
627
|
+
h("div", { className: "awp-menu-sep" }),
|
|
628
|
+
h("button", {
|
|
629
|
+
type: "button",
|
|
630
|
+
onClick: function () {
|
|
631
|
+
setHidden(true);
|
|
632
|
+
try { localStorage.setItem("argent.pet.hidden", "1"); } catch { /* noop */ }
|
|
633
|
+
setMenu(null);
|
|
634
|
+
}
|
|
635
|
+
}, "隐藏伞伞"));
|
|
636
|
+
|
|
637
|
+
if (hidden) {
|
|
638
|
+
return h("button", {
|
|
639
|
+
type: "button",
|
|
640
|
+
className: "awp-hidden-dot",
|
|
641
|
+
title: "伞伞已隐藏 · 左键恢复 / 右键菜单",
|
|
642
|
+
style: { right: pos.right + "px", bottom: pos.bottom + "px" },
|
|
643
|
+
onClick: function () {
|
|
644
|
+
setHidden(false);
|
|
645
|
+
try { localStorage.setItem("argent.pet.hidden", "0"); } catch { /* noop */ }
|
|
646
|
+
},
|
|
647
|
+
onContextMenu: function (e) {
|
|
648
|
+
e.preventDefault();
|
|
649
|
+
setHidden(false);
|
|
650
|
+
try { localStorage.setItem("argent.pet.hidden", "0"); } catch { /* noop */ }
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
return h("div", { style: rootStyle }, panel, bubble, pet, menuEl);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
var ADPMENU_CSS = "\n.awp-mush.awp-pop{animation:awp-pop .5s cubic-bezier(.34,1.56,.64,1) 1}\n@keyframes awp-pop{0%{transform:none}35%{transform:scale(1.14,.88) translateY(2%)}65%{transform:scale(.94,1.08) translateY(-5%)}100%{transform:none}}\n.awp-mush.awp-paused .awp-all,.awp-mush.awp-paused .awp-cap,.awp-mush.awp-paused .awp-eyes,.awp-mush.awp-paused .awp-prop,.awp-mush.awp-paused .awp-hands{animation-play-state:paused}\n.awp-menu{position:fixed;z-index:2147483001;min-width:152px;padding:6px;border-radius:10px;\n background:var(--dsw-alias-bg-layer-1,#18181f);border:1px solid var(--dsw-alias-border-l2,#34343f);\n box-shadow:0 12px 30px rgba(0,0,0,.45);font:12px/1.4 var(--dsw-font-family,system-ui,-apple-system,sans-serif);\n pointer-events:auto}\n.awp-menu button{display:block;width:100%;text-align:left;padding:7px 10px;border:none;border-radius:7px;\n background:transparent;color:var(--dsw-alias-label-primary,#f4f4f5);font:inherit;cursor:pointer}\n.awp-menu button:hover{background:rgba(167,139,250,.16)}\n.awp-menu .awp-menu-sep{height:1px;margin:5px 4px;background:var(--dsw-alias-border-l2,#34343f)}\n.awp-menu .awp-menu-dim{color:var(--dsw-alias-label-secondary,#9b95b0);cursor:default;padding:4px 10px;font-size:11px}\n.awp-hidden-dot{position:fixed;z-index:2147483000;width:14px;height:14px;padding:0;border-radius:50%;\n border:none;background:rgba(167,139,250,.55);cursor:pointer;box-shadow:0 0 0 3px rgba(167,139,250,.12)}\n.awp-hidden-dot:hover{background:rgba(167,139,250,.95)}\n\n.awp-menu-row{display:flex;gap:6px;padding:2px 6px 6px}\n.awp-menu-row button{width:auto;flex:1;text-align:center;padding:5px 0;border:1px solid var(--dsw-alias-border-l2,#34343f);\n border-radius:7px;background:transparent;color:var(--dsw-alias-label-primary,#f4f4f5);font:inherit;cursor:pointer}\n.awp-menu-row button:hover{background:rgba(167,139,250,.16)}\n.awp-menu-row button.on{background:rgba(167,139,250,.28);border-color:#a78bfa;font-weight:700}\n";
|
|
659
|
+
var CSS = "\n.awp-pet, .awp-pet * { box-sizing: border-box; }\n" + PET_MUSH_CSS + ADPMENU_CSS;
|
|
660
|
+
|
|
661
|
+
function injectCss() {
|
|
662
|
+
try {
|
|
663
|
+
if (!document || !document.head) return;
|
|
664
|
+
if (document.getElementById("argent-pet-css")) return;
|
|
665
|
+
var style = document.createElement("style");
|
|
666
|
+
style.id = "argent-pet-css";
|
|
667
|
+
style.textContent = CSS;
|
|
668
|
+
document.head.appendChild(style);
|
|
669
|
+
} catch { /* noop */ }
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
var name = "argent-client";
|
|
673
|
+
var inject = ["slots"];
|
|
674
|
+
|
|
675
|
+
function apply(ctx) {
|
|
676
|
+
injectCss();
|
|
677
|
+
try {
|
|
678
|
+
ctx.slots.inject("shell.overlay", function* () {
|
|
679
|
+
yield ctx.slots.register({ name: "shell.overlay", id: "argent-pet", order: 900 }, function () {
|
|
680
|
+
return h(ArgentPet, null);
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
} catch (e) {
|
|
684
|
+
console.warn("[argent] 桌宠注册失败(不影响 ERP 连接):", (e && e.message) || e);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
module.exports = { name: name, inject: inject, apply: apply };
|
|
689
|
+
return module.exports;
|
|
690
|
+
}
|
|
691
|
+
});
|