@befly-addon/admin 1.0.55 → 1.0.57

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 (61) hide show
  1. package/apis/admin/ins.ts +11 -15
  2. package/apis/admin/upd.ts +1 -13
  3. package/apis/auth/login.ts +49 -5
  4. package/apis/email/config.ts +16 -0
  5. package/apis/email/logList.ts +13 -0
  6. package/apis/email/send.ts +42 -0
  7. package/apis/email/verify.ts +12 -0
  8. package/apis/loginLog/list.ts +13 -0
  9. package/apis/operateLog/list.ts +13 -0
  10. package/apis/sysConfig/all.ts +12 -0
  11. package/apis/sysConfig/del.ts +30 -0
  12. package/apis/sysConfig/get.ts +31 -0
  13. package/apis/sysConfig/ins.ts +38 -0
  14. package/apis/sysConfig/list.ts +14 -0
  15. package/apis/sysConfig/upd.ts +50 -0
  16. package/package.json +14 -3
  17. package/plugins/email.ts +206 -0
  18. package/styles/variables.scss +121 -60
  19. package/tables/admin.json +12 -15
  20. package/tables/emailLog.json +69 -0
  21. package/tables/loginLog.json +96 -0
  22. package/tables/operateLog.json +82 -0
  23. package/tables/role.json +1 -1
  24. package/tables/sysConfig.json +53 -0
  25. package/views/403_1/meta.json +4 -0
  26. package/views/{dict → config/dict}/index.vue +27 -38
  27. package/views/config/dict/meta.json +4 -0
  28. package/views/config/meta.json +4 -0
  29. package/views/config/system/components/edit.vue +179 -0
  30. package/views/config/system/index.vue +256 -0
  31. package/views/config/system/meta.json +4 -0
  32. package/views/index/index.vue +46 -9
  33. package/views/index/meta.json +4 -0
  34. package/views/log/email/index.vue +285 -0
  35. package/views/log/email/meta.json +4 -0
  36. package/views/log/login/index.vue +180 -0
  37. package/views/log/login/meta.json +4 -0
  38. package/views/log/meta.json +4 -0
  39. package/views/log/operate/index.vue +242 -0
  40. package/views/log/operate/meta.json +4 -0
  41. package/views/login_1/meta.json +4 -0
  42. package/views/{admin → people/admin}/components/edit.vue +22 -24
  43. package/views/{admin → people/admin}/index.vue +21 -61
  44. package/views/people/admin/meta.json +4 -0
  45. package/views/people/meta.json +4 -0
  46. package/views/{api → permission/api}/index.vue +17 -55
  47. package/views/permission/api/meta.json +4 -0
  48. package/views/{menu → permission/menu}/index.vue +17 -56
  49. package/views/permission/menu/meta.json +4 -0
  50. package/views/permission/meta.json +4 -0
  51. package/views/{role → permission/role}/components/api.vue +13 -38
  52. package/views/{role → permission/role}/components/edit.vue +9 -8
  53. package/views/{role → permission/role}/components/menu.vue +2 -25
  54. package/views/{role → permission/role}/index.vue +27 -36
  55. package/views/permission/role/meta.json +4 -0
  56. /package/views/{403 → 403_1}/index.vue +0 -0
  57. /package/views/{dict → config/dict}/components/edit.vue +0 -0
  58. /package/views/{login → login_1}/components/emailLoginForm.vue +0 -0
  59. /package/views/{login → login_1}/components/registerForm.vue +0 -0
  60. /package/views/{login → login_1}/components/welcomePanel.vue +0 -0
  61. /package/views/{login/index_1.vue → login_1/index.vue} +0 -0
