@peng_kai/kit 0.3.0-beta.35 → 0.3.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cloneDeep, eq, mapValues } from 'lodash-es';
|
|
2
|
-
import { type DeepReadonly, type MaybeRefOrGetter, reactive, toRef, watch } from 'vue';
|
|
2
|
+
import { type DeepReadonly, type MaybeRefOrGetter, reactive, toRef, watch, isReadonly, toRaw } from 'vue';
|
|
3
3
|
|
|
4
4
|
export type ShcemeConfig<T> = {
|
|
5
5
|
[P in keyof T]: {
|
|
@@ -40,24 +40,26 @@ export function useFilterParams<T extends Record<string, any>>(shcemes: ShcemeCo
|
|
|
40
40
|
const pesponsiveParams = Object.keys(modifiableParams).filter(k => !!shcemes[k]?.responsive).map(k => toRef(modifiableParams, k));
|
|
41
41
|
const readonlyParams = reactive(cloneDeep(modifiableParams));
|
|
42
42
|
|
|
43
|
-
const update = (force?: boolean) => {
|
|
43
|
+
const update = (force?: boolean, resetPage?: boolean) => {
|
|
44
44
|
const prevParams = Object.freeze({ ...modifiableParams });
|
|
45
45
|
const beforeParams = {};
|
|
46
46
|
const modifiedParamKeys = Object.keys(readonlyParams).filter(pk => !eq(modifiableParams[pk], readonlyParams[pk]));
|
|
47
47
|
const beforeFuns = Object.entries(shcemes).filter(([k, s]) => modifiedParamKeys.includes(k) && !!s.before).map(([_, s]) => s.before!);
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let needResetPage = modifiedParamKeys.some(k => !!shcemes[k]?.resetPage);
|
|
49
|
+
needResetPage = needResetPage || !!force;
|
|
50
|
+
needResetPage = typeof resetPage === 'boolean' ? resetPage : needResetPage;
|
|
51
|
+
const pageParams = needResetPage ? { page: 1 } : {};
|
|
50
52
|
|
|
51
53
|
beforeFuns.forEach(fun => fun(beforeParams, prevParams));
|
|
52
54
|
Object.assign(readonlyParams, prevParams, pageParams, beforeParams);
|
|
53
55
|
|
|
56
|
+
const modifiableParamsRaw = toRaw(modifiableParams);
|
|
57
|
+
const isReadonlyParams = (k: keyof T) => isReadonly(modifiableParamsRaw[k]);
|
|
54
58
|
for (const k in readonlyParams) {
|
|
55
|
-
|
|
56
|
-
try {
|
|
59
|
+
if (!isReadonlyParams(k)) {
|
|
57
60
|
// @ts-expect-error 类型错误,暂时不理会
|
|
58
61
|
modifiableParams[k] = readonlyParams[k];
|
|
59
62
|
}
|
|
60
|
-
catch {}
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
if (force)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Modal as AntModal } from 'ant-design-vue';
|
|
2
2
|
import { tryOnBeforeUnmount, tryOnMounted } from '@vueuse/core';
|
|
3
|
-
import { createVNode, defineComponent, isProxy, onDeactivated, onMounted, reactive, toRef, toRefs } from 'vue';
|
|
3
|
+
import { createVNode, defineComponent, isProxy, onBeforeUnmount, onDeactivated, onMounted, reactive, toRef, toRefs } from 'vue';
|
|
4
4
|
import type { Component } from 'vue';
|
|
5
5
|
import type { ModalProps } from 'ant-design-vue';
|
|
6
6
|
import type { ComponentEmit, ComponentProps } from 'vue-component-type-helpers';
|
|
@@ -110,6 +110,8 @@ export function useAntdModal<Comp extends Component>(
|
|
|
110
110
|
const PresetComponent = defineComponent({
|
|
111
111
|
setup(props) {
|
|
112
112
|
onMounted(() => _modalProps.opener?.(open as any));
|
|
113
|
+
onBeforeUnmount(_onClose);
|
|
114
|
+
onDeactivated(_onClose);
|
|
113
115
|
|
|
114
116
|
return () => {
|
|
115
117
|
return createVNode(AntModal, { ..._modalProps, ...props }, {
|
|
@@ -127,8 +129,8 @@ export function useAntdModal<Comp extends Component>(
|
|
|
127
129
|
(compProps as any).onClose = onClose;
|
|
128
130
|
(compProps as any).onConfirm = onConfirm;
|
|
129
131
|
|
|
130
|
-
tryOnBeforeUnmount(_onClose);
|
|
131
|
-
tryOnMounted(() => onDeactivated(_onClose));
|
|
132
|
+
// tryOnBeforeUnmount(_onClose);
|
|
133
|
+
// tryOnMounted(() => onDeactivated(_onClose));
|
|
132
134
|
|
|
133
135
|
return {
|
|
134
136
|
PresetComponent,
|