From d88c38df562b45ab591e1f93e592af9350830baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=A2=A6?= Date: Wed, 3 Jun 2026 17:12:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9A=90=E8=97=8F=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/system/setting/account.vue | 220 ++++++++++++++-------------- 1 file changed, 108 insertions(+), 112 deletions(-) diff --git a/src/page/system/setting/account.vue b/src/page/system/setting/account.vue index eea1237..2df9fc7 100644 --- a/src/page/system/setting/account.vue +++ b/src/page/system/setting/account.vue @@ -3,37 +3,37 @@ import ChangePassword from './changePassword.vue' import { userStore } from '@/stores' import { storeToRefs } from 'pinia' import { useRouter } from 'vue-router' -import { getSN, isNotStudyMachine } from '@/utils' -import { useTips } from '@/hooks' -import { debounce } from 'lodash-es' -import { loading } from '@/components/mj/mj-loading' +// import { getSN, isNotStudyMachine } from '@/utils' +// import { useTips } from '@/hooks' +// import { debounce } from 'lodash-es' +// import { loading } from '@/components/mj/mj-loading' import hud from '@/utils/hud' -import settingApi from '@/api/system/setting' -import userApi from '@/api/system/user' +// import settingApi from '@/api/system/setting' +// import userApi from '@/api/system/user' -const emits = defineEmits(['updateAccount']) +// const emits = defineEmits(['updateAccount']) const router = useRouter() -const { logout, changeAccount, getUserNow, clearUser } = userStore() -const { userInfo, userRecords } = storeToRefs(userStore()) +const { logout } = userStore() +const { userInfo } = storeToRefs(userStore()) -interface AccountItemType { - account?: string - avatarFrameUrl?: string - avatarUrl?: string - nickName?: string - nickNameFrameUrl?: string - personalImageNum?: number - token?: string -} +// interface AccountItemType { +// account?: string +// avatarFrameUrl?: string +// avatarUrl?: string +// nickName?: string +// nickNameFrameUrl?: string +// personalImageNum?: number +// token?: string +// } const OSS_URL = import.meta.env.VITE_OSS_URL const bg = `url(${OSS_URL}/urm/header_bg.svg) 100%/cover no-repeat` -const addAccount = `url(${OSS_URL}/urm/system_setting_account_add.svg) 100%/cover no-repeat` +// const addAccount = `url(${OSS_URL}/urm/system_setting_account_add.svg) 100%/cover no-repeat` const showDia = ref(false) -const accountLoading = ref(false) +// const accountLoading = ref(false) -const activeAccount = ref({}) -const accountList = ref([]) +// const activeAccount = ref({}) +// const accountList = ref([]) // 退出登录 async function handleConfirmLogout() { @@ -47,95 +47,90 @@ async function handleConfirmLogout() { }) } -// 切换账号 -async function handleSwitchAccount(i: AccountItemType) { - if (i.account === userInfo.value.account) return - try { - loading.show('正在切换中...') - - if (isNotStudyMachine) { - const { data } = await userApi.switchUser({ - account: i.account, - targetAccountOldToken: i.token, - }) - await changeAccount(data.data) - } else { - const { data } = await settingApi.changeLoginAccApi({ account: i.account as string }) - await changeAccount(data.data) - } - activeAccount.value = i - // await getInspectorInfo() - // location.reload() - } catch (err: any) { - if (isNotStudyMachine) { - clearUser(i.account!) - } - router.push({ path: '/login', query: { back: 1, a: i.account } }) - if (err.data.message) { - useTips({ - tips: err.data.message, - }) - } - } finally { - loading.hide() - } -} - -// 登录过设备的账号 -async function getCurrentDeviceRelateAcc() { - // web环境使用本地账户信息 - if (isNotStudyMachine) { - accountList.value = userRecords.value - activeAccount.value = getUserNow() - return - } - accountLoading.value = true - try { - const { data } = await settingApi.getCurrentDeviceRelateAccApi() - accountList.value = data.data - activeAccount.value = data.data.find( - (item: AccountItemType) => item.account === userInfo.value.account, - ) - } catch (err) { - console.log(err) - } finally { - accountLoading.value = false - } -} -function handleAddAccount() { - router.push({ path: '/login', query: { back: 1 } }) -} -function handleDelete(i: AccountItemType) { - if (i.account === userInfo.value.account) return - - hud.alert({ - content: `确定要删除账号${hud.highlight(i.nickName)}吗?`, - ok: async () => { - if (isNotStudyMachine) { - clearUser(i.account!) - accountList.value = userRecords.value - return - } - // 安卓端删除设备关联账号 - settingApi - .deleteDeviceRelateAccApi({ - simSerialNumber: getSN(), - account: i.account, - }) - .then(() => getCurrentDeviceRelateAcc()) - }, - }) -} -const _handleDelete = debounce(handleDelete, 500, { - leading: true, - trailing: false, -}) -onMounted(() => { - getCurrentDeviceRelateAcc() -}) -onActivated(() => { - getCurrentDeviceRelateAcc() -}) +// 切换账号 - 暂时隐藏 +// async function handleSwitchAccount(i: AccountItemType) { +// if (i.account === userInfo.value.account) return +// try { +// loading.show('正在切换中...') +// +// if (isNotStudyMachine) { +// const { data } = await userApi.switchUser({ +// account: i.account, +// targetAccountOldToken: i.token, +// }) +// await changeAccount(data.data) +// } else { +// const { data } = await settingApi.changeLoginAccApi({ account: i.account as string }) +// await changeAccount(data.data) +// } +// activeAccount.value = i +// } catch (err: any) { +// if (isNotStudyMachine) { +// clearUser(i.account!) +// } +// router.push({ path: '/login', query: { back: 1, a: i.account } }) +// if (err.data.message) { +// useTips({ +// tips: err.data.message, +// }) +// } +// } finally { +// loading.hide() +// } +// } +// +// async function getCurrentDeviceRelateAcc() { +// if (isNotStudyMachine) { +// accountList.value = userRecords.value +// activeAccount.value = getUserNow() +// return +// } +// accountLoading.value = true +// try { +// const { data } = await settingApi.getCurrentDeviceRelateAccApi() +// accountList.value = data.data +// activeAccount.value = data.data.find( +// (item: AccountItemType) => item.account === userInfo.value.account, +// ) +// } catch (err) { +// console.log(err) +// } finally { +// accountLoading.value = false +// } +// } +// function handleAddAccount() { +// router.push({ path: '/login', query: { back: 1 } }) +// } +// function handleDelete(i: AccountItemType) { +// if (i.account === userInfo.value.account) return +// +// hud.alert({ +// content: `确定要删除账号${hud.highlight(i.nickName)}吗?`, +// ok: async () => { +// if (isNotStudyMachine) { +// clearUser(i.account!) +// accountList.value = userRecords.value +// return +// } +// settingApi +// .deleteDeviceRelateAccApi({ +// simSerialNumber: getSN(), +// account: i.account, +// }) +// .then(() => getCurrentDeviceRelateAcc()) +// }, +// }) +// } +// const _handleDelete = debounce(handleDelete, 500, { +// leading: true, +// trailing: false, +// }) +// onMounted(() => { +// getCurrentDeviceRelateAcc() +// }) +// onActivated(() => { +// getCurrentDeviceRelateAcc() +// })