@@ -0,0 +1,82 @@
1
+ {
2
+ "adminId": {
3
+ "name": "管理员ID",
4
+ "type": "number",
5
+ "min": 0,
6
+ "max": 999999999999999,
7
+ "index": true
8
+ },
9
+ "username": {
10
+ "name": "用户名",
11
+ "type": "string",
12
+ "min": 1,
13
+ "max": 50
14
+ },
15
+ "nickname": {
16
+ "name": "昵称",
17
+ "type": "string",
18
+ "max": 50
19
+ },
20
+ "ip": {
21
+ "name": "操作IP",
22
+ "type": "string",
23
+ "max": 50,
24
+ "index": true
25
+ },
26
+ "module": {
27
+ "name": "操作模块",
28
+ "type": "string",
29
+ "max": 50,
30
+ "index": true
31
+ },
32
+ "action": {
33
+ "name": "操作类型",
34
+ "type": "string",
35
+ "max": 50,
36
+ "index": true
37
+ },
38
+ "method": {
39
+ "name": "请求方法",
40
+ "type": "string",
41
+ "max": 10
42
+ },
43
+ "path": {
44
+ "name": "请求路径",
45
+ "type": "string",
46
+ "max": 200
47
+ },
48
+ "params": {
49
+ "name": "请求参数",
50
+ "type": "text"
51
+ },
52
+ "result": {
53
+ "name": "操作结果",
54
+ "type": "number",
55
+ "min": 0,
56
+ "max": 1,
57
+ "default": 1,
58
+ "comment": "1成功 0失败"
59
+ },
60
+ "response": {
61
+ "name": "响应内容",
62
+ "type": "text"
63
+ },
64
+ "duration": {
65
+ "name": "耗时毫秒",
66
+ "type": "number",
67
+ "min": 0,
68
+ "max": 999999999
69
+ },
70
+ "operateTime": {
71
+ "name": "操作时间",
72
+ "type": "number",
73
+ "min": 0,
74
+ "max": 9999999999999,
75
+ "index": true
76
+ },
77
+ "remark": {
78
+ "name": "备注",
79
+ "type": "string",
80
+ "max": 500
81
+ }
82
+ }
package/tables/role.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "min": 2,
13
13
  "max": 50,
14
14
  "index": true,
15
- "regexp": "@alphanumeric_"
15
+ "regexp": "@alphanumericDash_"
16
16
  },
17
17
  "description": {
18
18
  "name": "角色描述",
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": {
3
+ "name": "配置名称",
4
+ "type": "string",
5
+ "min": 2,
6
+ "max": 50
7
+ },
8
+ "code": {
9
+ "name": "配置代码",
10
+ "type": "string",
11
+ "min": 2,
12
+ "max": 100,
13
+ "unique": true,
14
+ "regexp": "@alphanumeric_"
15
+ },
16
+ "value": {
17
+ "name": "配置值",
18
+ "type": "text"
19
+ },
20
+ "valueType": {
21
+ "name": "值类型",
22
+ "type": "string",
23
+ "max": 20,
24
+ "default": "string",
25
+ "comment": "string number boolean json"
26
+ },
27
+ "group": {
28
+ "name": "配置分组",
29
+ "type": "string",
30
+ "max": 50,
31
+ "index": true
32
+ },
33
+ "sort": {
34
+ "name": "排序",
35
+ "type": "number",
36
+ "min": 0,
37
+ "max": 9999,
38
+ "default": 0
39
+ },
40
+ "isSystem": {
41
+ "name": "是否系统配置",
42
+ "type": "number",
43
+ "min": 0,
44
+ "max": 1,
45
+ "default": 0,
46
+ "comment": "1是 0否"
47
+ },
48
+ "description": {
49
+ "name": "描述说明",
50
+ "type": "string",
51
+ "max": 500
52
+ }
53
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "403",
3
+ "order": 101
4
+ }
@@ -9,7 +9,7 @@
9
9
  </TButton>
10
10
  </div>
11
11
  <div class="right">
12
- <TButton @click="$Method.handleRefresh">
12
+ <TButton shape="circle" @click="$Method.handleRefresh">
13
13
  <template #icon>
14
14
  <ILucideRotateCw />
15
15
  </template>
@@ -18,15 +18,18 @@
18
18
  </div>
19
19
  <div class="main-content">
20
20
  <div class="main-table">
21
- <TTable v-bind="withTableProps()" :data="$Data.dictList" :columns="$Data.columns" :loading="$Data.loading" :active-row-keys="$Data.activeRowKeys" @active-change="$Method.onActiveChange">
21
+ <TTable :data="$Data.dictList" :columns="$Data.columns" :loading="$Data.loading" :active-row-keys="$Data.activeRowKeys" row-key="id" height="calc(100vh - 94px)" active-row-type="single" @active-change="$Method.onActiveChange">
22
22
  <template #state="{ row }">
