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