befly-admin 3.12.7 → 3.12.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly-admin",
3
- "version": "3.12.7",
4
- "gitHead": "1fb5271f37e552345c9531248d4e3fef32175352",
3
+ "version": "3.12.8",
4
+ "gitHead": "c30de9bab631596341b6bc28490579a9923c87d6",
5
5
  "private": false,
6
6
  "description": "Befly Admin - 基于 Vue3 + TDesign Vue Next 的后台管理系统",
7
7
  "files": [
@@ -64,6 +64,11 @@ type DeleteConfirmContent = {
64
64
  status?: "warning" | "danger" | "info" | "success";
65
65
  };
66
66
 
67
+ type ConfirmDialogInstance = {
68
+ destroy?: () => void;
69
+ setConfirmLoading?: (loading: boolean) => void;
70
+ };
71
+
67
72
  type DeleteEndpoint<Row extends TableRowData> = {
68
73
  path: string;
69
74
  idKey?: string;
@@ -373,7 +378,7 @@ async function loadList(options?: LoadListOptions): Promise<void> {
373
378
  if (seq !== requestSeq) {
374
379
  return;
375
380
  }
376
- void showMessageError("加载数据失败");
381
+ void MessagePlugin.error("加载数据失败");
377
382
  } finally {
378
383
  if (seq === requestSeq) {
379
384
  $Data.loading = false;
@@ -451,7 +456,7 @@ function getDeleteConfirmContent(ep: DeleteEndpoint<TableRowData>, row: TableRow
451
456
  async function deleteRow(row: TableRowData): Promise<void> {
452
457
  const ep = props.endpoints?.delete;
453
458
  if (!ep) {
454
- await showMessageError("未配置删除接口");
459
+ MessagePlugin.error("未配置删除接口");
455
460
  return;
456
461
  }
457
462
 
@@ -460,13 +465,13 @@ async function deleteRow(row: TableRowData): Promise<void> {
460
465
  const rawId = record[idKey];
461
466
 
462
467
  if (rawId === null || rawId === undefined || rawId === "") {
463
- await showMessageError("删除失败:缺少主键");
468
+ MessagePlugin.error("删除失败:缺少主键");
464
469
  return;
465
470
  }
466
471
 
467
472
  const confirmContent = getDeleteConfirmContent(ep, row);
468
473
 
469
- let dialog: { destroy?: () => void; setConfirmLoading?: (v: boolean) => void } | null = null;
474
+ let dialog: ConfirmDialogInstance | null = null;
470
475
  let destroyed = false;
471
476
 
472
477
  const destroy = () => {
@@ -477,7 +482,7 @@ async function deleteRow(row: TableRowData): Promise<void> {
477
482
  }
478
483
  };
479
484
 
480
- dialog = await openConfirmDialog({
485
+ dialog = DialogPlugin.confirm({
481
486
  header: confirmContent.header,
482
487
  body: confirmContent.body,
483
488
  status: confirmContent.status || "warning",
@@ -506,12 +511,12 @@ async function deleteRow(row: TableRowData): Promise<void> {
506
511
  dropKeyValue: ep.dropKeyValue
507
512
  });
508
513
 
509
- await showMessageSuccess("删除成功");
514
+ MessagePlugin.success("删除成功");
510
515
  destroy();
511
516
  emit("deleted", { row: row });
512
517
  await reload({ keepSelection: true });
513
518
  } catch (error) {
514
- await showMessageError("删除失败");
519
+ MessagePlugin.error("删除失败");
515
520
  } finally {
516
521
  if (dialog && typeof dialog.setConfirmLoading === "function") {
517
522
  dialog.setConfirmLoading(false);
@@ -206,7 +206,7 @@ async function fetchUserMenus() {
206
206
  $Data.userMenus = treeResult.tree;
207
207
  setActiveMenu();
208
208
  } catch (error) {
209
- void showMessageError("获取用户菜单失败");
209
+ void MessagePlugin.error("获取用户菜单失败");
210
210
  }
211
211
  }
212
212
 
@@ -265,7 +265,7 @@ async function handleLogout() {
265
265
  }
266
266
  };
267
267
 
268
- dialog = await openConfirmDialog({
268
+ dialog = DialogPlugin.confirm({
269
269
  header: "确认退出登录",
270
270
  body: "确定要退出登录吗?",
271
271
  status: "warning",
@@ -277,10 +277,10 @@ async function handleLogout() {
277
277
  try {
278
278
  $Storage.local.remove("token");
279
279
  await router.push(loginPath);
280
- await showMessageSuccess("退出成功");
280
+ MessagePlugin.success("退出成功");
281
281
  destroy();
282
282
  } catch (error) {
283
- await showMessageError("退出失败");
283
+ MessagePlugin.error("退出失败");
284
284
  destroy();
285
285
  } finally {
286
286
  if (dialog && typeof dialog.setConfirmLoading === "function") {
@@ -301,7 +301,7 @@ function handleSettings() {
301
301
  function onAvatarUploadSuccess(res) {
302
302
  if (res.response?.code === 0 && res.response?.data?.url) {
303
303
  $Data.userInfo.avatar = res.response.data.url;
304
- void showMessageSuccess("头像上传成功");
304
+ void MessagePlugin.success("头像上传成功");
305
305
  }
306
306
  }
307
307
 
@@ -73,7 +73,7 @@ function isNormalizedHttpError(value: unknown): value is HttpError {
73
73
  async function showNetworkErrorToast(): Promise<void> {
74
74
  try {
75
75
  // 在测试/非浏览器环境下,提示组件可能不可用;仅在需要展示提示时再加载。
76
- await showMessageError("网络连接失败");
76
+ MessagePlugin.error("网络连接失败");
77
77
  } catch {
78
78
  // ignore
79
79
  }
@@ -59,7 +59,6 @@ declare global {
59
59
  const onUnmounted: typeof import('vue').onUnmounted
60
60
  const onUpdated: typeof import('vue').onUpdated
61
61
  const onWatcherCleanup: typeof import('vue').onWatcherCleanup
62
- const openConfirmDialog: typeof import('../utils/tdesignPlugins').openConfirmDialog
63
62
  const provide: typeof import('vue').provide
64
63
  const reactive: typeof import('vue').reactive
65
64
  const readonly: typeof import('vue').readonly
@@ -71,9 +70,6 @@ declare global {
71
70
  const shallowReactive: typeof import('vue').shallowReactive
72
71
  const shallowReadonly: typeof import('vue').shallowReadonly
73
72
  const shallowRef: typeof import('vue').shallowRef
74
- const showMessageError: typeof import('../utils/tdesignPlugins').showMessageError
75
- const showMessageSuccess: typeof import('../utils/tdesignPlugins').showMessageSuccess
76
- const showMessageWarning: typeof import('../utils/tdesignPlugins').showMessageWarning
77
73
  const storeToRefs: typeof import('pinia').storeToRefs
78
74
  const toRaw: typeof import('vue').toRaw
79
75
  const toRef: typeof import('vue').toRef
@@ -102,9 +98,6 @@ declare global {
102
98
  export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, ShallowRef, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
103
99
  import('vue')
104
100
  // @ts-ignore
105
- export type { ConfirmDialogStatus, ConfirmDialogOptions, ConfirmDialogInstance } from '../utils/tdesignPlugins'
106
- import('../utils/tdesignPlugins')
107
- // @ts-ignore
108
101
  export type { BeflyAdminConfig } from '../plugins/config'
109
102
  import('../plugins/config')
110
103
  // @ts-ignore
@@ -166,7 +159,6 @@ declare module 'vue' {
166
159
  readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
167
160
  readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
168
161
  readonly onWatcherCleanup: UnwrapRef<typeof import('vue')['onWatcherCleanup']>
169
- readonly openConfirmDialog: UnwrapRef<typeof import('../utils/tdesignPlugins')['openConfirmDialog']>
170
162
  readonly provide: UnwrapRef<typeof import('vue')['provide']>
171
163
  readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
172
164
  readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
@@ -177,9 +169,6 @@ declare module 'vue' {
177
169
  readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
178
170
  readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
179
171
  readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
180
- readonly showMessageError: UnwrapRef<typeof import('../utils/tdesignPlugins')['showMessageError']>
181
- readonly showMessageSuccess: UnwrapRef<typeof import('../utils/tdesignPlugins')['showMessageSuccess']>
182
- readonly showMessageWarning: UnwrapRef<typeof import('../utils/tdesignPlugins')['showMessageWarning']>
183
172
  readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
184
173
  readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
185
174
  readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
@@ -1,57 +0,0 @@
1
- let messagePluginPromise: Promise<typeof import("tdesign-vue-next/es/message/plugin")> | null = null;
2
- let dialogPluginPromise: Promise<typeof import("tdesign-vue-next/es/dialog/plugin")> | null = null;
3
-
4
- export async function showMessageSuccess(content: string): Promise<void> {
5
- const mod = await getMessagePlugin();
6
- mod.MessagePlugin.success(content);
7
- }
8
-
9
- export async function showMessageError(content: string): Promise<void> {
10
- const mod = await getMessagePlugin();
11
- mod.MessagePlugin.error(content);
12
- }
13
-
14
- export async function showMessageWarning(content: string): Promise<void> {
15
- const mod = await getMessagePlugin();
16
- mod.MessagePlugin.warning(content);
17
- }
18
-
19
- export type ConfirmDialogStatus = "warning" | "danger" | "info" | "success";
20
-
21
- export type ConfirmDialogOptions = {
22
- header: string;
23
- body: string;
24
- status?: ConfirmDialogStatus;
25
- confirmBtn?: string;
26
- cancelBtn?: string;
27
- onConfirm?: () => void | Promise<void>;
28
- onClose?: () => void;
29
- };
30
-
31
- export type ConfirmDialogInstance = {
32
- destroy?: () => void;
33
- setConfirmLoading?: (loading: boolean) => void;
34
- };
35
-
36
- export async function openConfirmDialog(options: ConfirmDialogOptions): Promise<ConfirmDialogInstance> {
37
- const mod = await getDialogPlugin();
38
- return mod.DialogPlugin.confirm(options);
39
- }
40
-
41
- async function getMessagePlugin(): Promise<typeof import("tdesign-vue-next/es/message/plugin")> {
42
- if (messagePluginPromise) {
43
- return messagePluginPromise;
44
- }
45
-
46
- messagePluginPromise = import("tdesign-vue-next/es/message/plugin");
47
- return messagePluginPromise;
48
- }
49
-
50
- async function getDialogPlugin(): Promise<typeof import("tdesign-vue-next/es/dialog/plugin")> {
51
- if (dialogPluginPromise) {
52
- return dialogPluginPromise;
53
- }
54
-
55
- dialogPluginPromise = import("tdesign-vue-next/es/dialog/plugin");
56
- return dialogPluginPromise;
57
- }