1.解决线上报错token的问题
parent
e5e3971635
commit
845a9f63e7
|
|
@ -23,7 +23,7 @@ const new_link = ref('');
|
|||
const index = window.location.href.lastIndexOf('?s=');
|
||||
const pro_url = window.location.href.substring(0, index);
|
||||
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
||||
const cookie = get_cookie('admin_info');
|
||||
const cookie = get_cookie('admin_info') || '';
|
||||
const token = ref('');
|
||||
const key = ref(0);
|
||||
onMounted(async () => {
|
||||
|
|
@ -31,7 +31,7 @@ onMounted(async () => {
|
|||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../../../temp.d.ts' : '../../../../temp_pro.d');
|
||||
token.value = '&token=' + temp_data.default.temp_token;
|
||||
} else {
|
||||
if (cookie) {
|
||||
if (cookie && cookie !== null && cookie !== 'null') {
|
||||
token.value = '&token=' + JSON.parse(cookie).token;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ const service = axios.create({
|
|||
service.interceptors.request.use(
|
||||
async (config: InternalAxiosRequestConfig) => {
|
||||
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
||||
const cookie = get_cookie('admin_info');
|
||||
const cookie = get_cookie('admin_info') || '';
|
||||
const symbol = config.url?.includes('?') ? '&' : '?';
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../temp.d' : '../../temp_pro.d');
|
||||
config.url = config.url + symbol + 'token=' + temp_data.default.temp_token;
|
||||
} else {
|
||||
if (cookie) {
|
||||
config.url = config.url + '&token=' + JSON.parse(cookie).token;
|
||||
if (cookie && cookie !== null && cookie !== 'null') {
|
||||
config.url = config.url + '&token=' + JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : '';
|
||||
}
|
||||
}
|
||||
return config;
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ interface componentsData {
|
|||
}
|
||||
const components = ref<componentsData[]>([]);
|
||||
const url_computer = (name: string) => {
|
||||
const new_url = ref(new URL(`../../../../assets/images/layout/siderbar/${name}.png`, import.meta.url).href).value;
|
||||
let new_url = ref(new URL(`../../../../assets/images/layout/siderbar/${name}.png`, import.meta.url).href).value;
|
||||
return new_url;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue