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

View File

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