pukaad-ui-lib 1.278.0 → 1.280.0
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/module.json
CHANGED
|
@@ -87,7 +87,14 @@ const props = defineProps({
|
|
|
87
87
|
coverImage: []
|
|
88
88
|
}) }
|
|
89
89
|
});
|
|
90
|
-
|
|
90
|
+
function cloneItem(item) {
|
|
91
|
+
const { coverImage, ...rest } = item;
|
|
92
|
+
return {
|
|
93
|
+
...JSON.parse(JSON.stringify(rest)),
|
|
94
|
+
coverImage: coverImage?.map((img) => ({ ...img })) ?? []
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const form = ref(cloneItem(props.item));
|
|
91
98
|
const isLoading = ref(false);
|
|
92
99
|
const isOpen = defineModel({ type: Boolean, ...{
|
|
93
100
|
default: false
|
|
@@ -98,7 +105,7 @@ const drawerTitle = computed(() => {
|
|
|
98
105
|
});
|
|
99
106
|
watch(isOpen, (newVal) => {
|
|
100
107
|
if (newVal) {
|
|
101
|
-
form.value =
|
|
108
|
+
form.value = cloneItem(props.item);
|
|
102
109
|
}
|
|
103
110
|
});
|
|
104
111
|
const onClose = async () => {
|
|
@@ -157,10 +164,19 @@ const onSaveDraft = async () => {
|
|
|
157
164
|
}
|
|
158
165
|
} else {
|
|
159
166
|
try {
|
|
167
|
+
const rawCoverImage = form.value.coverImage?.map((img) => ({
|
|
168
|
+
file: img.file,
|
|
169
|
+
// File object is not a proxy, safe to copy reference
|
|
170
|
+
url: img.url
|
|
171
|
+
})) || [];
|
|
160
172
|
const draftData = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
id: form.value.id || `draft_${Date.now()}`,
|
|
174
|
+
title: form.value.title,
|
|
175
|
+
content: JSON.parse(JSON.stringify(form.value.content || [])),
|
|
176
|
+
tags: JSON.parse(JSON.stringify(form.value.tags || [])),
|
|
177
|
+
disableComment: form.value.disableComment,
|
|
178
|
+
coverImage: rawCoverImage,
|
|
179
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
164
180
|
};
|
|
165
181
|
const request = indexedDB.open("PukaadDraftsDB", 1);
|
|
166
182
|
request.onupgradeneeded = (e) => {
|