jobdone-shared-files 1.1.25 → 1.1.26

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.
@@ -217,6 +217,9 @@ const previewImagesOnHide = () => {
217
217
  const activeTab = ref('records');
218
218
  const filterDate = ref('');
219
219
  const selectedImages = ref([]);
220
+ // 統一 selectedImages 元素要保留的欄位;toggleImage / toggleAllInRecord / show / submit 都吃這份,未來增刪欄位只需改這一處
221
+ const SELECTED_IMAGE_KEYS = ['id', 'url', 'thumbnailUrl', 'fileName'];
222
+ const pickSelectedImage = (img) => Object.fromEntries(SELECTED_IMAGE_KEYS.map((k) => [k, img[k]]));
220
223
  // 改用 reactive Set 取代 computed Set。Vue 3 對 reactive 集合提供 per-element 反應式追蹤,
221
224
  // template 裡 .has(id) 只會在「該 id 的選取狀態變動」時 invalidate,
222
225
  // 不會像 computed Set(每次都回傳新 Set 物件)那樣讓所有 button 的 binding 一起重新評估
@@ -263,9 +266,8 @@ const mediasByMonth = computed(() => { // 將圖片依年月日分類,方便
263
266
  const month = months.get(monthKey);
264
267
  if (!month.days.has(dayKey)) month.days.set(dayKey, { dayKey, dayLabel, items: [] });
265
268
  const day = month.days.get(dayKey);
266
- for (const img of record.images) {
267
- day.items.push({ id: img.id, url: img.url, thumbnailUrl: img.thumbnailUrl });
268
- }
269
+ // pickSelectedImage 確保 day.items 與 selectedImages 同形(特別是 fileName),點擊後丟進 toggleImage 才不會掉欄位
270
+ for (const img of record.images) day.items.push(pickSelectedImage(img));
269
271
  }
270
272
  // 月與日皆以由新到舊呈現;monthKey/dayKey 是 ISO 格式(YYYY-MM、YYYY-MM-DD),字串遞減排序即等同日期遞減
271
273
  return Array.from(months.values())
@@ -335,7 +337,7 @@ const toggleImage = (img) => {
335
337
  selectedImages.value.splice(idx, 1);
336
338
  selectedImageIds.delete(img.id);
337
339
  } else {
338
- selectedImages.value.push({ id: img.id, url: img.url, thumbnailUrl: img.thumbnailUrl, fileName: img.fileName });
340
+ selectedImages.value.push(pickSelectedImage(img));
339
341
  selectedImageIds.add(img.id);
340
342
  }
341
343
  };
@@ -360,7 +362,7 @@ const toggleAllInRecord = (record) => {
360
362
  } else {
361
363
  const toAdd = record.images
362
364
  .filter((img) => !selectedImageIds.has(img.id))
363
- .map((img) => ({ id: img.id, url: img.url, thumbnailUrl: img.thumbnailUrl, fileName: img.fileName }));
365
+ .map((img) => pickSelectedImage(img));
364
366
  selectedImages.value.push(...toAdd);
365
367
  for (const m of toAdd) selectedImageIds.add(m.id);
366
368
  }
@@ -379,7 +381,7 @@ const closeModal = () => {
379
381
 
380
382
  const show = (preSelected = []) => {
381
383
  // 開啟時可帶入已選圖片,讓使用者看到先前的選擇狀態(例如再次開啟時保留勾選)
382
- selectedImages.value = preSelected.map((img) => ({ id: img.id, url: img.url, fileName: img.fileName }));
384
+ selectedImages.value = preSelected.map((img) => pickSelectedImage(img));
383
385
  selectedImageIds.clear();
384
386
  for (const img of preSelected) selectedImageIds.add(img.id);
385
387
  modalShow(modalDom.value, closeModal);
@@ -388,8 +390,7 @@ const show = (preSelected = []) => {
388
390
 
389
391
  const submit = () => {
390
392
  modalHide(modalDom.value);
391
- // thumbnailUrl 是內部顯示用、不外流;對外帶出 { id, url, fileName }
392
- emit('afterSubmit', selectedImages.value.map((m) => ({ id: m.id, url: m.url, fileName: m.fileName })));
393
+ emit('afterSubmit', selectedImages.value.map((m) => pickSelectedImage(m)));
393
394
  };
394
395
  // #endregion 光箱操作相關
395
396
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jobdone-shared-files",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "Shared JS and SCSS for Jobdone Enterprise.",
5
5
  "main": "index.js",
6
6
  "scripts": {