主包未使用的js文件删除
This commit is contained in:
@@ -1,173 +1,174 @@
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
isRef,
|
||||
nextTick
|
||||
} from 'vue'
|
||||
|
||||
export function usePagination(
|
||||
requestFn,
|
||||
transformFn,
|
||||
options = {}
|
||||
) {
|
||||
const list = ref([])
|
||||
const loading = ref(false)
|
||||
const error = ref(false)
|
||||
const finished = ref(false)
|
||||
const firstLoading = ref(true)
|
||||
const empty = ref(false)
|
||||
|
||||
const {
|
||||
pageSize = 10,
|
||||
search = {},
|
||||
autoWatchSearch = false,
|
||||
debounceTime = 300,
|
||||
autoFetch = false,
|
||||
|
||||
// 字段映射
|
||||
dataKey = 'rows',
|
||||
totalKey = 'total',
|
||||
|
||||
// 分页字段名映射
|
||||
pageField = 'current',
|
||||
sizeField = 'pageSize',
|
||||
|
||||
onBeforeRequest,
|
||||
onAfterRequest
|
||||
} = options
|
||||
|
||||
const pageState = reactive({
|
||||
page: 1,
|
||||
pageSize: isRef(pageSize) ? pageSize.value : pageSize,
|
||||
total: 0,
|
||||
maxPage: 1,
|
||||
search: isRef(search) ? search.value : search
|
||||
})
|
||||
|
||||
let debounceTimer = null
|
||||
|
||||
const fetchData = async (type = 'refresh') => {
|
||||
if (loading.value) return Promise.resolve()
|
||||
console.log(type)
|
||||
loading.value = true
|
||||
error.value = false
|
||||
|
||||
if (typeof onBeforeRequest === 'function') {
|
||||
try {
|
||||
onBeforeRequest(type, pageState)
|
||||
} catch (err) {
|
||||
console.warn('onBeforeRequest 执行异常:', err)
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'refresh') {
|
||||
pageState.page = 1
|
||||
finished.value = false
|
||||
if (list.value.length === 0) {
|
||||
firstLoading.value = true
|
||||
}
|
||||
} else if (type === 'loadMore') {
|
||||
if (pageState.page >= pageState.maxPage) {
|
||||
loading.value = false
|
||||
finished.value = true
|
||||
return Promise.resolve('no more')
|
||||
}
|
||||
pageState.page += 1
|
||||
}
|
||||
|
||||
const params = {
|
||||
...pageState.search,
|
||||
[pageField]: pageState.page,
|
||||
[sizeField]: pageState.pageSize,
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await requestFn(params)
|
||||
|
||||
const rawData = res[dataKey]
|
||||
const total = res[totalKey] || 99999999
|
||||
console.log(total, rawData)
|
||||
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
|
||||
|
||||
if (type === 'refresh') {
|
||||
list.value = data
|
||||
} else {
|
||||
list.value.push(...data)
|
||||
}
|
||||
|
||||
pageState.total = total
|
||||
pageState.maxPage = Math.ceil(total / pageState.pageSize)
|
||||
|
||||
finished.value = list.value.length >= total
|
||||
empty.value = list.value.length === 0
|
||||
} catch (err) {
|
||||
console.error('分页请求失败:', err)
|
||||
error.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
firstLoading.value = false
|
||||
|
||||
if (typeof onAfterRequest === 'function') {
|
||||
try {
|
||||
onAfterRequest(type, pageState, {
|
||||
error: error.value
|
||||
})
|
||||
} catch (err) {
|
||||
console.warn('onAfterRequest 执行异常:', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const refresh = () => fetchData('refresh')
|
||||
const loadMore = () => fetchData('loadMore')
|
||||
|
||||
const resetPagination = () => {
|
||||
list.value = []
|
||||
pageState.page = 1
|
||||
pageState.total = 0
|
||||
pageState.maxPage = 1
|
||||
finished.value = false
|
||||
error.value = false
|
||||
firstLoading.value = true
|
||||
empty.value = false
|
||||
}
|
||||
|
||||
if (autoWatchSearch && isRef(search)) {
|
||||
watch(search, (newVal) => {
|
||||
pageState.search = newVal
|
||||
clearTimeout(debounceTimer)
|
||||
debounceTimer = setTimeout(() => {
|
||||
refresh()
|
||||
}, debounceTime)
|
||||
}, {
|
||||
deep: true
|
||||
})
|
||||
}
|
||||
|
||||
watch(pageSize, (newVal) => {
|
||||
pageState.pageSize = newVal
|
||||
}, {
|
||||
deep: true
|
||||
})
|
||||
|
||||
if (autoFetch) {
|
||||
nextTick(() => {
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
list,
|
||||
loading,
|
||||
error,
|
||||
finished,
|
||||
firstLoading,
|
||||
empty,
|
||||
pageState,
|
||||
refresh,
|
||||
loadMore,
|
||||
resetPagination
|
||||
}
|
||||
}
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
isRef,
|
||||
nextTick
|
||||
} from 'vue'
|
||||
|
||||
export function usePagination(
|
||||
requestFn,
|
||||
transformFn,
|
||||
options = {}
|
||||
) {
|
||||
const list = ref([])
|
||||
const loading = ref(false)
|
||||
const error = ref(false)
|
||||
const finished = ref(false)
|
||||
const firstLoading = ref(true)
|
||||
const empty = ref(false)
|
||||
|
||||
const {
|
||||
pageSize = 10,
|
||||
search = {},
|
||||
autoWatchSearch = false,
|
||||
debounceTime = 300,
|
||||
autoFetch = false,
|
||||
|
||||
// 字段映射
|
||||
dataKey = 'rows',
|
||||
totalKey = 'total',
|
||||
|
||||
// 分页字段名映射
|
||||
pageField = 'current',
|
||||
sizeField = 'pageSize',
|
||||
|
||||
onBeforeRequest,
|
||||
onAfterRequest
|
||||
} = options
|
||||
|
||||
const pageState = reactive({
|
||||
page: 1,
|
||||
pageSize: isRef(pageSize) ? pageSize.value : pageSize,
|
||||
total: 0,
|
||||
maxPage: 1,
|
||||
search: isRef(search) ? search.value : search
|
||||
})
|
||||
|
||||
let debounceTimer = null
|
||||
|
||||
const fetchData = async (type = 'refresh') => {
|
||||
if (loading.value) return Promise.resolve()
|
||||
console.log(type)
|
||||
loading.value = true
|
||||
error.value = false
|
||||
|
||||
if (typeof onBeforeRequest === 'function') {
|
||||
try {
|
||||
onBeforeRequest(type, pageState)
|
||||
} catch (err) {
|
||||
console.warn('onBeforeRequest 执行异常:', err)
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'refresh') {
|
||||
pageState.page = 1
|
||||
finished.value = false
|
||||
if (list.value.length === 0) {
|
||||
firstLoading.value = true
|
||||
}
|
||||
} else if (type === 'loadMore') {
|
||||
if (pageState.page >= pageState.maxPage) {
|
||||
loading.value = false
|
||||
finished.value = true
|
||||
return Promise.resolve('no more')
|
||||
}
|
||||
pageState.page += 1
|
||||
}
|
||||
|
||||
const params = {
|
||||
...pageState.search,
|
||||
[pageField]: pageState.page,
|
||||
[sizeField]: pageState.pageSize,
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await requestFn(params)
|
||||
|
||||
const rawData = res[dataKey]
|
||||
const total = res[totalKey] || 99999999
|
||||
console.log(total, rawData)
|
||||
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
|
||||
|
||||
if (type === 'refresh') {
|
||||
list.value = data
|
||||
} else {
|
||||
list.value.push(...data)
|
||||
}
|
||||
|
||||
pageState.total = total
|
||||
pageState.maxPage = Math.ceil(total / pageState.pageSize)
|
||||
|
||||
finished.value = list.value.length >= total
|
||||
empty.value = list.value.length === 0
|
||||
} catch (err) {
|
||||
console.error('分页请求失败:', err)
|
||||
error.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
firstLoading.value = false
|
||||
|
||||
if (typeof onAfterRequest === 'function') {
|
||||
try {
|
||||
onAfterRequest(type, pageState, {
|
||||
error: error.value
|
||||
})
|
||||
} catch (err) {
|
||||
console.warn('onAfterRequest 执行异常:', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const refresh = () => fetchData('refresh')
|
||||
const loadMore = () => fetchData('loadMore')
|
||||
|
||||
const resetPagination = () => {
|
||||
list.value = []
|
||||
pageState.page = 1
|
||||
pageState.total = 0
|
||||
pageState.maxPage = 1
|
||||
finished.value = false
|
||||
error.value = false
|
||||
firstLoading.value = true
|
||||
empty.value = false
|
||||
}
|
||||
|
||||
if (autoWatchSearch && isRef(search)) {
|
||||
watch(search, (newVal) => {
|
||||
pageState.search = newVal
|
||||
clearTimeout(debounceTimer)
|
||||
debounceTimer = setTimeout(() => {
|
||||
refresh()
|
||||
}, debounceTime)
|
||||
}, {
|
||||
deep: true
|
||||
})
|
||||
}
|
||||
|
||||
watch(pageSize, (newVal) => {
|
||||
pageState.pageSize = newVal
|
||||
}, {
|
||||
deep: true
|
||||
})
|
||||
|
||||
if (autoFetch) {
|
||||
nextTick(() => {
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
list,
|
||||
loading,
|
||||
error,
|
||||
finished,
|
||||
firstLoading,
|
||||
empty,
|
||||
pageState,
|
||||
refresh,
|
||||
loadMore,
|
||||
resetPagination
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import useUserStore from '@/stores/useUserStore';
|
||||
const { $api, navTo, navBack, vacanciesTo } = inject('globalFunction');
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useLocationStore from '@/stores/useLocationStore';
|
||||
import { usePagination } from '@/hook/usePagination';
|
||||
import { usePagination } from '@/packageA/hook/usePagination';
|
||||
import { jobMoreMap } from '@/utils/markdownParser';
|
||||
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
|
||||
const loadmoreRef = ref(null);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import request from '@/utilCa/request.js'
|
||||
import request from '@/packageCa/utilCa/request.js'
|
||||
|
||||
const api = {}
|
||||
// 获取职业大类 中类
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import request from '@/utilCa/request.js'
|
||||
import request from '@/packageCa/utilCa/request.js'
|
||||
|
||||
const api = {}
|
||||
// 获取生涯罗盘
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import request from '@/utilCa/request.js'
|
||||
import request from '@/packageCa/utilCa/request.js'
|
||||
|
||||
const api = {}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import request from '@/utilCa/request.js'
|
||||
import request from '@/packageCa/utilCa/request.js'
|
||||
|
||||
const api = {}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
import contrastBox from "@/packageCa/testReport/components/contrastBox.vue"
|
||||
import api from "@/packageCa/apiCa/testManage.js";
|
||||
import theme from '@/uni_modules/lime-echart/static/walden.json';
|
||||
const echarts = require('../../uni_modules/lime-echart/static/echarts.min.js');
|
||||
const echarts = require('../../utilCa/echarts.min.js');
|
||||
// import * as echarts from '@/uni_modules/lime-echart/static/echarts.min';
|
||||
// // 注册主题
|
||||
// echarts.registerTheme('theme', theme);
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
import contrastBox from "@/packageCa/testReport/components/contrastBox.vue"
|
||||
import api from "@/packageCa/apiCa/testManage.js";
|
||||
import theme from '@/uni_modules/lime-echart/static/walden.json';
|
||||
const echarts = require('../../uni_modules/lime-echart/static/echarts.min.js');
|
||||
const echarts = require('../../utilCa/echarts.min.js');
|
||||
// import * as echarts from '@/uni_modules/lime-echart/static/echarts.min';
|
||||
// // 注册主题
|
||||
// echarts.registerTheme('theme', theme);
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
import api from "@/packageCa/apiCa/testManage.js"
|
||||
import wayData from "./multipleAbilityData.json";
|
||||
import theme from '@/uni_modules/lime-echart/static/walden.json';
|
||||
const echarts = require('../../uni_modules/lime-echart/static/echarts.min.js');
|
||||
const echarts = require('../../utilCa/echarts.min.js');
|
||||
// import * as echarts from '@/uni_modules/lime-echart/static/echarts.min';
|
||||
// // 注册主题
|
||||
// echarts.registerTheme('theme', theme);
|
||||
|
||||
@@ -402,7 +402,7 @@
|
||||
import opts from "./chartOpts.js"
|
||||
import api from "@/packageCa/apiCa/testManage.js";
|
||||
import theme from '@/uni_modules/lime-echart/static/walden.json';
|
||||
const echarts = require('../../uni_modules/lime-echart/static/echarts.min.js');
|
||||
const echarts = require('../../utilCa/echarts.min.js');
|
||||
// import * as echarts from '@/uni_modules/lime-echart/static/echarts.min';
|
||||
// // 注册主题
|
||||
// echarts.registerTheme('theme', theme);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
import contrastBox from "@/packageCa/testReport/components/contrastBox.vue"
|
||||
import api from "@/packageCa/apiCa/testManage.js";
|
||||
import theme from '@/uni_modules/lime-echart/static/walden.json';
|
||||
const echarts = require('../../uni_modules/lime-echart/static/echarts.min.js');
|
||||
const echarts = require('../../utilCa/echarts.min.js');
|
||||
// import * as echarts from '@/uni_modules/lime-echart/static/echarts.min';
|
||||
// // 注册主题
|
||||
// echarts.registerTheme('theme', theme);
|
||||
|
||||
@@ -36,4 +36,5 @@ export {
|
||||
baseUrl7,
|
||||
baseUrl8,
|
||||
filestore_site
|
||||
}
|
||||
}
|
||||
|
||||
1
packageCa/utilCa/echarts.min.js
vendored
Normal file
1
packageCa/utilCa/echarts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -16,4 +16,5 @@ export function ossImageUrl(path, process) {
|
||||
|
||||
// 没有处理参数时,直接返回原始路径
|
||||
return `${BASE_IMAGE_URL}/${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +111,5 @@ request.globalRequest = (url, method, data, power, type) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
export default request
|
||||
export default request
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
<script setup>
|
||||
import { reactive, inject, watch, ref, onMounted, watchEffect, nextTick } from 'vue';
|
||||
import { usePagination } from '@/hook/usePagination';
|
||||
import { usePagination } from '@/packageA/hook/usePagination';
|
||||
const { $api, navTo } = inject('globalFunction');
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
|
||||
Reference in New Issue
Block a user