@befly-addon/admin 1.1.29 → 1.1.31

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 (123) hide show
  1. package/apis/admin/cacheRefresh.ts +29 -24
  2. package/apis/admin/del.ts +12 -12
  3. package/apis/admin/detail.ts +9 -41
  4. package/apis/admin/ins.ts +28 -21
  5. package/apis/admin/list.ts +12 -12
  6. package/apis/admin/upd.ts +49 -14
  7. package/apis/api/all.ts +14 -10
  8. package/apis/api/list.ts +16 -25
  9. package/apis/auth/login.ts +55 -52
  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 +24 -7
  20. package/apis/dict/del.ts +9 -17
  21. package/apis/dict/detail.ts +30 -16
  22. package/apis/dict/ins.ts +36 -18
  23. package/apis/dict/items.ts +27 -0
  24. package/apis/dict/list.ts +35 -10
  25. package/apis/dict/upd.ts +54 -20
  26. package/apis/dictType/all.ts +11 -0
  27. package/apis/dictType/del.ts +32 -0
  28. package/apis/dictType/detail.ts +17 -0
  29. package/apis/dictType/ins.ts +30 -0
  30. package/apis/dictType/list.ts +22 -0
  31. package/apis/dictType/upd.ts +42 -0
  32. package/apis/email/config.ts +4 -4
  33. package/apis/email/logList.ts +10 -10
  34. package/apis/email/send.ts +18 -18
  35. package/apis/email/verify.ts +5 -5
  36. package/apis/loginLog/list.ts +10 -10
  37. package/apis/menu/all.ts +17 -20
  38. package/apis/menu/list.ts +12 -13
  39. package/apis/operateLog/list.ts +10 -10
  40. package/apis/role/all.ts +7 -7
  41. package/apis/role/apiSave.ts +14 -16
  42. package/apis/role/apis.ts +24 -0
  43. package/apis/role/del.ts +27 -19
  44. package/apis/role/detail.ts +6 -7
  45. package/apis/role/ins.ts +10 -10
  46. package/apis/role/list.ts +11 -11
  47. package/apis/role/menuSave.ts +12 -14
  48. package/apis/role/menus.ts +24 -0
  49. package/apis/role/save.ts +14 -15
  50. package/apis/role/upd.ts +10 -10
  51. package/apis/sysConfig/all.ts +5 -6
  52. package/apis/sysConfig/del.ts +10 -10
  53. package/apis/sysConfig/get.ts +10 -11
  54. package/apis/sysConfig/ins.ts +11 -11
  55. package/apis/sysConfig/list.ts +9 -9
  56. package/apis/sysConfig/upd.ts +11 -11
  57. package/libs/emailHelper.ts +7 -7
  58. package/package.json +46 -34
  59. package/plugins/email.ts +9 -9
  60. package/tables/admin.json +0 -6
  61. package/tables/dict.json +13 -19
  62. package/tables/dictType.json +28 -0
  63. package/tables/role.json +4 -2
  64. package/views/403_1/index.vue +19 -3
  65. package/views/config/dict/components/edit.vue +76 -124
  66. package/views/config/dict/index.vue +142 -84
  67. package/views/config/dictType/components/edit.vue +105 -0
  68. package/views/config/dictType/index.vue +242 -0
  69. package/views/config/index.vue +12 -0
  70. package/views/config/system/components/edit.vue +36 -36
  71. package/views/config/system/index.vue +79 -50
  72. package/views/index/components/addonList.vue +3 -3
  73. package/views/index/components/environmentInfo.vue +10 -10
  74. package/views/index/components/operationLogs.vue +10 -10
  75. package/views/index/components/performanceMetrics.vue +8 -8
  76. package/views/index/components/quickActions.vue +3 -3
  77. package/views/index/components/serviceStatus.vue +19 -19
  78. package/views/index/components/systemNotifications.vue +12 -12
  79. package/views/index/components/systemOverview.vue +7 -7
  80. package/views/index/components/systemResources.vue +11 -11
  81. package/views/index/components/userInfo.vue +20 -19
  82. package/views/index/index.vue +12 -5
  83. package/views/log/email/index.vue +58 -51
  84. package/views/log/index.vue +12 -0
  85. package/views/log/login/index.vue +45 -38
  86. package/views/log/operate/index.vue +55 -48
  87. package/views/login_1/index.vue +191 -2
  88. package/views/people/admin/components/edit.vue +28 -29
  89. package/views/people/admin/index.vue +76 -40
  90. package/views/people/index.vue +12 -0
  91. package/views/permission/api/index.vue +21 -15
  92. package/views/permission/index.vue +12 -0
  93. package/views/permission/menu/index.vue +31 -16
  94. package/views/permission/role/components/api.vue +23 -23
  95. package/views/permission/role/components/edit.vue +18 -18
  96. package/views/permission/role/components/menu.vue +17 -19
  97. package/views/permission/role/index.vue +84 -49
  98. package/apis/admin/roleDetail.ts +0 -29
  99. package/apis/admin/roleSave.ts +0 -39
  100. package/apis/auth/logout.ts +0 -17
  101. package/apis/auth/register.ts +0 -43
  102. package/apis/dashboard/changelog.ts +0 -31
  103. package/apis/role/apiDetail.ts +0 -24
  104. package/apis/role/menuDetail.ts +0 -24
  105. package/views/403_1/meta.json +0 -4
  106. package/views/config/dict/meta.json +0 -4
  107. package/views/config/meta.json +0 -4
  108. package/views/config/system/meta.json +0 -4
  109. package/views/index/meta.json +0 -4
  110. package/views/log/email/meta.json +0 -4
  111. package/views/log/login/meta.json +0 -4
  112. package/views/log/meta.json +0 -4
  113. package/views/log/operate/meta.json +0 -4
  114. package/views/login_1/components/emailLoginForm.vue +0 -174
  115. package/views/login_1/components/registerForm.vue +0 -175
  116. package/views/login_1/components/welcomePanel.vue +0 -61
  117. package/views/login_1/meta.json +0 -4
  118. package/views/people/admin/meta.json +0 -4
  119. package/views/people/meta.json +0 -4
  120. package/views/permission/api/meta.json +0 -4
  121. package/views/permission/menu/meta.json +0 -4
  122. package/views/permission/meta.json +0 -4
  123. package/views/permission/role/meta.json +0 -4
@@ -1,22 +1,36 @@
1
- export default {
2
- name: '获取字典详情',
3
- fields: {
4
- id: '@id'
5
- },
1
+ export default {
2
+ name: "获取字典详情",
3
+ fields: { "@id": true },
4
+ required: ["id"],
6
5
  handler: async (befly, ctx) => {
7
- try {
8
- const dict = await befly.db.getDetail({
9
- table: 'addon_admin_dict',
10
- fields: ['id', 'name', 'code', 'value', 'sort', 'pid', 'description', 'state', 'created_at', 'updated_at'],
11
- where: {
12
- id: ctx.body.id
6
+ const dict = await befly.db.getOne({
7
+ table: "addon_admin_dict",
8
+ joins: [
9
+ //
10
+ {
11
+ table: "addon_admin_dict_type",
12
+ on: "addon_admin_dict.type_code = addon_admin_dict_type.code"
13
13
  }
14
- });
14
+ ],
15
+ fields: [
16
+ //
17
+ "addon_admin_dict.id",
18
+ "addon_admin_dict.typeCode",
19
+ "addon_admin_dict.key",
20
+ "addon_admin_dict.label",
21
+ "addon_admin_dict.sort",
22
+ "addon_admin_dict.remark",
23
+ "addon_admin_dict.createdAt",
24
+ "addon_admin_dict.updatedAt",
25
+ "addon_admin_dict_type.name AS typeName"
26
+ ],
27
+ where: { "addon_admin_dict.id": ctx.body.id }
28
+ });
15
29
 
16
- return befly.tool.Yes('操作成功', dict);
17
- } catch (error: any) {
18
- befly.logger.error({ err: error }, '获取字典详情失败');
19
- return befly.tool.No('操作失败');
30
+ if (!dict?.id) {
31
+ return befly.tool.No("字典项不存在");
20
32
  }
33
+
34
+ return befly.tool.Yes("获取成功", dict);
21
35
  }
22
36
  };
package/apis/dict/ins.ts CHANGED
@@ -1,26 +1,44 @@
1
- import adminDictTable from '../../tables/dict.json';
1
+ import adminDictTable from "../../tables/dict.json";
2
2
 
3
3
  export default {
4
- name: '添加字典',
4
+ name: "添加字典",
5
5
  fields: adminDictTable,
6
+ required: ["typeCode", "key", "label"],
6
7
  handler: async (befly, ctx) => {
7
- try {
8
- const dictId = await befly.db.insData({
9
- table: 'addon_admin_dict',
10
- data: {
11
- name: ctx.body.name,
12
- code: ctx.body.code,
13
- value: ctx.body.value,
14
- sort: ctx.body.sort,
15
- pid: ctx.body.pid,
16
- description: ctx.body.description
17
- }
18
- });
8
+ // 验证 typeCode 是否存在
9
+ const dictType = await befly.db.getOne({
10
+ table: "addon_admin_dict_type",
11
+ where: { code: ctx.body.typeCode }
12
+ });
19
13
 
20
- return befly.tool.Yes('操作成功', { id: dictId });
21
- } catch (error) {
22
- befly.logger.error({ err: error }, '添加字典失败');
23
- return befly.tool.No('操作失败');
14
+ if (!dictType?.id) {
15
+ return befly.tool.No("字典类型不存在");
24
16
  }
17
+
18
+ // 检查 typeCode+key 是否已存在
19
+ const existing = await befly.db.getOne({
20
+ table: "addon_admin_dict",
21
+ where: {
22
+ typeCode: ctx.body.typeCode,
23
+ key: ctx.body.key
24
+ }
25
+ });
26
+
27
+ if (existing?.id) {
28
+ return befly.tool.No("该类型下已存在相同的键名");
29
+ }
30
+
31
+ const dictId = await befly.db.insData({
32
+ table: "addon_admin_dict",
33
+ data: {
34
+ typeCode: ctx.body.typeCode,
35
+ key: ctx.body.key,
36
+ label: ctx.body.label,
37
+ sort: ctx.body.sort,
38
+ remark: ctx.body.remark
39
+ }
40
+ });
41
+
42
+ return befly.tool.Yes("添加成功", { id: dictId });
25
43
  }
26
44
  };
@@ -0,0 +1,27 @@
1
+ export default {
2
+ name: "获取字典项列表",
3
+ fields: {
4
+ typeCode: { type: "string", label: "类型代码", required: true }
5
+ },
6
+ required: ["typeCode"],
7
+ handler: async (befly, ctx) => {
8
+ // 验证 typeCode 是否存在
9
+ const dictType = await befly.db.getOne({
10
+ table: "addon_admin_dict_type",
11
+ where: { code: ctx.body.typeCode }
12
+ });
13
+
14
+ if (!dictType?.id) {
15
+ return befly.tool.No("字典类型不存在");
16
+ }
17
+
18
+ // 获取该类型下的所有字典项
19
+ const items = await befly.db.getAll({
20
+ table: "addon_admin_dict",
21
+ where: { typeCode: ctx.body.typeCode },
22
+ orderBy: ["sort#ASC", "id#ASC"]
23
+ });
24
+
25
+ return befly.tool.Yes("获取成功", items);
26
+ }
27
+ };
package/apis/dict/list.ts CHANGED
@@ -1,20 +1,45 @@
1
- export default {
2
- name: '获取字典列表',
1
+ export default {
2
+ name: "获取字典列表",
3
3
  fields: {
4
- page: '@page',
5
- limit: '@limit',
6
- keyword: '@keyword',
7
- state: '@state'
4
+ page: "@page",
5
+ limit: "@limit",
6
+ typeCode: { type: "string", label: "类型代码" },
7
+ keyword: "@keyword"
8
8
  },
9
9
  handler: async (befly, ctx) => {
10
+ const where: any = {};
11
+ if (ctx.body.typeCode) where["addon_admin_dict.typeCode"] = ctx.body.typeCode;
12
+ if (ctx.body.keyword) {
13
+ where.$or = [{ "addon_admin_dict.key$like": `%${ctx.body.keyword}%` }, { "addon_admin_dict.label$like": `%${ctx.body.keyword}%` }];
14
+ }
15
+
10
16
  const result = await befly.db.getList({
11
- table: 'addon_admin_dict',
12
- fields: ['id', 'name', 'code', 'value', 'sort', 'pid', 'description', 'state', 'created_at', 'updated_at'],
17
+ table: "addon_admin_dict",
18
+ joins: [
19
+ //
20
+ {
21
+ table: "addon_admin_dict_type",
22
+ on: "addon_admin_dict.type_code = addon_admin_dict_type.code"
23
+ }
24
+ ],
25
+ fields: [
26
+ //
27
+ "addon_admin_dict.id",
28
+ "addon_admin_dict.typeCode",
29
+ "addon_admin_dict.key",
30
+ "addon_admin_dict.label",
31
+ "addon_admin_dict.sort",
32
+ "addon_admin_dict.remark",
33
+ "addon_admin_dict.createdAt",
34
+ "addon_admin_dict.updatedAt",
35
+ "addon_admin_dict_type.name AS typeName"
36
+ ],
37
+ where: where,
13
38
  page: ctx.body.page,
14
39
  limit: ctx.body.limit,
15
- orderBy: ['sort#ASC', 'id#ASC']
40
+ orderBy: ["addon_admin_dict.sort#ASC", "addon_admin_dict.id#ASC"]
16
41
  });
17
42
 
18
- return befly.tool.Yes('操作成功', result);
43
+ return befly.tool.Yes("获取成功", result);
19
44
  }
20
45
  };
package/apis/dict/upd.ts CHANGED
@@ -1,30 +1,64 @@
1
- import adminDictTable from '../../tables/dict.json';
1
+ import adminDictTable from "../../tables/dict.json";
2
2
 
3
3
  export default {
4
- name: '更新字典',
5
- fields: adminDictTable,
4
+ name: "更新字典",
5
+ fields: {
6
+ ...adminDictTable,
7
+ "@id": true
8
+ },
9
+ required: ["id"],
6
10
  handler: async (befly, ctx) => {
7
- try {
8
- await befly.db.updData({
9
- table: 'addon_admin_dict',
10
- data: {
11
- name: ctx.body.name,
12
- code: ctx.body.code,
13
- value: ctx.body.value,
14
- sort: ctx.body.sort,
15
- pid: ctx.body.pid,
16
- description: ctx.body.description,
17
- state: ctx.body.state
18
- },
11
+ const { id, typeCode, key, label, sort, remark } = ctx.body;
12
+
13
+ // 如果更新了 typeCode,验证其是否存在
14
+ if (typeCode) {
15
+ const dictType = await befly.db.getOne({
16
+ table: "addon_admin_dict_type",
17
+ where: { code: typeCode }
18
+ });
19
+
20
+ if (!dictType?.id) {
21
+ return befly.tool.No("字典类型不存在");
22
+ }
23
+ }
24
+
25
+ // 如果更新了 typeCode 或 key,检查唯一性
26
+ if (typeCode || key) {
27
+ const current = await befly.db.getOne({
28
+ table: "addon_admin_dict",
29
+ where: { id: id }
30
+ });
31
+
32
+ const checkTypeCode = typeCode || current?.typeCode;
33
+ const checkKey = key || current?.key;
34
+
35
+ const existing = await befly.db.getOne({
36
+ table: "addon_admin_dict",
19
37
  where: {
20
- id: ctx.body.id
38
+ typeCode: checkTypeCode,
39
+ key: checkKey,
40
+ id$ne: id
21
41
  }
22
42
  });
23
43
 
24
- return befly.tool.Yes('操作成功');
25
- } catch (error) {
26
- befly.logger.error({ err: error }, '更新字典失败');
27
- return befly.tool.No('操作失败');
44
+ if (existing?.id) {
45
+ return befly.tool.No("该类型下已存在相同的键名");
46
+ }
28
47
  }
48
+
49
+ const updateData: Record<string, any> = {};
50
+ if (typeCode !== undefined) updateData.typeCode = typeCode;
51
+ if (key !== undefined) updateData.key = key;
52
+ if (label !== undefined) updateData.label = label;
53
+ if (sort !== undefined) updateData.sort = sort;
54
+ if (remark !== undefined) updateData.remark = remark;
55
+
56
+ await befly.db.updData({
57
+ table: "addon_admin_dict",
58
+ data: updateData,
59
+ where: { id: id }
60
+ });
61
+
62
+ return befly.tool.Yes("更新成功");
29
63
  }
30
64
  };
@@ -0,0 +1,11 @@
1
+ export default {
2
+ name: "获取所有字典类型",
3
+ handler: async (befly) => {
4
+ const result = await befly.db.getAll({
5
+ table: "addon_admin_dict_type",
6
+ orderBy: ["sort#ASC", "id#ASC"]
7
+ });
8
+
9
+ return befly.tool.Yes("操作成功", { lists: result.lists });
10
+ }
11
+ };
@@ -0,0 +1,32 @@
1
+ export default {
2
+ name: "删除字典类型",
3
+ fields: { "@id": true },
4
+ required: ["id"],
5
+ handler: async (befly, ctx) => {
6
+ const { id } = ctx.body;
7
+
8
+ // 检查是否有字典项引用此类型
9
+ const dictItems = await befly.db.getOne({
10
+ table: "addon_admin_dict",
11
+ where: {
12
+ typeCode: (
13
+ await befly.db.getOne({
14
+ table: "addon_admin_dict_type",
15
+ where: { id: id }
16
+ })
17
+ )?.code
18
+ }
19
+ });
20
+
21
+ if (dictItems?.id) {
22
+ return befly.tool.No("该类型下存在字典项,无法删除");
23
+ }
24
+
25
+ await befly.db.delData({
26
+ table: "addon_admin_dict_type",
27
+ where: { id: id }
28
+ });
29
+
30
+ return befly.tool.Yes("删除成功");
31
+ }
32
+ };
@@ -0,0 +1,17 @@
1
+ export default {
2
+ name: "字典类型详情",
3
+ fields: { "@id": true },
4
+ required: ["id"],
5
+ handler: async (befly, ctx) => {
6
+ const detail = await befly.db.getDetail({
7
+ table: "addon_admin_dict_type",
8
+ where: { id: ctx.body.id }
9
+ });
10
+
11
+ if (!detail?.id) {
12
+ return befly.tool.No("字典类型不存在");
13
+ }
14
+
15
+ return befly.tool.Yes("获取成功", detail);
16
+ }
17
+ };
@@ -0,0 +1,30 @@
1
+ import dictTypeTable from "../../tables/dictType.json";
2
+
3
+ export default {
4
+ name: "添加字典类型",
5
+ fields: dictTypeTable,
6
+ required: ["code", "name"],
7
+ handler: async (befly, ctx) => {
8
+ // 检查代码是否已存在
9
+ const existing = await befly.db.getOne({
10
+ table: "addon_admin_dict_type",
11
+ where: { code: ctx.body.code }
12
+ });
13
+
14
+ if (existing?.id) {
15
+ return befly.tool.No("类型代码已存在");
16
+ }
17
+
18
+ const typeId = await befly.db.insData({
19
+ table: "addon_admin_dict_type",
20
+ data: {
21
+ code: ctx.body.code,
22
+ name: ctx.body.name,
23
+ description: ctx.body.description,
24
+ sort: ctx.body.sort
25
+ }
26
+ });
27
+
28
+ return befly.tool.Yes("添加成功", { id: typeId });
29
+ }
30
+ };
@@ -0,0 +1,22 @@
1
+ export default {
2
+ name: "获取字典类型列表",
3
+ fields: {
4
+ page: "@page",
5
+ limit: "@limit",
6
+ keyword: "@keyword",
7
+ state: "@state"
8
+ },
9
+ handler: async (befly, ctx) => {
10
+ const result = await befly.db.getList({
11
+ table: "addon_admin_dict_type",
12
+ where: {
13
+ name$like: ctx.body.keyword ? `%${ctx.body.keyword}%` : undefined
14
+ },
15
+ orderBy: ["sort#ASC", "id#ASC"],
16
+ page: ctx.body.page,
17
+ limit: ctx.body.limit
18
+ });
19
+
20
+ return befly.tool.Yes("操作成功", result);
21
+ }
22
+ };
@@ -0,0 +1,42 @@
1
+ import dictTypeTable from "../../tables/dictType.json";
2
+
3
+ export default {
4
+ name: "更新字典类型",
5
+ fields: {
6
+ ...dictTypeTable,
7
+ "@id": true
8
+ },
9
+ required: ["id"],
10
+ handler: async (befly, ctx) => {
11
+ const { id, code, name, description, sort } = ctx.body;
12
+
13
+ // 如果更新了 code,需要检查是否已被使用
14
+ if (code) {
15
+ const existing = await befly.db.getOne({
16
+ table: "addon_admin_dict_type",
17
+ where: {
18
+ code: code,
19
+ id$ne: id
20
+ }
21
+ });
22
+
23
+ if (existing?.id) {
24
+ return befly.tool.No("类型代码已被使用");
25
+ }
26
+ }
27
+
28
+ const updateData: Record<string, any> = {};
29
+ if (code !== undefined) updateData.code = code;
30
+ if (name !== undefined) updateData.name = name;
31
+ if (description !== undefined) updateData.description = description;
32
+ if (sort !== undefined) updateData.sort = sort;
33
+
34
+ await befly.db.updData({
35
+ table: "addon_admin_dict_type",
36
+ data: updateData,
37
+ where: { id: id }
38
+ });
39
+
40
+ return befly.tool.Yes("更新成功");
41
+ }
42
+ };
@@ -1,13 +1,13 @@
1
1
  export default {
2
- name: '获取邮件配置',
3
- handler: async (befly, ctx) => {
2
+ name: "获取邮件配置",
3
+ handler: async (befly) => {
4
4
  if (!(befly as any).addon_admin_email) {
5
- return befly.tool.No('邮件插件未加载,请检查配置');
5
+ return befly.tool.No("邮件插件未加载,请检查配置");
6
6
  }
7
7
 
8
8
  const config = (befly as any).addon_admin_email.getConfig();
9
9
 
10
- return befly.tool.Yes('获取成功', {
10
+ return befly.tool.Yes("获取成功", {
11
11
  host: config.host,
12
12
  port: config.port,
13
13
  secure: config.secure,
@@ -1,19 +1,19 @@
1
1
  export default {
2
- name: '邮件发送日志列表',
2
+ name: "邮件发送日志列表",
3
3
  fields: {
4
- page: '@page',
5
- limit: '@limit',
6
- keyword: '@keyword',
7
- state: '@state'
4
+ page: "@page",
5
+ limit: "@limit",
6
+ keyword: "@keyword",
7
+ state: "@state"
8
8
  },
9
9
  handler: async (befly, ctx) => {
10
10
  const result = await befly.db.getList({
11
- table: 'addon_admin_email_log',
12
- page: ctx.body.page || 1,
13
- limit: ctx.body.limit || 30,
14
- orderBy: ['sendTime#DESC']
11
+ table: "addon_admin_email_log",
12
+ page: ctx.body.page,
13
+ limit: ctx.body.limit,
14
+ orderBy: ["sendTime#DESC"]
15
15
  });
16
16
 
17
- return befly.tool.Yes('获取成功', result);
17
+ return befly.tool.Yes("获取成功", result);
18
18
  }
19
19
  };
@@ -1,28 +1,28 @@
1
- import emailLogTable from '../../tables/emailLog.json';
1
+ import emailLogTable from "../../tables/emailLog.json";
2
2
 
3
3
  export default {
4
- name: '发送邮件',
4
+ name: "发送邮件",
5
5
  fields: {
6
6
  to: emailLogTable.toEmail,
7
7
  subject: emailLogTable.subject,
8
8
  content: {
9
- name: '邮件内容',
10
- type: 'string',
9
+ name: "邮件内容",
10
+ type: "string",
11
11
  min: 1,
12
12
  max: 50000
13
13
  },
14
14
  cc: emailLogTable.ccEmail,
15
15
  bcc: emailLogTable.bccEmail,
16
16
  isHtml: {
17
- name: '是否HTML',
18
- type: 'boolean',
17
+ name: "是否HTML",
18
+ type: "boolean",
19
19
  default: true
20
20
  }
21
21
  },
22
- required: ['to', 'subject', 'content'],
22
+ required: ["to", "subject", "content"],
23
23
  handler: async (befly, ctx) => {
24
24
  if (!(befly as any).addon_admin_email) {
25
- return befly.tool.No('邮件插件未加载,请检查配置');
25
+ return befly.tool.No("邮件插件未加载,请检查配置");
26
26
  }
27
27
 
28
28
  const startTime = Date.now();
@@ -40,30 +40,30 @@ export default {
40
40
  // 记录邮件发送日志
41
41
  try {
42
42
  await befly.db.insData({
43
- table: 'addon_admin_email_log',
43
+ table: "addon_admin_email_log",
44
44
  data: {
45
45
  adminId: ctx.user?.id || 0,
46
- username: ctx.user?.username || '',
47
- nickname: ctx.user?.nickname || '',
46
+ username: ctx.user?.username || "",
47
+ nickname: ctx.user?.nickname || "",
48
48
  toEmail: ctx.body.to,
49
49
  subject: ctx.body.subject,
50
50
  content: ctx.body.content,
51
- ccEmail: ctx.body.cc || '',
52
- bccEmail: ctx.body.bcc || '',
51
+ ccEmail: ctx.body.cc || "",
52
+ bccEmail: ctx.body.bcc || "",
53
53
  sendTime: startTime,
54
54
  sendResult: result.success ? 1 : 0,
55
- messageId: result.messageId || '',
56
- failReason: result.error || ''
55
+ messageId: result.messageId || "",
56
+ failReason: result.error || ""
57
57
  }
58
58
  });
59
59
  } catch (logError: any) {
60
- befly.logger.error({ err: logError }, '记录邮件日志失败');
60
+ befly.logger.error({ err: logError }, "记录邮件日志失败");
61
61
  }
62
62
 
63
63
  if (result.success) {
64
- return befly.tool.Yes('发送成功', { messageId: result.messageId });
64
+ return befly.tool.Yes("发送成功", { messageId: result.messageId });
65
65
  }
66
66
 
67
- return befly.tool.No(result.error || '发送失败');
67
+ return befly.tool.No(result.error || "发送失败");
68
68
  }
69
69
  };
@@ -1,16 +1,16 @@
1
1
  export default {
2
- name: '验证邮件配置',
3
- handler: async (befly, ctx) => {
2
+ name: "验证邮件配置",
3
+ handler: async (befly) => {
4
4
  if (!(befly as any).addon_admin_email) {
5
- return befly.tool.No('邮件插件未加载,请检查配置');
5
+ return befly.tool.No("邮件插件未加载,请检查配置");
6
6
  }
7
7
 
8
8
  const isValid = await (befly as any).addon_admin_email.verify();
9
9
 
10
10
  if (isValid) {
11
- return befly.tool.Yes('邮件服务配置正常');
11
+ return befly.tool.Yes("邮件服务配置正常");
12
12
  }
13
13
 
14
- return befly.tool.No('邮件服务配置异常,请检查 SMTP 设置');
14
+ return befly.tool.No("邮件服务配置异常,请检查 SMTP 设置");
15
15
  }
16
16
  };
@@ -1,19 +1,19 @@
1
1
  export default {
2
- name: '获取登录日志列表',
2
+ name: "获取登录日志列表",
3
3
  fields: {
4
- page: '@page',
5
- limit: '@limit',
6
- keyword: '@keyword',
7
- state: '@state'
4
+ page: "@page",
5
+ limit: "@limit",
6
+ keyword: "@keyword",
7
+ state: "@state"
8
8
  },
9
9
  handler: async (befly, ctx) => {
10
10
  const result = await befly.db.getList({
11
- table: 'addon_admin_login_log',
12
- page: ctx.body.page || 1,
13
- limit: ctx.body.limit || 30,
14
- orderBy: ['loginTime#DESC']
11
+ table: "addon_admin_login_log",
12
+ page: ctx.body.page,
13
+ limit: ctx.body.limit,
14
+ orderBy: ["loginTime#DESC"]
15
15
  });
16
16
 
17
- return befly.tool.Yes('获取成功', result);
17
+ return befly.tool.Yes("获取成功", result);
18
18
  }
19
19
  };