mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-13 04:46:46 +08:00
提交
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import {isRef, reactive, ref, toRefs, unref, watch, watchEffect} from "vue";
|
||||
import {getCookieForName, setCookie, throttle} from "@/api/method";
|
||||
import { isRef, reactive, ref, toRefs, unref, watch, watchEffect } from "vue";
|
||||
import { getCookieForName, setCookie, throttle } from "@/api/method";
|
||||
import JSONBigInt from "json-bigint";
|
||||
import router from "@/router";
|
||||
import {message} from "ant-design-vue";
|
||||
import {REFRESH_TOKEN, VALIDATE_TOKEN} from "@/api/apis";
|
||||
import {REFRESH_TOKEN_API} from "@/api/ThirdApi";
|
||||
import { message } from "ant-design-vue";
|
||||
import { REFRESH_TOKEN, VALIDATE_TOKEN } from "@/api/apis";
|
||||
import { REFRESH_TOKEN_API } from "@/api/ThirdApi";
|
||||
import growthHttp from "./configGrowth";
|
||||
|
||||
const JSONBigIntStr = JSONBigInt({ storeAsString: true });
|
||||
|
||||
@@ -163,7 +164,7 @@ export function useNewRowsPageNoInit(_url, params) {
|
||||
state.data = r.data.list;
|
||||
state.total = r.data.total;
|
||||
state.loading = false;
|
||||
}).catch((err)=>{
|
||||
}).catch((err) => {
|
||||
state.data = [];
|
||||
state.total = 0;
|
||||
state.loading = false;
|
||||
@@ -260,7 +261,7 @@ export function useRowsPage(_url, params, init = true) {
|
||||
* @param init
|
||||
* @param listing
|
||||
*/
|
||||
export function useTotalPage(_url, params, init = true,listing = false) {
|
||||
export function useTotalPage(_url, params, init = true, listing = false) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
@@ -304,7 +305,7 @@ export function useTotalPage(_url, params, init = true,listing = false) {
|
||||
reset,
|
||||
};
|
||||
}
|
||||
export function usePage(_url, params, init = true,listing = false) {
|
||||
export function usePage(_url, params, init = true, listing = false) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
@@ -348,7 +349,7 @@ export function usePage(_url, params, init = true,listing = false) {
|
||||
reset,
|
||||
};
|
||||
}
|
||||
export function useThrottlePage(_url, params = {}, init = true) {
|
||||
export function useThrottlePage(_url, params = {}, init = true) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
@@ -371,7 +372,7 @@ export function usePage(_url, params, init = true,listing = false) {
|
||||
}
|
||||
return request(_url, params).then(r => {
|
||||
state.data = params.pageNo === 1 ? r.data.list : [...state.data, ...r.data.list];
|
||||
state.totalPage = r.data.total/10 || 1;
|
||||
state.totalPage = r.data.total / 10 || 1;
|
||||
state.total = r.data.total;
|
||||
state.loading = false;
|
||||
}).catch(err => {
|
||||
@@ -386,6 +387,44 @@ export function usePage(_url, params, init = true,listing = false) {
|
||||
};
|
||||
}
|
||||
|
||||
export function growthRequest(_url, params, init = true) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
total: 1,
|
||||
pageNo: 1,
|
||||
pages: 1,
|
||||
loading: false
|
||||
});
|
||||
|
||||
function reset() {
|
||||
state.data = [];
|
||||
state.loading = false;
|
||||
state.pageNo = 1
|
||||
state.pages = 1
|
||||
}
|
||||
|
||||
function fetch() {
|
||||
state.loading = true;
|
||||
return growthHttp.get(unref(_url), { params: unref(params) }).then(r => {
|
||||
state.data = r.data.data.records;
|
||||
state.total = r.data.data.total;
|
||||
state.pageNo = r.data.data.pageNum
|
||||
state.pages = r.data.data.pageSize
|
||||
state.loading = false;
|
||||
}).catch((err) => {
|
||||
state.data = [];
|
||||
state.total = 0;
|
||||
state.loading = false;
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
reset,
|
||||
};
|
||||
}
|
||||
|
||||
export function useRequest(_url, params, init = true) {
|
||||
|
||||
@@ -504,15 +543,15 @@ export async function request(_url, params) {
|
||||
window.location.href = process.env.VUE_APP_LOGIN_URL + encodeURIComponent(window.location.protocol + process.env.VUE_APP_BOE_API_URL + process.env.VUE_APP_BASE + router.currentRoute.value.fullPath)
|
||||
localStorage.removeItem('refreshPage')
|
||||
return Promise.reject(res);
|
||||
}else if(res.code=== 1001){
|
||||
return boeRequest(REFRESH_TOKEN_API).then((res)=>{
|
||||
if(res.code===0 || res.code === 200){
|
||||
} else if (res.code === 1001) {
|
||||
return boeRequest(REFRESH_TOKEN_API).then((res) => {
|
||||
if (res.code === 0 || res.code === 200) {
|
||||
return request(_url, params)
|
||||
}
|
||||
})
|
||||
}
|
||||
//刷新token
|
||||
res.show ? message.error(res.msg):res.msg=='无数据'?null:message.error('系统接口数据异常,请联系管理员');
|
||||
res.show ? message.error(res.msg) : res.msg == '无数据' ? null : message.error('系统接口数据异常,请联系管理员');
|
||||
return Promise.reject(res);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user