feat: 隐藏账号切换
This commit is contained in:
parent
1c75a9b070
commit
d88c38df56
@ -3,37 +3,37 @@ import ChangePassword from './changePassword.vue'
|
|||||||
import { userStore } from '@/stores'
|
import { userStore } from '@/stores'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { getSN, isNotStudyMachine } from '@/utils'
|
// import { getSN, isNotStudyMachine } from '@/utils'
|
||||||
import { useTips } from '@/hooks'
|
// import { useTips } from '@/hooks'
|
||||||
import { debounce } from 'lodash-es'
|
// import { debounce } from 'lodash-es'
|
||||||
import { loading } from '@/components/mj/mj-loading'
|
// import { loading } from '@/components/mj/mj-loading'
|
||||||
import hud from '@/utils/hud'
|
import hud from '@/utils/hud'
|
||||||
import settingApi from '@/api/system/setting'
|
// import settingApi from '@/api/system/setting'
|
||||||
import userApi from '@/api/system/user'
|
// import userApi from '@/api/system/user'
|
||||||
|
|
||||||
const emits = defineEmits(['updateAccount'])
|
// const emits = defineEmits(['updateAccount'])
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { logout, changeAccount, getUserNow, clearUser } = userStore()
|
const { logout } = userStore()
|
||||||
const { userInfo, userRecords } = storeToRefs(userStore())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
|
|
||||||
interface AccountItemType {
|
// interface AccountItemType {
|
||||||
account?: string
|
// account?: string
|
||||||
avatarFrameUrl?: string
|
// avatarFrameUrl?: string
|
||||||
avatarUrl?: string
|
// avatarUrl?: string
|
||||||
nickName?: string
|
// nickName?: string
|
||||||
nickNameFrameUrl?: string
|
// nickNameFrameUrl?: string
|
||||||
personalImageNum?: number
|
// personalImageNum?: number
|
||||||
token?: string
|
// token?: string
|
||||||
}
|
// }
|
||||||
|
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_URL
|
const OSS_URL = import.meta.env.VITE_OSS_URL
|
||||||
const bg = `url(${OSS_URL}/urm/header_bg.svg) 100%/cover no-repeat`
|
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 showDia = ref(false)
|
||||||
const accountLoading = ref(false)
|
// const accountLoading = ref(false)
|
||||||
|
|
||||||
const activeAccount = ref<AccountItemType>({})
|
// const activeAccount = ref<AccountItemType>({})
|
||||||
const accountList = ref<AccountItemType[]>([])
|
// const accountList = ref<AccountItemType[]>([])
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
async function handleConfirmLogout() {
|
async function handleConfirmLogout() {
|
||||||
@ -47,95 +47,90 @@ async function handleConfirmLogout() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换账号
|
// 切换账号 - 暂时隐藏
|
||||||
async function handleSwitchAccount(i: AccountItemType) {
|
// async function handleSwitchAccount(i: AccountItemType) {
|
||||||
if (i.account === userInfo.value.account) return
|
// if (i.account === userInfo.value.account) return
|
||||||
try {
|
// try {
|
||||||
loading.show('正在切换中...')
|
// loading.show('正在切换中...')
|
||||||
|
//
|
||||||
if (isNotStudyMachine) {
|
// if (isNotStudyMachine) {
|
||||||
const { data } = await userApi.switchUser({
|
// const { data } = await userApi.switchUser({
|
||||||
account: i.account,
|
// account: i.account,
|
||||||
targetAccountOldToken: i.token,
|
// targetAccountOldToken: i.token,
|
||||||
})
|
// })
|
||||||
await changeAccount(data.data)
|
// await changeAccount(data.data)
|
||||||
} else {
|
// } else {
|
||||||
const { data } = await settingApi.changeLoginAccApi({ account: i.account as string })
|
// const { data } = await settingApi.changeLoginAccApi({ account: i.account as string })
|
||||||
await changeAccount(data.data)
|
// await changeAccount(data.data)
|
||||||
}
|
// }
|
||||||
activeAccount.value = i
|
// activeAccount.value = i
|
||||||
// await getInspectorInfo()
|
// } catch (err: any) {
|
||||||
// location.reload()
|
// if (isNotStudyMachine) {
|
||||||
} catch (err: any) {
|
// clearUser(i.account!)
|
||||||
if (isNotStudyMachine) {
|
// }
|
||||||
clearUser(i.account!)
|
// router.push({ path: '/login', query: { back: 1, a: i.account } })
|
||||||
}
|
// if (err.data.message) {
|
||||||
router.push({ path: '/login', query: { back: 1, a: i.account } })
|
// useTips({
|
||||||
if (err.data.message) {
|
// tips: err.data.message,
|
||||||
useTips({
|
// })
|
||||||
tips: err.data.message,
|
// }
|
||||||
})
|
// } finally {
|
||||||
}
|
// loading.hide()
|
||||||
} finally {
|
// }
|
||||||
loading.hide()
|
// }
|
||||||
}
|
//
|
||||||
}
|
// async function getCurrentDeviceRelateAcc() {
|
||||||
|
// if (isNotStudyMachine) {
|
||||||
// 登录过设备的账号
|
// accountList.value = userRecords.value
|
||||||
async function getCurrentDeviceRelateAcc() {
|
// activeAccount.value = getUserNow()
|
||||||
// web环境使用本地账户信息
|
// return
|
||||||
if (isNotStudyMachine) {
|
// }
|
||||||
accountList.value = userRecords.value
|
// accountLoading.value = true
|
||||||
activeAccount.value = getUserNow()
|
// try {
|
||||||
return
|
// const { data } = await settingApi.getCurrentDeviceRelateAccApi()
|
||||||
}
|
// accountList.value = data.data
|
||||||
accountLoading.value = true
|
// activeAccount.value = data.data.find(
|
||||||
try {
|
// (item: AccountItemType) => item.account === userInfo.value.account,
|
||||||
const { data } = await settingApi.getCurrentDeviceRelateAccApi()
|
// )
|
||||||
accountList.value = data.data
|
// } catch (err) {
|
||||||
activeAccount.value = data.data.find(
|
// console.log(err)
|
||||||
(item: AccountItemType) => item.account === userInfo.value.account,
|
// } finally {
|
||||||
)
|
// accountLoading.value = false
|
||||||
} catch (err) {
|
// }
|
||||||
console.log(err)
|
// }
|
||||||
} finally {
|
// function handleAddAccount() {
|
||||||
accountLoading.value = false
|
// router.push({ path: '/login', query: { back: 1 } })
|
||||||
}
|
// }
|
||||||
}
|
// function handleDelete(i: AccountItemType) {
|
||||||
function handleAddAccount() {
|
// if (i.account === userInfo.value.account) return
|
||||||
router.push({ path: '/login', query: { back: 1 } })
|
//
|
||||||
}
|
// hud.alert({
|
||||||
function handleDelete(i: AccountItemType) {
|
// content: `确定要删除账号${hud.highlight(i.nickName)}吗?`,
|
||||||
if (i.account === userInfo.value.account) return
|
// ok: async () => {
|
||||||
|
// if (isNotStudyMachine) {
|
||||||
hud.alert({
|
// clearUser(i.account!)
|
||||||
content: `确定要删除账号${hud.highlight(i.nickName)}吗?`,
|
// accountList.value = userRecords.value
|
||||||
ok: async () => {
|
// return
|
||||||
if (isNotStudyMachine) {
|
// }
|
||||||
clearUser(i.account!)
|
// settingApi
|
||||||
accountList.value = userRecords.value
|
// .deleteDeviceRelateAccApi({
|
||||||
return
|
// simSerialNumber: getSN(),
|
||||||
}
|
// account: i.account,
|
||||||
// 安卓端删除设备关联账号
|
// })
|
||||||
settingApi
|
// .then(() => getCurrentDeviceRelateAcc())
|
||||||
.deleteDeviceRelateAccApi({
|
// },
|
||||||
simSerialNumber: getSN(),
|
// })
|
||||||
account: i.account,
|
// }
|
||||||
})
|
// const _handleDelete = debounce(handleDelete, 500, {
|
||||||
.then(() => getCurrentDeviceRelateAcc())
|
// leading: true,
|
||||||
},
|
// trailing: false,
|
||||||
})
|
// })
|
||||||
}
|
// onMounted(() => {
|
||||||
const _handleDelete = debounce(handleDelete, 500, {
|
// getCurrentDeviceRelateAcc()
|
||||||
leading: true,
|
// })
|
||||||
trailing: false,
|
// onActivated(() => {
|
||||||
})
|
// getCurrentDeviceRelateAcc()
|
||||||
onMounted(() => {
|
// })
|
||||||
getCurrentDeviceRelateAcc()
|
|
||||||
})
|
|
||||||
onActivated(() => {
|
|
||||||
getCurrentDeviceRelateAcc()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="account_module hidden_scroll">
|
<div class="account_module hidden_scroll">
|
||||||
@ -187,7 +182,7 @@ onActivated(() => {
|
|||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 切换账号 -->
|
<!-- 切换账号 - 暂时隐藏
|
||||||
<div class="switch_account">
|
<div class="switch_account">
|
||||||
<div
|
<div
|
||||||
class="header"
|
class="header"
|
||||||
@ -224,6 +219,7 @@ onActivated(() => {
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
<ChangePassword v-model="showDia" />
|
<ChangePassword v-model="showDia" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user