mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-09 19:06:48 +08:00
init
This commit is contained in:
@@ -2,6 +2,7 @@ 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 {getCookie} from "@/api/utils";
|
||||||
|
import {BASE} from "@/api/api";
|
||||||
|
|
||||||
export function usePage(_url, param) {
|
export function usePage(_url, param) {
|
||||||
|
|
||||||
@@ -22,7 +23,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
|
||||||
@@ -82,7 +83,7 @@ export async function request(_url, params) {
|
|||||||
}
|
}
|
||||||
const body = method !== 'get' ? params || {} : {}
|
const body = method !== 'get' ? params || {} : {}
|
||||||
return axios({
|
return axios({
|
||||||
url,
|
url: BASE + url,
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'X-Token': localStorage.getItem('token'),
|
'X-Token': localStorage.getItem('token'),
|
||||||
|
|||||||
Reference in New Issue
Block a user