mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-11 03:46:48 +08:00
Merge branch 'manage-release' of http://gitlab.dongwu-inc.com:10080/BOE/fe-stu into release
# Conflicts: # src/api/request.js
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import {reactive, ref, toRefs, watch} from "vue";
|
import {reactive, ref, toRefs, watch} from "vue";
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {getCookie} from "@/api/utils";
|
|
||||||
import {BASE} from "@/api/api";
|
|
||||||
|
|
||||||
export function usePage(_url, param) {
|
export function usePage(_url, param) {
|
||||||
|
|
||||||
@@ -23,7 +21,7 @@ export function usePage(_url, param) {
|
|||||||
function fetchData() {
|
function fetchData() {
|
||||||
state.loading = true
|
state.loading = true
|
||||||
request(_url, state.params).then(r => {
|
request(_url, state.params).then(r => {
|
||||||
state.params.pageNo === 1 ? (state.data = (r.data.records || r.data.rows)) : (state.data = [...state.data, ...(r.data.records || r.data.rows)])
|
state.params.pageNo === 1 ? (state.data = (r.data.records||r.data.rows)) : (state.data = [...state.data, ...(r.data.records||r.data.rows)])
|
||||||
state.size = r.data.size
|
state.size = r.data.size
|
||||||
state.total = r.data.total
|
state.total = r.data.total
|
||||||
state.current = r.data.current
|
state.current = r.data.current
|
||||||
@@ -89,7 +87,7 @@ export async function request(_url, params) {
|
|||||||
'X-Token': localStorage.getItem('token'),
|
'X-Token': localStorage.getItem('token'),
|
||||||
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
|
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
|
||||||
},
|
},
|
||||||
baseURL: BASE,
|
baseURL: '/manageApi-release',
|
||||||
...method !== 'get' ? {data: JSON.stringify(body)} : {}
|
...method !== 'get' ? {data: JSON.stringify(body)} : {}
|
||||||
}).then(resp => resp.data).then(response => {
|
}).then(resp => resp.data).then(response => {
|
||||||
if (response.code !== 200 && response.code !== 0) {
|
if (response.code !== 200 && response.code !== 0) {
|
||||||
@@ -111,39 +109,4 @@ export async function request(_url, params) {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
// router.push({path: '/login'})
|
// router.push({path: '/login'})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
export async function boeRequest(_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 axios({
|
|
||||||
url,
|
|
||||||
method,
|
|
||||||
headers: {
|
|
||||||
token: getCookie('token'),
|
|
||||||
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
|
|
||||||
},
|
|
||||||
baseURL: '',
|
|
||||||
...method !== 'get' ? {data: JSON.stringify(body)} : {}
|
|
||||||
}).then(resp => resp.data).then(response => {
|
|
||||||
return response
|
|
||||||
}).catch(e => {
|
|
||||||
console.log(2222)
|
|
||||||
console.log(e)
|
|
||||||
// router.push({path: '/login'})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ const routes = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory("/fe-student"),
|
history: createWebHistory("/fe-student-release"),
|
||||||
routes
|
routes
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user