@ftjs/core 0.4.2 → 0.4.5
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.
- package/dist/index.js +25 -9
- package/dist/type-helper.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unref, inject, computed, ref, watch, onUnmounted, provide, toValue, nextTick } from "vue";
|
|
1
|
+
import { unref, inject, computed, ref, watch, onUnmounted, provide, toValue, watchEffect, nextTick } from "vue";
|
|
2
2
|
const isBrowser = typeof window !== "undefined";
|
|
3
3
|
const getField = (column) => {
|
|
4
4
|
var _a;
|
|
@@ -104,10 +104,18 @@ const useColumnsChecked = (columns, cache) => {
|
|
|
104
104
|
});
|
|
105
105
|
return Object.fromEntries(entries);
|
|
106
106
|
});
|
|
107
|
-
const storageV =
|
|
107
|
+
const storageV = computed(() => {
|
|
108
|
+
return getStorage(storageKey, toValue(cache));
|
|
109
|
+
});
|
|
108
110
|
const vRef = ref(
|
|
109
|
-
|
|
111
|
+
{}
|
|
110
112
|
);
|
|
113
|
+
watchEffect(() => {
|
|
114
|
+
vRef.value = {
|
|
115
|
+
...columnsV.value,
|
|
116
|
+
...storageV.value
|
|
117
|
+
};
|
|
118
|
+
});
|
|
111
119
|
const columnsChecked = computed({
|
|
112
120
|
get() {
|
|
113
121
|
return Object.entries(vRef.value).filter(([_, show]) => show).map(([field]) => field);
|
|
@@ -121,7 +129,7 @@ const useColumnsChecked = (columns, cache) => {
|
|
|
121
129
|
return [field, show];
|
|
122
130
|
});
|
|
123
131
|
vRef.value = Object.fromEntries(entries);
|
|
124
|
-
setStorage(storageKey, storageV2, cache);
|
|
132
|
+
setStorage(storageKey, storageV2, toValue(cache));
|
|
125
133
|
}
|
|
126
134
|
});
|
|
127
135
|
const resetColumnsChecked = () => {
|
|
@@ -142,10 +150,18 @@ const useColumnsSorted = (columns, cache) => {
|
|
|
142
150
|
});
|
|
143
151
|
return Object.fromEntries(entries);
|
|
144
152
|
});
|
|
145
|
-
const storageV =
|
|
153
|
+
const storageV = computed(() => {
|
|
154
|
+
return getStorage(storageKey, toValue(cache));
|
|
155
|
+
});
|
|
146
156
|
const vRef = ref(
|
|
147
|
-
|
|
157
|
+
{}
|
|
148
158
|
);
|
|
159
|
+
watchEffect(() => {
|
|
160
|
+
vRef.value = {
|
|
161
|
+
...columnsV.value,
|
|
162
|
+
...storageV.value
|
|
163
|
+
};
|
|
164
|
+
});
|
|
149
165
|
const columnsSort = computed({
|
|
150
166
|
get() {
|
|
151
167
|
return vRef.value;
|
|
@@ -160,7 +176,7 @@ const useColumnsSorted = (columns, cache) => {
|
|
|
160
176
|
return [field, v[field]];
|
|
161
177
|
});
|
|
162
178
|
vRef.value = Object.fromEntries(entries);
|
|
163
|
-
setStorage(storageKey, storageV2, cache);
|
|
179
|
+
setStorage(storageKey, storageV2, toValue(cache));
|
|
164
180
|
}
|
|
165
181
|
});
|
|
166
182
|
const resetColumnsSort = () => {
|
|
@@ -200,11 +216,11 @@ const useForm = (props) => {
|
|
|
200
216
|
});
|
|
201
217
|
const { columnsChecked, resetColumnsChecked } = useColumnsChecked(
|
|
202
218
|
columns,
|
|
203
|
-
props.cache
|
|
219
|
+
() => props.cache
|
|
204
220
|
);
|
|
205
221
|
const { columnsSort, resetColumnsSort } = useColumnsSorted(
|
|
206
222
|
columns,
|
|
207
|
-
props.cache
|
|
223
|
+
() => props.cache
|
|
208
224
|
);
|
|
209
225
|
let tmpDefaultForm;
|
|
210
226
|
const watchMap = /* @__PURE__ */ new Map();
|
package/dist/type-helper.d.ts
CHANGED
|
@@ -29,4 +29,10 @@ export type Unrefs<T> = {
|
|
|
29
29
|
export type Refs<T> = {
|
|
30
30
|
[K in keyof T]: T[K] extends Ref<any> ? T[K] : MaybeRef<T[K]>;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* 工具类型:提取 Column 的类型
|
|
34
|
+
*/
|
|
35
|
+
export type ExtractColumnType<T> = T extends {
|
|
36
|
+
type: infer U;
|
|
37
|
+
} ? U : never;
|
|
32
38
|
export {};
|