@befly-addon/admin 1.1.30 → 1.1.32

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.
Files changed (111) hide show
  1. package/apis/admin/cacheRefresh.ts +29 -21
  2. package/apis/admin/del.ts +10 -10
  3. package/apis/admin/detail.ts +7 -7
  4. package/apis/admin/ins.ts +11 -11
  5. package/apis/admin/list.ts +10 -10
  6. package/apis/admin/upd.ts +14 -14
  7. package/apis/api/all.ts +8 -8
  8. package/apis/api/list.ts +10 -10
  9. package/apis/auth/login.ts +43 -43
  10. package/apis/auth/sendSmsCode.ts +6 -6
  11. package/apis/dashboard/configStatus.ts +18 -18
  12. package/apis/dashboard/environmentInfo.ts +12 -12
  13. package/apis/dashboard/performanceMetrics.ts +5 -5
  14. package/apis/dashboard/permissionStats.ts +7 -7
  15. package/apis/dashboard/serviceStatus.ts +29 -29
  16. package/apis/dashboard/systemInfo.ts +5 -5
  17. package/apis/dashboard/systemOverview.ts +7 -7
  18. package/apis/dashboard/systemResources.ts +8 -8
  19. package/apis/dict/all.ts +16 -16
  20. package/apis/dict/del.ts +6 -6
  21. package/apis/dict/detail.ts +19 -19
  22. package/apis/dict/ins.ts +9 -9
  23. package/apis/dict/items.ts +8 -8
  24. package/apis/dict/list.ts +22 -22
  25. package/apis/dict/upd.ts +11 -11
  26. package/apis/dictType/all.ts +5 -5
  27. package/apis/dictType/del.ts +8 -8
  28. package/apis/dictType/detail.ts +6 -6
  29. package/apis/dictType/ins.ts +7 -7
  30. package/apis/dictType/list.ts +8 -10
  31. package/apis/dictType/upd.ts +8 -8
  32. package/apis/email/config.ts +4 -4
  33. package/apis/email/logList.ts +8 -8
  34. package/apis/email/send.ts +18 -18
  35. package/apis/email/verify.ts +5 -5
  36. package/apis/loginLog/list.ts +8 -8
  37. package/apis/menu/all.ts +16 -18
  38. package/apis/menu/list.ts +12 -12
  39. package/apis/operateLog/list.ts +8 -8
  40. package/apis/role/all.ts +7 -7
  41. package/apis/role/apiSave.ts +10 -13
  42. package/apis/role/apis.ts +7 -12
  43. package/apis/role/del.ts +14 -14
  44. package/apis/role/detail.ts +6 -6
  45. package/apis/role/ins.ts +10 -10
  46. package/apis/role/list.ts +11 -11
  47. package/apis/role/menuSave.ts +8 -11
  48. package/apis/role/menus.ts +7 -12
  49. package/apis/role/save.ts +12 -12
  50. package/apis/role/upd.ts +10 -10
  51. package/apis/sysConfig/all.ts +5 -5
  52. package/apis/sysConfig/del.ts +9 -9
  53. package/apis/sysConfig/get.ts +9 -9
  54. package/apis/sysConfig/ins.ts +11 -11
  55. package/apis/sysConfig/list.ts +9 -9
  56. package/apis/sysConfig/upd.ts +10 -10
  57. package/libs/emailHelper.ts +7 -7
  58. package/package.json +46 -34
  59. package/plugins/email.ts +9 -9
  60. package/tables/role.json +4 -2
  61. package/views/403_1/index.vue +19 -3
  62. package/views/config/dict/components/edit.vue +26 -28
  63. package/views/config/dict/index.vue +88 -52
  64. package/views/config/dictType/components/edit.vue +22 -23
  65. package/views/config/dictType/index.vue +82 -46
  66. package/views/config/index.vue +12 -0
  67. package/views/config/system/components/edit.vue +36 -36
  68. package/views/config/system/index.vue +79 -50
  69. package/views/index/components/addonList.vue +3 -3
  70. package/views/index/components/environmentInfo.vue +10 -10
  71. package/views/index/components/operationLogs.vue +10 -10
  72. package/views/index/components/performanceMetrics.vue +8 -8
  73. package/views/index/components/quickActions.vue +3 -3
  74. package/views/index/components/serviceStatus.vue +19 -19
  75. package/views/index/components/systemNotifications.vue +12 -12
  76. package/views/index/components/systemOverview.vue +7 -7
  77. package/views/index/components/systemResources.vue +11 -11
  78. package/views/index/components/userInfo.vue +20 -19
  79. package/views/index/index.vue +12 -5
  80. package/views/log/email/index.vue +58 -51
  81. package/views/log/index.vue +12 -0
  82. package/views/log/login/index.vue +45 -38
  83. package/views/log/operate/index.vue +55 -48
  84. package/views/login_1/index.vue +25 -18
  85. package/views/people/admin/components/edit.vue +25 -26
  86. package/views/people/admin/index.vue +76 -40
  87. package/views/people/index.vue +12 -0
  88. package/views/permission/api/index.vue +21 -15
  89. package/views/permission/index.vue +12 -0
  90. package/views/permission/menu/index.vue +31 -16
  91. package/views/permission/role/components/api.vue +21 -21
  92. package/views/permission/role/components/edit.vue +18 -18
  93. package/views/permission/role/components/menu.vue +14 -16
  94. package/views/permission/role/index.vue +84 -49
  95. package/views/403_1/meta.json +0 -4
  96. package/views/config/dict/meta.json +0 -4
  97. package/views/config/dictType/meta.json +0 -4
  98. package/views/config/meta.json +0 -4
  99. package/views/config/system/meta.json +0 -4
  100. package/views/index/meta.json +0 -4
  101. package/views/log/email/meta.json +0 -4
  102. package/views/log/login/meta.json +0 -4
  103. package/views/log/meta.json +0 -4
  104. package/views/log/operate/meta.json +0 -4
  105. package/views/login_1/meta.json +0 -4
  106. package/views/people/admin/meta.json +0 -4
  107. package/views/people/meta.json +0 -4
  108. package/views/permission/api/meta.json +0 -4
  109. package/views/permission/menu/meta.json +0 -4
  110. package/views/permission/meta.json +0 -4
  111. package/views/permission/role/meta.json +0 -4
@@ -45,10 +45,10 @@ import {
45
45
  Radio as TRadio,
46
46
  Button as TButton,
47
47
  MessagePlugin
48
- } from 'tdesign-vue-next';
49
- import { $Http } from '@/plugins/http';
50
- import { fieldClear } from 'befly-shared/fieldClear';
51
- import { hashPassword } from 'befly-shared/hashPassword';
48
+ } from "tdesign-vue-next";
49
+ import { $Http } from "@/plugins/http";
50
+ import { fieldClear } from "befly-vite/utils/fieldClear";
51
+ import { hashPassword } from "befly-vite/utils/hashPassword";
52
52
 
53
53
  const $Prop = defineProps({
54
54
  modelValue: {
@@ -57,7 +57,7 @@ const $Prop = defineProps({
57
57
  },
58
58
  actionType: {
59
59
  type: String,
60
- default: 'add'
60
+ default: "add"
61
61
  },
62
62
  rowData: {
63
63
  type: Object,
@@ -65,7 +65,7 @@ const $Prop = defineProps({
65
65
  }
66
66
  });
67
67
 
68
- const $Emit = defineEmits(['update:modelValue', 'success']);
68
+ const $Emit = defineEmits(["update:modelValue", "success"]);
69
69
 
70
70
  // 表单引用
71
71
  const $From = $shallowRef({
@@ -77,14 +77,14 @@ const $Data = $ref({
77
77
  submitting: false,
78
78
  allRoleLists: [],
79
79
  keys: {
80
- label: 'name',
81
- value: 'code'
80
+ label: "name",
81
+ value: "code"
82
82
  },
83
83
  formData: {
84
84
  id: null,
85
- username: '',
86
- password: '',
87
- nickname: '',
85
+ username: "",
86
+ password: "",
87
+ nickname: "",
88
88
  roleCode: null,
89
89
  state: 1
90
90
  }
@@ -92,13 +92,13 @@ const $Data = $ref({
92
92
 
93
93
  const $Data2 = $shallowRef({
94
94
  formRules: {
95
- username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
95
+ username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
96
96
  password: [
97
- { required: true, message: '请输入密码', trigger: 'blur' },
98
- { min: 6, message: '密码至少6位', trigger: 'blur' }
97
+ { required: true, message: "请输入密码", trigger: "blur" },
98
+ { min: 6, message: "密码至少6位", trigger: "blur" }
99
99
  ],
100
- roleCode: [{ required: true, message: '请选择角色', trigger: 'change' }],
101
- nickname: [{ min: 2, max: 50, message: '昵称长度在 2 到 50 个字符', trigger: 'blur' }]
100
+ roleCode: [{ required: true, message: "请选择角色", trigger: "change" }],
101
+ nickname: [{ min: 2, max: 50, message: "昵称长度在 2 到 50 个字符", trigger: "blur" }]
102
102
  }
103
103
  });
104
104
 
@@ -107,7 +107,7 @@ const $Method = {
107
107
  async initData() {
108
108
  $Method.onShow();
109
109
  await $Method.apiRoleLists();
110
- if ($Prop.actionType === 'upd' && $Prop.rowData.id) {
110
+ if ($Prop.actionType === "upd" && $Prop.rowData.id) {
111
111
  $Data.formData = { ...$Prop.rowData };
112
112
  }
113
113
  },
@@ -121,17 +121,16 @@ const $Method = {
121
121
  onClose() {
122
122
  $Data.visible = false;
123
123
  setTimeout(() => {
124
- $Emit('update:modelValue', false);
124
+ $Emit("update:modelValue", false);
125
125
  }, 300);
126
126
  },
127
127
 
128
128
  async apiRoleLists() {
129
129
  try {
130
- const result = await $Http('/addon/admin/role/all');
130
+ const result = await $Http("/addon/admin/role/all");
131
131
  $Data.allRoleLists = result.data || [];
132
132
  } catch (error) {
133
- console.error('加载角色列表失败:', error);
134
- MessagePlugin.error('加载角色列表失败');
133
+ MessagePlugin.error("加载角色列表失败");
135
134
  }
136
135
  },
137
136
 
@@ -141,20 +140,20 @@ const $Method = {
141
140
  if (!valid) return;
142
141
 
143
142
  $Data.submitting = true;
144
- const formData = $Prop.actionType === 'add' ? fieldClear($Data.formData, { omitKeys: ['id', 'state'] }) : fieldClear($Data.formData, { omitKeys: ['password'] });
143
+ const formData = $Prop.actionType === "add" ? fieldClear($Data.formData, { omitKeys: ["id", "state"] }) : fieldClear($Data.formData, { omitKeys: ["password"] });
145
144
 
146
145
  // 添加管理员时,对密码进行 SHA-256 加密
147
- if ($Prop.actionType === 'add' && formData.password) {
146
+ if ($Prop.actionType === "add" && formData.password) {
148
147
  formData.password = await hashPassword(formData.password);
149
148
  }
150
149
 
151
- const result = await $Http($Prop.actionType === 'upd' ? '/addon/admin/admin/upd' : '/addon/admin/admin/ins', formData);
150
+ const result = await $Http($Prop.actionType === "upd" ? "/addon/admin/admin/upd" : "/addon/admin/admin/ins", formData);
152
151
 
153
152
  MessagePlugin.success(result.msg);
154
- $Emit('success');
153
+ $Emit("success");
155
154
  $Method.onClose();
156
155
  } catch (error) {
157
- MessagePlugin.error(error.msg || '提交失败');
156
+ MessagePlugin.error(error.msg || "提交失败");
158
157
  } finally {
159
158
  $Data.submitting = false;
160
159
  }
@@ -19,7 +19,16 @@
19
19
 
20
20
  <div class="main-content">
21
21
  <div class="main-table">
22
- <TTable :data="$Data.tableData" :columns="$Data.columns" :loading="$Data.loading" :active-row-keys="$Data.activeRowKeys" row-key="id" height="calc(100vh - var(--search-height) - var(--pagination-height) - var(--layout-gap) * 4)" active-row-type="single" @active-change="$Method.onActiveChange">
22
+ <TTable
23
+ :data="$Data.tableData"
24
+ :columns="$Data.columns"
25
+ :loading="$Data.loading"
26
+ :active-row-keys="$Data.activeRowKeys"
27
+ row-key="id"
28
+ height="calc(100vh - var(--search-height) - var(--pagination-height) - var(--layout-gap) * 4)"
29
+ active-row-type="single"
30
+ @active-change="$Method.onActiveChange"
31
+ >
23
32
  <template #state="{ row }">
24
33
  <TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
25
34
  <TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
@@ -61,38 +70,45 @@
61
70
  </template>
62
71
 
63
72
  <script setup>
64
- import { Button as TButton, Table as TTable, Tag as TTag, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from 'tdesign-vue-next';
65
- import ILucidePlus from '~icons/lucide/plus';
66
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
67
- import ILucidePencil from '~icons/lucide/pencil';
68
- import ILucideTrash2 from '~icons/lucide/trash-2';
69
- import ILucideChevronDown from '~icons/lucide/chevron-down';
70
- import EditDialog from './components/edit.vue';
71
- import DetailPanel from '@/components/DetailPanel.vue';
72
- import { $Http } from '@/plugins/http';
73
- import { withDefaultColumns } from 'befly-shared/withDefaultColumns';
73
+ import { Button as TButton, Table as TTable, Tag as TTag, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from "tdesign-vue-next";
74
+ import ILucidePlus from "~icons/lucide/plus";
75
+ import ILucideRotateCw from "~icons/lucide/rotate-cw";
76
+ import ILucidePencil from "~icons/lucide/pencil";
77
+ import ILucideTrash2 from "~icons/lucide/trash-2";
78
+ import ILucideChevronDown from "~icons/lucide/chevron-down";
79
+ import EditDialog from "./components/edit.vue";
80
+ import DetailPanel from "@/components/DetailPanel.vue";
81
+ import { $Http } from "@/plugins/http";
82
+ import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
83
+
84
+ definePage({
85
+ meta: {
86
+ title: "管理员",
87
+ order: 1
88
+ }
89
+ });
74
90
 
75
91
  // 响应式数据
76
92
  const $Data = $ref({
77
93
  tableData: [],
78
94
  loading: false,
79
95
  columns: withDefaultColumns([
80
- { colKey: 'username', title: '用户名', fixed: 'left' },
81
- { colKey: 'id', title: '序号' },
82
- { colKey: 'nickname', title: '昵称' },
83
- { colKey: 'roleCode', title: '角色' },
84
- { colKey: 'state', title: '状态' },
85
- { colKey: 'operation', title: '操作' }
96
+ { colKey: "username", title: "用户名", fixed: "left" },
97
+ { colKey: "id", title: "序号" },
98
+ { colKey: "nickname", title: "昵称" },
99
+ { colKey: "roleCode", title: "角色" },
100
+ { colKey: "state", title: "状态" },
101
+ { colKey: "operation", title: "操作" }
86
102
  ]),
87
103
  pagerConfig: {
88
104
  currentPage: 1,
89
105
  limit: 30,
90
106
  total: 0,
91
- align: 'right',
92
- layout: 'total, prev, pager, next, jumper'
107
+ align: "right",
108
+ layout: "total, prev, pager, next, jumper"
93
109
  },
94
110
  editVisible: false,
95
- actionType: 'add',
111
+ actionType: "add",
96
112
  rowData: {},
97
113
  currentRow: null,
98
114
  activeRowKeys: []
@@ -108,7 +124,7 @@ const $Method = {
108
124
  async apiAdminList() {
109
125
  $Data.loading = true;
110
126
  try {
111
- const res = await $Http('/addon/admin/admin/list', {
127
+ const res = await $Http("/addon/admin/admin/list", {
112
128
  page: $Data.pagerConfig.currentPage,
113
129
  limit: $Data.pagerConfig.limit
114
130
  });
@@ -124,8 +140,7 @@ const $Method = {
124
140
  $Data.activeRowKeys = [];
125
141
  }
126
142
  } catch (error) {
127
- console.error('加载管理员列表失败:', error);
128
- MessagePlugin.error('加载数据失败');
143
+ MessagePlugin.error("加载数据失败");
129
144
  } finally {
130
145
  $Data.loading = false;
131
146
  }
@@ -133,22 +148,43 @@ const $Method = {
133
148
 
134
149
  // 删除管理员
135
150
  async apiAdminDel(row) {
136
- DialogPlugin.confirm({
137
- header: '确认删除',
138
- body: `确定要删除管理员“${row.username}” 吗?`,
139
- status: 'warning'
140
- }).then(async () => {
141
- try {
142
- const res = await $Http('/addon/admin/admin/del', { id: row.id });
143
- if (res.code === 0) {
144
- MessagePlugin.success('删除成功');
145
- $Method.apiAdminList();
146
- } else {
147
- MessagePlugin.error(res.msg || '删除失败');
151
+ let dialog = null;
152
+ let destroyed = false;
153
+
154
+ const destroy = () => {
155
+ if (destroyed) return;
156
+ destroyed = true;
157
+ if (dialog && typeof dialog.destroy === "function") {
158
+ dialog.destroy();
159
+ }
160
+ };
161
+
162
+ dialog = DialogPlugin.confirm({
163
+ header: "确认删除",
164
+ body: `确认删除管理员“${row.username}”吗?`,
165
+ status: "warning",
166
+ confirmBtn: "删除",
167
+ cancelBtn: "取消",
168
+ onConfirm: async () => {
169
+ if (dialog && typeof dialog.setConfirmLoading === "function") {
170
+ dialog.setConfirmLoading(true);
171
+ }
172
+
173
+ try {
174
+ await $Http("/addon/admin/admin/del", { id: row.id });
175
+ MessagePlugin.success("删除成功");
176
+ destroy();
177
+ await $Method.apiAdminList();
178
+ } catch (error) {
179
+ MessagePlugin.error("删除失败");
180
+ } finally {
181
+ if (dialog && typeof dialog.setConfirmLoading === "function") {
182
+ dialog.setConfirmLoading(false);
183
+ }
148
184
  }
149
- } catch (error) {
150
- console.error('删除失败:', error);
151
- MessagePlugin.error('删除失败');
185
+ },
186
+ onClose: () => {
187
+ destroy();
152
188
  }
153
189
  });
154
190
  },
@@ -188,9 +224,9 @@ const $Method = {
188
224
  onAction(command, rowData) {
189
225
  $Data.actionType = command;
190
226
  $Data.rowData = rowData;
191
- if (command === 'add' || command === 'upd') {
227
+ if (command === "add" || command === "upd") {
192
228
  $Data.editVisible = true;
193
- } else if (command === 'del') {
229
+ } else if (command === "del") {
194
230
  $Method.apiAdminDel(rowData);
195
231
  }
196
232
  }
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <RouterView />
3
+ </template>
4
+
5
+ <script setup>
6
+ definePage({
7
+ meta: {
8
+ title: "人员管理",
9
+ order: 10
10
+ }
11
+ });
12
+ </script>
@@ -51,25 +51,32 @@
51
51
  </template>
52
52
 
53
53
  <script setup>
54
- import { Button as TButton, Table as TTable, Tag as TTag, Input as TInput, MessagePlugin } from 'tdesign-vue-next';
55
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
56
- import ILucideSearch from '~icons/lucide/search';
57
- import { $Http } from '@/plugins/http';
58
- import { withDefaultColumns } from 'befly-shared/withDefaultColumns';
59
- import DetailPanel from '@/components/DetailPanel.vue';
54
+ import { Button as TButton, Table as TTable, Tag as TTag, Input as TInput, MessagePlugin } from "tdesign-vue-next";
55
+ import ILucideRotateCw from "~icons/lucide/rotate-cw";
56
+ import ILucideSearch from "~icons/lucide/search";
57
+ import { $Http } from "@/plugins/http";
58
+ import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
59
+ import DetailPanel from "@/components/DetailPanel.vue";
60
+
61
+ definePage({
62
+ meta: {
63
+ title: "接口列表",
64
+ order: 3
65
+ }
66
+ });
60
67
 
61
68
  // 响应式数据
62
69
  const $Data = $ref({
63
70
  tableData: [],
64
71
  allData: [],
65
72
  loading: false,
66
- searchKeyword: '',
73
+ searchKeyword: "",
67
74
  columns: withDefaultColumns([
68
- { colKey: 'name', title: '接口名称' },
69
- { colKey: 'id', title: '序号' },
70
- { colKey: 'path', title: '接口路径' },
71
- { colKey: 'method', title: '请求方法' },
72
- { colKey: 'addonName', title: '所属组件' }
75
+ { colKey: "name", title: "接口名称" },
76
+ { colKey: "id", title: "序号" },
77
+ { colKey: "path", title: "接口路径" },
78
+ { colKey: "method", title: "请求方法" },
79
+ { colKey: "addonName", title: "所属组件" }
73
80
  ]),
74
81
  currentRow: null,
75
82
  activeRowKeys: []
@@ -85,7 +92,7 @@ const $Method = {
85
92
  async loadApiAll() {
86
93
  $Data.loading = true;
87
94
  try {
88
- const res = await $Http('/addon/admin/api/all');
95
+ const res = await $Http("/addon/admin/api/all");
89
96
  const list = res.data?.lists || [];
90
97
  $Data.allData = list;
91
98
  $Data.tableData = list;
@@ -99,8 +106,7 @@ const $Method = {
99
106
  $Data.activeRowKeys = [];
100
107
  }
101
108
  } catch (error) {
102
- console.error('加载接口列表失败:', error);
103
- MessagePlugin.error('加载数据失败');
109
+ MessagePlugin.error("加载数据失败");
104
110
  } finally {
105
111
  $Data.loading = false;
106
112
  }
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <RouterView />
3
+ </template>
4
+
5
+ <script setup>
6
+ definePage({
7
+ meta: {
8
+ title: "权限设置",
9
+ order: 20
10
+ }
11
+ });
12
+ </script>
@@ -13,7 +13,17 @@
13
13
 
14
14
  <div class="main-content">
15
15
  <div class="main-table">
16
- <TTable v-bind="withTreeTableProps()" :data="$Data.tableData" :columns="$Data.columns" :loading="$Data.loading" :active-row-keys="$Data.activeRowKeys" row-key="id" height="calc(100vh - var(--search-height) - var(--layout-gap) * 2)" active-row-type="single" @active-change="$Method.onActiveChange">
16
+ <TTable
17
+ :data="$Data.tableData"
18
+ :columns="$Data.columns"
19
+ :loading="$Data.loading"
20
+ :active-row-keys="$Data.activeRowKeys"
21
+ row-key="id"
22
+ height="calc(100vh - var(--search-height) - var(--layout-gap) * 2)"
23
+ active-row-type="single"
24
+ :tree="{ childrenKey: 'children', treeNodeColumnIndex: 0, defaultExpandAll: true }"
25
+ @active-change="$Method.onActiveChange"
26
+ >
17
27
  <template #state="{ row }">
18
28
  <TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
19
29
  <TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
@@ -30,24 +40,30 @@
30
40
  </template>
31
41
 
32
42
  <script setup>
33
- import { Button as TButton, Table as TTable, Tag as TTag, MessagePlugin } from 'tdesign-vue-next';
34
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
35
- import DetailPanel from '@/components/DetailPanel.vue';
36
- import { $Http } from '@/plugins/http';
37
- import { withDefaultColumns } from 'befly-shared/withDefaultColumns';
38
- import { withTreeTableProps } from '@/utils';
43
+ import { Button as TButton, Table as TTable, Tag as TTag, MessagePlugin } from "tdesign-vue-next";
44
+ import ILucideRotateCw from "~icons/lucide/rotate-cw";
45
+ import DetailPanel from "@/components/DetailPanel.vue";
46
+ import { $Http } from "@/plugins/http";
47
+ import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
48
+
49
+ definePage({
50
+ meta: {
51
+ title: "菜单列表",
52
+ order: 2
53
+ }
54
+ });
39
55
 
40
56
  // 响应式数据
41
57
  const $Data = $ref({
42
58
  tableData: [],
43
59
  loading: false,
44
60
  columns: withDefaultColumns([
45
- { colKey: 'name', title: '菜单名称', fixed: 'left' },
46
- { colKey: 'id', title: '序号' },
47
- { colKey: 'path', title: '路由路径' },
48
- { colKey: 'icon', title: '图标' },
49
- { colKey: 'sort', title: '排序' },
50
- { colKey: 'state', title: '状态' }
61
+ { colKey: "name", title: "菜单名称", fixed: "left" },
62
+ { colKey: "id", title: "序号" },
63
+ { colKey: "path", title: "路由路径" },
64
+ { colKey: "icon", title: "图标" },
65
+ { colKey: "sort", title: "排序" },
66
+ { colKey: "state", title: "状态" }
51
67
  ]),
52
68
  currentRow: null,
53
69
  activeRowKeys: []
@@ -63,7 +79,7 @@ const $Method = {
63
79
  async apiMenuList() {
64
80
  $Data.loading = true;
65
81
  try {
66
- const res = await $Http('/addon/admin/menu/list');
82
+ const res = await $Http("/addon/admin/menu/list");
67
83
  // 构建树形结构
68
84
  $Data.tableData = $Method.buildTree(res.data || []);
69
85
 
@@ -76,8 +92,7 @@ const $Method = {
76
92
  $Data.activeRowKeys = [];
77
93
  }
78
94
  } catch (error) {
79
- console.error('加载菜单列表失败:', error);
80
- MessagePlugin.error('加载数据失败');
95
+ MessagePlugin.error("加载数据失败");
81
96
  } finally {
82
97
  $Data.loading = false;
83
98
  }
@@ -16,7 +16,9 @@
16
16
  <div class="group-header">{{ group.title }}</div>
17
17
  <div class="api-checkbox-list">
18
18
  <TCheckboxGroup v-model="$Data.checkedApiIds">
19
- <TCheckbox v-for="api in group.apis" :key="api.id" :value="api.id"> {{ api.label }} </TCheckbox>
19
+ <TCheckbox v-for="api in group.apis" :key="api.id" :value="api.id">
20
+ {{ api.label }}
21
+ </TCheckbox>
20
22
  </TCheckboxGroup>
21
23
  </div>
22
24
  </div>
@@ -35,9 +37,9 @@
35
37
  </template>
36
38
 
37
39
  <script setup>
38
- import { Dialog as TDialog, Input as TInput, CheckboxGroup as TCheckboxGroup, Checkbox as TCheckbox, Button as TButton, MessagePlugin } from 'tdesign-vue-next';
39
- import ILucideSearch from '~icons/lucide/search';
40
- import { $Http } from '@/plugins/http';
40
+ import { Dialog as TDialog, Input as TInput, CheckboxGroup as TCheckboxGroup, Checkbox as TCheckbox, Button as TButton, MessagePlugin } from "tdesign-vue-next";
41
+ import ILucideSearch from "~icons/lucide/search";
42
+ import { $Http } from "@/plugins/http";
41
43
 
42
44
  const $Prop = defineProps({
43
45
  modelValue: {
@@ -50,14 +52,14 @@ const $Prop = defineProps({
50
52
  }
51
53
  });
52
54
 
53
- const $Emit = defineEmits(['update:modelValue', 'success']);
55
+ const $Emit = defineEmits(["update:modelValue", "success"]);
54
56
 
55
57
  const $Data = $ref({
56
58
  visible: false,
57
59
  submitting: false,
58
60
  apiData: [],
59
61
  filteredApiData: [],
60
- searchText: '',
62
+ searchText: "",
61
63
  checkedApiIds: []
62
64
  });
63
65
 
@@ -78,21 +80,21 @@ const $Method = {
78
80
  onClose() {
79
81
  $Data.visible = false;
80
82
  setTimeout(() => {
81
- $Emit('update:modelValue', false);
83
+ $Emit("update:modelValue", false);
82
84
  }, 300);
83
85
  },
84
86
 
85
87
  // 加载所有接口
86
88
  async apiApiAll() {
87
89
  try {
88
- const res = await $Http('/addon/admin/api/all');
90
+ const res = await $Http("/addon/admin/api/all");
89
91
 
90
92
  // 将接口列表按 addonTitle 分组
91
93
  const apiMap = new Map();
92
94
 
93
95
  res.data.lists.forEach((api) => {
94
- const addonTitle = api.addonTitle || api.addonName || '项目接口';
95
- const addonName = api.addonName || 'project';
96
+ const addonTitle = api.addonTitle || api.addonName || "项目接口";
97
+ const addonName = api.addonName || "project";
96
98
 
97
99
  if (!apiMap.has(addonName)) {
98
100
  apiMap.set(addonName, {
@@ -111,8 +113,7 @@ const $Method = {
111
113
 
112
114
  $Data.apiData = Array.from(apiMap.values());
113
115
  } catch (error) {
114
- console.error('加载接口失败:', error);
115
- MessagePlugin.error('加载接口失败');
116
+ MessagePlugin.error("加载接口失败");
116
117
  }
117
118
  },
118
119
 
@@ -121,13 +122,13 @@ const $Method = {
121
122
  if (!$Prop.rowData.id) return;
122
123
 
123
124
  try {
124
- const res = await $Http('/addon/admin/role/apis', {
125
+ const res = await $Http("/addon/admin/role/apis", {
125
126
  roleCode: $Prop.rowData.code
126
127
  });
127
128
 
128
129
  $Data.checkedApiIds = res.data.apiIds || [];
129
130
  } catch (error) {
130
- console.error('加载角色接口失败:', error);
131
+ MessagePlugin.error("加载数据失败");
131
132
  }
132
133
  },
133
134
 
@@ -152,21 +153,20 @@ const $Method = {
152
153
  try {
153
154
  $Data.submitting = true;
154
155
 
155
- const res = await $Http('/addon/admin/role/apiSave', {
156
+ const res = await $Http("/addon/admin/role/apiSave", {
156
157
  roleCode: $Prop.rowData.code,
157
158
  apiIds: $Data.checkedApiIds
158
159
  });
159
160
 
160
161
  if (res.code === 0) {
161
- MessagePlugin.success('保存成功');
162
+ MessagePlugin.success("保存成功");
162
163
  $Data.visible = false;
163
- $Emit('success');
164
+ $Emit("success");
164
165
  } else {
165
- MessagePlugin.error(res.msg || '保存失败');
166
+ MessagePlugin.error(res.msg || "保存失败");
166
167
  }
167
168
  } catch (error) {
168
- console.error('保存失败:', error);
169
- MessagePlugin.error('保存失败');
169
+ MessagePlugin.error("保存失败");
170
170
  } finally {
171
171
  $Data.submitting = false;
172
172
  }
@@ -215,7 +215,7 @@ $Method.initData();
215
215
  gap: 8px;
216
216
 
217
217
  &::before {
218
- content: '';
218
+ content: "";
219
219
  width: 8px;
220
220
  height: 8px;
221
221
  border-radius: 50%;