mirror of
https://github.com/imdap/ruoyi-plus-vben5.git
synced 2026-05-08 19:31:25 +08:00
Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin into antdv-next
This commit is contained in:
@@ -46,6 +46,8 @@ interface Props {
|
||||
alwaysLoad?: boolean;
|
||||
/** 在api请求之前的回调函数 */
|
||||
beforeFetch?: AnyPromiseFunction<any, any>;
|
||||
/** 在api请求之前的判断是否允许请求的回调函数 */
|
||||
shouldFetch?: AnyPromiseFunction<any, boolean>;
|
||||
/** 在api请求之后的回调函数 */
|
||||
afterFetch?: AnyPromiseFunction<any, any>;
|
||||
/** 直接传入选项数据,也作为api返回空数据时的后备数据 */
|
||||
@@ -88,6 +90,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
alwaysLoad: false,
|
||||
loadingSlot: '',
|
||||
beforeFetch: undefined,
|
||||
shouldFetch: undefined,
|
||||
afterFetch: undefined,
|
||||
modelPropName: 'modelValue',
|
||||
api: undefined,
|
||||
@@ -159,7 +162,7 @@ const bindProps = computed(() => {
|
||||
});
|
||||
|
||||
async function fetchApi() {
|
||||
const { api, beforeFetch, afterFetch, resultField } = props;
|
||||
const { api, beforeFetch, shouldFetch, afterFetch, resultField } = props;
|
||||
|
||||
if (!api || !isFunction(api)) {
|
||||
return;
|
||||
@@ -178,6 +181,14 @@ async function fetchApi() {
|
||||
if (beforeFetch && isFunction(beforeFetch)) {
|
||||
finalParams = (await beforeFetch(cloneDeep(finalParams))) || finalParams;
|
||||
}
|
||||
// 判断是否需要控制执行中断
|
||||
if (
|
||||
shouldFetch &&
|
||||
isFunction(shouldFetch) &&
|
||||
!(await shouldFetch(finalParams))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
let res = await api(finalParams);
|
||||
if (afterFetch && isFunction(afterFetch)) {
|
||||
res = (await afterFetch(res)) || res;
|
||||
|
||||
@@ -12,7 +12,7 @@ import type {
|
||||
|
||||
import { computed, useAttrs } from 'vue';
|
||||
// @ts-expect-error - vue-json-viewer does not expose compatible typings for this import path
|
||||
import VueJsonViewer from 'vue-json-viewer';
|
||||
import VueJsonViewerImport from 'vue-json-viewer';
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
@@ -42,6 +42,11 @@ const emit = defineEmits<{
|
||||
valueClick: [value: JsonViewerValue];
|
||||
}>();
|
||||
|
||||
/** CJS/UMD 在 Vite 下解析为 { default: Component },需解包否则会出现 missing template or render */
|
||||
const VueJsonViewer =
|
||||
(VueJsonViewerImport as { default?: typeof VueJsonViewerImport }).default ??
|
||||
VueJsonViewerImport;
|
||||
|
||||
const attrs: SetupContext['attrs'] = useAttrs();
|
||||
|
||||
function handleClick(event: MouseEvent) {
|
||||
|
||||
Reference in New Issue
Block a user