23
- <TTag v-if="row.state === 1" theme="success">正常</TTag>
24
- <TTag v-else-if="row.state === 2" theme="warning">禁用</TTag>
25
- <TTag v-else theme="danger">已删除</TTag>
23
+ <TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
24
+ <TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
25
+ <TTag v-else shape="round" theme="danger" variant="light-outline">已删除</TTag>
26
26
  </template>
27
27
  <template #operation="{ row }">
28
- <TDropdown trigger="click" min-column-width="120" @click="(data) => $Method.onAction(data.value, row)">
29
- <TButton variant="text" size="small">操作</TButton>
28
+ <TDropdown trigger="click" placement="bottom-right" @click="(data) => $Method.onAction(data.value, row)">
29
+ <TButton theme="primary" size="small">
30
+ 操作
31
+ <template #suffix> <t-icon name="chevron-down" size="16" /></template>
32
+ </TButton>
30
33
  <TDropdownMenu slot="dropdown">
31
34
  <TDropdownItem value="upd">
32
35
  <ILucidePencil />
@@ -43,19 +46,7 @@
43
46
  </div>
44
47
 
45
48
  <div class="main-detail">
46
- <DetailPanel
47
- :data="$Data.currentRow"
48
- :fields="[
49
- { key: 'id', label: 'ID' },
50
- { key: 'name', label: '字典名称' },
51
- { key: 'code', label: '字典代码' },
52
- { key: 'value', label: '字典值' },
53
- { key: 'pid', label: '父级ID', default: '顶级' },
54
- { key: 'sort', label: '排序' },
55
- { key: 'description', label: '描述' },
56
- { key: 'state', label: '状态' }
57
- ]"
58
- />
49
+ <DetailPanel :data="$Data.currentRow" :fields="$Data.columns" />
59
50
  </div>
60
51
  </div>
61
52
 
@@ -77,7 +68,7 @@ import ILucideTrash2 from '~icons/lucide/trash-2';
77
68
  import EditDialog from './components/edit.vue';
78
69
  import DetailPanel from '@/components/DetailPanel.vue';
79
70
  import { $Http } from '@/plugins/http';
80
- import { withDefaultColumns, withTableProps } from '@/utils';
71
+ import { withDefaultColumns } from '@/utils';
81
72
 
82
73
  // 响应式数据
