v-dict 1.1.0 → 1.1.1
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/README.md +10 -1
- package/dist/index.cjs +3 -2
- package/dist/index.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,11 @@ export const useRemoteStatusDict = dm.defineDict('REMOTE_STATUS', {
|
|
|
68
68
|
}
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
+
// clear dict data
|
|
72
|
+
// dm.clear('REMOTE_STATUS')
|
|
73
|
+
|
|
74
|
+
// clear all dict data
|
|
75
|
+
// dm.clear()
|
|
71
76
|
```
|
|
72
77
|
|
|
73
78
|
### xx.vue
|
|
@@ -91,7 +96,9 @@ const statusDict = useRemoteStatusDict({
|
|
|
91
96
|
// Data sharing by default, independent data source when clone is true
|
|
92
97
|
clone: true,
|
|
93
98
|
// Whether the remote dictionary loads data immediately
|
|
94
|
-
immediate: false
|
|
99
|
+
immediate: false,
|
|
100
|
+
// whether to reload
|
|
101
|
+
refresh: false
|
|
95
102
|
}) // statusDict is reactive!!!
|
|
96
103
|
|
|
97
104
|
const { E, map, list } = statusDict
|
|
@@ -135,6 +142,8 @@ onMounted(async () => {
|
|
|
135
142
|
await statusDict.loadPromise // immediate = true, using loadPromise to wait load
|
|
136
143
|
// do after dict load
|
|
137
144
|
console.log(statusDict.list)
|
|
145
|
+
// clear dict data
|
|
146
|
+
// statusDict.clear()
|
|
138
147
|
})
|
|
139
148
|
</script>
|
|
140
149
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -79,7 +79,7 @@ function createDictManager(managerOptions = {}) {
|
|
|
79
79
|
fetch = managerFetch,
|
|
80
80
|
extra
|
|
81
81
|
} = (_a = lodashEs.isFunction(defineDictOptions) ? defineDictOptions() : defineDictOptions) != null ? _a : {};
|
|
82
|
-
let
|
|
82
|
+
let managerLoaded = false;
|
|
83
83
|
const managerLoadPromise = vue.shallowRef(createPromise());
|
|
84
84
|
maps[code] = /* @__PURE__ */ new Map();
|
|
85
85
|
async function loadDict(options, mapRef) {
|
|
@@ -96,11 +96,12 @@ function createDictManager(managerOptions = {}) {
|
|
|
96
96
|
} else {
|
|
97
97
|
mapRef.value = dataMap;
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
managerLoaded = true;
|
|
100
100
|
}
|
|
101
101
|
return (useDictOptions) => {
|
|
102
102
|
useDictOptions = lodashEs.merge({ clone: false, immediate: true, refresh: false }, useDictOptions);
|
|
103
103
|
const { clone, immediate, refresh } = useDictOptions;
|
|
104
|
+
let loaded = !clone ? managerLoaded : false;
|
|
104
105
|
const loadPromise = !clone ? managerLoadPromise : vue.shallowRef(createPromise());
|
|
105
106
|
const mapRef = !clone ? vue.toRef(maps, code) : vue.ref(/* @__PURE__ */ new Map());
|
|
106
107
|
const objRef = vue.ref({});
|
package/dist/index.js
CHANGED
|
@@ -77,7 +77,7 @@ function createDictManager(managerOptions = {}) {
|
|
|
77
77
|
fetch = managerFetch,
|
|
78
78
|
extra
|
|
79
79
|
} = (_a = isFunction(defineDictOptions) ? defineDictOptions() : defineDictOptions) != null ? _a : {};
|
|
80
|
-
let
|
|
80
|
+
let managerLoaded = false;
|
|
81
81
|
const managerLoadPromise = shallowRef(createPromise());
|
|
82
82
|
maps[code] = /* @__PURE__ */ new Map();
|
|
83
83
|
async function loadDict(options, mapRef) {
|
|
@@ -94,11 +94,12 @@ function createDictManager(managerOptions = {}) {
|
|
|
94
94
|
} else {
|
|
95
95
|
mapRef.value = dataMap;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
managerLoaded = true;
|
|
98
98
|
}
|
|
99
99
|
return (useDictOptions) => {
|
|
100
100
|
useDictOptions = merge({ clone: false, immediate: true, refresh: false }, useDictOptions);
|
|
101
101
|
const { clone, immediate, refresh } = useDictOptions;
|
|
102
|
+
let loaded = !clone ? managerLoaded : false;
|
|
102
103
|
const loadPromise = !clone ? managerLoadPromise : shallowRef(createPromise());
|
|
103
104
|
const mapRef = !clone ? toRef(maps, code) : ref(/* @__PURE__ */ new Map());
|
|
104
105
|
const objRef = ref({});
|