--fix 权限名单

This commit is contained in:
yuping
2023-01-31 01:45:35 +08:00
parent e00206c8ef
commit 000db01834
11 changed files with 647 additions and 960 deletions

1
src/api/apis.js Normal file
View File

@@ -0,0 +1 @@
export const STUDENT_LIST = '/admin/student/getStudent'

View File

@@ -1,4 +1,4 @@
import {reactive, ref, toRefs, watch} from "vue";
import {isRef, reactive, ref, toRefs, unref, watch, watchEffect} from "vue";
import {getCookieForName, throttle} from "@/api/method";
import JSONBigInt from 'json-bigint';
@@ -22,7 +22,7 @@ export function useBoeApiPage(_url, params = {}, config = {
function fetch() {
state.loading = true
return request(_url, params).then(r => {
return boeRequest(_url, params).then(r => {
state.data = config.result(r)
state.totalPage = config.totalPage(r)
state.total = config.total(r)
@@ -62,7 +62,7 @@ export function useBoeApi(_url, params = {}, config = {
function fetch() {
state.loading = true
return request(_url, params).then(r => {
return boeRequest(_url, params).then(r => {
state.data = config.result(r)
state.loading = false
})
@@ -95,7 +95,7 @@ export function useBoeUserListPage(_url, params = {}, init = true) {
state.loading = false
return
}
return request(_url, params).then(r => {
return boeRequest(_url, params).then(r => {
state.data = params.page === 1 ? r.result.userInfoList : [...state.data, ...r.result.userInfoList]
state.totalPage = r.result.totalPage
state.total = r.result.totalElement
@@ -110,31 +110,48 @@ export function useBoeUserListPage(_url, params = {}, init = true) {
};
}
export function usePage(_url, params = {}, init = true) {
export function usePage(_url, params, init = true) {
const state = reactive({
data: [],
total:1,
current:1,
pages:1,
loading: false
})
watch(params, () => {
fetch()
})
if (isRef(params)) {
watch(params, () => {
fetch()
})
}
function reset(){
state.data = []
state.loading = false
}
function fetch() {
state.loading = true
return request(_url, params).then(r => {
console.log('fetch')
console.log(r)
state.data = r.result
return request(unref(_url), unref(params)).then(r => {
state.data = r.data.records
state.current = r.data.current
state.pages = r.data.pages
state.total = r.data.total
state.loading = false
})
}
init && fetch()
if (isRef(_url)) {
watchEffect(fetch)
} else {
init && fetch()
}
return {
...toRefs(state),
fetch,
reset,
};
}
@@ -163,7 +180,7 @@ export function useRequest(_url, params = {}, init = true) {
};
}
export async function request(_url, params) {
export async function boeRequest(_url, params) {
const s = _url.split(' ')
let url = s[0]
const method = s[1]?.toLowerCase() || 'get'
@@ -193,23 +210,34 @@ export async function request(_url, params) {
}).then(res => {
return JSONBigIntStr.parse(res)
})
// return axios({
// url,
// method,
// headers: {
// token: getCookie('token'),
// ...method !== 'get' ? {'Content-Type': 'application/json'} : {}
// },
// baseURL: '',
// ...method !== 'get' ? {data: JSON.stringify(body)} : {}
// }).then(resp => {
// return resp.data
// }).then(response => {
// console.log(response)
// return response
// }).catch(e => {
// console.log(2222)
// console.log(e)
// // router.push({path: '/login'})
// })
}
export async function request(_url, params) {
const s = _url.split(' ')
let url = s[0]
const method = s[1]?.toLowerCase() || 'get'
if (method === 'get') {
let paramsArray = [];
if (params) {
Object.keys(params).forEach(key => paramsArray.push(key + '=' + params[key]))
if (url.search(/\?/) === -1) {
url += '?' + paramsArray.join('&')
} else {
url += '&' + paramsArray.join('&')
}
}
}
const body = method !== 'get' ? params || {} : {}
return fetch(process.env.VUE_APP_BASE_API + url, {
method,
headers: {
token: getCookieForName('token'),
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
},
...method !== 'get' ? {body: JSON.stringify(body)} : {}
}).then(res => {
return res.text()
}).then(res => {
return JSONBigIntStr.parse(res)
})
}