新增教师节

This commit is contained in:
joshen@zcwytd.com
2023-09-06 17:21:30 +08:00
parent 10b9e2cfa5
commit f543d1ee5b
27 changed files with 5798 additions and 1360 deletions

46
src/hooks/useRequest.js Normal file
View File

@@ -0,0 +1,46 @@
import { isRef, reactive, ref, toRefs, unref, watch, watchEffect } from "vue";
import http from '@/api/configPublic'
const useTotalPage = (_url, params, config = {}) => {
const s = _url.split(" ");
const url = s[0];
let methods = 'post'
if (s[1]) methods = 'get'
const state = reactive({
data: [],
total: 1,
current: 1,
pages: 1,
pageNo: 1,
pageSize: 10,
loading: false
});
if (isRef(_url)) {
watchEffect(fetch);
}
function reset() {
state.data = [];
state.loading = false;
}
function fetch() {
state.loading = true;
return http[methods](unref(url), !s[1] ? unref(params) : { params: unref(params) }, { ...config }).then(r => {
state.data = r.data?.records || 0;
state.total = r.data?.total || 0;
state.loading = false;
})
}
return {
...toRefs(state),
fetch,
reset,
};
}
export {
useTotalPage
}