From f2c809a142de8048dca5576a9c125dd5bc05a80c Mon Sep 17 00:00:00 2001
From: Bunny <1319900154@qq.com>
Date: Sun, 27 Oct 2024 17:27:21 +0800
Subject: [PATCH] =?UTF-8?q?page:=20=F0=9F=93=84=20=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=94=A8=E9=82=AE=E7=AE=B1=E6=88=96=E8=80=85?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E7=99=BB=E5=BD=95,=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E9=83=A8=E5=88=86=E7=BC=BA=E9=99=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Table/Userinfo/UserinfoDialog.vue | 4 +-
src/store/system/adminUser.ts | 2 +-
src/store/system/user.ts | 7 +-
src/views/account-settings/profile.vue | 12 +-
src/views/account-settings/utils/columns.ts | 7 +-
src/views/account-settings/utils/hooks.tsx | 13 +-
src/views/login/index.vue | 15 +-
src/views/login/login-email.vue | 155 ++++++++++++++++++
src/views/login/login-form.vue | 80 ++-------
src/views/login/utils/hooks.ts | 9 +
src/views/login/utils/rule.ts | 23 ++-
src/views/login/utils/static.ts | 5 -
.../system/adminUser/admin-user-dialog.vue | 6 +-
src/views/system/adminUser/index.vue | 4 +-
src/views/system/adminUser/utils/columns.tsx | 2 +-
src/views/system/adminUser/utils/hooks.tsx | 4 +-
src/views/system/adminUser/utils/types.ts | 2 +-
.../system/menu/assign-router-to-role.vue | 4 +-
src/views/system/menu/utils/hooks.tsx | 49 ++++--
19 files changed, 280 insertions(+), 123 deletions(-)
create mode 100644 src/views/login/login-email.vue
create mode 100644 src/views/login/utils/hooks.ts
delete mode 100644 src/views/login/utils/static.ts
diff --git a/src/components/Table/Userinfo/UserinfoDialog.vue b/src/components/Table/Userinfo/UserinfoDialog.vue
index 430d204..6ad01c5 100644
--- a/src/components/Table/Userinfo/UserinfoDialog.vue
+++ b/src/components/Table/Userinfo/UserinfoDialog.vue
@@ -57,7 +57,7 @@ onMounted(() => {
{{ userinfo.username }}
- {{ userinfo.nickName }}
+ {{ userinfo.nickname }}
{{ userinfo.email }}
{{ userinfo.phone }}
@@ -100,7 +100,7 @@ onMounted(() => {
-
+
diff --git a/src/store/system/adminUser.ts b/src/store/system/adminUser.ts
index 63411d5..14aa06d 100644
--- a/src/store/system/adminUser.ts
+++ b/src/store/system/adminUser.ts
@@ -27,7 +27,7 @@ export const useAdminUserStore = defineStore('adminUserStore', {
// 用户名
username: undefined,
// 昵称
- nickName: undefined,
+ nickname: undefined,
// 邮箱
email: undefined,
// 手机号
diff --git a/src/store/system/user.ts b/src/store/system/user.ts
index 46baa21..c5a44fc 100644
--- a/src/store/system/user.ts
+++ b/src/store/system/user.ts
@@ -49,9 +49,8 @@ export const useUserStore = defineStore({
return false;
},
- /** 前端登出(不调用接口) */
+ /** 前端登出 */
async logOut() {
- // 登出
const result = await fetchLogout();
if (result.code == 200) {
this.username = '';
@@ -83,7 +82,9 @@ export const useUserStore = defineStore({
async getUserinfo() {
const result = await fetchGetUserinfo();
if (result.code === 200) {
- return result.data;
+ const data = result.data;
+ setToken(data);
+ return data;
}
return {};
},
diff --git a/src/views/account-settings/profile.vue b/src/views/account-settings/profile.vue
index 0141c74..765be73 100644
--- a/src/views/account-settings/profile.vue
+++ b/src/views/account-settings/profile.vue
@@ -47,7 +47,11 @@ const onSubmit = async (formEl: FormInstance) => {
const avatar = uploadAvatarSrc.value;
if (avatar) userInfos.avatar = avatar;
- await adminUserStore.updateAdminUserByLocalUser(userInfos);
+ // 更新用户信息
+ const result = await adminUserStore.updateAdminUserByLocalUser(userInfos);
+ if (!result) return;
+
+ // 重新加载用户信息
await onSearchByUserinfo();
} else {
message($t('required_fields'), { type: 'warning' });
@@ -81,12 +85,12 @@ onMounted(() => {
-
+
-
-
+
+
diff --git a/src/views/account-settings/utils/columns.ts b/src/views/account-settings/utils/columns.ts
index 9c2c28b..54b4de3 100644
--- a/src/views/account-settings/utils/columns.ts
+++ b/src/views/account-settings/utils/columns.ts
@@ -13,8 +13,8 @@ export const columns: TableColumnList = [
{ type: 'index', index: (index: number) => index + 1, label: '序号', width: 60 },
// 用户名
{ label: $t('userLoginLog_username'), prop: 'username', width: 180 },
- // // 登录Ip
- // { label: $t('userLoginLog_ipAddress'), prop: 'ipAddress', width: 140 },
+ // 登录Ip
+ { label: $t('userLoginLog_ipAddress'), prop: 'ipAddress', width: 140 },
// 登录Ip归属地
{ label: $t('userLoginLog_ipRegion'), prop: 'ipRegion' },
// // 登录时代理
@@ -35,8 +35,7 @@ export const columns: TableColumnList = [
// 修改用户信息规则校验
export const rules = reactive>({
- username: [{ required: true, message: '昵称必填', trigger: 'blur' }],
- nickName: [{ required: true, message: '昵称必填', trigger: 'blur' }],
+ nickname: [{ required: true, message: '昵称必填', trigger: 'blur' }],
email: [{ required: true, message: '昵称必填', trigger: 'blur' }],
});
diff --git a/src/views/account-settings/utils/hooks.tsx b/src/views/account-settings/utils/hooks.tsx
index 1fe9e28..883c361 100644
--- a/src/views/account-settings/utils/hooks.tsx
+++ b/src/views/account-settings/utils/hooks.tsx
@@ -12,7 +12,6 @@ export const uploadAvatarSrc = ref();
// 剪裁头像是否显示
export const isShow = ref(false);
-
const userStore = useUserStore();
// 用户信息内容
@@ -23,7 +22,7 @@ export const userInfos = reactive({
email: '',
phone: '',
summary: '',
- nickName: '',
+ nickname: '',
password: '',
sex: '',
});
@@ -31,7 +30,15 @@ export const userInfos = reactive({
/** 获取用户信息内容 */
export const onSearchByUserinfo = async () => {
const data = await userStore.getUserinfo();
- Object.assign(userInfos, data);
+ userInfos.summary = data.personDescription;
+ userInfos.avatar = data.avatar;
+ userInfos.username = data.username;
+ userInfos.nickname = data.nickname;
+ userInfos.email = data.email;
+ userInfos.phone = data.phone;
+ userInfos.nickname = data.nickname;
+ userInfos.password = data.password;
+ userInfos.sex = data.sex;
};
/** 修改头像 */
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 53a96e9..ca3d187 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -2,22 +2,20 @@
import Motion from './utils/motion';
import { useNav } from '@/layout/hooks/useNav';
import { useLayout } from '@/layout/hooks/useLayout';
-import { avatar, bg, illustration } from './utils/static';
+import bg from '@/assets/login/bg.png';
+import avatar from '@/assets/login/avatar.svg?component';
+import illustration from '@/assets/login/illustration.svg?component';
import { onMounted, toRaw } from 'vue';
import { useTranslationLang } from '@/layout/hooks/useTranslationLang';
import { useDataThemeChange } from '@/layout/hooks/useDataThemeChange';
-
import dayIcon from '@/assets/svg/day.svg?component';
import darkIcon from '@/assets/svg/dark.svg?component';
import globalization from '@/assets/svg/globalization.svg?component';
import Check from '@iconify-icons/ep/check';
-
import LoginForm from '@/views/login/login-form.vue';
+import LoginEmail from '@/views/login/login-email.vue';
import { userI18nTypeStore } from '@/store/i18n/i18nType';
-
-defineOptions({
- name: 'Login',
-});
+import { currentPage } from '@/views/login/utils/hooks';
const { initStorage } = useLayout();
initStorage();
@@ -73,7 +71,8 @@ onMounted(() => {
-
+
+
diff --git a/src/views/login/login-email.vue b/src/views/login/login-email.vue
new file mode 100644
index 0000000..b9edaf6
--- /dev/null
+++ b/src/views/login/login-email.vue
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('login.getEmailCode') }}
+
+
+ {{ sendSecond }}
+ {{ t('login.getCodeInfo') }}
+
+
+
+
+ {{ userStore.readMeDay }}天免登录(邮箱验证码随便输入,后端校验验证码已注释)
+
+
+
+
+
+
+ {{ t('login.login') }}
+
+
+
+
+
+
+ {{ t('login.pureBack') }}
+
+
+
+
+
diff --git a/src/views/login/login-form.vue b/src/views/login/login-form.vue
index 33ec0fc..e27ec1d 100644
--- a/src/views/login/login-form.vue
+++ b/src/views/login/login-form.vue
@@ -1,5 +1,4 @@
-
-
+
+
@@ -113,32 +76,25 @@ onBeforeUnmount(() => {
-
-
-
-
-
-
-
-
- {{ t('login.getEmailCode') }}
-
-
- {{ sendSecond }}
- {{ t('login.getCodeInfo') }}
-
-
-
{{ userStore.readMeDay }}天免登录(邮箱验证码随便输入,后端校验验证码已注释)
-
-
- {{ t('login.login') }}
-
+
+
+
+ {{ t('login.login') }}
+
+
+
+
+
+
+
+ 邮箱登录
+
diff --git a/src/views/login/utils/hooks.ts b/src/views/login/utils/hooks.ts
new file mode 100644
index 0000000..1c95677
--- /dev/null
+++ b/src/views/login/utils/hooks.ts
@@ -0,0 +1,9 @@
+import { ref } from 'vue';
+
+// 0普通登录,1邮箱登录,其中0为普通登录
+export const currentPage = ref(0);
+
+/** 返回到默认登录页面 */
+export const onBack = () => {
+ currentPage.value = 0;
+};
diff --git a/src/views/login/utils/rule.ts b/src/views/login/utils/rule.ts
index f2f9ea9..32e847f 100644
--- a/src/views/login/utils/rule.ts
+++ b/src/views/login/utils/rule.ts
@@ -5,8 +5,8 @@ import { $t } from '@/plugins/i18n';
/** 密码正则(密码格式应为8-18位数字、字母、符号的任意两种组合) */
export const REGEXP_PWD = /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[()])+$)(?!^.*[\u4E00-\u9FA5].*$)([^(0-9a-zA-Z)]|[()]|[a-z]|[A-Z]|[0-9]){8,18}$/;
-/** 登录校验 */
-const loginRules = reactive({
+/** 邮箱登录校验 */
+export const emailRules = reactive({
username: [{ required: true, message: $t('login.usernameRegex'), trigger: 'blur' }],
password: [
{
@@ -25,4 +25,21 @@ const loginRules = reactive({
emailCode: [{ required: true, trigger: 'blur', type: 'string' }],
});
-export { loginRules };
+/** 登录校验 */
+export const formRules = reactive({
+ username: [{ required: true, message: $t('login.usernameRegex'), trigger: 'blur' }],
+ password: [
+ {
+ validator: (rule, value, callback) => {
+ if (value === '') {
+ callback(new Error($t('login.purePassWordReg')));
+ } else if (!REGEXP_PWD.test(value)) {
+ callback(new Error($t('login.purePassWordRuleReg')));
+ } else {
+ callback();
+ }
+ },
+ trigger: 'blur',
+ },
+ ],
+});
diff --git a/src/views/login/utils/static.ts b/src/views/login/utils/static.ts
deleted file mode 100644
index 9640151..0000000
--- a/src/views/login/utils/static.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import bg from '@/assets/login/bg.png';
-import avatar from '@/assets/login/avatar.svg?component';
-import illustration from '@/assets/login/illustration.svg?component';
-
-export { bg, avatar, illustration };
diff --git a/src/views/system/adminUser/admin-user-dialog.vue b/src/views/system/adminUser/admin-user-dialog.vue
index 6dc94d7..64c156f 100644
--- a/src/views/system/adminUser/admin-user-dialog.vue
+++ b/src/views/system/adminUser/admin-user-dialog.vue
@@ -15,7 +15,7 @@ const props = withDefaults(defineProps(), {
// 用户名
username: undefined,
// 昵称
- nickName: undefined,
+ nickname: undefined,
// 邮箱
email: undefined,
// 手机号
@@ -55,8 +55,8 @@ defineExpose({ formRef });
-
-
+
+
diff --git a/src/views/system/adminUser/index.vue b/src/views/system/adminUser/index.vue
index 6eddb15..7b51913 100644
--- a/src/views/system/adminUser/index.vue
+++ b/src/views/system/adminUser/index.vue
@@ -96,8 +96,8 @@ onMounted(() => {
-
-
+
+
diff --git a/src/views/system/adminUser/utils/columns.tsx b/src/views/system/adminUser/utils/columns.tsx
index 0740a0b..2191411 100644
--- a/src/views/system/adminUser/utils/columns.tsx
+++ b/src/views/system/adminUser/utils/columns.tsx
@@ -13,7 +13,7 @@ export const columns: TableColumnList = [
// 状态
{ label: $t('adminUser_status'), prop: 'status', slot: 'status' },
// 昵称
- { label: $t('adminUser_nickName'), prop: 'nickName', width: 260 },
+ { label: $t('adminUser_nickname'), prop: 'nickname', width: 260 },
// 邮箱
{ label: $t('adminUser_email'), prop: 'email', width: 260 },
// 手机号
diff --git a/src/views/system/adminUser/utils/hooks.tsx b/src/views/system/adminUser/utils/hooks.tsx
index 530f74a..49fec1d 100644
--- a/src/views/system/adminUser/utils/hooks.tsx
+++ b/src/views/system/adminUser/utils/hooks.tsx
@@ -59,7 +59,7 @@ export function onAdd() {
props: {
formInline: {
username: undefined,
- nickName: undefined,
+ nickname: undefined,
email: undefined,
phone: undefined,
password: undefined,
@@ -100,7 +100,7 @@ export function onUpdate(row: any) {
props: {
formInline: {
username: row.username,
- nickName: row.nickName,
+ nickname: row.nickname,
email: row.email,
phone: row.phone,
password: row.password,
diff --git a/src/views/system/adminUser/utils/types.ts b/src/views/system/adminUser/utils/types.ts
index 326a4ea..0dcf561 100644
--- a/src/views/system/adminUser/utils/types.ts
+++ b/src/views/system/adminUser/utils/types.ts
@@ -3,7 +3,7 @@ export interface FormItemProps {
// 用户名
username: string;
// 昵称
- nickName: string;
+ nickname: string;
// 邮箱
email: string;
// 手机号
diff --git a/src/views/system/menu/assign-router-to-role.vue b/src/views/system/menu/assign-router-to-role.vue
index 2710caf..a9f5072 100644
--- a/src/views/system/menu/assign-router-to-role.vue
+++ b/src/views/system/menu/assign-router-to-role.vue
@@ -6,6 +6,7 @@ import { $t } from '@/plugins/i18n';
const props = defineProps({
routerId: { type: String as PropType },
+ warning: { type: String as PropType },
});
const roleStore = useRoleStore();
@@ -36,7 +37,8 @@ defineExpose({ assignRoles });
-
+
+
{{ warning }}
{
draggable: true,
closeOnClickModal: false,
fullscreenIcon: true,
+ props: { warning: $t('assignBatchRolesToRouterTip') },
contentRenderer: () => ,
beforeSure: async (done: any) => {
// 表格功能
@@ -253,23 +255,34 @@ export const assignBatchRolesToRouter = () => {
/** 清除选中所以角色 */
export const clearAllRolesSelect = async () => {
- // 表格功能
- const { clearSelection } = tableRef.value.getTableRef();
-
- const confirm = await messageBox({
+ addDialog({
title: $t('batchUpdates'),
- showMessage: false,
- confirmMessage: undefined,
- cancelMessage: $t('cancel'),
+ width: '35%',
+ draggable: true,
+ closeOnClickModal: false,
+ fullscreenIcon: true,
+ contentRenderer: () => {$t('clearAllRolesSelectTip')},
+ beforeSure: async () => {
+ // 表格功能
+ const { clearSelection } = tableRef.value.getTableRef();
+
+ addDialog({
+ title: $t('doubleCheck'),
+ width: '30%',
+ draggable: true,
+ closeOnClickModal: false,
+ fullscreenIcon: true,
+ contentRenderer: () => {$t('clearAllRolesSelectTip')},
+ beforeSure: async () => {
+ // 清除所有角色
+ const result = await menuStore.clearAllRolesSelect(selectIds.value);
+
+ // 更新成功关闭弹窗
+ if (!result) return;
+ clearSelection();
+ closeAllDialog();
+ },
+ });
+ },
});
-
- // 取消修改
- if (!confirm) return;
-
- // 分配用户角色
- const result = await menuStore.clearAllRolesSelect(selectIds.value);
-
- // 更新成功关闭弹窗
- if (!result) return;
- clearSelection();
};