Commit dd2ad8ed by 王立鹏

Merge branch '代码优化/10803' into 'master'

【代码优化 10803】feat: 获取新token优化、发表视频按钮优化等

See merge request !9
parents 9ecaf19a c97f8332
import { defineStore } from 'pinia'
import { useLocalStorage } from '@vueuse/core'
import { useStorage } from '@vueuse/core'
export const useOnlineTimeStore = defineStore('onlineTime', () => {
const showOnlineTime = useLocalStorage('show-online-time', true)
const showOnlineTime = useStorage('show-online-time', true)
return {
showOnlineTime,
}
......
......@@ -13,7 +13,7 @@ import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
import service from './index'
import { useUserStore } from '@/stores/user'
import { push, type PushClearMethods } from 'notivue'
import { generateLoginKey } from '@/api'
/**
* 后端逻辑code报错处理
* @param backendServiceResult 后端传来错误信息
......@@ -129,25 +129,41 @@ async function handleUnAuthorized(axiosError: AxiosError) {
// 捕捉这一个错误
await promiseFlashing
return service.request(axiosError.config as AxiosRequestConfig)
} catch (e) {
// 获取refreshToken接口报错
} catch (e: any) {
console.log(e)
create401ErrorMsg()
userStore.clearAllUserInfo()
return Promise.reject(e)
// 获取refreshToken接口报错
// 直接重新登陆
// 获取登陆的key
const { data } = await generateLoginKey({
timestamp: Date.now(),
type: 1,
userId: userStore.userInfo?.userId || '',
})
// 清理sessionStorage
localStorage.clear()
await userStore.getUserInfoByCode({
code: data,
isCodeLogin: 1,
})
window.location.reload()
// console.log(e)
// create401ErrorMsg()
// userStore.clearAllUserInfo()
// return Promise.reject(e)
} finally {
promiseFlashing = null
}
}
let msgIns: PushClearMethods | null = null
// let msgIns: PushClearMethods | null = null
function create401ErrorMsg() {
if (!msgIns) {
msgIns = push.error({
message: '重新获取token失败,请关闭标签页,重新打开',
duration: 0,
})
}
return msgIns
}
// function create401ErrorMsg() {
// if (!msgIns) {
// msgIns = push.error({
// message: '重新获取token失败,请关闭标签页,重新打开',
// duration: 0,
// })
// }
// return msgIns
// }
......@@ -260,6 +260,7 @@
@click="handleSubmit(ReleaseStatusTypeEnum.DRAFT)"
size="large"
class="w-full !border-gray-200 hover:!border-indigo-300 hover:!text-indigo-600 transition-colors duration-200"
:loading="loading"
>
<el-icon class="mr-2">
<IEpDocument />
......@@ -269,6 +270,7 @@
<el-button
type="primary"
size="large"
:loading="loading"
class="w-full !bg-gradient-to-r !from-indigo-500 !to-purple-600 !border-none shadow-lg hover:shadow-xl transition-shadow duration-300"
@click="handleSubmit(ReleaseStatusTypeEnum.PUBLISH)"
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment