@yuku123/z-team-component 0.2.26 → 0.2.29

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.
@@ -1,975 +0,0 @@
1
- import { jsxs as o, jsx as e, Fragment as re } from "react/jsx-runtime";
2
- import { SearchOutlined as Ce, ReloadOutlined as Se, PlusOutlined as Te, FileZipOutlined as Z, CloudDownloadOutlined as Y, EditOutlined as fe, UserSwitchOutlined as Ue, ArrowLeftOutlined as ve, UserOutlined as $e, CloudUploadOutlined as Be, PictureOutlined as de, EyeOutlined as Ie, ChromeOutlined as De, ToolOutlined as Pe, AppleOutlined as Re, AppstoreOutlined as Oe } from "@ant-design/icons";
3
- import { useState as u, useEffect as ce, useCallback as L } from "react";
4
- import { a as U, f as $, B, u as I } from "./api--Fg0hL9Y.js";
5
- import { u as x } from "./useAppStore-wgWaxcyc.js";
6
- import { message as T, Input as H, Tooltip as me, Button as b, Spin as se, Empty as Ae, Popconfirm as pe, Tag as le, Modal as Le, Select as ze, Upload as ue, Tabs as Me } from "antd";
7
- import _e from "react-markdown";
8
- import be from "rehype-highlight";
9
- import ge from "remark-gfm";
10
- function j(a) {
11
- return a ? `?token=${encodeURIComponent(a)}` : "";
12
- }
13
- function P(a) {
14
- return a && a.startsWith("http://") && a.includes(".aliyuncs.com/") ? "https://" + a.slice(7) : a;
15
- }
16
- function X(a) {
17
- return {
18
- ...a,
19
- coverUrl: P(a.coverUrl),
20
- fileUrl: P(a.fileUrl)
21
- };
22
- }
23
- async function xe(a = {}, n = "") {
24
- const l = new URLSearchParams();
25
- n && l.set("token", n), a.category && l.set("category", a.category), a.keyword && l.set("keyword", a.keyword), a.mine && l.set("mine", "true");
26
- const r = l.toString(), c = await U(
27
- `${B}/market/resources${r ? `?${r}` : ""}`,
28
- $
29
- );
30
- return (await I(
31
- c,
32
- "获取资源列表失败"
33
- )).map(X);
34
- }
35
- async function Ne(a, n = "") {
36
- const l = await U(
37
- `${B}/market/resources/${a}${j(n)}`,
38
- $
39
- ), r = await I(
40
- l,
41
- "获取资源详情失败"
42
- );
43
- return X(r);
44
- }
45
- async function Fe(a, n, l = "") {
46
- const r = new URLSearchParams();
47
- r.set("publish", n ? "true" : "false"), l && r.set("token", l);
48
- const c = await U(`${B}/market/resources?${r.toString()}`, {
49
- ...$,
50
- method: "POST",
51
- headers: { "Content-Type": "application/json" },
52
- body: JSON.stringify({
53
- ...a,
54
- coverUrl: P(a.coverUrl ?? null),
55
- fileUrl: P(a.fileUrl ?? null)
56
- })
57
- }), h = await I(c, "新建资源失败");
58
- return X(h);
59
- }
60
- async function ye(a, n, l, r = "") {
61
- const c = new URLSearchParams();
62
- l !== null && c.set("publish", l ? "true" : "false"), r && c.set("token", r);
63
- const h = c.toString(), s = await U(
64
- `${B}/market/resources/${a}${h ? `?${h}` : ""}`,
65
- {
66
- ...$,
67
- method: "PUT",
68
- headers: { "Content-Type": "application/json" },
69
- body: JSON.stringify({
70
- ...n,
71
- coverUrl: P(n.coverUrl ?? null),
72
- fileUrl: P(n.fileUrl ?? null)
73
- })
74
- }
75
- ), p = await I(s, "保存资源失败");
76
- return X(p);
77
- }
78
- async function we(a, n = "") {
79
- const l = await U(
80
- `${B}/market/resources/${a}${j(n)}`,
81
- { ...$, method: "DELETE" }
82
- );
83
- return I(l, "删除资源失败");
84
- }
85
- async function ke(a, n = "", l) {
86
- const r = new URLSearchParams();
87
- n && r.set("token", n);
88
- const c = await U(
89
- `${B}/market/resources/${a}/download?${r.toString()}`,
90
- { ...$, method: "POST" }
91
- ), h = await I(c, "下载失败");
92
- return {
93
- ...h,
94
- fileUrl: P(h.fileUrl) ?? h.fileUrl
95
- };
96
- }
97
- async function Ee(a, n = "") {
98
- const l = new FormData();
99
- l.append("file", a);
100
- const r = await U(
101
- `${B}/market/upload-package${j(n)}`,
102
- { ...$, method: "POST", body: l }
103
- ), c = await I(r, "上传资源包失败");
104
- return { ...c, url: P(c.url) ?? c.url };
105
- }
106
- async function We(a, n = "") {
107
- const l = new FormData();
108
- l.append("file", a);
109
- const r = await U(`${B}/market/upload-cover${j(n)}`, {
110
- ...$,
111
- method: "POST",
112
- body: l
113
- }), c = await I(r, "上传封面失败");
114
- return { ...c, url: P(c.url) ?? c.url };
115
- }
116
- async function he(a, n = "") {
117
- const l = new URLSearchParams();
118
- a && l.set("keyword", a), n && l.set("token", n);
119
- const r = l.toString(), c = await U(
120
- `${B}/market/users${r ? `?${r}` : ""}`,
121
- $
122
- );
123
- return I(c, "搜索用户失败");
124
- }
125
- async function He(a, n, l = "") {
126
- const r = await U(
127
- `${B}/market/resources/${a}/transfer-owner${j(l)}`,
128
- {
129
- ...$,
130
- method: "POST",
131
- headers: { "Content-Type": "application/json" },
132
- body: JSON.stringify({ targetStaffId: n })
133
- }
134
- );
135
- return I(r, "转交失败");
136
- }
137
- const je = "_market_11tb9_1", Ge = "_subNav_11tb9_10", Ve = "_subNavItem_11tb9_22", qe = "_subNavItemActive_11tb9_43", Je = "_tabBody_11tb9_48", Ke = "_comingSoon_11tb9_54", Ze = "_comingSoonIcon_11tb9_64", Ye = "_comingSoonTitle_11tb9_68", Qe = "_comingSoonDesc_11tb9_74", Xe = "_listWrap_11tb9_79", et = "_toolbar_11tb9_83", tt = "_toolbarCount_11tb9_90", at = "_toolbarRight_11tb9_95", nt = "_emptyWrap_11tb9_101", it = "_cardGrid_11tb9_106", ot = "_card_11tb9_106", lt = "_cardCover_11tb9_129", rt = "_cardCoverFallback_11tb9_143", ct = "_cardDraftBadge_11tb9_153", st = "_cardBody_11tb9_164", dt = "_cardTitle_11tb9_172", mt = "_cardSummary_11tb9_181", ut = "_cardMeta_11tb9_192", ht = "_cardCreator_11tb9_200", ft = "_cardDownloads_11tb9_207", vt = "_cardFileName_11tb9_213", pt = "_cardActions_11tb9_217", _t = "_cardDraftTag_11tb9_226", bt = "_editorWrap_11tb9_233", gt = "_detailWrap_11tb9_234", Nt = "_editorTopBar_11tb9_241", yt = "_backBtn_11tb9_251", wt = "_editorTitle_11tb9_268", kt = "_editorTopActions_11tb9_277", Ct = "_editorBody_11tb9_283", St = "_detailBody_11tb9_284", Tt = "_section_11tb9_294", Ut = "_sectionTitle_11tb9_301", $t = "_uploaderInner_11tb9_311", Bt = "_uploaderIcon_11tb9_315", It = "_uploaderText_11tb9_321", Dt = "_uploaderFile_11tb9_326", Pt = "_coverRow_11tb9_332", Rt = "_coverPreview_11tb9_338", Ot = "_coverRemove_11tb9_354", At = "_formRow_11tb9_360", Lt = "_formLabel_11tb9_371", zt = "_docEditor_11tb9_379", Mt = "_docPreview_11tb9_385", xt = "_docPreviewEmpty_11tb9_440", Ft = "_detailHeader_11tb9_447", Et = "_detailCover_11tb9_456", Wt = "_detailInfo_11tb9_472", Ht = "_detailNameRow_11tb9_480", jt = "_detailName_11tb9_480", Gt = "_detailSummary_11tb9_494", Vt = "_detailMeta_11tb9_500", qt = "_detailActions_11tb9_509", Jt = "_detailDocSection_11tb9_515", t = {
138
- market: je,
139
- subNav: Ge,
140
- subNavItem: Ve,
141
- subNavItemActive: qe,
142
- tabBody: Je,
143
- comingSoon: Ke,
144
- comingSoonIcon: Ze,
145
- comingSoonTitle: Ye,
146
- comingSoonDesc: Qe,
147
- listWrap: Xe,
148
- toolbar: et,
149
- toolbarCount: tt,
150
- toolbarRight: at,
151
- emptyWrap: nt,
152
- cardGrid: it,
153
- card: ot,
154
- cardCover: lt,
155
- cardCoverFallback: rt,
156
- cardDraftBadge: ct,
157
- cardBody: st,
158
- cardTitle: dt,
159
- cardSummary: mt,
160
- cardMeta: ut,
161
- cardCreator: ht,
162
- cardDownloads: ft,
163
- cardFileName: vt,
164
- cardActions: pt,
165
- cardDraftTag: _t,
166
- editorWrap: bt,
167
- detailWrap: gt,
168
- editorTopBar: Nt,
169
- backBtn: yt,
170
- editorTitle: wt,
171
- editorTopActions: kt,
172
- editorBody: Ct,
173
- detailBody: St,
174
- section: Tt,
175
- sectionTitle: Ut,
176
- uploaderInner: $t,
177
- uploaderIcon: Bt,
178
- uploaderText: It,
179
- uploaderFile: Dt,
180
- coverRow: Pt,
181
- coverPreview: Rt,
182
- coverRemove: Ot,
183
- formRow: At,
184
- formLabel: Lt,
185
- docEditor: zt,
186
- docPreview: Mt,
187
- docPreviewEmpty: xt,
188
- detailHeader: Ft,
189
- detailCover: Et,
190
- detailInfo: Wt,
191
- detailNameRow: Ht,
192
- detailName: jt,
193
- detailSummary: Gt,
194
- detailMeta: Vt,
195
- detailActions: qt,
196
- detailDocSection: Jt
197
- }, Kt = {
198
- "browser-plugin": "浏览器插件",
199
- "ztools-plugin": "zTools 插件",
200
- software: "软件资源"
201
- };
202
- function Q(a) {
203
- return !a || a <= 0 ? "-" : a < 1024 ? `${a} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(1)} KB` : a < 1024 * 1024 * 1024 ? `${(a / 1024 / 1024).toFixed(1)} MB` : `${(a / 1024 / 1024 / 1024).toFixed(2)} GB`;
204
- }
205
- function Zt({
206
- resources: a,
207
- loading: n,
208
- category: l,
209
- onReload: r,
210
- onCreate: c,
211
- onOpenDetail: h,
212
- onEdit: s
213
- }) {
214
- const p = x((i) => i.token), w = x((i) => i.currentUser), N = w != null && w.id ? String(w.id) : "", [k, m] = u(""), [C, A] = u(null), [v, S] = u(null), [R, O] = u([]), [z, D] = u(!1), [f, g] = u(null), [G, F] = u(!1), [E, V] = u(a);
215
- ce(() => {
216
- V(a);
217
- }, [a]);
218
- const M = k.trim() ? E.filter(
219
- (i) => i.name.toLowerCase().includes(k.trim().toLowerCase()) || (i.summary ?? "").toLowerCase().includes(k.trim().toLowerCase())
220
- ) : E, q = L(
221
- async (i) => {
222
- if (i.fileUrl) {
223
- A(i.id);
224
- try {
225
- const y = await ke(i.id, p);
226
- if (y.fileUrl) {
227
- const _ = document.createElement("a");
228
- _.href = y.fileUrl, _.download = y.fileName || i.name, _.target = "_blank", _.rel = "noopener", document.body.appendChild(_), _.click(), _.remove(), r();
229
- }
230
- } catch {
231
- } finally {
232
- A(null);
233
- }
234
- }
235
- },
236
- [p, r]
237
- ), J = L(
238
- async (i) => {
239
- try {
240
- await we(i, p), T.success("已删除"), r();
241
- } catch {
242
- }
243
- },
244
- [p, r]
245
- ), ee = L(
246
- (i) => {
247
- S(i), g(null), O([]), D(!0), he("", p).then(
248
- (y) => O(
249
- y.filter((_) => String(_.id) !== i.creatorId)
250
- )
251
- ).catch(() => {
252
- }).finally(() => D(!1));
253
- },
254
- [p]
255
- ), te = L(
256
- (i) => {
257
- D(!0), he(i, p).then(
258
- (y) => O(
259
- v ? y.filter((_) => String(_.id) !== v.creatorId) : y
260
- )
261
- ).catch(() => {
262
- }).finally(() => D(!1));
263
- },
264
- [p, v]
265
- ), ae = L(async () => {
266
- if (!(!v || f === null)) {
267
- F(!0);
268
- try {
269
- await He(v.id, f, p), T.success("已转交"), S(null), r();
270
- } catch {
271
- } finally {
272
- F(!1);
273
- }
274
- }
275
- }, [v, f, p, r]);
276
- return /* @__PURE__ */ o("div", { className: t.listWrap, children: [
277
- /* @__PURE__ */ o("div", { className: t.toolbar, children: [
278
- /* @__PURE__ */ e(
279
- H,
280
- {
281
- allowClear: !0,
282
- prefix: /* @__PURE__ */ e(Ce, { style: { color: "#999" } }),
283
- placeholder: "搜索资源名称/简介",
284
- value: k,
285
- onChange: (i) => m(i.target.value),
286
- style: { width: 260 }
287
- }
288
- ),
289
- /* @__PURE__ */ o("span", { className: t.toolbarCount, children: [
290
- "共 ",
291
- M.length,
292
- " 个",
293
- Kt[l] ?? "资源"
294
- ] }),
295
- /* @__PURE__ */ o("div", { className: t.toolbarRight, children: [
296
- /* @__PURE__ */ e(me, { title: "刷新", children: /* @__PURE__ */ e(b, { icon: /* @__PURE__ */ e(Se, {}), onClick: r }) }),
297
- /* @__PURE__ */ e(b, { type: "primary", icon: /* @__PURE__ */ e(Te, {}), onClick: c, children: "新增资源" })
298
- ] })
299
- ] }),
300
- /* @__PURE__ */ e(se, { spinning: n, children: M.length === 0 && !n ? /* @__PURE__ */ e("div", { className: t.emptyWrap, children: /* @__PURE__ */ e(Ae, { description: "暂无资源,点击右上角「新增资源」上传第一个" }) }) : /* @__PURE__ */ e("div", { className: t.cardGrid, children: M.map((i) => {
301
- const y = i.creatorId === N, _ = i.status === 0;
302
- return /* @__PURE__ */ o(
303
- "div",
304
- {
305
- className: t.card,
306
- onClick: () => h(i),
307
- children: [
308
- /* @__PURE__ */ o("div", { className: t.cardCover, children: [
309
- i.coverUrl ? /* @__PURE__ */ e("img", { src: i.coverUrl, alt: i.name }) : /* @__PURE__ */ e("div", { className: t.cardCoverFallback, children: /* @__PURE__ */ e(Z, {}) }),
310
- _ && /* @__PURE__ */ e("span", { className: t.cardDraftBadge, children: "草稿" })
311
- ] }),
312
- /* @__PURE__ */ o("div", { className: t.cardBody, children: [
313
- /* @__PURE__ */ e("div", { className: t.cardTitle, title: i.name, children: i.name }),
314
- /* @__PURE__ */ e("div", { className: t.cardSummary, children: i.summary || "暂无简介" }),
315
- /* @__PURE__ */ o("div", { className: t.cardMeta, children: [
316
- /* @__PURE__ */ e("span", { className: t.cardCreator, children: i.creatorName }),
317
- /* @__PURE__ */ o(
318
- "span",
319
- {
320
- className: t.cardDownloads,
321
- title: `累计下载 ${i.downloadCount} 次`,
322
- children: [
323
- /* @__PURE__ */ e(Y, {}),
324
- " ",
325
- i.downloadCount,
326
- " ",
327
- "次下载"
328
- ]
329
- }
330
- ),
331
- i.version && /* @__PURE__ */ o(
332
- "span",
333
- {
334
- className: t.cardFileName,
335
- title: `版本 ${i.version}`,
336
- children: [
337
- "v",
338
- i.version
339
- ]
340
- }
341
- ),
342
- i.fileName && /* @__PURE__ */ e(
343
- "span",
344
- {
345
- className: t.cardFileName,
346
- title: `${i.fileName}(${Q(
347
- i.fileSize
348
- )})`,
349
- children: Q(i.fileSize)
350
- }
351
- )
352
- ] }),
353
- /* @__PURE__ */ o(
354
- "div",
355
- {
356
- className: t.cardActions,
357
- onClick: (d) => d.stopPropagation(),
358
- children: [
359
- /* @__PURE__ */ e(
360
- b,
361
- {
362
- size: "small",
363
- type: "primary",
364
- icon: /* @__PURE__ */ e(Y, {}),
365
- disabled: !i.fileUrl,
366
- loading: C === i.id,
367
- onClick: () => void q(i),
368
- children: "下载"
369
- }
370
- ),
371
- y && /* @__PURE__ */ o(re, { children: [
372
- /* @__PURE__ */ e(
373
- b,
374
- {
375
- size: "small",
376
- icon: /* @__PURE__ */ e(fe, {}),
377
- onClick: () => s(i),
378
- children: "编辑"
379
- }
380
- ),
381
- /* @__PURE__ */ e(
382
- pe,
383
- {
384
- title: "确定删除该资源?",
385
- onConfirm: () => void J(i.id),
386
- children: /* @__PURE__ */ e(b, { size: "small", danger: !0, children: "删除" })
387
- }
388
- )
389
- ] }),
390
- y && /* @__PURE__ */ e(me, { title: "转交给其他用户接手维护", children: /* @__PURE__ */ e(
391
- b,
392
- {
393
- size: "small",
394
- icon: /* @__PURE__ */ e(Ue, {}),
395
- onClick: () => ee(i)
396
- }
397
- ) }),
398
- _ && /* @__PURE__ */ e(le, { color: "orange", className: t.cardDraftTag, children: "仅自己可见" })
399
- ]
400
- }
401
- )
402
- ] })
403
- ]
404
- },
405
- i.id
406
- );
407
- }) }) }),
408
- /* @__PURE__ */ o(
409
- Le,
410
- {
411
- open: v !== null,
412
- title: `转交「${(v == null ? void 0 : v.name) ?? ""}」所有权`,
413
- okText: "转交",
414
- okButtonProps: {
415
- disabled: f === null,
416
- loading: G
417
- },
418
- onCancel: () => S(null),
419
- onOk: () => void ae(),
420
- destroyOnHidden: !0,
421
- children: [
422
- /* @__PURE__ */ o("p", { style: { color: "#666", marginBottom: 12 }, children: [
423
- "转交后「",
424
- v == null ? void 0 : v.creatorName,
425
- "」将失去该资源的编辑/删除权,由新所有者接手维护。"
426
- ] }),
427
- /* @__PURE__ */ e(
428
- ze,
429
- {
430
- showSearch: !0,
431
- filterOption: !1,
432
- placeholder: "输入姓名/账号/工号搜索",
433
- style: { width: "100%" },
434
- loading: z,
435
- value: f,
436
- onSearch: te,
437
- onChange: (i) => g(i),
438
- options: R.map((i) => ({
439
- value: i.id,
440
- label: `${i.name}(${i.accountNo ?? i.jobNumber ?? i.id})`
441
- }))
442
- }
443
- )
444
- ]
445
- }
446
- )
447
- ] });
448
- }
449
- function Yt({
450
- resource: a,
451
- currentUserId: n,
452
- onBack: l,
453
- onEdit: r,
454
- onDeleted: c
455
- }) {
456
- var D;
457
- const h = x((f) => f.token), [s, p] = u(a), [w, N] = u(!a.docContent), [k, m] = u(!1), [C, A] = u(!1);
458
- ce(() => {
459
- let f = !0;
460
- if (!(a.docContent !== null && a.docContent !== void 0))
461
- return N(!0), Ne(a.id, h).then((g) => {
462
- f && p(g);
463
- }).catch(() => {
464
- }).finally(() => {
465
- f && N(!1);
466
- }), () => {
467
- f = !1;
468
- };
469
- }, [a, h]);
470
- const v = s.creatorId === n, S = s.status === 0, R = async () => {
471
- if (s.fileUrl) {
472
- m(!0);
473
- try {
474
- const f = await ke(s.id, h);
475
- if (f.fileUrl) {
476
- const g = document.createElement("a");
477
- g.href = f.fileUrl, g.download = f.fileName || s.name, g.target = "_blank", g.rel = "noopener", document.body.appendChild(g), g.click(), g.remove();
478
- }
479
- } catch {
480
- } finally {
481
- m(!1);
482
- }
483
- }
484
- }, O = async (f) => {
485
- A(!0);
486
- try {
487
- await ye(s.id, {}, f, h), T.success(f ? "已发布" : "已下架为草稿"), l();
488
- } catch {
489
- } finally {
490
- A(!1);
491
- }
492
- }, z = async () => {
493
- try {
494
- await we(s.id, h), T.success("已删除"), c();
495
- } catch {
496
- }
497
- };
498
- return /* @__PURE__ */ o("div", { className: t.detailWrap, children: [
499
- /* @__PURE__ */ o("div", { className: t.editorTopBar, children: [
500
- /* @__PURE__ */ o("button", { type: "button", className: t.backBtn, onClick: l, children: [
501
- /* @__PURE__ */ e(ve, {}),
502
- " 返回列表"
503
- ] }),
504
- /* @__PURE__ */ e("span", { className: t.editorTitle, children: s.name }),
505
- /* @__PURE__ */ e("div", { className: t.editorTopActions, children: v && /* @__PURE__ */ o(re, { children: [
506
- !S && /* @__PURE__ */ e(
507
- b,
508
- {
509
- loading: C,
510
- onClick: () => void O(!1),
511
- children: "下架为草稿"
512
- }
513
- ),
514
- S && /* @__PURE__ */ e(
515
- b,
516
- {
517
- type: "primary",
518
- ghost: !0,
519
- loading: C,
520
- onClick: () => void O(!0),
521
- children: "发布"
522
- }
523
- ),
524
- /* @__PURE__ */ e(b, { icon: /* @__PURE__ */ e(fe, {}), onClick: () => r(s), children: "编辑" }),
525
- /* @__PURE__ */ e(
526
- pe,
527
- {
528
- title: "确定删除该资源?",
529
- onConfirm: () => void z(),
530
- children: /* @__PURE__ */ e(b, { danger: !0, children: "删除" })
531
- }
532
- )
533
- ] }) })
534
- ] }),
535
- /* @__PURE__ */ o("div", { className: t.detailBody, children: [
536
- /* @__PURE__ */ o("div", { className: t.detailHeader, children: [
537
- /* @__PURE__ */ e("div", { className: t.detailCover, children: s.coverUrl ? /* @__PURE__ */ e("img", { src: s.coverUrl, alt: s.name }) : /* @__PURE__ */ e("div", { className: t.cardCoverFallback, children: /* @__PURE__ */ e(Z, {}) }) }),
538
- /* @__PURE__ */ o("div", { className: t.detailInfo, children: [
539
- /* @__PURE__ */ o("div", { className: t.detailNameRow, children: [
540
- /* @__PURE__ */ e("h1", { className: t.detailName, children: s.name }),
541
- S ? /* @__PURE__ */ e(le, { color: "orange", children: "草稿(仅自己可见)" }) : /* @__PURE__ */ e(le, { color: "green", children: "已发布" })
542
- ] }),
543
- /* @__PURE__ */ e("div", { className: t.detailSummary, children: s.summary || "暂无简介" }),
544
- /* @__PURE__ */ o("div", { className: t.detailMeta, children: [
545
- /* @__PURE__ */ o("span", { children: [
546
- /* @__PURE__ */ e($e, {}),
547
- " ",
548
- s.creatorName
549
- ] }),
550
- /* @__PURE__ */ o("span", { children: [
551
- /* @__PURE__ */ e(Y, {}),
552
- " ",
553
- s.downloadCount,
554
- " 次下载"
555
- ] }),
556
- s.version && /* @__PURE__ */ o("span", { title: `版本 ${s.version}`, children: [
557
- "v",
558
- s.version
559
- ] }),
560
- s.fileName && /* @__PURE__ */ o("span", { title: s.fileName, children: [
561
- /* @__PURE__ */ e(Z, {}),
562
- " ",
563
- s.fileName,
564
- "(",
565
- Q(s.fileSize),
566
- ")"
567
- ] }),
568
- /* @__PURE__ */ o("span", { children: [
569
- "更新于 ",
570
- ((D = s.updateTime) == null ? void 0 : D.slice(0, 10)) ?? "-"
571
- ] })
572
- ] }),
573
- /* @__PURE__ */ e("div", { className: t.detailActions, children: /* @__PURE__ */ e(
574
- b,
575
- {
576
- type: "primary",
577
- size: "large",
578
- icon: /* @__PURE__ */ e(Y, {}),
579
- disabled: !s.fileUrl,
580
- loading: k,
581
- onClick: () => void R(),
582
- children: "下载资源包"
583
- }
584
- ) })
585
- ] })
586
- ] }),
587
- /* @__PURE__ */ o("div", { className: t.detailDocSection, children: [
588
- /* @__PURE__ */ e("div", { className: t.sectionTitle, children: "使用说明" }),
589
- /* @__PURE__ */ e(se, { spinning: w, children: /* @__PURE__ */ e("div", { className: t.docPreview, children: s.docContent ? /* @__PURE__ */ e(
590
- _e,
591
- {
592
- remarkPlugins: [ge],
593
- rehypePlugins: [be],
594
- children: s.docContent
595
- }
596
- ) : /* @__PURE__ */ e("div", { className: t.docPreviewEmpty, children: "创建者暂未补充使用说明" }) }) })
597
- ] })
598
- ] })
599
- ] });
600
- }
601
- function Qt(a) {
602
- const n = (a ?? "").trim();
603
- if (!n) return "1.0.1";
604
- const l = n.match(/^(.*)\.(\d+)$/);
605
- return l ? `${l[1]}.${Number(l[2]) + 1}` : /^\d+$/.test(n) ? String(Number(n) + 1) : n;
606
- }
607
- function Xt({
608
- category: a,
609
- resource: n,
610
- onSaved: l,
611
- onCancel: r
612
- }) {
613
- const c = x((d) => d.token), h = a === "ztools-plugin", [s, p] = u((n == null ? void 0 : n.name) ?? ""), [w, N] = u((n == null ? void 0 : n.summary) ?? ""), [k, m] = u((n == null ? void 0 : n.version) ?? ""), [C, A] = u((n == null ? void 0 : n.docContent) ?? ""), [v, S] = u((n == null ? void 0 : n.coverUrl) ?? ""), [R, O] = u((n == null ? void 0 : n.fileUrl) ?? ""), [z, D] = u((n == null ? void 0 : n.fileName) ?? ""), [f, g] = u((n == null ? void 0 : n.fileSize) ?? 0), [G, F] = u(!1), [E, V] = u(!1), [M, q] = u(null), [J, ee] = u("edit"), te = async (d) => {
614
- const W = R;
615
- F(!0);
616
- try {
617
- const K = await Ee(d, c);
618
- O(K.url), D(K.fileName ?? d.name), g(K.size);
619
- const ne = k.trim();
620
- if (W && ne) {
621
- const ie = Qt(ne);
622
- if (ie !== ne)
623
- return m(ie), T.success(
624
- `资源包已替换,版本号自动升级至 v${ie}(可手动修改)`
625
- ), !1;
626
- }
627
- T.success(`资源包已上传:${K.fileName ?? d.name}`);
628
- } catch {
629
- } finally {
630
- F(!1);
631
- }
632
- return !1;
633
- }, ae = async (d) => {
634
- V(!0);
635
- try {
636
- const W = await We(d, c);
637
- S(W.url), T.success("封面已上传");
638
- } catch {
639
- } finally {
640
- V(!1);
641
- }
642
- return !1;
643
- }, i = () => ({
644
- name: s.trim(),
645
- summary: w.trim() || void 0,
646
- docContent: C || void 0,
647
- coverUrl: v || void 0,
648
- fileUrl: R || void 0,
649
- fileName: z || void 0,
650
- fileSize: f || void 0,
651
- version: k.trim() || void 0
652
- }), y = (d) => s.trim() ? d && !R ? (T.warning("发布前请先上传资源包"), !1) : !0 : (T.warning("请填写资源名称"), !1), _ = async (d) => {
653
- if (y(d)) {
654
- q(d ? "publish" : "draft");
655
- try {
656
- const W = n ? await ye(n.id, i(), d, c) : await Fe(
657
- { ...i(), category: a },
658
- d,
659
- c
660
- );
661
- T.success(d ? "已发布" : "已保存草稿"), l(W);
662
- } catch {
663
- } finally {
664
- q(null);
665
- }
666
- }
667
- };
668
- return /* @__PURE__ */ o("div", { className: t.editorWrap, children: [
669
- /* @__PURE__ */ o("div", { className: t.editorTopBar, children: [
670
- /* @__PURE__ */ o("button", { type: "button", className: t.backBtn, onClick: r, children: [
671
- /* @__PURE__ */ e(ve, {}),
672
- " 返回列表"
673
- ] }),
674
- /* @__PURE__ */ e("span", { className: t.editorTitle, children: n ? "编辑资源" : "新增资源" }),
675
- /* @__PURE__ */ o("div", { className: t.editorTopActions, children: [
676
- /* @__PURE__ */ e(
677
- b,
678
- {
679
- onClick: () => void _(!1),
680
- loading: M === "draft",
681
- children: "保存草稿"
682
- }
683
- ),
684
- /* @__PURE__ */ e(
685
- b,
686
- {
687
- type: "primary",
688
- onClick: () => void _(!0),
689
- loading: M === "publish",
690
- children: (n == null ? void 0 : n.status) === 1 ? "保存并保持发布" : "直接发布"
691
- }
692
- )
693
- ] })
694
- ] }),
695
- /* @__PURE__ */ o("div", { className: t.editorBody, children: [
696
- /* @__PURE__ */ o("div", { className: t.section, children: [
697
- /* @__PURE__ */ o("div", { className: t.sectionTitle, children: [
698
- /* @__PURE__ */ e(Z, {}),
699
- " 资源包(唯一,重新上传将替换)"
700
- ] }),
701
- /* @__PURE__ */ e(
702
- ue.Dragger,
703
- {
704
- accept: h ? ".html,.htm,.zip" : ".zip,.crx,.xpi,.tar,.gz,.rar,.7z,.exe,.dmg,.apk",
705
- showUploadList: !1,
706
- maxCount: 1,
707
- beforeUpload: (d) => (te(d), !1),
708
- disabled: G,
709
- children: /* @__PURE__ */ e("div", { className: t.uploaderInner, children: G ? /* @__PURE__ */ e(se, {}) : /* @__PURE__ */ o(re, { children: [
710
- /* @__PURE__ */ e("p", { className: t.uploaderIcon, children: /* @__PURE__ */ e(Be, {}) }),
711
- /* @__PURE__ */ e("p", { className: t.uploaderText, children: h ? "点击或拖拽插件 HTML 文件到此处上传(z-biz-tool-box 插件入口,最大 200MB)" : "点击或拖拽资源包到此处上传(zip / crx 等,最大 200MB)" }),
712
- R && /* @__PURE__ */ o("p", { className: t.uploaderFile, children: [
713
- "当前:",
714
- z,
715
- "(",
716
- Q(f),
717
- ")"
718
- ] })
719
- ] }) })
720
- }
721
- )
722
- ] }),
723
- /* @__PURE__ */ o("div", { className: t.section, children: [
724
- /* @__PURE__ */ o("div", { className: t.sectionTitle, children: [
725
- /* @__PURE__ */ e(de, {}),
726
- " 封面图(可选)"
727
- ] }),
728
- /* @__PURE__ */ e("div", { className: t.coverRow, children: v ? /* @__PURE__ */ o("div", { className: t.coverPreview, children: [
729
- /* @__PURE__ */ e("img", { src: v, alt: "封面" }),
730
- /* @__PURE__ */ e(
731
- b,
732
- {
733
- size: "small",
734
- danger: !0,
735
- className: t.coverRemove,
736
- onClick: () => S(""),
737
- children: "移除"
738
- }
739
- )
740
- ] }) : /* @__PURE__ */ e(
741
- ue,
742
- {
743
- accept: "image/png,image/jpeg,image/gif,image/bmp,image/webp",
744
- showUploadList: !1,
745
- beforeUpload: (d) => (ae(d), !1),
746
- disabled: E,
747
- children: /* @__PURE__ */ e(b, { icon: /* @__PURE__ */ e(de, {}), loading: E, children: "上传封面图" })
748
- }
749
- ) })
750
- ] }),
751
- /* @__PURE__ */ o("div", { className: t.section, children: [
752
- /* @__PURE__ */ e("div", { className: t.sectionTitle, children: "基本信息" }),
753
- /* @__PURE__ */ o("div", { className: t.formRow, children: [
754
- /* @__PURE__ */ e("div", { className: t.formLabel, children: "资源名称" }),
755
- /* @__PURE__ */ e(
756
- H,
757
- {
758
- placeholder: "如:Header Forge 请求头锻造器",
759
- value: s,
760
- maxLength: 200,
761
- onChange: (d) => p(d.target.value)
762
- }
763
- )
764
- ] }),
765
- /* @__PURE__ */ o("div", { className: t.formRow, children: [
766
- /* @__PURE__ */ e("div", { className: t.formLabel, children: "简介" }),
767
- /* @__PURE__ */ e(
768
- H.TextArea,
769
- {
770
- placeholder: "一句话介绍该资源解决什么问题",
771
- value: w,
772
- maxLength: 500,
773
- rows: 2,
774
- onChange: (d) => N(d.target.value)
775
- }
776
- )
777
- ] }),
778
- /* @__PURE__ */ o("div", { className: t.formRow, children: [
779
- /* @__PURE__ */ o("div", { className: t.formLabel, children: [
780
- "版本号(替换资源包自动升级;",
781
- h ? "zTools 插件缺省 1.0.0" : "可选",
782
- ")"
783
- ] }),
784
- /* @__PURE__ */ e(
785
- H,
786
- {
787
- placeholder: "如:1.2.0",
788
- value: k,
789
- maxLength: 50,
790
- style: { width: 220 },
791
- onChange: (d) => m(d.target.value)
792
- }
793
- )
794
- ] })
795
- ] }),
796
- /* @__PURE__ */ o("div", { className: t.section, children: [
797
- /* @__PURE__ */ e("div", { className: t.sectionTitle, children: "使用说明文档(Markdown)" }),
798
- /* @__PURE__ */ e(
799
- Me,
800
- {
801
- activeKey: J,
802
- onChange: (d) => ee(d),
803
- items: [
804
- { key: "edit", label: "编辑" },
805
- { key: "preview", label: "预览" }
806
- ]
807
- }
808
- ),
809
- J === "edit" ? /* @__PURE__ */ e(
810
- H.TextArea,
811
- {
812
- className: t.docEditor,
813
- value: C,
814
- onChange: (d) => A(d.target.value),
815
- placeholder: `# 使用说明
816
-
817
- ## 安装步骤
818
- 1. 下载资源包
819
- 2. 浏览器打开 chrome://extensions
820
- 3. ...`,
821
- autoSize: { minRows: 12, maxRows: 24 }
822
- }
823
- ) : /* @__PURE__ */ e("div", { className: t.docPreview, children: C ? /* @__PURE__ */ e(
824
- _e,
825
- {
826
- remarkPlugins: [ge],
827
- rehypePlugins: [be],
828
- children: C
829
- }
830
- ) : /* @__PURE__ */ o("div", { className: t.docPreviewEmpty, children: [
831
- /* @__PURE__ */ e(Ie, {}),
832
- " 暂无内容"
833
- ] }) })
834
- ] })
835
- ] })
836
- ] });
837
- }
838
- function oe({ category: a }) {
839
- const n = x((m) => m.token), l = x((m) => m.currentUser), [r, c] = u({ kind: "list" }), [h, s] = u([]), [p, w] = u(!1), N = L(async () => {
840
- w(!0);
841
- try {
842
- const m = await xe({ category: a }, n);
843
- s(Array.isArray(m) ? m : []);
844
- } catch {
845
- } finally {
846
- w(!1);
847
- }
848
- }, [a, n]);
849
- ce(() => {
850
- N();
851
- }, [N]);
852
- const k = L(
853
- async (m) => {
854
- if (!m) {
855
- c({ kind: "editor", resource: null });
856
- return;
857
- }
858
- if (m.docContent !== null && m.docContent !== void 0) {
859
- c({ kind: "editor", resource: m });
860
- return;
861
- }
862
- try {
863
- const C = await Ne(m.id, n);
864
- c({ kind: "editor", resource: C });
865
- } catch {
866
- c({ kind: "list" });
867
- }
868
- },
869
- [n]
870
- );
871
- return r.kind === "editor" ? /* @__PURE__ */ e(
872
- Xt,
873
- {
874
- category: a,
875
- resource: r.resource,
876
- onSaved: (m) => {
877
- c({ kind: "detail", resource: m }), N();
878
- },
879
- onCancel: () => c({ kind: "list" })
880
- }
881
- ) : r.kind === "detail" ? /* @__PURE__ */ e(
882
- Yt,
883
- {
884
- resource: r.resource,
885
- currentUserId: l != null && l.id ? String(l.id) : "",
886
- onBack: () => {
887
- c({ kind: "list" }), N();
888
- },
889
- onEdit: (m) => c({ kind: "editor", resource: m }),
890
- onDeleted: () => {
891
- c({ kind: "list" }), N();
892
- }
893
- }
894
- ) : /* @__PURE__ */ e("div", { className: t.tabBody, children: /* @__PURE__ */ e(
895
- Zt,
896
- {
897
- resources: h,
898
- loading: p,
899
- category: a,
900
- onReload: N,
901
- onCreate: () => c({ kind: "editor", resource: null }),
902
- onOpenDetail: (m) => c({ kind: "detail", resource: m }),
903
- onEdit: (m) => void k(m)
904
- }
905
- ) });
906
- }
907
- function sa() {
908
- const [a, n] = u("browser-plugin");
909
- return /* @__PURE__ */ o("div", { className: t.market, children: [
910
- /* @__PURE__ */ o("div", { className: t.subNav, children: [
911
- /* @__PURE__ */ o(
912
- "button",
913
- {
914
- type: "button",
915
- className: `${t.subNavItem} ${a === "browser-plugin" ? t.subNavItemActive : ""}`,
916
- onClick: () => n("browser-plugin"),
917
- children: [
918
- /* @__PURE__ */ e(De, {}),
919
- " 浏览器插件"
920
- ]
921
- }
922
- ),
923
- /* @__PURE__ */ o(
924
- "button",
925
- {
926
- type: "button",
927
- className: `${t.subNavItem} ${a === "ztools-plugin" ? t.subNavItemActive : ""}`,
928
- onClick: () => n("ztools-plugin"),
929
- title: "z-biz-tool-box 桌面工具箱插件",
930
- children: [
931
- /* @__PURE__ */ e(Pe, {}),
932
- " zTools 插件"
933
- ]
934
- }
935
- ),
936
- /* @__PURE__ */ o(
937
- "button",
938
- {
939
- type: "button",
940
- className: `${t.subNavItem} ${a === "software" ? t.subNavItemActive : ""}`,
941
- onClick: () => n("software"),
942
- title: "z-biz-tool 系列桌面客户端(macOS dmg 安装包)",
943
- children: [
944
- /* @__PURE__ */ e(Re, {}),
945
- " 软件资源"
946
- ]
947
- }
948
- ),
949
- /* @__PURE__ */ o(
950
- "button",
951
- {
952
- type: "button",
953
- className: `${t.subNavItem} ${a === "coming" ? t.subNavItemActive : ""}`,
954
- onClick: () => n("coming"),
955
- title: "更多分类规划中",
956
- children: [
957
- /* @__PURE__ */ e(Oe, {}),
958
- " 更多分类"
959
- ]
960
- }
961
- )
962
- ] }),
963
- a === "browser-plugin" && /* @__PURE__ */ e(oe, { category: "browser-plugin" }),
964
- a === "ztools-plugin" && /* @__PURE__ */ e(oe, { category: "ztools-plugin" }),
965
- a === "software" && /* @__PURE__ */ e(oe, { category: "software" }),
966
- a === "coming" && /* @__PURE__ */ o("div", { className: t.comingSoon, children: [
967
- /* @__PURE__ */ e("div", { className: t.comingSoonIcon, children: "🧩" }),
968
- /* @__PURE__ */ e("div", { className: t.comingSoonTitle, children: "更多分类敬请期待" }),
969
- /* @__PURE__ */ e("div", { className: t.comingSoonDesc, children: "市场将陆续开放脚本工具等更多资源分类" })
970
- ] })
971
- ] });
972
- }
973
- export {
974
- sa as default
975
- };