labull-framework 0.1.4 → 0.1.6
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/magic-block.js +802 -735
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/magic-block.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useRouter as
|
|
3
|
-
import { A as
|
|
4
|
-
import { u as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as We, ref as w, computed as O, watch as me, nextTick as et, onMounted as lt, onBeforeUnmount as rt, openBlock as m, createElementBlock as h, normalizeStyle as ct, normalizeClass as X, unref as _e, createElementVNode as p, toDisplayString as g, createCommentVNode as E, Fragment as N, renderList as Z, withModifiers as Nt, createBlock as It, withDirectives as Lt, vModelText as Dt, createTextVNode as J, createStaticVNode as Ft } from "vue";
|
|
2
|
+
import { useRouter as ut } from "vue-router";
|
|
3
|
+
import { A as zt, b as Q, c as Ke, u as dt } from "./chunk-index-BWpDbB19.js";
|
|
4
|
+
import { u as Ht, o as qe, b as pt, _ as ft, d as Kt } from "./chunk-ProductShell.vue_vue_type_style_index_0_scoped_0fb37099_lang-BpRKKThg.js";
|
|
5
|
+
const V = "__mb", mt = "call", Ue = "reply", bt = "host-ready", ht = "height", qt = "html, body { overflow: hidden !important; }", Ut = `
|
|
6
6
|
(function () {
|
|
7
7
|
var seq = 0, waiting = {}, queue = [], ready = false, last = -1;
|
|
8
8
|
function call(method, args) {
|
|
@@ -10,16 +10,16 @@ const K = "__mb", dt = "call", Fe = "reply", pt = "host-ready", ft = "height", I
|
|
|
10
10
|
function run() {
|
|
11
11
|
var id = ++seq;
|
|
12
12
|
waiting[id] = { resolve: resolve, reject: reject };
|
|
13
|
-
parent.postMessage({ '${
|
|
13
|
+
parent.postMessage({ '${V}': '${mt}', id: id, method: method, args: args }, '*');
|
|
14
14
|
}
|
|
15
15
|
if (ready) run(); else queue.push(run);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
window.addEventListener('message', function (event) {
|
|
19
19
|
var data = event.data, pending;
|
|
20
|
-
if (!data || data['${
|
|
21
|
-
if (data['${
|
|
22
|
-
if (data['${
|
|
20
|
+
if (!data || data['${V}'] === undefined) return;
|
|
21
|
+
if (data['${V}'] === '${bt}') { ready = true; queue.splice(0).forEach(function (run) { run(); }); return; }
|
|
22
|
+
if (data['${V}'] !== '${Ue}') return;
|
|
23
23
|
if (!(pending = waiting[data.id])) return;
|
|
24
24
|
delete waiting[data.id];
|
|
25
25
|
if (data.ok) pending.resolve(data.value); else pending.reject(new Error(data.error || '调用失败'));
|
|
@@ -60,7 +60,7 @@ const K = "__mb", dt = "call", Fe = "reply", pt = "host-ready", ft = "height", I
|
|
|
60
60
|
if (height > 0) height += 1;
|
|
61
61
|
if (height === last) return; /* 一样高就不再发:否则「宿主改高度 → 触发观察 → 又发一次」会转个不停 */
|
|
62
62
|
last = height;
|
|
63
|
-
parent.postMessage({ '${
|
|
63
|
+
parent.postMessage({ '${V}': '${ht}', height: height }, '*');
|
|
64
64
|
}
|
|
65
65
|
function start() {
|
|
66
66
|
report();
|
|
@@ -69,28 +69,28 @@ const K = "__mb", dt = "call", Fe = "reply", pt = "host-ready", ft = "height", I
|
|
|
69
69
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start();
|
|
70
70
|
setInterval(report, 500);
|
|
71
71
|
})();
|
|
72
|
-
`,
|
|
73
|
-
function
|
|
72
|
+
`, Jt = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/;
|
|
73
|
+
function gt(t) {
|
|
74
74
|
const e = typeof window > "u" ? "http://localhost" : window.location.href;
|
|
75
|
-
return new URL(`${
|
|
75
|
+
return new URL(`${zt}${t}`, e);
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const tt = (() => {
|
|
78
78
|
try {
|
|
79
|
-
return
|
|
79
|
+
return gt("").origin;
|
|
80
80
|
} catch {
|
|
81
81
|
return typeof window > "u" ? "" : window.location.origin;
|
|
82
82
|
}
|
|
83
83
|
})();
|
|
84
|
-
async function
|
|
85
|
-
if (!
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
const l =
|
|
84
|
+
async function Vt(t, e, o) {
|
|
85
|
+
if (!Jt.test(e)) throw new Error(`路由名不合法:${e}(要写成 类名.方法名,例如 Customer.create)`);
|
|
86
|
+
const a = gt(`/bx/${t}/${e}`);
|
|
87
|
+
if (a.origin !== tt) throw new Error(`后端地址必须是本应用的(${tt}):${a.origin}`);
|
|
88
|
+
const l = o instanceof Blob ? o : null, r = await fetch(a.toString(), {
|
|
89
89
|
method: "POST",
|
|
90
90
|
credentials: "include",
|
|
91
91
|
// 带上 HttpOnly 会话 cookie;authHeaders('POST') 给 CSRF 头(缺了 403)
|
|
92
|
-
headers: l ? { "Content-Type": l.type || "application/octet-stream", ...
|
|
93
|
-
body: l ?? JSON.stringify(
|
|
92
|
+
headers: l ? { "Content-Type": l.type || "application/octet-stream", ...Ke("POST") } : { "Content-Type": "application/json", ...Ke("POST") },
|
|
93
|
+
body: l ?? JSON.stringify(o ?? {})
|
|
94
94
|
}), u = await r.text().catch(() => "");
|
|
95
95
|
if (r.ok) {
|
|
96
96
|
if (!u) return null;
|
|
@@ -109,16 +109,16 @@ async function Ft(t, e, n) {
|
|
|
109
109
|
}
|
|
110
110
|
throw new Error(c ? `${e} 调用失败:${c.slice(0, 300)}` : `${e} 调用失败(${r.status})`);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
const
|
|
112
|
+
function Gt(t, e) {
|
|
113
|
+
const o = (u) => {
|
|
114
114
|
try {
|
|
115
115
|
t.contentWindow?.postMessage(u, "*");
|
|
116
116
|
} catch (c) {
|
|
117
117
|
console.warn("[magic-block] 有一条宿主消息没能发给块(协议继续走):", c);
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
|
-
async function
|
|
121
|
-
if (u === "getMe") return await
|
|
120
|
+
async function a(u, c) {
|
|
121
|
+
if (u === "getMe") return await Q("/auth/me");
|
|
122
122
|
if (u === "navigateTab") {
|
|
123
123
|
const d = typeof c[0] == "string" ? c[0].trim() : "";
|
|
124
124
|
if (!d || !e.onNavigateTab) throw new Error(`跳不了 ${d || "(空地址)"}:这个页面没有把宿主接到路由上`);
|
|
@@ -134,7 +134,7 @@ function zt(t, e) {
|
|
|
134
134
|
const d = typeof c[0] == "string" ? c[0].trim() : "", f = c[1];
|
|
135
135
|
if (!d) throw new Error("后端调用的路由名是空的:要写成 magicBackendApi.类名.方法名(参数)");
|
|
136
136
|
if (!f || typeof f != "object" || Array.isArray(f)) throw new Error(`magicBackendApi.${d}(params) 的参数要么是一个对象,要么是一个文件(File / Blob)`);
|
|
137
|
-
return await
|
|
137
|
+
return await Vt(e.uuid, d, f);
|
|
138
138
|
}
|
|
139
139
|
throw new Error(`不认识的方法:${String(u)}(这块桥只有 getMe / navigateTab / context / setTabTitle / backend 五个)`);
|
|
140
140
|
}
|
|
@@ -142,127 +142,127 @@ function zt(t, e) {
|
|
|
142
142
|
if (u.source !== t.contentWindow) return;
|
|
143
143
|
const c = u.data;
|
|
144
144
|
if (!c) return;
|
|
145
|
-
if (c[
|
|
145
|
+
if (c[V] === ht) {
|
|
146
146
|
const f = typeof c.height == "number" ? c.height : NaN;
|
|
147
147
|
Number.isFinite(f) && f > 0 && e.onHeight?.(f);
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
if (c[
|
|
150
|
+
if (c[V] !== mt) return;
|
|
151
151
|
const d = c.id;
|
|
152
152
|
(async () => {
|
|
153
153
|
try {
|
|
154
|
-
|
|
154
|
+
o({ [V]: Ue, id: d, ok: !0, value: await a(String(c.method), c.args ?? []) });
|
|
155
155
|
} catch (f) {
|
|
156
|
-
|
|
156
|
+
o({ [V]: Ue, id: d, ok: !1, error: f instanceof Error ? f.message : String(f) });
|
|
157
157
|
}
|
|
158
158
|
})();
|
|
159
159
|
};
|
|
160
160
|
window.addEventListener("message", l);
|
|
161
|
-
const r = () =>
|
|
161
|
+
const r = () => o({ [V]: bt });
|
|
162
162
|
return r(), t.addEventListener("load", r), () => {
|
|
163
163
|
window.removeEventListener("message", l), t.removeEventListener("load", r);
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
172
|
-
return
|
|
166
|
+
const vt = "index.open.html", Yt = "backend_open.py", Wt = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
167
|
+
function nt(t, e) {
|
|
168
|
+
if (Wt.test(t)) return;
|
|
169
|
+
const o = (t.split(/[?#]/)[0] ?? "").replace(/^\.\//, "").replace(/^\/+/, "");
|
|
170
|
+
if (o in e) return o;
|
|
171
|
+
const a = o.split("/").pop() ?? "";
|
|
172
|
+
return a ? Object.keys(e).find((l) => (l.split("/").pop() ?? "") === a) : void 0;
|
|
173
173
|
}
|
|
174
|
-
const
|
|
175
|
-
function
|
|
176
|
-
return `${
|
|
174
|
+
const yt = "\0mb:";
|
|
175
|
+
function Zt(t) {
|
|
176
|
+
return `${yt}${t}\0`;
|
|
177
177
|
}
|
|
178
|
-
const
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
return { html: t.replace(
|
|
182
|
-
const y =
|
|
183
|
-
return y === void 0 ? u :
|
|
184
|
-
${
|
|
178
|
+
const Xt = /<script\b([^>]*?)\bsrc\s*=\s*(["'])(.*?)\2([^>]*)>\s*<\/script\s*>/gi, Qt = /<link\b([^>]*?)\bhref\s*=\s*(["'])(.*?)\2([^>]*?)\/?>/gi;
|
|
179
|
+
function en(t, e) {
|
|
180
|
+
const o = [], a = (u) => (o.push(u), Zt(o.length - 1));
|
|
181
|
+
return { html: t.replace(Xt, (u, c, d, f, $) => {
|
|
182
|
+
const y = nt(f, e);
|
|
183
|
+
return y === void 0 ? u : a(`<script${c}${$}>
|
|
184
|
+
${_t(e[y] ?? "")}
|
|
185
185
|
<\/script>`);
|
|
186
|
-
}).replace(
|
|
187
|
-
if (!/\brel\s*=\s*(?:"|')?stylesheet/i.test(`${c}${
|
|
188
|
-
const y =
|
|
189
|
-
return y === void 0 ? u :
|
|
186
|
+
}).replace(Qt, (u, c, d, f, $) => {
|
|
187
|
+
if (!/\brel\s*=\s*(?:"|')?stylesheet/i.test(`${c}${$}`)) return u;
|
|
188
|
+
const y = nt(f, e);
|
|
189
|
+
return y === void 0 ? u : a(`<style>
|
|
190
190
|
${e[y]}
|
|
191
191
|
</style>`);
|
|
192
|
-
}), slots:
|
|
192
|
+
}), slots: o };
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function _t(t) {
|
|
195
195
|
return t.replace(/<\/(script)/gi, "<\\/$1");
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
const
|
|
199
|
-
return
|
|
197
|
+
function kt(t, e) {
|
|
198
|
+
const o = /<\/head\s*>/i.exec(t);
|
|
199
|
+
return o ? `${t.slice(0, o.index)}${e}${t.slice(o.index)}` : `${e}${t}`;
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
return e ?
|
|
203
|
-
${
|
|
201
|
+
function tn(t, e) {
|
|
202
|
+
return e ? kt(t, `<script>
|
|
203
|
+
${_t(e)}
|
|
204
204
|
<\/script>
|
|
205
205
|
`) : t;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
return e ?
|
|
207
|
+
function ot(t, e) {
|
|
208
|
+
return e ? kt(t, `<style data-magic-block="host">
|
|
209
209
|
${e}
|
|
210
210
|
</style>
|
|
211
211
|
`) : t;
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
const
|
|
213
|
+
function nn(t, e = "") {
|
|
214
|
+
const o = typeof e == "string" ? e : e.bootstrap ?? "", a = typeof e == "string" ? "" : e.css ?? "", l = typeof e == "string" ? "" : e.themeCss ?? "", r = t[vt];
|
|
215
215
|
if (r === void 0) return "";
|
|
216
|
-
const { html: u, slots: c } =
|
|
216
|
+
const { html: u, slots: c } = en(r, t), d = tn(ot(ot(u, l), a), o), f = d.split(yt);
|
|
217
217
|
if (f.length === 1) return d;
|
|
218
|
-
let
|
|
218
|
+
let $ = f[0] ?? "";
|
|
219
219
|
for (let y = 1; y < f.length; y += 1) {
|
|
220
|
-
const _ = f[y] ?? "",
|
|
221
|
-
|
|
220
|
+
const _ = f[y] ?? "", I = _.indexOf("\0"), A = Number(_.slice(0, I));
|
|
221
|
+
$ += (c[A] ?? "") + _.slice(I + 1);
|
|
222
222
|
}
|
|
223
|
-
return
|
|
223
|
+
return $;
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
let
|
|
227
|
-
const
|
|
228
|
-
function
|
|
229
|
-
return
|
|
230
|
-
|
|
225
|
+
const ke = /* @__PURE__ */ new Map();
|
|
226
|
+
let be = null;
|
|
227
|
+
const Je = /* @__PURE__ */ new Set();
|
|
228
|
+
function on(t) {
|
|
229
|
+
return Je.add(t), () => {
|
|
230
|
+
Je.delete(t);
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
for (const t of
|
|
233
|
+
function sn() {
|
|
234
|
+
ke.clear(), be = null;
|
|
235
|
+
for (const t of Je) t();
|
|
236
236
|
}
|
|
237
|
-
async function
|
|
237
|
+
async function an(t) {
|
|
238
238
|
const e = [...new Set(t)].filter(Boolean);
|
|
239
|
-
if (e.some((
|
|
240
|
-
|
|
239
|
+
if (e.some((o) => !ke.has(o))) {
|
|
240
|
+
be && await be.catch(() => {
|
|
241
241
|
});
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
for (const l of
|
|
245
|
-
return
|
|
242
|
+
const o = e.filter((a) => !ke.has(a));
|
|
243
|
+
o.length > 0 && (be = Q(`/magic-blocks/render?ids=${o.map(encodeURIComponent).join(",")}`).then((a) => {
|
|
244
|
+
for (const l of a) l?.id && ke.set(l.id, l);
|
|
245
|
+
return a;
|
|
246
246
|
}).catch(() => []).finally(() => {
|
|
247
|
-
|
|
248
|
-
}), await
|
|
247
|
+
be = null;
|
|
248
|
+
}), await be.catch(() => {
|
|
249
249
|
}));
|
|
250
250
|
}
|
|
251
|
-
return e.map((
|
|
251
|
+
return e.map((o) => ke.get(o)).filter((o) => !!o);
|
|
252
252
|
}
|
|
253
|
-
const
|
|
254
|
-
function
|
|
255
|
-
const
|
|
256
|
-
if (/@font-face|@keyframes/i.test(
|
|
257
|
-
const
|
|
258
|
-
return /(^|[\s,>+~])(\.p-|\.pi(?![a-z])|\.pi-|\.labull-|:root|html(?![a-z-])|body(?![a-z-])|\*|:where\()/.test(
|
|
253
|
+
const re = "labull.css", Me = "CONTROLS.lock.html";
|
|
254
|
+
function ln(t, e) {
|
|
255
|
+
const o = String(e || "");
|
|
256
|
+
if (/@font-face|@keyframes/i.test(o)) return !0;
|
|
257
|
+
const a = String(t || "");
|
|
258
|
+
return /(^|[\s,>+~])(\.p-|\.pi(?![a-z])|\.pi-|\.labull-|:root|html(?![a-z-])|body(?![a-z-])|\*|:where\()/.test(a) ? !0 : /--(?:sp|surface|primary|text-color|content|highlight|focus-ring|p-)/.test(o);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
for (let
|
|
262
|
-
const l = t[
|
|
260
|
+
function wt(t, e, o) {
|
|
261
|
+
for (let a = 0; a < t.length; a += 1) {
|
|
262
|
+
const l = t[a], r = String(l.cssText || ""), u = String(l.selectorText || "");
|
|
263
263
|
if (l.cssRules && l.cssRules.length > 0) {
|
|
264
264
|
const c = [];
|
|
265
|
-
if (
|
|
265
|
+
if (wt(l.cssRules, c, o), c.length === 0) continue;
|
|
266
266
|
const d = r.slice(0, r.indexOf("{")).trim();
|
|
267
267
|
e.push(`${d} {
|
|
268
268
|
${c.map((f) => " " + f).join(`
|
|
@@ -270,12 +270,12 @@ ${c.map((f) => " " + f).join(`
|
|
|
270
270
|
}`);
|
|
271
271
|
continue;
|
|
272
272
|
}
|
|
273
|
-
|
|
273
|
+
ln(u, r) && (e.push(r), o.n += 1);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const t = [], e = [],
|
|
278
|
-
let
|
|
276
|
+
function $t() {
|
|
277
|
+
const t = [], e = [], o = { n: 0 };
|
|
278
|
+
let a = 0;
|
|
279
279
|
const l = typeof document > "u" ? [] : Array.from(document.styleSheets);
|
|
280
280
|
for (const u of l) {
|
|
281
281
|
const c = u.href || "(内联 <style>)";
|
|
@@ -288,18 +288,18 @@ function _t() {
|
|
|
288
288
|
}
|
|
289
289
|
if (!d || d.length === 0) continue;
|
|
290
290
|
const f = [];
|
|
291
|
-
|
|
291
|
+
wt(d, f, o), f.length !== 0 && (a += 1, t.push(`/* ── ${c} ── */`, ...f));
|
|
292
292
|
}
|
|
293
293
|
return { css: [
|
|
294
294
|
"/* 生成物:每次导出都会重写,别手改。",
|
|
295
295
|
" *",
|
|
296
296
|
" * 这是这个应用此刻真正在用的 **labull 主题 + 控件样式**(token / PrimeVue 控件 / 结构类 / 图标)。",
|
|
297
|
-
` * 收自 ${
|
|
297
|
+
` * 收自 ${a} 张样式表、${o.n} 条规则。`,
|
|
298
298
|
e.length > 0 ? ` * ⚠️ 有 ${e.length} 张样式表读不到规则(跨源,浏览器不让读):${e.join(" / ")} —— 需要的话手动补一份。` : " * (没有读不到的样式表:收全了。)",
|
|
299
299
|
" *",
|
|
300
300
|
" * 怎么用(块里):**什么都不用加** —— 宿主会把这一份注入每个块的 iframe(`MagicBlockHost` 的 `theme` prop),",
|
|
301
301
|
' * 所以直接写类名就行:`<button class="p-button">` / `<input class="p-inputtext">` / `<span class="p-tag">`。',
|
|
302
|
-
" * 这一份放在开发包里是给你**查 / 对照 / 抄**用的(`" +
|
|
302
|
+
" * 这一份放在开发包里是给你**查 / 对照 / 抄**用的(`" + Me + "` 里的每一块 markup 都能直接用)。",
|
|
303
303
|
" * ⚠️ 别把它当块包文件塞进块里:它 500 KB 上下,而且宿主已经注入了一份(重复只会更慢)。",
|
|
304
304
|
" * ⚠️ 块里**只有 CSS,没有 JS 组件**:下拉 / 日期 / 弹窗那些要装了 PrimeVue 才有行为,",
|
|
305
305
|
" * 这里能用的是类名(按钮、输入框、标签、面板、表格、图标)。",
|
|
@@ -308,10 +308,10 @@ function _t() {
|
|
|
308
308
|
].join(`
|
|
309
309
|
`) + t.join(`
|
|
310
310
|
`) + `
|
|
311
|
-
`, sheets:
|
|
311
|
+
`, sheets: a, skipped: e, rules: o.n };
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
const
|
|
313
|
+
function rn() {
|
|
314
|
+
const o = [
|
|
315
315
|
["按钮", '<button class="p-button" type="button">主要按钮</button>'],
|
|
316
316
|
["次要按钮", '<button class="p-button p-button-outlined" type="button">次要按钮</button>'],
|
|
317
317
|
["纯文字按钮", '<button class="p-button p-button-text" type="button">纯文字</button>'],
|
|
@@ -328,8 +328,8 @@ function en() {
|
|
|
328
328
|
["面板 + 标题", '<div class="labull-panel"><h2 class="labull-subject-title"><i class="pi pi-list"></i> 面板标题</h2><p>面板正文。</p></div>'],
|
|
329
329
|
["表格", "<table><thead><tr><th>列 A</th><th>列 B</th></tr></thead><tbody><tr><td>值</td><td>值</td></tr></tbody></table>"]
|
|
330
330
|
].map(
|
|
331
|
-
([
|
|
332
|
-
<h3>${
|
|
331
|
+
([a, l]) => ` <section>
|
|
332
|
+
<h3>${a}</h3>
|
|
333
333
|
<div class="demo">${l}</div>
|
|
334
334
|
<pre>${l.replace(/&/g, "&").replace(/</g, "<")}</pre>
|
|
335
335
|
</section>`
|
|
@@ -343,7 +343,7 @@ function en() {
|
|
|
343
343
|
<head>
|
|
344
344
|
<meta charset="utf-8">
|
|
345
345
|
<title>labull 控件清单</title>
|
|
346
|
-
<link rel="stylesheet" href="${
|
|
346
|
+
<link rel="stylesheet" href="${re}">
|
|
347
347
|
<style>
|
|
348
348
|
body { margin: 0; padding: 16px; }
|
|
349
349
|
h1 { margin: 0 0 4px; font-size: 18px; }
|
|
@@ -359,72 +359,72 @@ function en() {
|
|
|
359
359
|
<body>
|
|
360
360
|
<h1>labull 控件清单</h1>
|
|
361
361
|
<p class="lead">
|
|
362
|
-
这些类名来自 <code>${
|
|
362
|
+
这些类名来自 <code>${re}</code>(与应用同源同版本)。块里别自己写一套配色 / 按钮:
|
|
363
363
|
把这一行加进 <code>index.open.html</code> 的 <code><head></code>,
|
|
364
364
|
下面每一块 markup 都能直接用:
|
|
365
|
-
<code><link rel="stylesheet" href="${
|
|
365
|
+
<code><link rel="stylesheet" href="${re}"></code>
|
|
366
366
|
<br />
|
|
367
367
|
⚠️ 这里**只有 CSS,没有 JS 组件**:下拉 / 日期 / 弹窗那些要装了 PrimeVue 才有行为(块里没有构建步骤)。
|
|
368
368
|
</p>
|
|
369
|
-
${
|
|
369
|
+
${o}
|
|
370
370
|
</body>
|
|
371
371
|
</html>
|
|
372
372
|
`;
|
|
373
373
|
}
|
|
374
|
-
const
|
|
375
|
-
let
|
|
376
|
-
function
|
|
377
|
-
for (const t of
|
|
374
|
+
const ce = /* @__PURE__ */ new Map(), Ve = /* @__PURE__ */ new Set(), cn = 4e3;
|
|
375
|
+
let Ge = "", Ce = null;
|
|
376
|
+
function st() {
|
|
377
|
+
for (const t of Ve) t();
|
|
378
378
|
}
|
|
379
|
-
function
|
|
380
|
-
return
|
|
381
|
-
|
|
379
|
+
function un(t) {
|
|
380
|
+
return Ve.add(t), () => {
|
|
381
|
+
Ve.delete(t);
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
|
-
function
|
|
385
|
-
return
|
|
384
|
+
function Ie() {
|
|
385
|
+
return Ge;
|
|
386
386
|
}
|
|
387
|
-
function
|
|
388
|
-
const
|
|
389
|
-
if (!
|
|
387
|
+
function dn(t, e) {
|
|
388
|
+
const o = String(t || "").trim(), a = String(e || "").trim();
|
|
389
|
+
if (!o || !a) return () => {
|
|
390
390
|
};
|
|
391
|
-
let l =
|
|
392
|
-
return l || (l = /* @__PURE__ */ new Set(),
|
|
393
|
-
const r =
|
|
394
|
-
r && (r.delete(
|
|
391
|
+
let l = ce.get(o);
|
|
392
|
+
return l || (l = /* @__PURE__ */ new Set(), ce.set(o, l)), l.add(a), () => {
|
|
393
|
+
const r = ce.get(o);
|
|
394
|
+
r && (r.delete(a), r.size === 0 && ce.delete(o));
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
|
-
function
|
|
398
|
-
const
|
|
399
|
-
if (!
|
|
400
|
-
for (const l of
|
|
401
|
-
if (l !== e && !(
|
|
397
|
+
function Ye(t, e, o) {
|
|
398
|
+
const a = ce.get(String(t || ""));
|
|
399
|
+
if (!a) return null;
|
|
400
|
+
for (const l of a)
|
|
401
|
+
if (l !== e && !(o && !o(l)))
|
|
402
402
|
return l;
|
|
403
403
|
return null;
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
return [...
|
|
405
|
+
function pn(t) {
|
|
406
|
+
return [...ce.get(String(t || "")) ?? []];
|
|
407
407
|
}
|
|
408
|
-
function
|
|
409
|
-
const
|
|
410
|
-
return !
|
|
408
|
+
function fn(t, e, o) {
|
|
409
|
+
const a = ce.get(String(t || ""));
|
|
410
|
+
return !a || a.size === 0 || a.has(e) ? null : Ye(t, e, o);
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}, Math.max(1, e)),
|
|
412
|
+
function xt(t, e = cn) {
|
|
413
|
+
Ge = String(t || ""), Ce !== null && clearTimeout(Ce), Ce = setTimeout(() => {
|
|
414
|
+
Ce = null, Ge = "", st();
|
|
415
|
+
}, Math.max(1, e)), st();
|
|
416
416
|
}
|
|
417
|
-
const
|
|
417
|
+
const mn = ["data-magic-block", "data-magic-module"], bn = ["srcdoc", "title"], hn = { class: "mb__state" }, gn = { class: "mb__brief" }, vn = {
|
|
418
418
|
key: 0,
|
|
419
419
|
class: "mb__reason"
|
|
420
|
-
},
|
|
420
|
+
}, yn = {
|
|
421
421
|
key: 1,
|
|
422
422
|
class: "mb__issues"
|
|
423
|
-
},
|
|
423
|
+
}, _n = {
|
|
424
424
|
key: 2,
|
|
425
425
|
class: "mb__ring",
|
|
426
426
|
"aria-hidden": "true"
|
|
427
|
-
},
|
|
427
|
+
}, kn = ["title", "aria-label"], wn = ["title", "aria-label"], $n = ["title", "aria-label"], xn = ["title", "aria-label"], En = /* @__PURE__ */ We({
|
|
428
428
|
__name: "MagicBlockHost",
|
|
429
429
|
props: {
|
|
430
430
|
uuid: {},
|
|
@@ -433,188 +433,188 @@ const ln = ["data-magic-block", "data-magic-module"], rn = ["srcdoc", "title"],
|
|
|
433
433
|
theme: { type: Boolean, default: !0 }
|
|
434
434
|
},
|
|
435
435
|
setup(t) {
|
|
436
|
-
const e = t,
|
|
437
|
-
let y = null, _ = null,
|
|
438
|
-
const
|
|
439
|
-
const
|
|
440
|
-
for (const [k, C] of Object.entries(c.value?.files ?? {})) k !==
|
|
441
|
-
return
|
|
442
|
-
}),
|
|
443
|
-
let
|
|
444
|
-
function
|
|
436
|
+
const e = t, o = Ht(), a = ut(), { isStaff: l } = dt(), r = w(null), u = w(null), c = w(null), d = w(!1), f = w(0), $ = w(0);
|
|
437
|
+
let y = null, _ = null, I = null, A = null, ee = null, ne = null;
|
|
438
|
+
const P = O(() => e.name.trim() || e.uuid), S = O(() => c.value?.state ?? ""), D = O(() => S.value === "invalid" ? "校验不通过" : S.value === "draft" ? "未开发" : P.value), oe = O(() => (c.value?.brief ?? "").trim() || (c.value?.name ?? "").trim() || P.value), K = O(() => (c.value?.reason ?? "").trim()), ue = O(() => c.value?.issues ?? []), $e = O(() => Math.max($.value, f.value, 1)), Ae = O(() => ({ height: `${$e.value}px` })), G = O(() => {
|
|
439
|
+
const v = {};
|
|
440
|
+
for (const [k, C] of Object.entries(c.value?.files ?? {})) k !== Yt && (v[k] = C);
|
|
441
|
+
return v;
|
|
442
|
+
}), Y = O(() => S.value === "ok" && typeof G.value[vt] == "string");
|
|
443
|
+
let B = null;
|
|
444
|
+
function de() {
|
|
445
445
|
if (!e.theme) return "";
|
|
446
|
-
if (
|
|
446
|
+
if (B !== null || (B = "", typeof document > "u")) return B;
|
|
447
447
|
try {
|
|
448
|
-
|
|
448
|
+
B = $t().css;
|
|
449
449
|
} catch {
|
|
450
|
-
|
|
450
|
+
B = "";
|
|
451
451
|
}
|
|
452
|
-
return
|
|
452
|
+
return B;
|
|
453
453
|
}
|
|
454
|
-
const W =
|
|
455
|
-
if (!
|
|
456
|
-
const
|
|
457
|
-
return k && (
|
|
454
|
+
const W = O(() => {
|
|
455
|
+
if (!Y.value) return "";
|
|
456
|
+
const v = { bootstrap: Ut, css: qt }, k = de();
|
|
457
|
+
return k && (v.themeCss = k), nn(G.value, v);
|
|
458
458
|
});
|
|
459
|
-
function
|
|
460
|
-
return { key:
|
|
459
|
+
function se() {
|
|
460
|
+
return { key: o.key, path: o.path, params: o.params, query: o.query };
|
|
461
461
|
}
|
|
462
|
-
async function
|
|
463
|
-
const k =
|
|
462
|
+
async function j(v) {
|
|
463
|
+
const k = a.resolve(v);
|
|
464
464
|
if (k.matched.length === 0) {
|
|
465
|
-
const C =
|
|
466
|
-
throw new Error(`这个应用里没有页面 ${
|
|
465
|
+
const C = a.getRoutes().map((U) => U.path);
|
|
466
|
+
throw new Error(`这个应用里没有页面 ${v}。能跳的页面只有:${C.length > 0 ? C.join(" / ") : "(还没有配路由)"}`);
|
|
467
467
|
}
|
|
468
|
-
return
|
|
468
|
+
return qe(v) || k.fullPath;
|
|
469
469
|
}
|
|
470
|
-
function
|
|
471
|
-
|
|
472
|
-
const
|
|
473
|
-
|
|
470
|
+
function T() {
|
|
471
|
+
I?.(), I = null;
|
|
472
|
+
const v = u.value;
|
|
473
|
+
v && (I = Gt(v, {
|
|
474
474
|
uuid: e.uuid,
|
|
475
475
|
onHeight: (k) => {
|
|
476
476
|
f.value = k;
|
|
477
477
|
},
|
|
478
|
-
onNavigateTab:
|
|
479
|
-
context:
|
|
478
|
+
onNavigateTab: j,
|
|
479
|
+
context: se,
|
|
480
480
|
/* 🔴 块给**自己所属那条标签**起名:整页就是一个块时(`MagicBlockPage`),标签栏上那条
|
|
481
481
|
* 默认只有路由的 `meta.title`("订单详情"),而"订单 SO-42"只有块自己知道。 */
|
|
482
|
-
onTabTitle: (k, C) =>
|
|
482
|
+
onTabTitle: (k, C) => o.setTitle(k, C)
|
|
483
483
|
}));
|
|
484
484
|
}
|
|
485
|
-
async function
|
|
486
|
-
const
|
|
487
|
-
|
|
485
|
+
async function he() {
|
|
486
|
+
const v = e.uuid, k = await an([v]);
|
|
487
|
+
v === e.uuid && (c.value = k.find((C) => C.id === v) ?? null);
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function H() {
|
|
490
490
|
window.dispatchEvent(new CustomEvent("magic-block:open-console", { detail: { uuid: e.uuid } }));
|
|
491
491
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
492
|
+
function te(v = !1) {
|
|
493
|
+
v && ee?.(), ee = dn(e.uuid, o.key);
|
|
494
494
|
}
|
|
495
|
-
const
|
|
495
|
+
const ge = (v) => !pt(v, a), F = O(() => {
|
|
496
496
|
if (!l.value) return "";
|
|
497
|
-
const
|
|
498
|
-
return
|
|
497
|
+
const v = Ye(e.uuid, o.key, ge);
|
|
498
|
+
return v ? `管理员:切到还挂着这个块的标签 ${v}(点一下这一块会亮红框)` : "管理员:这个块只在这一条标签里挂着 —— 点一下会亮几秒红框";
|
|
499
499
|
});
|
|
500
|
-
function
|
|
500
|
+
function q() {
|
|
501
501
|
if (!l.value) return;
|
|
502
|
-
const
|
|
503
|
-
|
|
502
|
+
const v = Ye(e.uuid, o.key, ge);
|
|
503
|
+
xt(e.uuid), v && qe(v);
|
|
504
504
|
}
|
|
505
|
-
function
|
|
506
|
-
let k =
|
|
505
|
+
function xe(v) {
|
|
506
|
+
let k = v.parentElement;
|
|
507
507
|
for (; k; ) {
|
|
508
508
|
if (getComputedStyle(k).overflowY !== "visible" && k.clientHeight > 0) return k;
|
|
509
509
|
k = k.parentElement;
|
|
510
510
|
}
|
|
511
511
|
return document.documentElement;
|
|
512
512
|
}
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
if (!
|
|
516
|
-
const k =
|
|
517
|
-
return Math.max(0, Math.floor(
|
|
513
|
+
function Pe() {
|
|
514
|
+
const v = r.value;
|
|
515
|
+
if (!v) return 0;
|
|
516
|
+
const k = xe(v), C = getComputedStyle(k), U = parseFloat(C.paddingTop) || 0, ae = parseFloat(C.paddingBottom) || 0, ie = parseFloat(C.borderTopWidth) || 0, L = k === document.documentElement, Ee = L ? Math.max(0, window.innerHeight - U - ae) : Math.max(0, k.clientHeight - U - ae), Se = L ? U : k.getBoundingClientRect().top + ie + U, Te = L ? window.scrollY || 0 : k.scrollTop, Re = v.getBoundingClientRect().top - Se + Te;
|
|
517
|
+
return Math.max(0, Math.floor(Ee - Re));
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
if (!
|
|
521
|
-
const
|
|
522
|
-
|
|
519
|
+
function ve() {
|
|
520
|
+
if (!o.active.value || !r.value) return;
|
|
521
|
+
const v = Pe();
|
|
522
|
+
v > 0 && Math.abs(v - $.value) > 1 && ($.value = v);
|
|
523
523
|
}
|
|
524
|
-
function
|
|
524
|
+
function pe() {
|
|
525
525
|
if (!r.value) return;
|
|
526
|
-
const
|
|
527
|
-
y !==
|
|
526
|
+
const v = xe(r.value);
|
|
527
|
+
y !== v && (y = v, _?.disconnect(), _ = null), ve(), !(_ || typeof ResizeObserver > "u") && (_ = new ResizeObserver(() => ve()), _.observe(v));
|
|
528
528
|
}
|
|
529
|
-
return
|
|
530
|
-
f.value = 0,
|
|
531
|
-
}, { flush: "post" }),
|
|
532
|
-
|
|
533
|
-
}),
|
|
534
|
-
|
|
535
|
-
|
|
529
|
+
return me(u, () => T()), me(W, () => {
|
|
530
|
+
f.value = 0, $.value = 0, pe();
|
|
531
|
+
}, { flush: "post" }), me(() => e.uuid, () => {
|
|
532
|
+
et().then(() => pe());
|
|
533
|
+
}), me(() => o.active.value, (v) => {
|
|
534
|
+
v && et().then(() => {
|
|
535
|
+
pe();
|
|
536
536
|
const k = r.value;
|
|
537
537
|
!k || !k.isConnected || k.offsetParent === null || d.value && k.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
538
538
|
});
|
|
539
|
-
}),
|
|
540
|
-
f.value = 0, c.value = null,
|
|
541
|
-
}),
|
|
542
|
-
|
|
543
|
-
d.value =
|
|
544
|
-
}), d.value =
|
|
545
|
-
}),
|
|
546
|
-
_?.disconnect(), _ = null,
|
|
547
|
-
}), (
|
|
539
|
+
}), me(() => e.uuid, () => {
|
|
540
|
+
f.value = 0, c.value = null, te(!0), d.value = Ie() === e.uuid, he();
|
|
541
|
+
}), lt(() => {
|
|
542
|
+
A = on(() => void he()), ne = un(() => {
|
|
543
|
+
d.value = Ie() === e.uuid;
|
|
544
|
+
}), d.value = Ie() === e.uuid, te(), pe(), he();
|
|
545
|
+
}), rt(() => {
|
|
546
|
+
_?.disconnect(), _ = null, A?.(), A = null, ne?.(), ne = null, ee?.(), ee = null, I?.(), I = null;
|
|
547
|
+
}), (v, k) => (m(), h("div", {
|
|
548
548
|
ref_key: "el",
|
|
549
549
|
ref: r,
|
|
550
|
-
class:
|
|
551
|
-
style:
|
|
550
|
+
class: X(["mb", { "mb--admin": _e(l), "mb--lit": _e(l) && d.value }]),
|
|
551
|
+
style: ct(Ae.value),
|
|
552
552
|
"data-magic-block": t.uuid,
|
|
553
553
|
"data-magic-module": t.module
|
|
554
554
|
}, [
|
|
555
|
-
|
|
555
|
+
Y.value ? (m(), h("iframe", {
|
|
556
556
|
key: 0,
|
|
557
557
|
ref_key: "frame",
|
|
558
558
|
ref: u,
|
|
559
559
|
class: "mb__frame",
|
|
560
560
|
srcdoc: W.value,
|
|
561
|
-
title:
|
|
561
|
+
title: P.value,
|
|
562
562
|
scrolling: "no",
|
|
563
563
|
sandbox: "allow-scripts allow-forms allow-modals allow-popups allow-downloads"
|
|
564
|
-
}, null, 8,
|
|
564
|
+
}, null, 8, bn)) : (m(), h("div", {
|
|
565
565
|
key: 1,
|
|
566
|
-
class:
|
|
567
|
-
onClick:
|
|
566
|
+
class: X(["mb__empty", { "mb__empty--off": S.value === "invalid", "mb__empty--draft": S.value === "draft" }]),
|
|
567
|
+
onClick: q
|
|
568
568
|
}, [
|
|
569
|
-
p("p",
|
|
570
|
-
p("p",
|
|
571
|
-
S.value === "invalid" &&
|
|
572
|
-
S.value === "invalid" &&
|
|
573
|
-
(
|
|
574
|
-
key:
|
|
569
|
+
p("p", hn, g(D.value), 1),
|
|
570
|
+
p("p", gn, g(oe.value), 1),
|
|
571
|
+
S.value === "invalid" && K.value ? (m(), h("p", vn, g(K.value), 1)) : E("", !0),
|
|
572
|
+
S.value === "invalid" && ue.value.length > 0 ? (m(), h("ul", yn, [
|
|
573
|
+
(m(!0), h(N, null, Z(ue.value, (C, U) => (m(), h("li", {
|
|
574
|
+
key: U,
|
|
575
575
|
class: "mb__issue"
|
|
576
|
-
},
|
|
576
|
+
}, g(C.message), 1))), 128))
|
|
577
577
|
])) : E("", !0),
|
|
578
578
|
p("button", {
|
|
579
579
|
class: "mb__go",
|
|
580
580
|
type: "button",
|
|
581
|
-
onClick:
|
|
581
|
+
onClick: Nt(H, ["stop"])
|
|
582
582
|
}, "去控制台")
|
|
583
583
|
], 2)),
|
|
584
|
-
|
|
585
|
-
|
|
584
|
+
_e(l) ? (m(), h("span", _n)) : E("", !0),
|
|
585
|
+
_e(l) && Y.value ? (m(), h(N, { key: 3 }, [
|
|
586
586
|
p("button", {
|
|
587
587
|
class: "mb__grab mb__grab--top",
|
|
588
588
|
type: "button",
|
|
589
589
|
title: F.value,
|
|
590
590
|
"aria-label": F.value,
|
|
591
|
-
onClick:
|
|
592
|
-
}, null, 8,
|
|
591
|
+
onClick: q
|
|
592
|
+
}, null, 8, kn),
|
|
593
593
|
p("button", {
|
|
594
594
|
class: "mb__grab mb__grab--right",
|
|
595
595
|
type: "button",
|
|
596
596
|
title: F.value,
|
|
597
597
|
"aria-label": F.value,
|
|
598
|
-
onClick:
|
|
599
|
-
}, null, 8,
|
|
598
|
+
onClick: q
|
|
599
|
+
}, null, 8, wn),
|
|
600
600
|
p("button", {
|
|
601
601
|
class: "mb__grab mb__grab--bottom",
|
|
602
602
|
type: "button",
|
|
603
603
|
title: F.value,
|
|
604
604
|
"aria-label": F.value,
|
|
605
|
-
onClick:
|
|
606
|
-
}, null, 8,
|
|
605
|
+
onClick: q
|
|
606
|
+
}, null, 8, $n),
|
|
607
607
|
p("button", {
|
|
608
608
|
class: "mb__grab mb__grab--left",
|
|
609
609
|
type: "button",
|
|
610
610
|
title: F.value,
|
|
611
611
|
"aria-label": F.value,
|
|
612
|
-
onClick:
|
|
613
|
-
}, null, 8,
|
|
612
|
+
onClick: q
|
|
613
|
+
}, null, 8, xn)
|
|
614
614
|
], 64)) : E("", !0)
|
|
615
|
-
], 14,
|
|
615
|
+
], 14, mn));
|
|
616
616
|
}
|
|
617
|
-
}),
|
|
617
|
+
}), Sn = /* @__PURE__ */ ft(En, [["__scopeId", "data-v-8e1e849f"]]), $s = /* @__PURE__ */ We({
|
|
618
618
|
__name: "MagicBlockPage",
|
|
619
619
|
props: {
|
|
620
620
|
uuid: {},
|
|
@@ -623,144 +623,144 @@ const ln = ["data-magic-block", "data-magic-module"], rn = ["srcdoc", "title"],
|
|
|
623
623
|
theme: { type: Boolean, default: !0 }
|
|
624
624
|
},
|
|
625
625
|
setup(t) {
|
|
626
|
-
return (e,
|
|
626
|
+
return (e, o) => (m(), It(Sn, {
|
|
627
627
|
uuid: t.uuid,
|
|
628
628
|
name: t.name,
|
|
629
629
|
module: t.module,
|
|
630
630
|
theme: t.theme
|
|
631
631
|
}, null, 8, ["uuid", "name", "module", "theme"]));
|
|
632
632
|
}
|
|
633
|
-
}),
|
|
634
|
-
function
|
|
635
|
-
return t.length > 0 && t.length <=
|
|
633
|
+
}), Le = "index.open.html", De = "magic-block.open.yaml", Be = ["id", "module", "name", "brief"], Ze = 40, Tn = /^(?![A-Za-z]:)(?!\/)[A-Za-z0-9._\-/]+$/, Cn = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, Bn = /^[a-z][a-z0-9]*$/, Mn = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
634
|
+
function On(t) {
|
|
635
|
+
return t.length > 0 && t.length <= Ze && !/[\u0000-\u001f\u007f]/.test(t);
|
|
636
636
|
}
|
|
637
|
-
const
|
|
637
|
+
const An = {
|
|
638
638
|
id: "块的 uuid,必须与页面里挂载它时写死的那个 uuid 逐字一致",
|
|
639
639
|
module: "模块名(小写字母与数字,必须以字母开头),例如 home",
|
|
640
|
-
name: `可读名:可以用中文,不超过 ${
|
|
640
|
+
name: `可读名:可以用中文,不超过 ${Ze} 个字符`,
|
|
641
641
|
brief: "一句话说明这个块解决什么问题"
|
|
642
642
|
};
|
|
643
|
-
function
|
|
643
|
+
function at(t) {
|
|
644
644
|
const e = Object.keys(t);
|
|
645
645
|
return e.length > 0 ? `现在包里有:${e.join(" / ")}` : "现在这个包是空的";
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function Pn(t) {
|
|
648
648
|
let e = "";
|
|
649
|
-
for (let
|
|
650
|
-
const
|
|
649
|
+
for (let o = 0; o < t.length; o += 1) {
|
|
650
|
+
const a = t[o];
|
|
651
651
|
if (e)
|
|
652
|
-
|
|
653
|
-
else if (
|
|
654
|
-
else if (
|
|
652
|
+
a === e && (e = "");
|
|
653
|
+
else if (a === '"' || a === "'") e = a;
|
|
654
|
+
else if (a === "#") return t.slice(0, o);
|
|
655
655
|
}
|
|
656
656
|
return t;
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function Rn(t) {
|
|
659
659
|
let e = "";
|
|
660
|
-
for (let
|
|
661
|
-
const
|
|
660
|
+
for (let o = 0; o < t.length; o += 1) {
|
|
661
|
+
const a = t[o];
|
|
662
662
|
if (e)
|
|
663
|
-
|
|
664
|
-
else if (
|
|
665
|
-
else if (
|
|
663
|
+
a === e && (e = "");
|
|
664
|
+
else if (a === '"' || a === "'") e = a;
|
|
665
|
+
else if (a === ":") return o;
|
|
666
666
|
}
|
|
667
667
|
return -1;
|
|
668
668
|
}
|
|
669
|
-
function
|
|
669
|
+
function jn(t) {
|
|
670
670
|
return !t || t[0] !== '"' && t[0] !== "'" ? t : t.length >= 2 && t[t.length - 1] === t[0] ? t.slice(1, -1).trim() : t;
|
|
671
671
|
}
|
|
672
|
-
function
|
|
673
|
-
const e = [],
|
|
672
|
+
function Nn(t) {
|
|
673
|
+
const e = [], o = {}, a = {};
|
|
674
674
|
t.split(/\r?\n/).forEach((l, r) => {
|
|
675
|
-
const u = r + 1, c =
|
|
675
|
+
const u = r + 1, c = Pn(l).trim();
|
|
676
676
|
if (!c) return;
|
|
677
677
|
if (c.startsWith("-")) {
|
|
678
678
|
e.push(`第 ${u} 行是列表写法(${c}):清单只认「键: 值」,四个键各占一行 —— 例如 name: 客户档案`);
|
|
679
679
|
return;
|
|
680
680
|
}
|
|
681
|
-
const d =
|
|
681
|
+
const d = Rn(c);
|
|
682
682
|
if (d < 0) {
|
|
683
683
|
e.push(`第 ${u} 行不是「键: 值」(${c}):清单只认「键: 值」与 # 注释 —— 要么删掉这一行,要么照 name: 客户档案 写`);
|
|
684
684
|
return;
|
|
685
685
|
}
|
|
686
686
|
const f = c.slice(0, d).trim();
|
|
687
|
-
if (
|
|
688
|
-
e.push(`第 ${u} 行的键名不合法(${f}):键名只许字母或下划线开头,认得的键只有 ${
|
|
687
|
+
if (!Mn.test(f)) {
|
|
688
|
+
e.push(`第 ${u} 行的键名不合法(${f}):键名只许字母或下划线开头,认得的键只有 ${Be.join(" / ")}`);
|
|
689
689
|
return;
|
|
690
690
|
}
|
|
691
|
-
if (!
|
|
692
|
-
e.push(`第 ${u} 行的键不认识(${f}):清单只有 ${
|
|
691
|
+
if (!Be.includes(f)) {
|
|
692
|
+
e.push(`第 ${u} 行的键不认识(${f}):清单只有 ${Be.join(" / ")} 这四个键`);
|
|
693
693
|
return;
|
|
694
694
|
}
|
|
695
|
-
if (f in
|
|
696
|
-
e.push(`第 ${u} 行重复写了 ${f}(第 ${
|
|
695
|
+
if (f in a) {
|
|
696
|
+
e.push(`第 ${u} 行重复写了 ${f}(第 ${a[f]} 行已经写过):一个键只许出现一次`);
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
|
-
|
|
699
|
+
a[f] = u, o[f] = jn(c.slice(d + 1).trim());
|
|
700
700
|
});
|
|
701
|
-
for (const l of
|
|
702
|
-
const r =
|
|
701
|
+
for (const l of Be) {
|
|
702
|
+
const r = o[l] ?? "";
|
|
703
703
|
if (r === "") {
|
|
704
|
-
e.push(`清单里缺少 ${l}(或者是空的):${
|
|
704
|
+
e.push(`清单里缺少 ${l}(或者是空的):${An[l]}`);
|
|
705
705
|
continue;
|
|
706
706
|
}
|
|
707
|
-
l === "id" && !
|
|
707
|
+
l === "id" && !Cn.test(r) ? e.push(`清单里的 id 不是 uuid:${r} —— 要 8-4-4-4-12 那种十六进制`) : l === "module" && !Bn.test(r) ? e.push(
|
|
708
708
|
`清单里的 module 不合法:${r} —— 它同时是 Django 的 app label,所以只许小写字母与数字、必须以字母开头(不能有横线与下划线),例如 home / orders`
|
|
709
|
-
) : l === "name" && !
|
|
709
|
+
) : l === "name" && !On(r) && e.push(`清单里的 name 不合法:${r} —— 不能超过 ${Ze} 个字符、不能含控制字符(中文可以)`);
|
|
710
710
|
}
|
|
711
|
-
return [
|
|
711
|
+
return [o, e];
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
return
|
|
713
|
+
function In(t) {
|
|
714
|
+
return Tn.test(t) && !t.split("/").includes("..");
|
|
715
715
|
}
|
|
716
|
-
function
|
|
717
|
-
const e = [],
|
|
718
|
-
|
|
719
|
-
const
|
|
716
|
+
function Ln(t) {
|
|
717
|
+
const e = [], o = t[Le];
|
|
718
|
+
o === void 0 ? e.push(`包里缺入口:必须有 ${Le}(${at(t)})`) : o.trim() || e.push(`${Le} 不能是空文件`);
|
|
719
|
+
const a = t[De];
|
|
720
720
|
let l = {};
|
|
721
|
-
if (
|
|
722
|
-
e.push(`包里缺清单:必须有 ${
|
|
723
|
-
else if (!
|
|
724
|
-
e.push(`${
|
|
721
|
+
if (a === void 0)
|
|
722
|
+
e.push(`包里缺清单:必须有 ${De}(${at(t)})`);
|
|
723
|
+
else if (!a.trim())
|
|
724
|
+
e.push(`${De} 不能是空文件`);
|
|
725
725
|
else {
|
|
726
|
-
const [r, u] =
|
|
726
|
+
const [r, u] = Nn(a);
|
|
727
727
|
l = r, e.push(...u);
|
|
728
728
|
}
|
|
729
729
|
for (const r of Object.keys(t))
|
|
730
|
-
|
|
730
|
+
In(r) || e.push(`文件名不合法:${r}(只许字母数字与 . _ - /,且不许 .. 与绝对路径)`);
|
|
731
731
|
return { manifest: l, issues: e };
|
|
732
732
|
}
|
|
733
|
-
function
|
|
733
|
+
function Dn(t) {
|
|
734
734
|
const e = [];
|
|
735
735
|
if (t.length === 0)
|
|
736
736
|
return e.push("一个块都没勾:请在「读回改动」的结果里勾上要保存的块"), { selected: 0, issues: e };
|
|
737
|
-
for (const
|
|
738
|
-
const
|
|
739
|
-
for (const l of
|
|
737
|
+
for (const o of t) {
|
|
738
|
+
const a = o.name?.trim() || "(没有名字的块)";
|
|
739
|
+
for (const l of Ln(o.files ?? {}).issues) e.push(`${a}:${l}`);
|
|
740
740
|
}
|
|
741
741
|
return { selected: t.length, issues: e };
|
|
742
742
|
}
|
|
743
|
-
const
|
|
744
|
-
function
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
const
|
|
748
|
-
return /^[0-9]/.test(
|
|
743
|
+
const Fe = "pages.lock.ts";
|
|
744
|
+
function Fn(t, e) {
|
|
745
|
+
const o = String(t || "").split(/[^A-Za-z0-9]+/).filter(Boolean);
|
|
746
|
+
if (o.length === 0) return `Page${e + 1}`;
|
|
747
|
+
const a = o.map((l) => l[0].toUpperCase() + l.slice(1)).join("");
|
|
748
|
+
return /^[0-9]/.test(a) ? `P${a}` : a;
|
|
749
749
|
}
|
|
750
|
-
function
|
|
750
|
+
function zn(t, e) {
|
|
751
751
|
if (!e.has(t))
|
|
752
752
|
return e.add(t), t;
|
|
753
|
-
let
|
|
754
|
-
for (; e.has(`${t}${
|
|
755
|
-
const
|
|
756
|
-
return e.add(
|
|
753
|
+
let o = 2;
|
|
754
|
+
for (; e.has(`${t}${o}`); ) o += 1;
|
|
755
|
+
const a = `${t}${o}`;
|
|
756
|
+
return e.add(a), a;
|
|
757
757
|
}
|
|
758
|
-
function
|
|
759
|
-
const e = (t ?? []).filter((r) => r && typeof r.path == "string" && r.path.trim() !== ""),
|
|
758
|
+
function Hn(t) {
|
|
759
|
+
const e = (t ?? []).filter((r) => r && typeof r.path == "string" && r.path.trim() !== ""), o = /* @__PURE__ */ new Set(), a = [];
|
|
760
760
|
e.forEach((r, u) => {
|
|
761
761
|
const c = r.group?.trim() || "(没写 meta.group)";
|
|
762
|
-
let d =
|
|
763
|
-
d || (d = { title: c, rows: [] },
|
|
762
|
+
let d = a.find((f) => f.title === c);
|
|
763
|
+
d || (d = { title: c, rows: [] }, a.push(d)), d.rows.push({ key: zn(Fn(r.path, u), o), row: r });
|
|
764
764
|
});
|
|
765
765
|
const l = [
|
|
766
766
|
"/* 生成物:**每次导出都会重写**,别手改 —— 改了下次导出就没了。",
|
|
@@ -787,11 +787,11 @@ function jn(t) {
|
|
|
787
787
|
" */",
|
|
788
788
|
""
|
|
789
789
|
];
|
|
790
|
-
if (
|
|
790
|
+
if (a.length === 0)
|
|
791
791
|
l.push("/* ⚠️ 这次导出没拿到路由表(这个应用没装 vue-router,或者一条页面路由都没有)。 */", "export const Page = {} as const", "");
|
|
792
792
|
else {
|
|
793
793
|
l.push("export const Page = {");
|
|
794
|
-
for (const r of
|
|
794
|
+
for (const r of a) {
|
|
795
795
|
l.push(` // ── ${r.title} ──`);
|
|
796
796
|
for (const u of r.rows)
|
|
797
797
|
l.push(` /** ${u.row.title?.trim() || u.row.path}(${u.row.path}) */`), l.push(` ${u.key}: '${u.row.path}',`);
|
|
@@ -853,623 +853,690 @@ function jn(t) {
|
|
|
853
853
|
), l.join(`
|
|
854
854
|
`);
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function Et() {
|
|
857
857
|
return typeof window < "u" && typeof window.showDirectoryPicker == "function";
|
|
858
858
|
}
|
|
859
|
-
const
|
|
860
|
-
async function
|
|
861
|
-
if (!
|
|
859
|
+
const Kn = "这个浏览器没法直接写你本机的文件夹(少了 File System Access API):请用 Chrome / Edge,并且从 https 或 http://localhost 打开这个页面(内网 http 会更少 API)。";
|
|
860
|
+
async function ze() {
|
|
861
|
+
if (!Et()) throw new Error(Kn);
|
|
862
862
|
try {
|
|
863
863
|
const t = await window.showDirectoryPicker({ mode: "readwrite", id: "labull-magic-block" });
|
|
864
864
|
return { name: t.name, handle: t };
|
|
865
865
|
} catch (t) {
|
|
866
866
|
const e = t instanceof Error ? t.name : "";
|
|
867
|
-
throw e === "AbortError" ? new Error("取消选目录了:想导出就再点一次「选择文件夹」") : e === "SecurityError" ? new Error(`选不了这个目录:浏览器不让(${
|
|
867
|
+
throw e === "AbortError" ? new Error("取消选目录了:想导出就再点一次「选择文件夹」") : e === "SecurityError" ? new Error(`选不了这个目录:浏览器不让(${Oe(t)})—— 换一个目录,或确认页面是 https / localhost`) : new Error(`选目录失败:${Oe(t)}`);
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
function
|
|
870
|
+
function Oe(t) {
|
|
871
871
|
return (t instanceof Error ? t.message.trim() : String(t)) || "没有说原因";
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function qn(t) {
|
|
874
874
|
const e = String(t ?? "").split("/");
|
|
875
|
-
for (const
|
|
876
|
-
if (!
|
|
875
|
+
for (const o of e)
|
|
876
|
+
if (!o || o === "." || o === ".." || o.includes("\\") || /^[A-Za-z]:/.test(o))
|
|
877
877
|
throw new Error(`路径不合法:${t}(要相对路径,不许 .. / 盘符 / 反斜杠)`);
|
|
878
878
|
return e;
|
|
879
879
|
}
|
|
880
|
-
const
|
|
881
|
-
function
|
|
880
|
+
const Un = 8;
|
|
881
|
+
function Jn(t) {
|
|
882
882
|
const e = /* @__PURE__ */ new Map();
|
|
883
|
-
return (
|
|
884
|
-
const
|
|
883
|
+
return (o) => {
|
|
884
|
+
const a = o.join("\0"), l = e.get(a);
|
|
885
885
|
if (l) return l;
|
|
886
886
|
let r = Promise.resolve(t);
|
|
887
|
-
for (let u = 0; u <
|
|
888
|
-
const c =
|
|
889
|
-
r = f ?? r.then((
|
|
887
|
+
for (let u = 0; u < o.length; u += 1) {
|
|
888
|
+
const c = o[u], d = o.slice(0, u + 1).join("\0"), f = e.get(d);
|
|
889
|
+
r = f ?? r.then(($) => $.getDirectoryHandle(c, { create: !0 })), f || e.set(d, r);
|
|
890
890
|
}
|
|
891
891
|
return r;
|
|
892
892
|
};
|
|
893
893
|
}
|
|
894
|
-
async function
|
|
895
|
-
const
|
|
894
|
+
async function Vn(t, e, o) {
|
|
895
|
+
const a = Object.entries(e ?? {}).map(([$, y]) => ({ path: $, parts: qn($), body: String(y ?? "") })), l = a.length, r = [], u = Jn(t.handle);
|
|
896
896
|
let c = 0, d = 0;
|
|
897
|
-
|
|
897
|
+
o?.(0, l);
|
|
898
898
|
const f = async () => {
|
|
899
899
|
for (; ; ) {
|
|
900
|
-
const
|
|
900
|
+
const $ = c;
|
|
901
901
|
c += 1;
|
|
902
|
-
const y =
|
|
902
|
+
const y = a[$];
|
|
903
903
|
if (!y) return;
|
|
904
904
|
try {
|
|
905
|
-
const
|
|
905
|
+
const A = await (await (await u(y.parts.slice(0, -1))).getFileHandle(y.parts[y.parts.length - 1], { create: !0 })).createWritable();
|
|
906
906
|
try {
|
|
907
|
-
await
|
|
907
|
+
await A.write(y.body);
|
|
908
908
|
} finally {
|
|
909
|
-
await
|
|
909
|
+
await A.close();
|
|
910
910
|
}
|
|
911
911
|
d += 1;
|
|
912
912
|
} catch (_) {
|
|
913
|
-
r.push({ path: y.path, message:
|
|
913
|
+
r.push({ path: y.path, message: Oe(_) });
|
|
914
914
|
}
|
|
915
|
-
|
|
915
|
+
o?.(d + r.length, l);
|
|
916
916
|
}
|
|
917
917
|
};
|
|
918
|
-
return await Promise.all(Array.from({ length: Math.max(1, Math.min(
|
|
918
|
+
return await Promise.all(Array.from({ length: Math.max(1, Math.min(Un, l)) }, () => f())), r.sort(($, y) => $.path < y.path ? -1 : $.path > y.path ? 1 : 0), { written: d, failed: r, total: l };
|
|
919
919
|
}
|
|
920
|
-
async function
|
|
921
|
-
const
|
|
922
|
-
for (const u of await
|
|
920
|
+
async function Gn(t, e) {
|
|
921
|
+
const o = { items: [], topCount: 0, files: 0, dirs: 0 }, a = async (l, r) => {
|
|
922
|
+
for (const u of await we(l)) {
|
|
923
923
|
if (u.kind === "file") {
|
|
924
|
-
|
|
924
|
+
o.files += 1;
|
|
925
925
|
continue;
|
|
926
926
|
}
|
|
927
|
-
|
|
927
|
+
o.dirs += 1, !(r >= e.maxDepth) && (e.skipDirs.includes(u.name) || await a(u, r + 1));
|
|
928
928
|
}
|
|
929
929
|
};
|
|
930
|
-
for (const l of await
|
|
931
|
-
if (
|
|
930
|
+
for (const l of await we(t.handle))
|
|
931
|
+
if (o.items.push({ name: l.name, dir: l.kind === "directory" }), l.kind === "file") o.files += 1;
|
|
932
932
|
else {
|
|
933
|
-
if (
|
|
934
|
-
await
|
|
933
|
+
if (o.dirs += 1, e.skipDirs.includes(l.name) || e.maxDepth <= 0) continue;
|
|
934
|
+
await a(l, 1);
|
|
935
935
|
}
|
|
936
|
-
return
|
|
936
|
+
return o.topCount = o.items.length, o;
|
|
937
937
|
}
|
|
938
|
-
async function
|
|
938
|
+
async function Yn(t) {
|
|
939
939
|
const e = [];
|
|
940
|
-
for (const
|
|
941
|
-
let
|
|
942
|
-
for (const
|
|
943
|
-
await t.handle.removeEntry(
|
|
944
|
-
return
|
|
940
|
+
for (const a of await we(t.handle)) e.push(a.name);
|
|
941
|
+
let o = 0;
|
|
942
|
+
for (const a of e)
|
|
943
|
+
await t.handle.removeEntry(a, { recursive: !0 }), o += 1;
|
|
944
|
+
return o;
|
|
945
945
|
}
|
|
946
|
-
function
|
|
946
|
+
function Wn(t, e) {
|
|
947
947
|
if (t.name === e.blocksDir)
|
|
948
948
|
throw new Error(
|
|
949
949
|
`你选中的是「${e.blocksDir}」这一层(它就是放代码的那一层):导出会铺成 ${e.blocksDir}/${e.blocksDir}/…。请选它**上面**那一层 —— 也就是开发目录本身。`
|
|
950
950
|
);
|
|
951
951
|
}
|
|
952
|
-
async function
|
|
952
|
+
async function we(t) {
|
|
953
953
|
const e = [];
|
|
954
|
-
for await (const
|
|
955
|
-
return e.sort((
|
|
954
|
+
for await (const o of t.values()) e.push(o);
|
|
955
|
+
return e.sort((o, a) => o.name < a.name ? -1 : o.name > a.name ? 1 : 0), e;
|
|
956
956
|
}
|
|
957
|
-
function
|
|
957
|
+
function Zn(t) {
|
|
958
958
|
return t.charCodeAt(0) === 65279 ? t.slice(1) : t;
|
|
959
959
|
}
|
|
960
|
-
function
|
|
960
|
+
function Xn(t) {
|
|
961
961
|
const e = t.lastIndexOf(".");
|
|
962
962
|
return e <= 0 ? "" : t.slice(e).toLowerCase();
|
|
963
963
|
}
|
|
964
|
-
async function
|
|
964
|
+
async function St(t, e, o, a) {
|
|
965
965
|
const l = {};
|
|
966
|
-
for (const r of await
|
|
966
|
+
for (const r of await we(t)) {
|
|
967
967
|
const u = e ? `${e}/${r.name}` : r.name;
|
|
968
968
|
if (r.kind === "directory") {
|
|
969
|
-
if (
|
|
969
|
+
if (o.skipDirs.includes(r.name)) continue;
|
|
970
970
|
const c = r;
|
|
971
|
-
for (const [d, f] of Object.entries(await
|
|
971
|
+
for (const [d, f] of Object.entries(await St(c, u, o, a)))
|
|
972
972
|
l[`${r.name}/${d}`] = f;
|
|
973
973
|
continue;
|
|
974
974
|
}
|
|
975
|
-
if (!
|
|
976
|
-
if (!
|
|
977
|
-
|
|
975
|
+
if (!o.platformFiles.includes(r.name)) {
|
|
976
|
+
if (!o.textExt.includes(Xn(r.name))) {
|
|
977
|
+
a.failures.push({
|
|
978
978
|
kind: "file",
|
|
979
979
|
where: u,
|
|
980
|
-
message: `不是文本文件(认得的扩展名:${
|
|
980
|
+
message: `不是文本文件(认得的扩展名:${o.textExt.join(" ")}),已跳过`
|
|
981
981
|
});
|
|
982
982
|
continue;
|
|
983
983
|
}
|
|
984
984
|
try {
|
|
985
985
|
const c = await r.getFile();
|
|
986
|
-
if (c.size >
|
|
987
|
-
|
|
986
|
+
if (c.size > o.maxFileBytes) {
|
|
987
|
+
a.failures.push({
|
|
988
988
|
kind: "file",
|
|
989
989
|
where: u,
|
|
990
|
-
message: `文件 ${Math.round(c.size / 1024)} KB 超过上限 ${Math.floor(
|
|
990
|
+
message: `文件 ${Math.round(c.size / 1024)} KB 超过上限 ${Math.floor(o.maxFileBytes / 1024)} KB,已跳过`
|
|
991
991
|
});
|
|
992
992
|
continue;
|
|
993
993
|
}
|
|
994
|
-
l[r.name] =
|
|
994
|
+
l[r.name] = Zn(await c.text());
|
|
995
995
|
} catch (c) {
|
|
996
|
-
|
|
996
|
+
a.failures.push({ kind: "file", where: u, message: `读不了这个文件:${Oe(c)}` });
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
return l;
|
|
1001
1001
|
}
|
|
1002
|
-
async function
|
|
1003
|
-
const r = await
|
|
1004
|
-
if (u.length === 0 || c.some((d) => d.name ===
|
|
1005
|
-
l.folders.push({ where: e.join("/"), files: await
|
|
1002
|
+
async function Tt(t, e, o, a, l) {
|
|
1003
|
+
const r = await we(t), u = r.filter((d) => d.kind === "directory"), c = r.filter((d) => d.kind === "file");
|
|
1004
|
+
if (u.length === 0 || c.some((d) => d.name === a.entry)) {
|
|
1005
|
+
l.folders.push({ where: e.join("/"), files: await St(t, e.join("/"), a, l) });
|
|
1006
1006
|
return;
|
|
1007
1007
|
}
|
|
1008
1008
|
for (const d of c)
|
|
1009
|
-
e.length === 0 &&
|
|
1009
|
+
e.length === 0 && a.rootSkipFiles.includes(d.name.toLowerCase()) || l.failures.push({
|
|
1010
1010
|
kind: "file",
|
|
1011
1011
|
where: [...e, d.name].join("/"),
|
|
1012
|
-
message: `这一层直接放着一份文件,但它自己不是块文件夹、也没有 ${
|
|
1012
|
+
message: `这一层直接放着一份文件,但它自己不是块文件夹、也没有 ${a.entry},文件没有归属`
|
|
1013
1013
|
});
|
|
1014
1014
|
for (const d of u)
|
|
1015
|
-
if (!
|
|
1016
|
-
if (
|
|
1015
|
+
if (!a.skipDirs.includes(d.name)) {
|
|
1016
|
+
if (o >= a.maxDepth) {
|
|
1017
1017
|
l.truncated = !0, l.failures.push({
|
|
1018
1018
|
kind: "dir",
|
|
1019
1019
|
where: [...e, d.name].join("/"),
|
|
1020
|
-
message: `超过最大层数 ${
|
|
1020
|
+
message: `超过最大层数 ${a.maxDepth} 层还没见到 ${a.entry},没有继续往下找`
|
|
1021
1021
|
});
|
|
1022
1022
|
continue;
|
|
1023
1023
|
}
|
|
1024
|
-
await
|
|
1024
|
+
await Tt(d, [...e, d.name], o + 1, a, l);
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1027
|
+
function it(t) {
|
|
1028
1028
|
return t >= 1024 * 1024 ? `${(t / 1024 / 1024).toFixed(1)} MB` : `${Math.max(1, Math.round(t / 1024))} KB`;
|
|
1029
1029
|
}
|
|
1030
|
-
async function
|
|
1031
|
-
const
|
|
1032
|
-
await
|
|
1033
|
-
const
|
|
1030
|
+
async function Qn(t, e) {
|
|
1031
|
+
const o = { root: t.name, folders: [], failures: [], truncated: !1 };
|
|
1032
|
+
await Tt(t.handle, [], 0, e, o);
|
|
1033
|
+
const a = o.folders.reduce(
|
|
1034
1034
|
(l, r) => l + Object.values(r.files).reduce((u, c) => u + c.length, 0),
|
|
1035
1035
|
0
|
|
1036
1036
|
);
|
|
1037
|
-
if (
|
|
1037
|
+
if (a > e.maxBodyBytes)
|
|
1038
1038
|
throw new Error(
|
|
1039
|
-
`这个目录读到的正文有 ${
|
|
1039
|
+
`这个目录读到的正文有 ${it(a)},超过一次读回的上限 ${it(e.maxBodyBytes)}:请先只留要改的那几个块,或者把大文件挪走。`
|
|
1040
1040
|
);
|
|
1041
|
-
return
|
|
1041
|
+
return o;
|
|
1042
1042
|
}
|
|
1043
|
-
const
|
|
1043
|
+
const eo = {
|
|
1044
1044
|
key: 0,
|
|
1045
1045
|
class: "mbc"
|
|
1046
|
-
},
|
|
1046
|
+
}, to = { class: "mbc__head" }, no = ["disabled"], oo = {
|
|
1047
1047
|
key: 0,
|
|
1048
1048
|
class: "mbc__error"
|
|
1049
|
-
},
|
|
1049
|
+
}, so = {
|
|
1050
1050
|
key: 1,
|
|
1051
1051
|
class: "mbc__notice"
|
|
1052
|
-
},
|
|
1052
|
+
}, ao = { class: "mbc__panel" }, io = { class: "mbc__title" }, lo = { class: "mbc__list" }, ro = ["title", "onClick"], co = { class: "mbc__module" }, uo = { class: "mbc__name" }, po = {
|
|
1053
1053
|
key: 0,
|
|
1054
1054
|
class: "mbc__where"
|
|
1055
|
-
},
|
|
1055
|
+
}, fo = {
|
|
1056
1056
|
key: 0,
|
|
1057
1057
|
class: "mbc__detail"
|
|
1058
|
-
},
|
|
1058
|
+
}, mo = {
|
|
1059
1059
|
key: 0,
|
|
1060
1060
|
class: "mbc__hint"
|
|
1061
|
-
},
|
|
1061
|
+
}, bo = { class: "mbc__meta" }, ho = { class: "mbc__mono" }, go = { class: "mbc__actions" }, vo = ["disabled", "onClick"], yo = ["disabled", "onClick"], _o = ["disabled", "onClick"], ko = { class: "mbc__panel" }, wo = { class: "mbc__field" }, $o = { class: "mbc__radio" }, xo = ["checked"], Eo = { class: "mbc__radio" }, So = ["checked"], To = ["value", "disabled"], Co = {
|
|
1062
|
+
key: 0,
|
|
1063
|
+
value: ""
|
|
1064
|
+
}, Bo = ["value"], Mo = { class: "mbc__field" }, Oo = ["value"], Ao = ["disabled"], Po = ["disabled", "title"], Ro = { class: "mbc__hint" }, jo = {
|
|
1062
1065
|
key: 0,
|
|
1063
1066
|
class: "mbc__hint"
|
|
1064
|
-
},
|
|
1067
|
+
}, No = ["aria-valuenow"], Io = {
|
|
1065
1068
|
key: 3,
|
|
1066
1069
|
class: "mbc__confirm"
|
|
1067
|
-
},
|
|
1070
|
+
}, Lo = { class: "mbc__confirm-title" }, Do = { class: "mbc__confirm-body" }, Fo = {
|
|
1068
1071
|
key: 0,
|
|
1069
1072
|
class: "mbc__mono"
|
|
1070
|
-
},
|
|
1073
|
+
}, zo = { class: "mbc__actions" }, Ho = ["disabled"], Ko = ["disabled"], qo = ["disabled"], Uo = { class: "mbc__panel" }, Jo = { class: "mbc__field" }, Vo = ["value"], Go = ["disabled"], Yo = ["disabled"], Wo = {
|
|
1071
1074
|
key: 0,
|
|
1072
1075
|
class: "mbc__hint"
|
|
1073
|
-
},
|
|
1076
|
+
}, Zo = {
|
|
1074
1077
|
key: 1,
|
|
1075
1078
|
class: "mbc__hint"
|
|
1076
|
-
},
|
|
1079
|
+
}, Xo = {
|
|
1077
1080
|
key: 0,
|
|
1078
1081
|
class: "mbc__scan"
|
|
1079
|
-
},
|
|
1082
|
+
}, Qo = { class: "mbc__pick" }, es = ["disabled", "checked", "onChange"], ts = { class: "mbc__name" }, ns = { class: "mbc__module" }, os = { class: "mbc__hint" }, ss = { class: "mbc__mono" }, as = {
|
|
1080
1083
|
key: 0,
|
|
1081
1084
|
class: "mbc__problem"
|
|
1082
|
-
},
|
|
1085
|
+
}, is = { class: "mbc__hint mbc__mono" }, ls = {
|
|
1083
1086
|
key: 1,
|
|
1084
1087
|
class: "mbc__hint"
|
|
1085
|
-
},
|
|
1088
|
+
}, rs = {
|
|
1086
1089
|
key: 2,
|
|
1087
1090
|
class: "mbc__problem"
|
|
1088
|
-
},
|
|
1091
|
+
}, cs = {
|
|
1089
1092
|
key: 3,
|
|
1090
1093
|
class: "mbc__failures"
|
|
1091
|
-
},
|
|
1094
|
+
}, us = { class: "mbc__field mbc__field--end" }, ds = ["disabled"], ps = {
|
|
1092
1095
|
key: 2,
|
|
1093
1096
|
class: "mbc__panel"
|
|
1094
|
-
},
|
|
1097
|
+
}, fs = { class: "mbc__title" }, ms = {
|
|
1095
1098
|
key: 0,
|
|
1096
1099
|
class: "mbc__failures"
|
|
1097
|
-
},
|
|
1100
|
+
}, bs = {
|
|
1098
1101
|
key: 1,
|
|
1099
1102
|
class: "mbc__failures"
|
|
1100
|
-
},
|
|
1103
|
+
}, hs = { key: 0 }, gs = {
|
|
1101
1104
|
key: 1,
|
|
1102
1105
|
class: "mbc__failures mbc__failures--nested"
|
|
1103
|
-
},
|
|
1106
|
+
}, He = 2, vs = /* @__PURE__ */ We({
|
|
1104
1107
|
__name: "MagicBlockConsole",
|
|
1105
1108
|
setup(t) {
|
|
1106
|
-
const e = { modified: "有改动", unchanged: "没改动", missing: "目录里没有" }, { isStaff:
|
|
1109
|
+
const e = { modified: "有改动", unchanged: "没改动", missing: "目录里没有" }, { isStaff: o } = dt(), a = ut(), { active: l } = Kt(), r = (i) => !pt(i, a), u = w(!1), c = w(""), d = w([]), f = w(""), $ = w(""), y = w(""), _ = w(!1), I = w(!1), A = w(!1), ee = w(!1), ne = w(!1), P = w(null), S = w(null), D = w("one"), oe = w(Ae()), K = O(() => d.value.find((i) => i.id === oe.value) ?? null), ue = () => D.value === "all" ? {} : { blocks: [oe.value] };
|
|
1110
|
+
function $e(i) {
|
|
1111
|
+
oe.value = i;
|
|
1112
|
+
try {
|
|
1113
|
+
window.localStorage.setItem("mb:export-block", i);
|
|
1114
|
+
} catch {
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function Ae() {
|
|
1118
|
+
try {
|
|
1119
|
+
return window.localStorage.getItem("mb:export-block") ?? "";
|
|
1120
|
+
} catch {
|
|
1121
|
+
return "";
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
me(d, (i) => {
|
|
1125
|
+
i.length !== 0 && (i.some((n) => n.id === oe.value) || $e(i[0].id));
|
|
1126
|
+
});
|
|
1127
|
+
const G = w(null), Y = w(""), B = w(null), de = w({}), W = w([]), se = w([]), j = w(null), T = w({ active: !1, percent: 0, stage: "", failed: !1 }), he = O(() => ({
|
|
1107
1128
|
width: `${Math.max(0, Math.min(100, T.value.percent))}%`,
|
|
1108
1129
|
background: T.value.failed ? "var(--sp-color-danger)" : "var(--sp-color-primary, var(--primary-color))"
|
|
1109
1130
|
}));
|
|
1110
|
-
function
|
|
1111
|
-
T.value = { active: !0, percent: Math.max(T.value.percent, i), stage:
|
|
1131
|
+
function H(i, n) {
|
|
1132
|
+
T.value = { active: !0, percent: Math.max(T.value.percent, i), stage: n, failed: !1 };
|
|
1112
1133
|
try {
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1134
|
+
const s = window.localStorage.getItem("mb:progress") ?? "[]", b = JSON.parse(s);
|
|
1135
|
+
b.push({ p: T.value.percent, s: n, t: Math.round(performance.now()) }), window.localStorage.setItem("mb:progress", JSON.stringify(b));
|
|
1115
1136
|
} catch {
|
|
1116
1137
|
}
|
|
1117
1138
|
}
|
|
1118
|
-
function
|
|
1119
|
-
|
|
1139
|
+
function te(i, n) {
|
|
1140
|
+
H(i ? 100 : T.value.percent, n), T.value = { active: !i, percent: i ? 100 : T.value.percent, stage: n, failed: !i };
|
|
1120
1141
|
}
|
|
1121
|
-
const
|
|
1122
|
-
function
|
|
1142
|
+
const ge = (i) => (i.disabledReason ?? "").trim(), F = (i) => (i.issues ?? []).map((n) => String(n?.message ?? "")).filter(Boolean), q = (i) => pn(i.id);
|
|
1143
|
+
function xe(i) {
|
|
1123
1144
|
f.value = f.value === i.id ? "" : i.id;
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1126
|
-
const
|
|
1127
|
-
if (
|
|
1128
|
-
y.value = `「${
|
|
1145
|
+
const n = l.value;
|
|
1146
|
+
xt(i.id);
|
|
1147
|
+
const s = i.name || i.id, b = q(i);
|
|
1148
|
+
if (b.length === 0) {
|
|
1149
|
+
y.value = `「${s}」这次会话里还没在哪条标签上露过面:先打开挂着它的那一页,再点一次`;
|
|
1129
1150
|
return;
|
|
1130
1151
|
}
|
|
1131
|
-
if (
|
|
1132
|
-
y.value = `「${
|
|
1152
|
+
if (b.includes(n)) {
|
|
1153
|
+
y.value = `「${s}」就在这一条标签上(${b.join(" / ")}):已经把它标红`;
|
|
1133
1154
|
return;
|
|
1134
1155
|
}
|
|
1135
|
-
const x =
|
|
1156
|
+
const x = fn(i.id, n, r);
|
|
1136
1157
|
if (x) {
|
|
1137
|
-
y.value = `「${
|
|
1158
|
+
y.value = `「${s}」不在这一条标签上:正在切到 ${x} 那条标签`, qe(x);
|
|
1138
1159
|
return;
|
|
1139
1160
|
}
|
|
1140
|
-
y.value = `「${
|
|
1161
|
+
y.value = `「${s}」只挂在带参数的实例标签上(${b.join(" / ")}):不替你挑一单 —— 自己打开要看的那一页再点`;
|
|
1141
1162
|
}
|
|
1142
|
-
function
|
|
1143
|
-
const
|
|
1144
|
-
return
|
|
1145
|
-
${
|
|
1163
|
+
function Pe(i) {
|
|
1164
|
+
const n = q(i), s = n.length === 0 ? "点一下:这次会话里它还没在哪条标签上露过面" : `点一下:把「${i.name || i.id}」标红,并在需要时切到挂着它的标签(${n.join(" / ")})`, b = ge(i);
|
|
1165
|
+
return b ? `${b}
|
|
1166
|
+
${s}` : s;
|
|
1146
1167
|
}
|
|
1147
|
-
const
|
|
1168
|
+
const ve = O(() => {
|
|
1148
1169
|
const i = c.value.trim().toLowerCase();
|
|
1149
|
-
return i ? d.value.filter((
|
|
1150
|
-
}),
|
|
1151
|
-
function
|
|
1152
|
-
const i =
|
|
1153
|
-
for (const
|
|
1154
|
-
const x = typeof
|
|
1155
|
-
if (!x ||
|
|
1156
|
-
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1170
|
+
return i ? d.value.filter((n) => `${n.module} ${n.name} ${n.brief}`.toLowerCase().includes(i)) : d.value;
|
|
1171
|
+
}), pe = O(() => (B.value?.blocks ?? []).filter((i) => i.canApply)), v = O(() => pe.value.filter((i) => de.value[i.id] === !0));
|
|
1172
|
+
function k() {
|
|
1173
|
+
const i = a?.getRoutes?.() ?? [], n = /* @__PURE__ */ new Set(), s = [];
|
|
1174
|
+
for (const b of i) {
|
|
1175
|
+
const x = typeof b?.path == "string" ? b.path.trim() : "";
|
|
1176
|
+
if (!x || n.has(x) || x.includes(":") || x.includes("*") || b.redirect || !b.components?.default || b.meta?.tab === !1) continue;
|
|
1177
|
+
n.add(x);
|
|
1178
|
+
const z = b.meta?.title ?? b.meta?.sub, M = b.meta?.group;
|
|
1179
|
+
s.push({
|
|
1159
1180
|
path: x,
|
|
1160
|
-
title: typeof
|
|
1161
|
-
group: typeof
|
|
1181
|
+
title: typeof z == "string" && z.trim() ? z.trim() : x,
|
|
1182
|
+
group: typeof M == "string" ? M.trim() : ""
|
|
1162
1183
|
});
|
|
1163
1184
|
}
|
|
1164
|
-
return
|
|
1185
|
+
return s;
|
|
1165
1186
|
}
|
|
1166
|
-
function
|
|
1187
|
+
function C(i) {
|
|
1167
1188
|
return (i instanceof Error ? i.message.trim() : String(i)) || "请求没有到达后端(网络或登录态的问题),请重试";
|
|
1168
1189
|
}
|
|
1169
|
-
function
|
|
1170
|
-
const
|
|
1171
|
-
return Array.isArray(
|
|
1190
|
+
function U(i) {
|
|
1191
|
+
const n = i?.issues;
|
|
1192
|
+
return Array.isArray(n) ? n.map((s) => typeof s == "string" ? s : String(s?.message ?? "")).filter(Boolean) : [];
|
|
1172
1193
|
}
|
|
1173
|
-
async function ae(i,
|
|
1174
|
-
const
|
|
1194
|
+
async function ae(i, n) {
|
|
1195
|
+
const s = JSON.stringify(n);
|
|
1175
1196
|
try {
|
|
1176
|
-
return await
|
|
1177
|
-
} catch (
|
|
1178
|
-
const x =
|
|
1197
|
+
return await Q(i, { method: "POST", body: s });
|
|
1198
|
+
} catch (b) {
|
|
1199
|
+
const x = C(b), z = await fetch(`http://localhost:3000${i}`, {
|
|
1179
1200
|
method: "POST",
|
|
1180
1201
|
credentials: "include",
|
|
1181
|
-
headers: { "Content-Type": "application/json", ...
|
|
1182
|
-
body:
|
|
1183
|
-
}).then((
|
|
1184
|
-
throw
|
|
1185
|
-
- ${
|
|
1202
|
+
headers: { "Content-Type": "application/json", ...Ke("POST", !0) },
|
|
1203
|
+
body: s
|
|
1204
|
+
}).then((fe) => fe.json()).catch(() => null), M = U(z);
|
|
1205
|
+
throw M.length === 0 ? new Error(x) : new Error(`${String(z?.message ?? x)}
|
|
1206
|
+
- ${M.join(`
|
|
1186
1207
|
- `)}`);
|
|
1187
1208
|
}
|
|
1188
1209
|
}
|
|
1189
|
-
async function
|
|
1210
|
+
async function ie() {
|
|
1190
1211
|
try {
|
|
1191
|
-
const i = await
|
|
1212
|
+
const i = await Q("/magic-blocks/index");
|
|
1192
1213
|
d.value = i.blocks ?? [];
|
|
1193
1214
|
} catch (i) {
|
|
1194
|
-
|
|
1215
|
+
$.value = C(i);
|
|
1195
1216
|
}
|
|
1196
1217
|
}
|
|
1197
|
-
async function
|
|
1198
|
-
|
|
1218
|
+
async function L(i, n) {
|
|
1219
|
+
n.value = !0, $.value = "";
|
|
1199
1220
|
try {
|
|
1200
|
-
await i(),
|
|
1201
|
-
} catch (
|
|
1202
|
-
|
|
1221
|
+
await i(), sn();
|
|
1222
|
+
} catch (s) {
|
|
1223
|
+
$.value = C(s);
|
|
1203
1224
|
} finally {
|
|
1204
|
-
|
|
1225
|
+
n.value = !1;
|
|
1205
1226
|
}
|
|
1206
1227
|
}
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1228
|
+
const Ee = (i) => L(async () => {
|
|
1229
|
+
I.value = !0;
|
|
1209
1230
|
try {
|
|
1210
|
-
await
|
|
1231
|
+
await Q("/magic-blocks/check", { method: "POST", body: JSON.stringify(i ? { blocks: [i] } : {}) }), y.value = i ? "这一块重新体检完了" : "全部块重新体检完了", await ie();
|
|
1211
1232
|
} finally {
|
|
1212
|
-
|
|
1233
|
+
I.value = !1;
|
|
1213
1234
|
}
|
|
1214
|
-
}, _),
|
|
1215
|
-
const
|
|
1216
|
-
i === "export" ? (
|
|
1235
|
+
}, _), Se = (i) => L(async () => {
|
|
1236
|
+
const n = await ze();
|
|
1237
|
+
i === "export" ? (P.value = n, S.value || (S.value = n)) : (S.value = n, P.value || (P.value = n)), y.value = i === "export" ? `导出目录:${n.name}${S.value === n ? "(读回目录也填成它了)" : ""}` : `读回目录:${n.name}`;
|
|
1217
1238
|
}, _);
|
|
1218
|
-
async function
|
|
1239
|
+
async function Te() {
|
|
1219
1240
|
if (G.value) return G.value;
|
|
1220
|
-
const i = await
|
|
1241
|
+
const i = await Q("/magic-blocks/rules");
|
|
1221
1242
|
return G.value = i.rules, i.rules;
|
|
1222
1243
|
}
|
|
1223
|
-
const
|
|
1224
|
-
if (!
|
|
1225
|
-
|
|
1244
|
+
const Re = () => L(async () => {
|
|
1245
|
+
if (!Et()) throw new Error("这个浏览器没法直接写你本机的文件夹:请用 Chrome / Edge,并从 https 或 localhost 打开");
|
|
1246
|
+
if (D.value === "one" && !K.value)
|
|
1247
|
+
throw new Error("还没挑块:上面选「仅这一个块」时要先在下拉里挑一个块(或者把范围改成「全部块」)");
|
|
1248
|
+
A.value = !0, y.value = "", Y.value = "", $.value = "", T.value = { active: !0, percent: 0, stage: "准备…", failed: !1 };
|
|
1226
1249
|
try {
|
|
1227
|
-
const i =
|
|
1228
|
-
|
|
1229
|
-
const
|
|
1230
|
-
G.value =
|
|
1231
|
-
const
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1250
|
+
const i = P.value ?? await ze();
|
|
1251
|
+
P.value = i, S.value || (S.value = i);
|
|
1252
|
+
const n = await ae("/magic-blocks/export", ue());
|
|
1253
|
+
G.value = n.rules, Wn(i, n.rules);
|
|
1254
|
+
const s = await Gn(i, n.rules);
|
|
1255
|
+
if (s.topCount > 0) {
|
|
1256
|
+
H(5, "等你确认要不要先清空"), j.value = { target: i, inventory: s };
|
|
1234
1257
|
return;
|
|
1235
1258
|
}
|
|
1236
|
-
await
|
|
1259
|
+
await je(i, n, !1);
|
|
1237
1260
|
} catch (i) {
|
|
1238
|
-
throw
|
|
1261
|
+
throw te(!1, "导出失败"), i;
|
|
1239
1262
|
} finally {
|
|
1240
|
-
|
|
1263
|
+
A.value = !1;
|
|
1241
1264
|
}
|
|
1242
1265
|
}, _);
|
|
1243
|
-
async function
|
|
1266
|
+
async function je(i, n, s) {
|
|
1244
1267
|
try {
|
|
1245
|
-
|
|
1246
|
-
const
|
|
1268
|
+
H(20, "收主题与控件清单…");
|
|
1269
|
+
const b = { ...n.files };
|
|
1247
1270
|
let x = "";
|
|
1248
1271
|
await new Promise((R) => {
|
|
1249
1272
|
setTimeout(R, 0);
|
|
1250
1273
|
});
|
|
1274
|
+
const z = Hn(k());
|
|
1275
|
+
b[Fe] = z;
|
|
1251
1276
|
try {
|
|
1252
|
-
const R =
|
|
1253
|
-
|
|
1277
|
+
const R = $t(), ye = rn();
|
|
1278
|
+
b[re] = R.css, b[Me] = ye, n.exampleDir && (b[`${n.exampleDir}/${Fe}`] = z, b[`${n.exampleDir}/${re}`] = R.css, b[`${n.exampleDir}/${Me}`] = ye), x = R.skipped.length > 0 ? `;⚠️ 有 ${R.skipped.length} 张样式表读不到规则(跨源):${R.skipped.join(" / ")}` : "";
|
|
1254
1279
|
} catch (R) {
|
|
1255
|
-
x = `;主题 CSS 没收成(${
|
|
1280
|
+
x = `;主题 CSS 没收成(${C(R)}):${re} 没写,其余照旧`;
|
|
1256
1281
|
}
|
|
1257
|
-
let
|
|
1258
|
-
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1282
|
+
let M = "";
|
|
1283
|
+
s && (H(35, "清空目录…"), M = `,先清掉了 ${await Yn(i)} 项`);
|
|
1284
|
+
const fe = Object.keys(b).length, Ne = s ? 45 : 30;
|
|
1285
|
+
H(Ne, `写文件 0/${fe}…`);
|
|
1286
|
+
const le = await Vn(i, b, (R, ye) => {
|
|
1287
|
+
H(Ne + Math.round(R / Math.max(1, ye) * (95 - Ne)), `写文件 ${R}/${ye}…`);
|
|
1263
1288
|
});
|
|
1264
|
-
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
} catch (
|
|
1268
|
-
throw
|
|
1289
|
+
H(98, "收尾…");
|
|
1290
|
+
const jt = le.failed.length > 0 ? `;⚠️ ${le.failed.length} 个文件没写成:${le.failed.slice(0, 3).map((R) => `${R.path}(${R.message})`).join("、")}` + (le.failed.length > 3 ? ` 等 ${le.failed.length} 条` : "") : "";
|
|
1291
|
+
Y.value = `铺到「${i.name}」:${n.blocks} 个块、${le.written} 个文件(含 ${Fe} / ${re} / ${Me})${M}${jt}${x}`, y.value = le.failed.length > 0 ? "导出完了,但有文件没写成(见下面那句)" : "导出完了:用你自己的编辑器改,改完回这里「读回改动」", te(!0, "完成");
|
|
1292
|
+
} catch (b) {
|
|
1293
|
+
throw te(!1, "导出中途失败(已经铺进去的文件不会自己删掉)"), b;
|
|
1269
1294
|
}
|
|
1270
1295
|
}
|
|
1271
|
-
const
|
|
1272
|
-
const i =
|
|
1273
|
-
if (
|
|
1274
|
-
|
|
1296
|
+
const Ct = () => L(async () => {
|
|
1297
|
+
const i = j.value;
|
|
1298
|
+
if (j.value = null, !!i) {
|
|
1299
|
+
A.value = !0;
|
|
1275
1300
|
try {
|
|
1276
|
-
|
|
1277
|
-
const
|
|
1278
|
-
G.value =
|
|
1279
|
-
} catch (
|
|
1280
|
-
throw
|
|
1301
|
+
H(15, "重新取一份开发包…");
|
|
1302
|
+
const n = await ae("/magic-blocks/export", ue());
|
|
1303
|
+
G.value = n.rules, await je(i.target, n, !0);
|
|
1304
|
+
} catch (n) {
|
|
1305
|
+
throw te(!1, "导出失败"), n;
|
|
1281
1306
|
} finally {
|
|
1282
|
-
|
|
1307
|
+
A.value = !1;
|
|
1283
1308
|
}
|
|
1284
1309
|
}
|
|
1285
|
-
}, _),
|
|
1286
|
-
const i =
|
|
1287
|
-
if (
|
|
1288
|
-
|
|
1310
|
+
}, _), Bt = () => L(async () => {
|
|
1311
|
+
const i = j.value;
|
|
1312
|
+
if (j.value = null, !!i) {
|
|
1313
|
+
A.value = !0;
|
|
1289
1314
|
try {
|
|
1290
|
-
|
|
1291
|
-
const
|
|
1292
|
-
G.value =
|
|
1293
|
-
} catch (
|
|
1294
|
-
throw
|
|
1315
|
+
H(15, "重新取一份开发包…");
|
|
1316
|
+
const n = await ae("/magic-blocks/export", ue());
|
|
1317
|
+
G.value = n.rules, await je(i.target, n, !1);
|
|
1318
|
+
} catch (n) {
|
|
1319
|
+
throw te(!1, "导出失败"), n;
|
|
1295
1320
|
} finally {
|
|
1296
|
-
|
|
1321
|
+
A.value = !1;
|
|
1297
1322
|
}
|
|
1298
1323
|
}
|
|
1299
1324
|
}, _);
|
|
1300
|
-
function
|
|
1301
|
-
|
|
1325
|
+
function Mt() {
|
|
1326
|
+
j.value = null, T.value = { active: !1, percent: 0, stage: "", failed: !1 }, y.value = "这次没有导出(目录里的东西一个字节都没动)", Y.value = "";
|
|
1302
1327
|
}
|
|
1303
|
-
const
|
|
1304
|
-
const i = S.value ?? await
|
|
1305
|
-
S.value = i,
|
|
1328
|
+
const Xe = () => L(async () => {
|
|
1329
|
+
const i = S.value ?? await ze();
|
|
1330
|
+
S.value = i, P.value || (P.value = i), ee.value = !0, y.value = "", W.value = [], se.value = [];
|
|
1306
1331
|
try {
|
|
1307
|
-
const
|
|
1308
|
-
throw new Error(`取不到扫描规则(GET /magic-blocks/rules):${
|
|
1309
|
-
}),
|
|
1332
|
+
const n = await Te().catch((M) => {
|
|
1333
|
+
throw new Error(`取不到扫描规则(GET /magic-blocks/rules):${C(M)}`);
|
|
1334
|
+
}), s = await Qn(i, n), b = await Q("/magic-blocks/read", {
|
|
1310
1335
|
method: "POST",
|
|
1311
|
-
body: JSON.stringify({ ...
|
|
1336
|
+
body: JSON.stringify({ ...s, includeMissing: !1 })
|
|
1312
1337
|
});
|
|
1313
|
-
|
|
1338
|
+
B.value = b;
|
|
1314
1339
|
const x = {};
|
|
1315
|
-
for (const
|
|
1316
|
-
|
|
1317
|
-
const
|
|
1318
|
-
y.value = `扫到 ${
|
|
1340
|
+
for (const M of b.blocks ?? []) x[M.id] = M.status === "modified" && M.canApply;
|
|
1341
|
+
de.value = x;
|
|
1342
|
+
const z = (b.blocks ?? []).reduce((M, fe) => ({ ...M, [fe.status]: (M[fe.status] ?? 0) + 1 }), {});
|
|
1343
|
+
y.value = `扫到 ${b.folders} 个文件夹、${b.files} 个文件:有改动 ${z.modified ?? 0} / 没改动 ${z.unchanged ?? 0}` + (b.complete ? "" : "(层数到了上限,没走完,可能还有块没扫到)");
|
|
1319
1344
|
} finally {
|
|
1320
|
-
|
|
1345
|
+
ee.value = !1;
|
|
1321
1346
|
}
|
|
1322
|
-
}, _),
|
|
1323
|
-
const i =
|
|
1324
|
-
if (
|
|
1325
|
-
throw y.value = "", new Error(`前端校验没过(${
|
|
1326
|
-
- ${
|
|
1347
|
+
}, _), Ot = () => L(async () => {
|
|
1348
|
+
const i = v.value, n = Dn(i);
|
|
1349
|
+
if (W.value = n.issues, se.value = [], n.issues.length > 0)
|
|
1350
|
+
throw y.value = "", new Error(`前端校验没过(${n.issues.length} 条),没有发请求:
|
|
1351
|
+
- ${n.issues.join(`
|
|
1327
1352
|
- `)}`);
|
|
1328
|
-
|
|
1353
|
+
ne.value = !0, y.value = "";
|
|
1329
1354
|
try {
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1332
|
-
const
|
|
1333
|
-
await
|
|
1355
|
+
const s = await ae("/magic-blocks/import", { updatedBy: "", blocks: i });
|
|
1356
|
+
se.value = s.results ?? [], y.value = `保存:成功 ${s.saved} 个、失败 ${s.failed} 个`, await ie();
|
|
1357
|
+
const b = y.value;
|
|
1358
|
+
await Xe(), y.value = `${b};已重新读回该目录`;
|
|
1334
1359
|
} finally {
|
|
1335
|
-
|
|
1360
|
+
ne.value = !1;
|
|
1336
1361
|
}
|
|
1337
|
-
}, _),
|
|
1338
|
-
await
|
|
1339
|
-
}, _),
|
|
1340
|
-
window.confirm(`删掉「${i.name || i.id}」?库里这一行(连同它的文件包)会一起没。`) && (await
|
|
1362
|
+
}, _), At = (i) => L(async () => {
|
|
1363
|
+
await Q(`/magic-blocks/${encodeURIComponent(i.id)}/rollback`, { method: "POST" }), y.value = `「${i.name || i.id}」已回滚到上一版`, await ie();
|
|
1364
|
+
}, _), Pt = (i) => L(async () => {
|
|
1365
|
+
window.confirm(`删掉「${i.name || i.id}」?库里这一行(连同它的文件包)会一起没。`) && (await Q(`/magic-blocks/${encodeURIComponent(i.id)}`, { method: "DELETE" }), y.value = `「${i.name || i.id}」已删除`, await ie());
|
|
1341
1366
|
}, _);
|
|
1342
|
-
function
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1367
|
+
function Rt(i, n) {
|
|
1368
|
+
const s = n.target;
|
|
1369
|
+
de.value[i] = s?.checked === !0;
|
|
1345
1370
|
}
|
|
1346
|
-
function
|
|
1347
|
-
const
|
|
1348
|
-
u.value = !0, f.value =
|
|
1371
|
+
function Qe(i) {
|
|
1372
|
+
const n = i.detail?.uuid ?? "";
|
|
1373
|
+
u.value = !0, f.value = n;
|
|
1349
1374
|
}
|
|
1350
|
-
return
|
|
1351
|
-
window.addEventListener("magic-block:open-console",
|
|
1375
|
+
return lt(() => {
|
|
1376
|
+
window.addEventListener("magic-block:open-console", Qe), ie(), Te().catch(() => {
|
|
1352
1377
|
});
|
|
1353
|
-
}),
|
|
1378
|
+
}), rt(() => window.removeEventListener("magic-block:open-console", Qe)), (i, n) => _e(o) ? (m(), h(N, { key: 0 }, [
|
|
1354
1379
|
p("button", {
|
|
1355
1380
|
class: "fab",
|
|
1356
1381
|
type: "button",
|
|
1357
1382
|
title: "magic block 控制台",
|
|
1358
|
-
onClick:
|
|
1383
|
+
onClick: n[0] || (n[0] = (s) => u.value = !0)
|
|
1359
1384
|
}, "块"),
|
|
1360
|
-
u.value ? (
|
|
1361
|
-
p("header",
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
"onUpdate:modelValue":
|
|
1385
|
+
u.value ? (m(), h("aside", eo, [
|
|
1386
|
+
p("header", to, [
|
|
1387
|
+
n[15] || (n[15] = p("strong", null, "magic block", -1)),
|
|
1388
|
+
Lt(p("input", {
|
|
1389
|
+
"onUpdate:modelValue": n[1] || (n[1] = (s) => c.value = s),
|
|
1365
1390
|
class: "p-inputtext p-component mbc__grow",
|
|
1366
1391
|
type: "search",
|
|
1367
1392
|
placeholder: "筛选 module / 名字"
|
|
1368
1393
|
}, null, 512), [
|
|
1369
|
-
[
|
|
1394
|
+
[Dt, c.value]
|
|
1370
1395
|
]),
|
|
1371
1396
|
p("button", {
|
|
1372
1397
|
class: "p-button p-button-sm",
|
|
1373
1398
|
type: "button",
|
|
1374
1399
|
disabled: _.value,
|
|
1375
|
-
onClick:
|
|
1376
|
-
},
|
|
1400
|
+
onClick: n[2] || (n[2] = (s) => Ee())
|
|
1401
|
+
}, g(I.value ? "体检中…" : "重新体检全部"), 9, no),
|
|
1377
1402
|
p("button", {
|
|
1378
1403
|
class: "p-button p-button-sm p-button-text",
|
|
1379
1404
|
type: "button",
|
|
1380
|
-
onClick:
|
|
1405
|
+
onClick: n[3] || (n[3] = (s) => u.value = !1)
|
|
1381
1406
|
}, "关闭")
|
|
1382
1407
|
]),
|
|
1383
|
-
|
|
1384
|
-
y.value ? (
|
|
1385
|
-
p("section",
|
|
1386
|
-
p("h3",
|
|
1387
|
-
p("ul",
|
|
1388
|
-
(
|
|
1389
|
-
key:
|
|
1408
|
+
$.value ? (m(), h("p", oo, g($.value), 1)) : E("", !0),
|
|
1409
|
+
y.value ? (m(), h("p", so, g(y.value), 1)) : E("", !0),
|
|
1410
|
+
p("section", ao, [
|
|
1411
|
+
p("h3", io, "库里的块(" + g(ve.value.length) + " / " + g(d.value.length) + ")", 1),
|
|
1412
|
+
p("ul", lo, [
|
|
1413
|
+
(m(!0), h(N, null, Z(ve.value, (s) => (m(), h("li", {
|
|
1414
|
+
key: s.id
|
|
1390
1415
|
}, [
|
|
1391
1416
|
p("button", {
|
|
1392
1417
|
type: "button",
|
|
1393
|
-
class:
|
|
1394
|
-
title:
|
|
1395
|
-
onClick: (
|
|
1418
|
+
class: X(["mbc__row", { "is-active": s.id === f.value }]),
|
|
1419
|
+
title: Pe(s),
|
|
1420
|
+
onClick: (b) => xe(s)
|
|
1396
1421
|
}, [
|
|
1397
|
-
p("span",
|
|
1398
|
-
p("span",
|
|
1399
|
-
|
|
1422
|
+
p("span", co, g(s.module || "unassigned"), 1),
|
|
1423
|
+
p("span", uo, g(s.name || s.id), 1),
|
|
1424
|
+
q(s).length > 0 ? (m(), h("span", po, g(q(s).join(" / ")), 1)) : E("", !0),
|
|
1400
1425
|
p("em", {
|
|
1401
|
-
class:
|
|
1402
|
-
},
|
|
1403
|
-
], 10,
|
|
1404
|
-
f.value ===
|
|
1405
|
-
(
|
|
1426
|
+
class: X({ "is-off": s.enabled === !1 })
|
|
1427
|
+
}, g(s.enabled === !1 ? ge(s) || "校验失败已停用" : "可用"), 3)
|
|
1428
|
+
], 10, ro),
|
|
1429
|
+
f.value === s.id ? (m(), h("div", fo, [
|
|
1430
|
+
(m(!0), h(N, null, Z(F(s).slice(0, He), (b, x) => (m(), h("p", {
|
|
1406
1431
|
key: x,
|
|
1407
1432
|
class: "mbc__problem"
|
|
1408
|
-
},
|
|
1409
|
-
|
|
1410
|
-
p("dl",
|
|
1411
|
-
|
|
1412
|
-
p("dd", null,
|
|
1413
|
-
|
|
1414
|
-
p("dd", null,
|
|
1415
|
-
|
|
1416
|
-
p("dd", null,
|
|
1417
|
-
|
|
1418
|
-
p("dd",
|
|
1433
|
+
}, g(b), 1))), 128)),
|
|
1434
|
+
F(s).length > He ? (m(), h("p", mo, "还有 " + g(F(s).length - He) + " 条体检问题,点「体检这一块」看最新结论", 1)) : E("", !0),
|
|
1435
|
+
p("dl", bo, [
|
|
1436
|
+
n[16] || (n[16] = p("dt", null, "文件", -1)),
|
|
1437
|
+
p("dd", null, g((s.fileNames || []).join(" / ") || "(没有文件)"), 1),
|
|
1438
|
+
n[17] || (n[17] = p("dt", null, "更新", -1)),
|
|
1439
|
+
p("dd", null, g(s.updatedAt || "—"), 1),
|
|
1440
|
+
n[18] || (n[18] = p("dt", null, "上一版", -1)),
|
|
1441
|
+
p("dd", null, g(s.hasPrev ? s.prevUpdatedAt || "有" : "没有"), 1),
|
|
1442
|
+
n[19] || (n[19] = p("dt", null, "id", -1)),
|
|
1443
|
+
p("dd", ho, g(s.id), 1)
|
|
1419
1444
|
]),
|
|
1420
|
-
p("div",
|
|
1445
|
+
p("div", go, [
|
|
1421
1446
|
p("button", {
|
|
1422
1447
|
class: "p-button p-button-sm p-button-outlined",
|
|
1423
1448
|
type: "button",
|
|
1424
1449
|
disabled: _.value,
|
|
1425
|
-
onClick: (
|
|
1426
|
-
}, "体检这一块", 8,
|
|
1450
|
+
onClick: (b) => Ee(s.id)
|
|
1451
|
+
}, "体检这一块", 8, vo),
|
|
1427
1452
|
p("button", {
|
|
1428
1453
|
class: "p-button p-button-sm p-button-outlined",
|
|
1429
1454
|
type: "button",
|
|
1430
|
-
disabled: _.value || !
|
|
1431
|
-
onClick: (
|
|
1432
|
-
}, "回滚上一版", 8,
|
|
1455
|
+
disabled: _.value || !s.hasPrev,
|
|
1456
|
+
onClick: (b) => At(s)
|
|
1457
|
+
}, "回滚上一版", 8, yo),
|
|
1433
1458
|
p("button", {
|
|
1434
1459
|
class: "p-button p-button-sm p-button-text",
|
|
1435
1460
|
type: "button",
|
|
1436
1461
|
disabled: _.value,
|
|
1437
|
-
onClick: (
|
|
1438
|
-
}, "删除", 8,
|
|
1462
|
+
onClick: (b) => Pt(s)
|
|
1463
|
+
}, "删除", 8, _o)
|
|
1439
1464
|
])
|
|
1440
1465
|
])) : E("", !0)
|
|
1441
1466
|
]))), 128))
|
|
1442
1467
|
])
|
|
1443
1468
|
]),
|
|
1444
|
-
p("section",
|
|
1445
|
-
|
|
1446
|
-
p("div",
|
|
1447
|
-
|
|
1469
|
+
p("section", ko, [
|
|
1470
|
+
n[30] || (n[30] = p("h3", { class: "mbc__title" }, "导出去改(用你自己的编辑器)", -1)),
|
|
1471
|
+
p("div", wo, [
|
|
1472
|
+
n[21] || (n[21] = p("span", { class: "mbc__label" }, "导出范围", -1)),
|
|
1473
|
+
p("label", $o, [
|
|
1474
|
+
p("input", {
|
|
1475
|
+
type: "radio",
|
|
1476
|
+
name: "mbc-scope",
|
|
1477
|
+
value: "one",
|
|
1478
|
+
checked: D.value === "one",
|
|
1479
|
+
onChange: n[4] || (n[4] = (s) => D.value = "one")
|
|
1480
|
+
}, null, 40, xo),
|
|
1481
|
+
n[20] || (n[20] = J(" 仅这一个块 ", -1))
|
|
1482
|
+
]),
|
|
1483
|
+
p("label", Eo, [
|
|
1484
|
+
p("input", {
|
|
1485
|
+
type: "radio",
|
|
1486
|
+
name: "mbc-scope",
|
|
1487
|
+
value: "all",
|
|
1488
|
+
checked: D.value === "all",
|
|
1489
|
+
onChange: n[5] || (n[5] = (s) => D.value = "all")
|
|
1490
|
+
}, null, 40, So),
|
|
1491
|
+
J(" 全部块(" + g(d.value.length) + " 个) ", 1)
|
|
1492
|
+
]),
|
|
1493
|
+
D.value === "one" ? (m(), h("select", {
|
|
1494
|
+
key: 0,
|
|
1495
|
+
class: "p-inputtext p-component mbc__grow",
|
|
1496
|
+
value: oe.value,
|
|
1497
|
+
disabled: _.value || d.value.length === 0,
|
|
1498
|
+
onChange: n[6] || (n[6] = (s) => $e(s.target.value))
|
|
1499
|
+
}, [
|
|
1500
|
+
d.value.length === 0 ? (m(), h("option", Co, "(库里还没有块)")) : E("", !0),
|
|
1501
|
+
(m(!0), h(N, null, Z(d.value, (s) => (m(), h("option", {
|
|
1502
|
+
key: s.id,
|
|
1503
|
+
value: s.id
|
|
1504
|
+
}, g(s.module) + " / " + g(s.name || s.id), 9, Bo))), 128))
|
|
1505
|
+
], 40, To)) : E("", !0)
|
|
1506
|
+
]),
|
|
1507
|
+
p("div", Mo, [
|
|
1508
|
+
n[22] || (n[22] = p("label", { for: "mbc-dir" }, "导出目录", -1)),
|
|
1448
1509
|
p("input", {
|
|
1449
1510
|
id: "mbc-dir",
|
|
1450
1511
|
class: "p-inputtext p-component mbc__grow mbc__mono",
|
|
1451
1512
|
type: "text",
|
|
1452
1513
|
readonly: "",
|
|
1453
|
-
value:
|
|
1454
|
-
}, null, 8,
|
|
1514
|
+
value: P.value ? P.value.name : "(还没选:点右边那个按钮选一个文件夹)"
|
|
1515
|
+
}, null, 8, Oo),
|
|
1455
1516
|
p("button", {
|
|
1456
1517
|
class: "p-button p-button-sm p-button-outlined",
|
|
1457
1518
|
type: "button",
|
|
1458
1519
|
disabled: _.value,
|
|
1459
|
-
onClick:
|
|
1460
|
-
}, "选择文件夹", 8,
|
|
1520
|
+
onClick: n[7] || (n[7] = (s) => Se("export"))
|
|
1521
|
+
}, "选择文件夹", 8, Ao),
|
|
1461
1522
|
p("button", {
|
|
1462
1523
|
class: "p-button p-button-sm",
|
|
1463
1524
|
type: "button",
|
|
1464
|
-
disabled: _.value,
|
|
1465
|
-
|
|
1466
|
-
|
|
1525
|
+
disabled: _.value || D.value === "one" && !K.value,
|
|
1526
|
+
title: D.value === "one" && !K.value ? "先在左边挑一个块(或者把范围改成「全部块」)" : "",
|
|
1527
|
+
onClick: n[8] || (n[8] = (s) => Re())
|
|
1528
|
+
}, g(A.value ? "导出中…" : "导出"), 9, Po)
|
|
1467
1529
|
]),
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1530
|
+
p("p", Ro, [
|
|
1531
|
+
J(g(D.value === "all" ? `这一趟会铺全部 ${d.value.length} 个块` : K.value ? `这一趟只铺「${K.value.module} / ${K.value.name || K.value.id}」这一个块` : "先挑一个块") + "; ", 1),
|
|
1532
|
+
n[23] || (n[23] = p("span", { class: "mbc__mono" }, "workspace/<可读名>-<块 uuid>/", -1)),
|
|
1533
|
+
n[24] || (n[24] = J(" 只在选中块的包里出现。 ", -1))
|
|
1534
|
+
]),
|
|
1535
|
+
n[31] || (n[31] = Ft('<p class="mbc__hint" data-v-2f882aa4> 代码会铺在 <span class="mbc__mono" data-v-2f882aa4>workspace/<可读名>-<块 uuid>/</span>, 顶层另附 <span class="mbc__mono" data-v-2f882aa4>GUIDE.lock.md</span>(怎么改)、<span class="mbc__mono" data-v-2f882aa4>pages.lock.ts</span>(Page 枚举)、 <span class="mbc__mono" data-v-2f882aa4>backend.lock.pyi</span>(能用的库 / ctx / 环境变量 / 模型)、 <span class="mbc__mono" data-v-2f882aa4>labull.css</span> 与 <span class="mbc__mono" data-v-2f882aa4>CONTROLS.lock.html</span>(主题与控件清单)—— 那几份都是**生成物**。 另外还有一份 <span class="mbc__mono" data-v-2f882aa4>example/</span>(身份证 OCR 的完整例子):它**与这个顶层同构**, 顶层那几份生成物在里面各有一份同名副本,改名 / 搬走之后参考清单还跟着走。 </p>', 1)),
|
|
1536
|
+
Y.value ? (m(), h("p", jo, g(Y.value), 1)) : E("", !0),
|
|
1537
|
+
T.value.active ? (m(), h("div", {
|
|
1471
1538
|
key: 1,
|
|
1472
|
-
class:
|
|
1539
|
+
class: X(["mbc__progress", { "is-failed": T.value.failed }]),
|
|
1473
1540
|
role: "progressbar",
|
|
1474
1541
|
"aria-valuenow": T.value.percent,
|
|
1475
1542
|
"aria-valuemin": "0",
|
|
@@ -1477,136 +1544,136 @@ ${a}` : a;
|
|
|
1477
1544
|
}, [
|
|
1478
1545
|
p("div", {
|
|
1479
1546
|
class: "mbc__progress-bar",
|
|
1480
|
-
style:
|
|
1547
|
+
style: ct(he.value)
|
|
1481
1548
|
}, null, 4)
|
|
1482
|
-
], 10,
|
|
1483
|
-
T.value.active ? (
|
|
1549
|
+
], 10, No)) : E("", !0),
|
|
1550
|
+
T.value.active ? (m(), h("p", {
|
|
1484
1551
|
key: 2,
|
|
1485
|
-
class:
|
|
1486
|
-
},
|
|
1487
|
-
|
|
1488
|
-
p("p",
|
|
1489
|
-
p("p",
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1552
|
+
class: X(["mbc__hint", { "mbc__progress-note": T.value.failed }])
|
|
1553
|
+
}, g(T.value.failed ? "✗" : "") + " " + g(T.value.percent) + "% · " + g(T.value.stage), 3)) : E("", !0),
|
|
1554
|
+
j.value ? (m(), h("div", Io, [
|
|
1555
|
+
p("p", Lo, "「" + g(j.value.target.name) + "」里现在有 " + g(j.value.inventory.dirs) + " 个文件夹 / " + g(j.value.inventory.files) + " 个文件", 1),
|
|
1556
|
+
p("p", Do, [
|
|
1557
|
+
n[25] || (n[25] = J(" 接下来会", -1)),
|
|
1558
|
+
n[26] || (n[26] = p("b", null, "先全部删掉", -1)),
|
|
1559
|
+
n[27] || (n[27] = J("再铺一遍 —— 包括你改过、还没读回库的东西。 清空只动这个目录", -1)),
|
|
1560
|
+
n[28] || (n[28] = p("b", null, "里面", -1)),
|
|
1561
|
+
n[29] || (n[29] = J("的子项:目录本身、以及它外面的任何东西都不会被碰。 ", -1)),
|
|
1562
|
+
j.value.inventory.items.length > 0 ? (m(), h("span", Fo, "(" + g(j.value.inventory.items.slice(0, 6).map((s) => s.name).join(" / ")) + g(j.value.inventory.items.length > 6 ? " …" : "") + ")", 1)) : E("", !0)
|
|
1496
1563
|
]),
|
|
1497
|
-
p("div",
|
|
1564
|
+
p("div", zo, [
|
|
1498
1565
|
p("button", {
|
|
1499
1566
|
class: "p-button p-button-sm",
|
|
1500
1567
|
type: "button",
|
|
1501
1568
|
disabled: _.value,
|
|
1502
|
-
onClick:
|
|
1503
|
-
}, "清空并导出", 8,
|
|
1569
|
+
onClick: n[9] || (n[9] = (s) => Ct())
|
|
1570
|
+
}, "清空并导出", 8, Ho),
|
|
1504
1571
|
p("button", {
|
|
1505
1572
|
class: "p-button p-button-sm p-button-outlined",
|
|
1506
1573
|
type: "button",
|
|
1507
1574
|
disabled: _.value,
|
|
1508
|
-
onClick:
|
|
1509
|
-
}, "只覆盖", 8,
|
|
1575
|
+
onClick: n[10] || (n[10] = (s) => Bt())
|
|
1576
|
+
}, "只覆盖", 8, Ko),
|
|
1510
1577
|
p("button", {
|
|
1511
1578
|
class: "p-button p-button-sm p-button-text",
|
|
1512
1579
|
type: "button",
|
|
1513
1580
|
disabled: _.value,
|
|
1514
|
-
onClick:
|
|
1515
|
-
}, "取消", 8,
|
|
1581
|
+
onClick: n[11] || (n[11] = (s) => Mt())
|
|
1582
|
+
}, "取消", 8, qo)
|
|
1516
1583
|
])
|
|
1517
1584
|
])) : E("", !0)
|
|
1518
1585
|
]),
|
|
1519
|
-
p("section",
|
|
1520
|
-
|
|
1521
|
-
p("div",
|
|
1522
|
-
|
|
1586
|
+
p("section", Uo, [
|
|
1587
|
+
n[35] || (n[35] = p("h3", { class: "mbc__title" }, "读回改动", -1)),
|
|
1588
|
+
p("div", Jo, [
|
|
1589
|
+
n[32] || (n[32] = p("label", { for: "mbc-read-dir" }, "读回目录", -1)),
|
|
1523
1590
|
p("input", {
|
|
1524
1591
|
id: "mbc-read-dir",
|
|
1525
1592
|
class: "p-inputtext p-component mbc__grow mbc__mono",
|
|
1526
1593
|
type: "text",
|
|
1527
1594
|
readonly: "",
|
|
1528
1595
|
value: S.value ? S.value.name : "(还没选:导出会自动填上,也可以自己选一个)"
|
|
1529
|
-
}, null, 8,
|
|
1596
|
+
}, null, 8, Vo),
|
|
1530
1597
|
p("button", {
|
|
1531
1598
|
class: "p-button p-button-sm p-button-outlined",
|
|
1532
1599
|
type: "button",
|
|
1533
1600
|
disabled: _.value,
|
|
1534
|
-
onClick:
|
|
1535
|
-
}, "选择文件夹", 8,
|
|
1601
|
+
onClick: n[12] || (n[12] = (s) => Se("read"))
|
|
1602
|
+
}, "选择文件夹", 8, Go),
|
|
1536
1603
|
p("button", {
|
|
1537
1604
|
class: "p-button p-button-sm p-button-outlined",
|
|
1538
1605
|
type: "button",
|
|
1539
1606
|
disabled: _.value,
|
|
1540
|
-
onClick:
|
|
1541
|
-
},
|
|
1607
|
+
onClick: n[13] || (n[13] = (s) => Xe())
|
|
1608
|
+
}, g(ee.value ? "读回中…" : "读回改动"), 9, Yo)
|
|
1542
1609
|
]),
|
|
1543
|
-
S.value &&
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
(
|
|
1547
|
-
key:
|
|
1610
|
+
S.value && P.value && S.value.name !== P.value.name ? (m(), h("p", Wo, " 读回的是「" + g(S.value.name) + "」(与导出目录「" + g(P.value.name) + "」不是同一个 —— 想同步就再选一次)。 ", 1)) : (m(), h("p", Zo, "读回目录默认跟着导出目录;要读别的文件夹就点「选择文件夹」单独选一个。")),
|
|
1611
|
+
B.value ? (m(), h(N, { key: 2 }, [
|
|
1612
|
+
B.value.blocks.length > 0 ? (m(), h("ul", Xo, [
|
|
1613
|
+
(m(!0), h(N, null, Z(B.value.blocks, (s) => (m(), h("li", {
|
|
1614
|
+
key: s.id,
|
|
1548
1615
|
class: "mbc__block"
|
|
1549
1616
|
}, [
|
|
1550
|
-
p("label",
|
|
1617
|
+
p("label", Qo, [
|
|
1551
1618
|
p("span", {
|
|
1552
|
-
class:
|
|
1619
|
+
class: X(["p-checkbox p-component", { "p-disabled": !s.canApply }])
|
|
1553
1620
|
}, [
|
|
1554
1621
|
p("input", {
|
|
1555
1622
|
class: "p-checkbox-input",
|
|
1556
1623
|
type: "checkbox",
|
|
1557
|
-
disabled: !
|
|
1558
|
-
checked:
|
|
1559
|
-
onChange: (
|
|
1560
|
-
}, null, 40,
|
|
1561
|
-
|
|
1624
|
+
disabled: !s.canApply,
|
|
1625
|
+
checked: de.value[s.id] === !0,
|
|
1626
|
+
onChange: (b) => Rt(s.id, b)
|
|
1627
|
+
}, null, 40, es),
|
|
1628
|
+
n[33] || (n[33] = p("span", { class: "p-checkbox-box" }, null, -1))
|
|
1562
1629
|
], 2),
|
|
1563
|
-
p("span",
|
|
1630
|
+
p("span", ts, g(s.name || s.id), 1),
|
|
1564
1631
|
p("span", {
|
|
1565
|
-
class:
|
|
1566
|
-
},
|
|
1567
|
-
p("span",
|
|
1632
|
+
class: X(["p-tag", s.status === "modified" ? "p-tag-success" : s.status === "missing" ? "p-tag-warning" : ""])
|
|
1633
|
+
}, g(e[s.status]), 3),
|
|
1634
|
+
p("span", ns, g(s.module || "—"), 1)
|
|
1568
1635
|
]),
|
|
1569
|
-
p("p",
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
], 64)) :
|
|
1573
|
-
|
|
1574
|
-
p("span",
|
|
1575
|
-
], 64)) : (
|
|
1576
|
-
|
|
1636
|
+
p("p", os, [
|
|
1637
|
+
s.status === "missing" ? (m(), h(N, { key: 0 }, [
|
|
1638
|
+
J("目录里没有这一块,勾不上")
|
|
1639
|
+
], 64)) : s.changedFiles.length > 0 ? (m(), h(N, { key: 1 }, [
|
|
1640
|
+
n[34] || (n[34] = J("改了:", -1)),
|
|
1641
|
+
p("span", ss, g(s.changedFiles.join(" / ")), 1)
|
|
1642
|
+
], 64)) : (m(), h(N, { key: 2 }, [
|
|
1643
|
+
J("内容与库里一致")
|
|
1577
1644
|
], 64))
|
|
1578
1645
|
]),
|
|
1579
|
-
|
|
1580
|
-
p("p",
|
|
1646
|
+
s.blockedWhy ? (m(), h("p", as, "不能存:" + g(s.blockedWhy), 1)) : E("", !0),
|
|
1647
|
+
p("p", is, g(s.folder || s.where), 1)
|
|
1581
1648
|
]))), 128))
|
|
1582
|
-
])) : (
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
(
|
|
1649
|
+
])) : (m(), h("p", ls, "这个目录里没有认出任何块。")),
|
|
1650
|
+
B.value.unmatched.length > 0 ? (m(), h("p", rs, "认不出归属的文件夹(" + g(B.value.unmatched.length) + "):" + g(B.value.unmatched.join(" / ")), 1)) : E("", !0),
|
|
1651
|
+
B.value.failures.length > 0 ? (m(), h("ul", cs, [
|
|
1652
|
+
(m(!0), h(N, null, Z(B.value.failures, (s, b) => (m(), h("li", { key: b }, g(s.where || s.kind) + ":" + g(s.message), 1))), 128))
|
|
1586
1653
|
])) : E("", !0),
|
|
1587
|
-
p("div",
|
|
1654
|
+
p("div", us, [
|
|
1588
1655
|
p("button", {
|
|
1589
1656
|
class: "p-button p-button-sm",
|
|
1590
1657
|
type: "button",
|
|
1591
1658
|
disabled: _.value,
|
|
1592
|
-
onClick:
|
|
1593
|
-
},
|
|
1659
|
+
onClick: n[14] || (n[14] = (s) => Ot())
|
|
1660
|
+
}, g(ne.value ? "保存中…" : `保存选中的块(${v.value.length})`), 9, ds)
|
|
1594
1661
|
])
|
|
1595
1662
|
], 64)) : E("", !0)
|
|
1596
1663
|
]),
|
|
1597
|
-
|
|
1598
|
-
p("h3",
|
|
1599
|
-
|
|
1600
|
-
(
|
|
1601
|
-
])) : (
|
|
1602
|
-
(
|
|
1603
|
-
key:
|
|
1604
|
-
class:
|
|
1664
|
+
W.value.length > 0 || se.value.length > 0 ? (m(), h("section", ps, [
|
|
1665
|
+
p("h3", fs, g(W.value.length > 0 ? "前端校验拦下的问题" : "保存结果"), 1),
|
|
1666
|
+
W.value.length > 0 ? (m(), h("ul", ms, [
|
|
1667
|
+
(m(!0), h(N, null, Z(W.value, (s, b) => (m(), h("li", { key: b }, g(s), 1))), 128))
|
|
1668
|
+
])) : (m(), h("ul", bs, [
|
|
1669
|
+
(m(!0), h(N, null, Z(se.value, (s) => (m(), h("li", {
|
|
1670
|
+
key: s.id,
|
|
1671
|
+
class: X({ "is-ok": s.ok })
|
|
1605
1672
|
}, [
|
|
1606
|
-
p("strong", null,
|
|
1607
|
-
!
|
|
1608
|
-
!
|
|
1609
|
-
(
|
|
1673
|
+
p("strong", null, g(s.name || s.id) + ":" + g(s.ok ? "已保存" : "没保存"), 1),
|
|
1674
|
+
!s.ok && s.error ? (m(), h("span", hs, g(s.error), 1)) : E("", !0),
|
|
1675
|
+
!s.ok && (s.issues ?? []).length > 0 ? (m(), h("ul", gs, [
|
|
1676
|
+
(m(!0), h(N, null, Z(s.issues, (b, x) => (m(), h("li", { key: x }, g(b), 1))), 128))
|
|
1610
1677
|
])) : E("", !0)
|
|
1611
1678
|
], 2))), 128))
|
|
1612
1679
|
]))
|
|
@@ -1614,25 +1681,25 @@ ${a}` : a;
|
|
|
1614
1681
|
])) : E("", !0)
|
|
1615
1682
|
], 64)) : E("", !0);
|
|
1616
1683
|
}
|
|
1617
|
-
}),
|
|
1684
|
+
}), xs = /* @__PURE__ */ ft(vs, [["__scopeId", "data-v-2f882aa4"]]);
|
|
1618
1685
|
export {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1686
|
+
zt as API_BASE,
|
|
1687
|
+
Yt as BLOCK_BACKEND_FILE,
|
|
1688
|
+
vt as BLOCK_ENTRY,
|
|
1689
|
+
De as BLOCK_MANIFEST,
|
|
1690
|
+
Ut as CLIENT_SOURCE,
|
|
1691
|
+
Be as MANIFEST_KEYS,
|
|
1692
|
+
xs as MagicBlockConsole,
|
|
1693
|
+
$s as MagicBlockPage,
|
|
1694
|
+
Ze as NAME_MAX,
|
|
1695
|
+
nn as buildPreview,
|
|
1696
|
+
Dn as checkSelection,
|
|
1697
|
+
Gt as installBridge,
|
|
1698
|
+
an as loadBlockRender,
|
|
1699
|
+
on as onBlockRenderRefresh,
|
|
1700
|
+
Nn as parseManifest,
|
|
1701
|
+
sn as refreshBlockRender,
|
|
1702
|
+
In as validFileName,
|
|
1703
|
+
On as validName,
|
|
1704
|
+
Ln as validateBlock
|
|
1638
1705
|
};
|