Просмотр исходного кода

feat: 在用户管理和角色管理中添加默认密码提示及md5加密功能

laiqi 11 месяцев назад
Родитель
Сommit
435ea46c3e

+ 1 - 0
apps/web-ele/package.json

@@ -44,6 +44,7 @@
     "@vueuse/core": "catalog:",
     "@vueuse/core": "catalog:",
     "dayjs": "catalog:",
     "dayjs": "catalog:",
     "element-plus": "catalog:",
     "element-plus": "catalog:",
+    "js-md5": "^0.8.3",
     "pinia": "catalog:",
     "pinia": "catalog:",
     "qs": "^6.14.0",
     "qs": "^6.14.0",
     "uuid": "^11.0.5",
     "uuid": "^11.0.5",

+ 5 - 0
apps/web-ele/src/views/system-manage/role-manage/form.vue

@@ -120,6 +120,11 @@ const [Modal, modalApi] = useVbenModal({
         return;
         return;
       }
       }
 
 
+      // 如果是新增,group_delcode设置默认为0
+      if (formType.value === 'create') {
+        formValues.group_delcode = 0;
+      }
+
       await apiMap[formType.value]();
       await apiMap[formType.value]();
       ElMessage.success('操作成功');
       ElMessage.success('操作成功');
       emit('finish');
       emit('finish');

+ 30 - 0
apps/web-ele/src/views/system-manage/user-manage/form.vue

@@ -6,6 +6,7 @@ import { computed, onMounted, ref } from 'vue';
 import { useVbenModal } from '@vben/common-ui';
 import { useVbenModal } from '@vben/common-ui';
 
 
 import { ElMessage } from 'element-plus';
 import { ElMessage } from 'element-plus';
+import { md5 } from 'js-md5';
 
 
 import { useVbenForm, z } from '#/adapter/form';
 import { useVbenForm, z } from '#/adapter/form';
 import {
 import {
@@ -204,6 +205,11 @@ const [Modal, modalApi] = useVbenModal({
         return;
         return;
       }
       }
 
 
+      // 新增账号,设置默认密码accountpwd 123456,使用md5加密
+      if (formType.value === 'create') {
+        (processedValues as any).accountpwd = md5('123456');
+      }
+
       await apiMap[formType.value]();
       await apiMap[formType.value]();
       ElMessage.success('操作成功');
       ElMessage.success('操作成功');
       emit('finish');
       emit('finish');
@@ -254,5 +260,29 @@ const [Modal, modalApi] = useVbenModal({
 <template>
 <template>
   <Modal :title="getTitle">
   <Modal :title="getTitle">
     <BaseForm />
     <BaseForm />
+    <!-- 新增账号时的温馨提示 -->
+    <div
+      v-if="formType === 'create'"
+      class="mt-4 rounded border-l-4 border-blue-400 bg-blue-50 p-3"
+    >
+      <div class="flex items-center">
+        <svg
+          class="mr-2 h-4 w-4 text-blue-600"
+          fill="currentColor"
+          viewBox="0 0 20 20"
+        >
+          <path
+            fill-rule="evenodd"
+            d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
+            clip-rule="evenodd"
+          />
+        </svg>
+        <span class="text-sm text-blue-800">
+          <strong>温馨提示:</strong>新建账号的默认密码为
+          <code class="rounded bg-blue-100 px-1">123456</code>
+          ,请及时提醒用户修改密码。
+        </span>
+      </div>
+    </div>
   </Modal>
   </Modal>
 </template>
 </template>

+ 1 - 0
pnpm-workspace.yaml

@@ -191,3 +191,4 @@ catalog:
   watermark-js-plus: ^1.6.0
   watermark-js-plus: ^1.6.0
   zod: ^3.24.3
   zod: ^3.24.3
   zod-defaults: ^0.1.3
   zod-defaults: ^0.1.3
+  js-md5: ^0.8.3