feat: 🚀 token无感刷新
This commit is contained in:
@@ -2,7 +2,7 @@ ENV = 'dev'
|
||||
|
||||
VITE_APP_API_BASEURL =https://dev.ow.f2b211.com/admapi/v1
|
||||
#前端回显图片之类的地址
|
||||
VITE_APP_API_BASE_UPLOAD_URL =https://dev.ow.f2b211.com/
|
||||
VITE_APP_API_BASE_UPLOAD_URL =https://dev.ow.f2b211.com
|
||||
# 本地环境
|
||||
VITE_USER_NODE_ENV = development
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { showFullScreenLoading, tryHideFullScreenLoading } from "@/config/servic
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ResultData } from "@/api/interface";
|
||||
import { ResultEnum } from "@/enums/httpEnum";
|
||||
import { checkStatus } from "./helper/checkStatus";
|
||||
// import { checkStatus } from "./helper/checkStatus";
|
||||
import { useUserStore } from "@/stores/modules/user";
|
||||
import router from "@/routers";
|
||||
//获取导出表格name
|
||||
@@ -54,7 +54,7 @@ class RequestHttp {
|
||||
// 当前请求不需要显示 loading,在 api 服务中通过指定的第三个参数: { noLoading: true } 来控制
|
||||
config.noLoading || showFullScreenLoading();
|
||||
if (config.headers && typeof config.headers.set === "function") {
|
||||
config.headers.set("Authorization", "Bearer" + " " + userStore.token);
|
||||
config.headers.set("Authorization", userStore.token);
|
||||
}
|
||||
return config;
|
||||
},
|
||||
@@ -74,7 +74,7 @@ class RequestHttp {
|
||||
//获取导出表格名称
|
||||
getDispositionName(response);
|
||||
// 获取响应头中的 Authorization 信息
|
||||
const authorization = response.headers["Authorization"];
|
||||
const authorization = response.headers["authorization"];
|
||||
if (authorization) {
|
||||
// 可以在这里更新用户的 token 信息
|
||||
const userStore = useUserStore();
|
||||
@@ -103,7 +103,7 @@ class RequestHttp {
|
||||
// 根据服务器响应的错误状态码,做不同的处理
|
||||
if (response) {
|
||||
console.log("error-走到了这里", response.status);
|
||||
checkStatus(response.status, response.data);
|
||||
// checkStatus(response.status, response.data);
|
||||
}
|
||||
// 服务器结果都没有返回(可能服务器错误可能客户端断网),断网处理:可以跳转到断网页面
|
||||
if (!window.navigator.onLine) router.replace("/500");
|
||||
|
||||
@@ -36,3 +36,7 @@ export const getProductListSortApi = (params: any) => {
|
||||
const { id, sort } = params;
|
||||
return http.post<any>(`${PRODUCT}/sort/${id}`, { sort });
|
||||
};
|
||||
// getProductCategoryListApi
|
||||
export const getProductCategoryListApi = () => {
|
||||
return http.get<any>(`/product/categorys`);
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<el-input v-model="scope.row.sort" @blur="handleBlur(scope.row)" @input="handleInput(scope.row)"></el-input>
|
||||
</template>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
|
||||
<template #operation="scope">
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #enabled="scope">
|
||||
<el-tag type="success" effect="dark">{{ scope.row.enabled === 1 ? "启用" : "禁用" }}</el-tag>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
|
||||
<template #status="scope">
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #is_audited="scope">
|
||||
<el-tag :type="scope.row.is_audited ? 'success' : 'danger'" effect="dark">{{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag type="success" effect="dark">{{ scope.row.status }}</el-tag>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #sort="scope">
|
||||
<el-input v-model="scope.row.sort" @blur="handleBlur(scope.row)" @input="handleInput(scope.row)"></el-input>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag type="success" effect="dark">{{ scope.row.status }}</el-tag>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'" effect="dark">{{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag type="danger" effect="dark">{{ scope.row.status ? "删除" : "删除" }}</el-tag>
|
||||
|
||||
@@ -268,7 +268,7 @@ const setUserData = (data: any) => {
|
||||
const { username, uid, token, avatar } = data;
|
||||
console.log();
|
||||
// 设置token
|
||||
userStore.setToken(token);
|
||||
userStore.setToken("Bearer" + " " + token);
|
||||
userStore.setUid(uid);
|
||||
userStore.setNickname(username);
|
||||
userStore.setAvatar(avatar);
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
:request-api="getProductBuypassListApi"
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #imgUrl="scope">
|
||||
<el-image :src="scope.row.imgUrl" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<!-- <template #imgUrl="scope">
|
||||
<el-image :src="scope.row.imgUrl ? h + scope.row.imgUrl : ''" style="width: 60px; height: 60px" />
|
||||
</template> -->
|
||||
<template #status="scope">
|
||||
<el-tag type="success" effect="dark">{{ scope.row.status }}</el-tag>
|
||||
</template>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #cover_image="scope">
|
||||
<el-image :src="h + scope.row.cover_image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.cover_image ? h + scope.row.cover_image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag effect="dark" :type="scope.row.status === 1 ? 'success' : 'danger'">{{
|
||||
@@ -59,9 +59,10 @@ import {
|
||||
getProductListApi,
|
||||
getProductUpOrShelvesApi,
|
||||
getProductListSortApi,
|
||||
getProductListExportApi
|
||||
getProductListExportApi,
|
||||
getProductCategoryListApi
|
||||
} from "@/api/modules/productList";
|
||||
import { getProductCategoryListApi } from "@/api/modules/productClass";
|
||||
// import { getProductCategoryListApi } from "@/api/modules/productClass";
|
||||
import { addLabelValue } from "./utils/common/addLabelValue";
|
||||
|
||||
//深拷贝方法
|
||||
@@ -112,7 +113,7 @@ const getProductListSort = async (row: any) => {
|
||||
|
||||
//产品分类(后端大佬说直接掉列表接口)
|
||||
const getProductCategoryList = async () => {
|
||||
const result = await getProductCategoryListApi({ page: 1, size: 500 });
|
||||
const result = await getProductCategoryListApi();
|
||||
if (result?.code === 0) {
|
||||
let dataClone: any = cloneDeep(result?.data);
|
||||
dataStore.formData[2].options = addLabelValue(dataClone);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag type="danger" effect="dark"> {{ scope.row.status === 1 ? "删除" : "删除" }}</el-tag>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag type="success" effect="dark">{{ scope.row.status }}</el-tag>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'" effect="dark">{{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
|
||||
<template #status="scope">
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:init-param="dataStore.initParam"
|
||||
>
|
||||
<template #image="scope">
|
||||
<el-image :src="h + scope.row.image" style="width: 60px; height: 60px" />
|
||||
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<el-tag type="success" effect="dark">{{ scope.row.status }}</el-tag>
|
||||
|
||||
Reference in New Issue
Block a user