83
74
  const $Data = $ref({
@@ -86,15 +77,15 @@ const $Data = $ref({
86
77
  activeRowKeys: [],
87
78
  currentRow: null,
88
79
  columns: withDefaultColumns([
89
- { colKey: 'index', title: '序号', width: 60, align: 'center' },
80
+ { colKey: 'index', title: '序号' },
90
81
  { colKey: 'name', title: '字典名称' },
91
- { colKey: 'code', title: '字典代码', width: 150 },
92
- { colKey: 'value', title: '字典值', width: 200 },
93
- { colKey: 'pid', title: '父级ID', width: 100 },
94
- { colKey: 'sort', title: '排序', width: 80 },
82
+ { colKey: 'code', title: '字典代码' },
83
+ { colKey: 'value', title: '字典值' },
84
+ { colKey: 'pid', title: '父级ID' },
85
+ { colKey: 'sort', title: '排序' },
95
86
  { colKey: 'description', title: '描述' },
96
- { colKey: 'state', title: '状态', width: 100, ellipsis: false },
97
- { colKey: 'operation', title: '操作', width: 120, align: 'right', ellipsis: false }
87
+ { colKey: 'state', title: '状态' },
88
+ { colKey: 'operation', title: '操作' }
98
89
  ]),
99
90
  pagerConfig: {
100
91
  currentPage: 1,
@@ -181,18 +172,16 @@ const $Method = {
181
172
  $Method.apiDictList();
182
173
  },
183
174
 
184
- // 高亮行变化(点击行选中)
185
- onActiveChange(value, { activeRowData }) {
175
+ // 高亮行变化
176
+ onActiveChange(value, context) {
177
+ // 禁止取消高亮:如果新值为空,保持当前选中
178
+ if (value.length === 0 && $Data.activeRowKeys.length > 0) {
179
+ return;
180
+ }
186
181
  $Data.activeRowKeys = value;
187
182
  // 更新当前高亮的行数据
188
- if (activeRowData && activeRowData.length > 0) {
189
- $Data.currentRow = activeRowData[0];
190
- } else if ($Data.dictList.length > 0) {
191
- // 如果取消高亮,默认显示第一行
192
- $Data.currentRow = $Data.dictList[0];
193
- $Data.activeRowKeys = [$Data.dictList[0].id];
194
- } else {
195
- $Data.currentRow = null;
183
+ if (context.activeRowList && context.activeRowList.length > 0) {
184
+ $Data.currentRow = context.activeRowList[0].row;
196
185
  }
197
186
  },
198
187
 
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "字典配置",
3
+ "order": 1
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "配置管理",
3
+ "order": 30
4
+ }
@@ -0,0 +1,179 @@
1
+ <template>
2
+ <TDialog v-model:visible="$Data.visible" :title="$Prop.actionType === 'upd' ? '编辑配置' : '添加配置'" width="600px" :append-to-body="true" :show-footer="true" :esc-closable="false" top="10vh" @close="$Method.onClose">
3
+ <TForm :model="$Data.formData" label-width="120px" label-position="left" :rules="$Data2.formRules" :ref="(el) => ($Form.form = el)">
4
+ <TFormItem label="配置名称" prop="name">
5
+ <TInput v-model="$Data.formData.name" placeholder="请输入配置名称" :disabled="$Data.isSystem" />
6
+ </TFormItem>
7
+ <TFormItem label="配置代码" prop="code">
8
+ <TInput v-model="$Data.formData.code" placeholder="请输入配置代码,如:site_name" :disabled="$Prop.actionType === 'upd'" />
9
+ </TFormItem>
10
+ <TFormItem label="配置值" prop="value">
11
+ <TTextarea v-if="$Data.formData.valueType === 'json' || $Data.formData.valueType === 'text'" v-model="$Data.formData.value" placeholder="请输入配置值" :autosize="{ minRows: 3, maxRows: 8 }" />
12
+ <TInput v-else v-model="$Data.formData.value" placeholder="请输入配置值" />
13
+ </TFormItem>
14
+ <TFormItem label="值类型" prop="valueType">
15
+ <TSelect v-model="$Data.formData.valueType" :disabled="$Data.isSystem">
16
+ <TOption label="字符串" value="string" />
17
+ <TOption label="数字" value="number" />
18
+ <TOption label="布尔" value="boolean" />
19
+ <TOption label="JSON" value="json" />
20
+ </TSelect>
21
+ </TFormItem>
22
+ <TFormItem label="配置分组" prop="group">
23
+ <TSelect v-model="$Data.formData.group" placeholder="请选择分组" clearable :disabled="$Data.isSystem">
24
+ <TOption v-for="item in $Data2.groupOptions" :key="item" :label="item" :value="item" />
25
+ </TSelect>
26
+ </TFormItem>
27
+ <TFormItem label="排序" prop="sort">
28
+ <TInputNumber v-model="$Data.formData.sort" :min="0" :max="9999" :disabled="$Data.isSystem" />
29
+ </TFormItem>
30
+ <TFormItem label="描述说明" prop="description">
31
+ <TTextarea v-model="$Data.formData.description" placeholder="请输入描述说明" :autosize="{ minRows: 2, maxRows: 4 }" :disabled="$Data.isSystem" />
32
+ </TFormItem>
33
+ <TFormItem v-if="$Prop.actionType === 'upd' && !$Data.isSystem" label="状态" prop="state">
34
+ <TRadioGroup v-model="$Data.formData.state">
35
+ <TRadio :value="1">正常</TRadio>
36
+ <TRadio :value="2">禁用</TRadio>
37
+ </TRadioGroup>
38
+ </TFormItem>
39
+ </TForm>
40
+ <template #footer>
41
+ <TButton @click="$Method.onClose">取消</TButton>
42
+ <TButton theme="primary" :loading="$Data.submitting" @click="$Method.onSubmit">确定</TButton>
43
+ </template>
44
+ </TDialog>
45
+ </template>
46
+
47
+ <script setup>
48
+ import { watch } from 'vue';
49
+ import { Dialog as TDialog, Form as TForm, FormItem as TFormItem, Input as TInput, Textarea as TTextarea, InputNumber as TInputNumber, Select as TSelect, Option as TOption, RadioGroup as TRadioGroup, Radio as TRadio, Button as TButton, MessagePlugin } from 'tdesign-vue-next';
50
+ import { $Http } from '@/plugins/http';
51
+
52
+ const $Prop = defineProps({
53
+ modelValue: {
54
+ type: Boolean,
55
+ default: false
56
+ },
57
+ actionType: {
58
+ type: String,
59
+ default: 'add'
60
+ },
61
+ rowData: {
62
+ type: Object,
63
+ default: () => ({})
64
+ }
65
+ });
66
+
67
+ const $Emit = defineEmits(['update:modelValue', 'success']);
68
+
69
+ // 表单引用
70
+ const $Form = $shallowRef({
71
+ form: null
72
+ });
73
+
74
+ const $Data = $ref({
75
+ visible: false,
76
+ submitting: false,
77
+ isSystem: false,
78
+ formData: {
79
+ id: 0,
80
+ name: '',
81
+ code: '',
82
+ value: '',
83
+ valueType: 'string',
84
+ group: '',
85
+ sort: 0,
86
+ description: '',
87
+ state: 1
88
+ }
89
+ });
90
+
91
+ const $Data2 = $shallowRef({
92
+ formRules: {
93
+ name: [{ required: true, message: '请输入配置名称', trigger: 'blur' }],
94
+ code: [
95
+ { required: true, message: '请输入配置代码', trigger: 'blur' },
96
+ { pattern: /^[a-zA-Z0-9_]+$/, message: '配置代码只能包含字母、数字和下划线', trigger: 'blur' }
97
+ ],
98
+ value: [{ required: true, message: '请输入配置值', trigger: 'blur' }],
99
+ valueType: [{ required: true, message: '请选择值类型', trigger: 'change' }]
100
+ },
101
+ groupOptions: ['基础配置', '邮件配置', '存储配置', '安全配置', '其他']
102
+ });
103
+
104
+ // 方法集合
105
+ const $Method = {
106
+ async initData() {
107
+ $Method.onShow();
108
+ },
109
+
110
+ onShow() {
111
+ $Data.visible = true;
112
+ if ($Prop.actionType === 'upd' && $Prop.rowData) {
113
+ $Data.formData.id = $Prop.rowData.id || 0;
114
+ $Data.formData.name = $Prop.rowData.name || '';
115
+ $Data.formData.code = $Prop.rowData.code || '';
116
+ $Data.formData.value = $Prop.rowData.value || '';
117
+ $Data.formData.valueType = $Prop.rowData.valueType || 'string';
118
+ $Data.formData.group = $Prop.rowData.group || '';
119
+ $Data.formData.sort = $Prop.rowData.sort || 0;
120
+ $Data.formData.description = $Prop.rowData.description || '';
121
+ $Data.formData.state = $Prop.rowData.state || 1;
122
+ $Data.isSystem = $Prop.rowData.isSystem === 1;
123
+ } else {
124
+ $Data.formData = {
125
+ id: 0,
126
+ name: '',
127
+ code: '',
128
+ value: '',
129
+ valueType: 'string',
130
+ group: '',
131
+ sort: 0,
132
+ description: '',
133
+ state: 1
134
+ };
135
+ $Data.isSystem = false;
136
+ }
137
+ },
138
+
139
+ onClose() {
140
+ $Data.visible = false;
141
+ $Emit('update:modelValue', false);
142
+ },
143
+
144
+ async onSubmit() {
145
+ const valid = await $Form.form?.validate();
146
+ if (valid !== true) return;
147
+
148
+ $Data.submitting = true;
149
+ try {
150
+ const api = $Prop.actionType === 'upd' ? '/addon/admin/sysConfig/upd' : '/addon/admin/sysConfig/ins';
151
+ const res = await $Http(api, $Data.formData);
152
+
153
+ if (res.code === 0) {
154
+ MessagePlugin.success($Prop.actionType === 'upd' ? '编辑成功' : '添加成功');
155
+ $Emit('success');
156
+ $Method.onClose();
157
+ } else {
158
+ MessagePlugin.error(res.msg || '操作失败');
159
+ }
160
+ } catch (error) {
161
+ MessagePlugin.error('操作失败');
162
+ } finally {
163
+ $Data.submitting = false;
164
+ }
165
+ }
166
+ };
167
+
168
+ watch(
169
+ () => $Prop.modelValue,
170
+ (val) => {
171
+ if (val) {
172
+ $Method.initData();
173
+ }
174
+ },
175
+ { immediate: true }
176
+ );
177
+ </script>
178
+
179
+ <style scoped lang="scss"></style>