refactor: clean up access token retrieval logic and remove unused authentication watcher

This commit is contained in:
wxg0103 2025-07-10 14:31:51 +08:00
parent e697ddafbc
commit d26872aefb
2 changed files with 24 additions and 23 deletions

View File

@ -25,16 +25,16 @@ const useApplicationStore = defineStore('application', {
async asyncGetAccessToken(id: string, loading?: Ref<boolean>) {
return new Promise((resolve, reject) => {
const user = useUserStore()
if (user.isEE() || user.isPE()) {
applicationXpackApi
.getAccessToken(id, loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
} else {
// if (user.isEE() || user.isPE()) {
// applicationXpackApi
// .getAccessToken(id, loading)
// .then((data) => {
// resolve(data)
// })
// .catch((error) => {
// reject(error)
// })
// } else {
applicationApi
.getAccessToken(id, loading)
.then((data) => {
@ -43,7 +43,7 @@ const useApplicationStore = defineStore('application', {
.catch((error) => {
reject(error)
})
}
// }
})
},

View File

@ -34,7 +34,7 @@
v-if="form.authentication"
v-model="form.authentication_value.type"
class="card__radio"
@change="(val: string) => val === 'password' && refreshAuthentication()"
@change="(val: string) => val === 'password'"
>
<el-card
shadow="never"
@ -179,16 +179,16 @@ watch(dialogVisible, (bool) => {
}
}
})
watch(
() => form.value.authentication,
(b) => {
if (b) {
applicationApi.getChatUserAuthType().then((ok) => {
auth_list.value = ok.data
})
}
},
)
// watch(
// () => form.value.authentication,
// (b) => {
// if (b) {
// applicationApi.getChatUserAuthType().then((ok) => {
// auth_list.value = ok.data
// })
// }
// },
// )
const open = (data: any) => {
form.value.access_num = data.access_num
form.value.white_active = data.white_active
@ -196,7 +196,7 @@ const open = (data: any) => {
form.value.authentication_value = data.authentication_value || {
type: 'password',
}
if (form.value.authentication_value.type === 'password') {
if (form.value.authentication_value.type === 'password' && !form.value.authentication_value.password_value) {
refreshAuthentication()
}
form.value.authentication = data.authentication
@ -239,6 +239,7 @@ function refreshAuthentication() {
}
function firstGeneration() {
console.log('firstGeneration')
if (form.value.authentication && !form.value.authentication_value) {
form.value.authentication_value = generateAuthenticationValue()
}