Skip to content

Commit

Permalink
feat: 更新默认取token的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
ATQQ committed Jan 21, 2024
1 parent b90aec3 commit 3fcdd62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import ImageUpload from './components/ImageUpload.vue'
import { useConfigStore } from './store';
import { useLocalStorage } from '@vueuse/core';
const store = useConfigStore()
const qiniuToken = useLocalStorage('qiniu-token', import.meta.env.VITE_APP_QINIU_TOKEN)
// 默认取用户设置的token
const qiniuToken = useLocalStorage('qiniu-token', '')
watch(qiniuToken, (newValue) => {
store.parseQiniuToken(newValue)
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/store/modules/configStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const configStore = defineStore('configStore', {
actions: {
parseQiniuToken(token?: string) {
try {
const config = JSON.parse(atob(token ?? import.meta.env.VITE_APP_QINIU_TOKEN))
// 兜底都取默认的token
const config = JSON.parse(atob(token || import.meta.env.VITE_APP_QINIU_TOKEN))
Object.assign(this.qiniu, config)
if (token) {
localStorage.setItem('qiniu-token', token)
}
}
catch (err: any) {
console.error(err)
ElMessage.error('token 有误,解析失败')
}
},
Expand Down

0 comments on commit 3fcdd62

Please sign in to comment.