mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-12-29 17:00:57 +08:00
refactor: 还原 loginStore 命名,重命名为 userStore
This commit is contained in:
@@ -11,12 +11,12 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const userInfo = computed(() => {
|
||||
return {
|
||||
nickname: loginStore.nickname,
|
||||
nickname: userStore.nickname,
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import getAvatar from '@/utils/avatar';
|
||||
|
||||
const userInfo = useLoginStore();
|
||||
const userInfo = useUserStore();
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import { LoginReq } from '@/api/auth/login';
|
||||
import { ValidatedError } from '@arco-design/web-vue';
|
||||
import { encryptByRsa } from '@/utils/encrypt';
|
||||
@@ -65,7 +65,7 @@
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const loading = ref(false);
|
||||
const captchaImgBase64 = ref();
|
||||
const loginConfig = useStorage('login-config', {
|
||||
@@ -100,7 +100,7 @@
|
||||
* 获取验证码
|
||||
*/
|
||||
const getCaptcha = () => {
|
||||
loginStore.getImgCaptcha().then((res) => {
|
||||
userStore.getImgCaptcha().then((res) => {
|
||||
form.value.uuid = res.data.uuid;
|
||||
captchaImgBase64.value = res.data.img;
|
||||
});
|
||||
@@ -123,7 +123,7 @@
|
||||
if (loading.value) return;
|
||||
if (!errors) {
|
||||
loading.value = true;
|
||||
loginStore
|
||||
userStore
|
||||
.login({
|
||||
username: values.username,
|
||||
password: encryptByRsa(values.password) || '',
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
<script lang="ts" setup>
|
||||
import { getCurrentInstance, ref, toRefs, reactive, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import { LoginReq } from '@/api/auth/login';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
const { t } = useI18n();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const loading = ref(false);
|
||||
const captchaLoading = ref(false);
|
||||
const captchaDisable = ref(false);
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
<script lang="ts" setup>
|
||||
import { getCurrentInstance, ref, toRefs, reactive, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import { LoginReq } from '@/api/auth/login';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
const { t } = useI18n();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const loading = ref(false);
|
||||
const captchaLoading = ref(false);
|
||||
const captchaDisable = ref(false);
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
<script setup lang="ts">
|
||||
import { getCurrentInstance, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const loading = ref(false);
|
||||
const source = route.query.source as string;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
const { redirect, ...othersQuery } = router.currentRoute.value.query;
|
||||
loginStore
|
||||
userStore
|
||||
.socialLogin(source, othersQuery)
|
||||
.then(() => {
|
||||
router.push({
|
||||
|
||||
@@ -56,20 +56,20 @@
|
||||
import { FieldRule } from '@arco-design/web-vue';
|
||||
import { BasicInfoModel, updateBasicInfo } from '@/api/system/user-center';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
|
||||
const { t } = useI18n();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const loading = ref(false);
|
||||
|
||||
const data = reactive({
|
||||
// 表单数据
|
||||
form: {
|
||||
username: loginStore.username,
|
||||
nickname: loginStore.nickname,
|
||||
gender: loginStore.gender,
|
||||
username: userStore.username,
|
||||
nickname: userStore.nickname,
|
||||
gender: userStore.gender,
|
||||
} as BasicInfoModel,
|
||||
// 表单验证规则
|
||||
rules: computed((): Record<string, FieldRule[]> => {
|
||||
@@ -107,8 +107,8 @@
|
||||
nickname: form.value.nickname,
|
||||
gender: form.value.gender,
|
||||
})
|
||||
.then((res) => {
|
||||
loginStore.getInfo();
|
||||
.then(() => {
|
||||
userStore.getInfo();
|
||||
proxy.$message.success(t('userCenter.basicInfo.form.save.success'));
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
OperationLogRecord,
|
||||
listOperationLog,
|
||||
} from '@/api/monitor/log';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const dataList = ref<OperationLogRecord[]>([]);
|
||||
const total = ref(0);
|
||||
@@ -73,7 +73,7 @@
|
||||
const data = reactive({
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
uid: loginStore.id,
|
||||
uid: userStore.id,
|
||||
page: 1,
|
||||
size: 10,
|
||||
sort: ['createTime,desc'],
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="content">
|
||||
<a-typography-paragraph v-if="loginStore.email">
|
||||
<a-typography-paragraph v-if="userStore.email">
|
||||
{{
|
||||
$t(
|
||||
'userCenter.securitySettings.updateEmail.placeholder.success.email'
|
||||
)
|
||||
}}:{{ loginStore.email }}
|
||||
}}:{{ userStore.email }}
|
||||
</a-typography-paragraph>
|
||||
<a-typography-paragraph v-else class="tip">
|
||||
{{
|
||||
@@ -114,13 +114,13 @@
|
||||
import { getMailCaptcha } from '@/api/common/captcha';
|
||||
import { updateEmail } from '@/api/system/user-center';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import { encryptByRsa } from '@/utils/encrypt';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
|
||||
const { t } = useI18n();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const captchaTime = ref(60);
|
||||
const captchaTimer = ref();
|
||||
const captchaLoading = ref(false);
|
||||
@@ -155,7 +155,7 @@
|
||||
},
|
||||
{
|
||||
validator: (value, callback) => {
|
||||
if (value === loginStore.email) {
|
||||
if (value === userStore.email) {
|
||||
callback(
|
||||
t(
|
||||
'userCenter.securitySettings.updateEmail.form.error.validator.newEmail'
|
||||
@@ -261,7 +261,7 @@
|
||||
currentPassword: encryptByRsa(form.currentPassword) || '',
|
||||
}).then((res) => {
|
||||
handleCancel();
|
||||
loginStore.getInfo();
|
||||
userStore.getInfo();
|
||||
proxy.$message.success(res.msg);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="content">
|
||||
<a-typography-paragraph v-if="loginStore.phone">
|
||||
<a-typography-paragraph v-if="userStore.phone">
|
||||
{{
|
||||
$t(
|
||||
'userCenter.securitySettings.updatePhone.placeholder.success.phone'
|
||||
)
|
||||
}}:{{ loginStore.phone }}
|
||||
}}:{{ userStore.phone }}
|
||||
</a-typography-paragraph>
|
||||
<a-typography-paragraph v-else class="tip">
|
||||
{{
|
||||
@@ -32,9 +32,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="content">
|
||||
<a-typography-paragraph v-if="loginStore.pwdResetTime">
|
||||
<a-typography-paragraph v-if="userStore.pwdResetTime">
|
||||
{{
|
||||
$t(
|
||||
'userCenter.securitySettings.updatePwd.placeholder.success.password'
|
||||
@@ -102,13 +102,13 @@
|
||||
import { FieldRule } from '@arco-design/web-vue';
|
||||
import { updatePassword } from '@/api/system/user-center';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import { encryptByRsa } from '@/utils/encrypt';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
|
||||
const { t } = useI18n();
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const visible = ref(false);
|
||||
|
||||
// 表单数据
|
||||
|
||||
@@ -38,31 +38,31 @@
|
||||
layout="inline-horizontal"
|
||||
>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.nickname')">{{
|
||||
loginStore.nickname
|
||||
userStore.nickname
|
||||
}}</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.gender')">
|
||||
<div v-if="loginStore.gender === 1">
|
||||
<div v-if="userStore.gender === 1">
|
||||
{{ $t('userCenter.panel.male') }}
|
||||
<icon-man style="color: #19bbf1" />
|
||||
</div>
|
||||
<div v-else-if="loginStore.gender === 2">
|
||||
<div v-else-if="userStore.gender === 2">
|
||||
{{ $t('userCenter.panel.female') }}
|
||||
<icon-woman style="color: #fa7fa9" />
|
||||
</div>
|
||||
<div v-else>{{ $t('userCenter.panel.unknown') }}</div>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.phone')">{{
|
||||
loginStore.phone || '暂无'
|
||||
userStore.phone || '暂无'
|
||||
}}</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.email')">{{
|
||||
loginStore.email || '暂无'
|
||||
userStore.email || '暂无'
|
||||
}}</a-descriptions-item>
|
||||
<a-descriptions-item :label="$t('userCenter.panel.label.deptName')">{{
|
||||
loginStore.deptName
|
||||
userStore.deptName
|
||||
}}</a-descriptions-item>
|
||||
<a-descriptions-item
|
||||
:label="$t('userCenter.panel.label.registrationDate')"
|
||||
>{{ loginStore.registrationDate }}</a-descriptions-item
|
||||
>{{ userStore.registrationDate }}</a-descriptions-item
|
||||
>
|
||||
</a-descriptions>
|
||||
</a-space>
|
||||
@@ -73,16 +73,16 @@
|
||||
import { getCurrentInstance, ref } from 'vue';
|
||||
import { FileItem, RequestOption } from '@arco-design/web-vue';
|
||||
import { uploadAvatar } from '@/api/system/user-center';
|
||||
import { useLoginStore } from '@/store';
|
||||
import { useUserStore } from '@/store';
|
||||
import getAvatar from '@/utils/avatar';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
|
||||
const loginStore = useLoginStore();
|
||||
const userStore = useUserStore();
|
||||
const avatar = {
|
||||
uid: '-2',
|
||||
name: 'avatar.png',
|
||||
url: getAvatar(loginStore.avatar, loginStore.gender),
|
||||
url: getAvatar(userStore.avatar, userStore.gender),
|
||||
};
|
||||
const avatarList = ref<FileItem[]>([avatar]);
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
uploadAvatar(formData)
|
||||
.then((res) => {
|
||||
onSuccess(res);
|
||||
loginStore.avatar = res.data.avatar;
|
||||
userStore.avatar = res.data.avatar;
|
||||
proxy.$message.success(res.msg);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user