ts-glitter 21.3.8 → 21.4.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.
Files changed (134) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-line.js +12 -1
  4. package/lowcode/backend-manager/bg-line.ts +16 -1
  5. package/lowcode/backend-manager/bg-notify.js +13 -2
  6. package/lowcode/backend-manager/bg-notify.ts +17 -2
  7. package/lowcode/backend-manager/bg-product.js +81 -30
  8. package/lowcode/backend-manager/bg-product.ts +95 -34
  9. package/lowcode/backend-manager/bg-recommend.js +109 -141
  10. package/lowcode/backend-manager/bg-recommend.ts +122 -144
  11. package/lowcode/backend-manager/bg-sns.js +14 -4
  12. package/lowcode/backend-manager/bg-sns.ts +18 -4
  13. package/lowcode/backend-manager/bg-widget.js +176 -12
  14. package/lowcode/backend-manager/bg-widget.ts +198 -13
  15. package/lowcode/cms-plugin/auto-fcm-advertise.js +13 -2
  16. package/lowcode/cms-plugin/auto-fcm-advertise.ts +16 -2
  17. package/lowcode/cms-plugin/auto-fcm-history.js +13 -2
  18. package/lowcode/cms-plugin/auto-fcm-history.ts +16 -2
  19. package/lowcode/cms-plugin/model/order.d.ts +1 -0
  20. package/lowcode/cms-plugin/module/order-excel.js +18 -2
  21. package/lowcode/cms-plugin/module/order-excel.ts +20 -9
  22. package/lowcode/cms-plugin/module/product-setting.js +2 -1
  23. package/lowcode/cms-plugin/module/product-setting.ts +2 -1
  24. package/lowcode/cms-plugin/module/user-excel.js +1 -1
  25. package/lowcode/cms-plugin/module/user-excel.ts +2 -2
  26. package/lowcode/cms-plugin/pos-pages/payment-page.js +3 -2
  27. package/lowcode/cms-plugin/pos-pages/payment-page.ts +11 -5
  28. package/lowcode/cms-plugin/pos-pages/products-page.ts +0 -1
  29. package/lowcode/cms-plugin/shopping-allowance-manager.js +3 -2
  30. package/lowcode/cms-plugin/shopping-allowance-manager.ts +3 -2
  31. package/lowcode/cms-plugin/shopping-discount-setting.js +2 -0
  32. package/lowcode/cms-plugin/shopping-discount-setting.ts +2 -0
  33. package/lowcode/cms-plugin/shopping-invoice-manager.js +7 -4
  34. package/lowcode/cms-plugin/shopping-invoice-manager.ts +12 -11
  35. package/lowcode/cms-plugin/shopping-order-manager.js +21 -4
  36. package/lowcode/cms-plugin/shopping-order-manager.ts +30 -11
  37. package/lowcode/cms-plugin/shopping-product-setting.js +45 -41
  38. package/lowcode/cms-plugin/shopping-product-setting.ts +55 -48
  39. package/lowcode/cms-plugin/shopping-rebate.js +52 -46
  40. package/lowcode/cms-plugin/shopping-rebate.ts +402 -396
  41. package/lowcode/cms-plugin/shopping-setting-advance.js +6 -6
  42. package/lowcode/cms-plugin/shopping-setting-advance.ts +7 -7
  43. package/lowcode/cms-plugin/shopping-setting-basic.js +44 -0
  44. package/lowcode/cms-plugin/shopping-setting-basic.ts +63 -1
  45. package/lowcode/cms-plugin/shopping-setting-stock-log.js +57 -0
  46. package/lowcode/cms-plugin/shopping-setting-stock-log.ts +101 -0
  47. package/lowcode/cms-plugin/user-list.js +10 -9
  48. package/lowcode/cms-plugin/user-list.ts +11 -8
  49. package/lowcode/css/editor.css +1 -1
  50. package/lowcode/form-view/editor/image-selector.js +83 -82
  51. package/lowcode/form-view/editor/image-selector.ts +115 -107
  52. package/lowcode/glitter-base/route/user.js +27 -34
  53. package/lowcode/glitter-base/route/user.ts +31 -40
  54. package/lowcode/glitterBundle/dialog/ShareDialog.js +1 -0
  55. package/lowcode/glitterBundle/dialog/ShareDialog.ts +2 -0
  56. package/lowcode/glitterBundle/dialog/dialog.js +2 -2
  57. package/lowcode/glitterBundle/dialog/dialog.ts +2 -2
  58. package/lowcode/glitterBundle/plugins/editor-elem.js +5 -11
  59. package/lowcode/glitterBundle/plugins/editor-elem.ts +11 -11
  60. package/lowcode/modules/image-library.js +836 -486
  61. package/lowcode/modules/image-library.ts +1760 -1418
  62. package/lowcode/modules/tool.js +10 -9
  63. package/lowcode/modules/tool.ts +11 -10
  64. package/lowcode/public-components/checkout/index.js +4 -2
  65. package/lowcode/public-components/checkout/index.ts +5 -3
  66. package/lowcode/public-models/product.ts +13 -0
  67. package/nxv0ptv53w.json +1 -0
  68. package/package.json +1 -1
  69. package/src/api-public/controllers/shop.js +2 -2
  70. package/src/api-public/controllers/shop.js.map +1 -1
  71. package/src/api-public/controllers/shop.ts +5 -2
  72. package/src/api-public/controllers/stock.js +1 -1
  73. package/src/api-public/controllers/stock.js.map +1 -1
  74. package/src/api-public/controllers/stock.ts +93 -81
  75. package/src/api-public/models/glitter-finance.js +2 -1
  76. package/src/api-public/models/glitter-finance.js.map +1 -1
  77. package/src/api-public/services/checkout-event.js +1 -0
  78. package/src/api-public/services/checkout-event.js.map +1 -1
  79. package/src/api-public/services/checkout-event.ts +2 -2
  80. package/src/api-public/services/data-analyze.d.ts +1 -1
  81. package/src/api-public/services/diff-record.d.ts +25 -0
  82. package/src/api-public/services/diff-record.js +158 -0
  83. package/src/api-public/services/diff-record.js.map +1 -0
  84. package/src/api-public/services/diff-record.ts +217 -0
  85. package/src/api-public/services/ezpay/tool.d.ts +1 -0
  86. package/src/api-public/services/financial-serviceV2.js +7 -17
  87. package/src/api-public/services/financial-serviceV2.js.map +1 -1
  88. package/src/api-public/services/public-table-check.js +25 -7
  89. package/src/api-public/services/public-table-check.js.map +1 -1
  90. package/src/api-public/services/public-table-check.ts +53 -31
  91. package/src/api-public/services/shopping.d.ts +2 -12
  92. package/src/api-public/services/shopping.js +16 -7
  93. package/src/api-public/services/shopping.js.map +1 -1
  94. package/src/api-public/services/shopping.ts +33 -7
  95. package/src/api-public/services/stock.d.ts +1 -1
  96. package/src/api-public/services/stock.js +19 -17
  97. package/src/api-public/services/stock.js.map +1 -1
  98. package/src/api-public/services/stock.ts +711 -696
  99. package/src/api-public/services/user.d.ts +1 -1
  100. package/src/api-public/services/user.js +25 -25
  101. package/src/api-public/services/user.js.map +1 -1
  102. package/src/api-public/services/user.ts +34 -27
  103. package/src/app-project/serverless/src/index.js +7 -17
  104. package/src/app-project/serverless/src/index.js.map +1 -1
  105. package/src/app-project/serverless/src/modules/CryptoJS.js +7 -17
  106. package/src/app-project/serverless/src/modules/CryptoJS.js.map +1 -1
  107. package/src/app-project/serverless/src/modules/database.d.ts +1 -1
  108. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  109. package/src/app-project/serverless/src/modules/ssh.js +7 -17
  110. package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
  111. package/src/firebase/message.js +2 -1
  112. package/src/firebase/message.js.map +1 -1
  113. package/src/helper/app_creater.js +2 -1
  114. package/src/helper/app_creater.js.map +1 -1
  115. package/src/helper/glitter-util.d.ts +1 -0
  116. package/src/lambda/interface.js +2 -2
  117. package/src/lambda/interface.js.map +1 -1
  118. package/src/modules/CryptoJS.js +7 -17
  119. package/src/modules/CryptoJS.js.map +1 -1
  120. package/src/modules/database.d.ts +1 -1
  121. package/src/modules/ssh.js +7 -17
  122. package/src/modules/ssh.js.map +1 -1
  123. package/src/modules/tool.d.ts +5 -0
  124. package/src/modules/tool.js +19 -0
  125. package/src/modules/tool.js.map +1 -1
  126. package/src/modules/tool.ts +27 -0
  127. package/src/run.js +2 -1
  128. package/src/run.js.map +1 -1
  129. package/src/services/app.js +7 -17
  130. package/src/services/app.js.map +1 -1
  131. package/src/services/saas-table-check.js +2 -2
  132. package/src/services/saas-table-check.js.map +1 -1
  133. package/src/services/ses.js +2 -1
  134. package/src/services/ses.js.map +1 -1
@@ -14,22 +14,57 @@ import { EditorElem } from '../glitterBundle/plugins/editor-elem.js';
14
14
  import { FilterOptions } from '../cms-plugin/filter-options.js';
15
15
  import { Tool } from './tool.js';
16
16
  const html = String.raw;
17
+ const css = String.raw;
17
18
  export class imageLibrary {
18
19
  static fileSystem(cf) {
19
20
  const gvc = cf.gvc;
20
21
  const vm = {
21
22
  id: cf.gvc.glitter.getUUID(),
23
+ footer_id: gvc.glitter.getUUID(),
22
24
  link: [],
23
25
  selected: false,
24
26
  loading: true,
25
27
  query: '',
26
28
  orderString: 'created_time_desc',
27
29
  type: 'file',
30
+ newFolder: {
31
+ selected: false,
32
+ title: '',
33
+ data: [],
34
+ items: [],
35
+ type: 'folder',
36
+ tag: [],
37
+ id: gvc.glitter.getUUID(),
38
+ },
39
+ };
40
+ const ids = {
41
+ classPrefix: 'image-library-dialog',
28
42
  };
43
+ gvc.addStyle(css `
44
+ .${ids.classPrefix} {
45
+ }
46
+ `);
29
47
  if (cf.key == 'folderEdit') {
30
48
  vm.tag = cf.tag;
31
49
  vm.type = 'folderEdit';
32
50
  }
51
+ function changeWindowsName(name) {
52
+ var _a, _b;
53
+ let titleContent = (_b = (_a = window === null || window === void 0 ? void 0 : window.parent) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.querySelector('.dialog-title div');
54
+ if (titleContent) {
55
+ titleContent.textContent = name;
56
+ }
57
+ }
58
+ function changeCancelBTNName(name) {
59
+ var _a, _b;
60
+ let backBTN = (_b = (_a = window === null || window === void 0 ? void 0 : window.parent) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.querySelector('.btn-snow span');
61
+ if (backBTN) {
62
+ backBTN.textContent = name;
63
+ }
64
+ }
65
+ function gClass(className) {
66
+ return ids.classPrefix + '-' + className;
67
+ }
33
68
  function getSelectCount(dd) {
34
69
  let count = 0;
35
70
  if (dd.selected) {
@@ -44,7 +79,7 @@ export class imageLibrary {
44
79
  if (data.response.value) {
45
80
  vm.link = data.response.value;
46
81
  function loop(array) {
47
- array.map((dd) => {
82
+ array.map(dd => {
48
83
  var _a;
49
84
  if (dd.type === 'folder') {
50
85
  loop((_a = dd.items) !== null && _a !== void 0 ? _a : []);
@@ -63,7 +98,7 @@ export class imageLibrary {
63
98
  }
64
99
  const dialog = new ShareDialog(cf.gvc.glitter);
65
100
  function clearNoNeedData(items) {
66
- items.map((dd) => {
101
+ items.map(dd => {
67
102
  if (dd.selected) {
68
103
  dd.selected = undefined;
69
104
  }
@@ -77,12 +112,16 @@ export class imageLibrary {
77
112
  key: 'image-manager',
78
113
  value: vm.link,
79
114
  user_id: 'manager',
80
- }).then((data) => {
115
+ }).then(data => {
81
116
  dialog.dataLoading({ visible: false });
82
117
  dialog.successMessage({ text: '儲存成功' });
83
118
  finish();
84
119
  });
85
120
  }
121
+ function closeFolderView(returnPage = 'folder') {
122
+ changeWindowsName('圖片庫');
123
+ changeCancelBTNName('取消');
124
+ }
86
125
  const isSafari = (() => {
87
126
  const userAgent = navigator.userAgent.toLowerCase();
88
127
  return userAgent.includes('safari') && !userAgent.includes('chrome') && !userAgent.includes('edg');
@@ -100,7 +139,7 @@ export class imageLibrary {
100
139
  view: () => {
101
140
  try {
102
141
  let editArray = [];
103
- let sortArray = array.map((dd) => {
142
+ let sortArray = array.map(dd => {
104
143
  return dd;
105
144
  });
106
145
  switch (vm.orderString) {
@@ -127,18 +166,20 @@ export class imageLibrary {
127
166
  break;
128
167
  }
129
168
  return sortArray
130
- .map((dd, index) => {
169
+ .map((fileItem, index) => {
131
170
  var _a;
132
171
  const passType = ['file', 'folderView', 'folderEdit', 'folderADD'];
133
172
  const noImageURL = 'https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722936949034-default_image.jpg';
134
- const originImageURL = passType.includes(vm.type) ? dd.data : (_a = vm.link.find((data) => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.tag) === null || _a === void 0 ? void 0 : _a.includes(dd.title); })) === null || _a === void 0 ? void 0 : _a.data;
173
+ const originImageURL = passType.includes(vm.type)
174
+ ? fileItem.data
175
+ : (_a = vm.link.find(data => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.tag) === null || _a === void 0 ? void 0 : _a.includes(fileItem.title); })) === null || _a === void 0 ? void 0 : _a.data;
135
176
  const originImageSplit = (originImageURL || '').split('/');
136
177
  const imageBoxClass = Tool.randomString(5);
137
- dd.title = dd.title || originImageSplit.pop() || '圖片尚未命名';
178
+ fileItem.title = fileItem.title || originImageSplit.pop() || '圖片尚未命名';
138
179
  if (editArray.length < index + 1) {
139
180
  editArray.push(false);
140
181
  }
141
- if (!dd.title.toLowerCase().includes(vm.query.toLowerCase())) {
182
+ if (!fileItem.title.toLowerCase().includes(vm.query.toLowerCase())) {
142
183
  return;
143
184
  }
144
185
  let viewID = gvc.glitter.getUUID();
@@ -148,22 +189,44 @@ export class imageLibrary {
148
189
  try {
149
190
  const imageUrl = originImageURL !== null && originImageURL !== void 0 ? originImageURL : noImageURL;
150
191
  function itemClick() {
192
+ var _a;
151
193
  if (vm.type == 'folder') {
152
- vm.tag = dd.title;
153
- that.selectImageLibrary(gvc, (selectData) => {
194
+ console.log("vm.link --", vm.link);
195
+ vm.type = 'folderEdit';
196
+ that.selectImageLibrary(gvc, selectData => {
154
197
  vm.link = selectData;
155
198
  gvc.notifyDataChange(vm.id);
156
199
  }, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
157
200
  key: 'folderEdit',
158
201
  mul: true,
159
- tag: dd.title,
202
+ tag: fileItem.title,
203
+ });
204
+ }
205
+ else if (vm.type == 'folderView') {
206
+ function updateLinkList(replaceId, newItem) {
207
+ const replaceItemIndex = vm.link.findIndex(i => i.id === replaceId);
208
+ console.log(replaceItemIndex);
209
+ if (replaceItemIndex < 0)
210
+ return;
211
+ if (newItem)
212
+ vm.link[replaceItemIndex] = newItem;
213
+ else
214
+ vm.link.splice(replaceItemIndex, 1);
215
+ save(() => gvc.notifyDataChange(vm.id));
216
+ }
217
+ cf.edit(fileItem, (replace) => {
218
+ var _a;
219
+ updateLinkList((_a = replace === null || replace === void 0 ? void 0 : replace.id) !== null && _a !== void 0 ? _a : fileItem.id, replace);
220
+ }, {
221
+ deleteStyle: 1,
222
+ tag: (_a = vm.tag) !== null && _a !== void 0 ? _a : '',
160
223
  });
161
224
  }
162
225
  else {
163
- cf.edit(dd, (replace) => {
226
+ cf.edit(fileItem, replace => {
164
227
  if (!replace) {
165
- let selectData = vm.link.findIndex((data) => {
166
- return data.id == dd.id;
228
+ let selectData = vm.link.findIndex(data => {
229
+ return data.id == fileItem.id;
167
230
  });
168
231
  vm.link.splice(selectData, 1);
169
232
  save(() => {
@@ -171,7 +234,7 @@ export class imageLibrary {
171
234
  });
172
235
  }
173
236
  else {
174
- let replaceIndex = vm.link.findIndex((data) => data.id == replace.id);
237
+ let replaceIndex = vm.link.findIndex(data => data.id == replace.id);
175
238
  vm.link[replaceIndex] = replace;
176
239
  save(() => {
177
240
  gvc.notifyDataChange(vm.id);
@@ -181,19 +244,18 @@ export class imageLibrary {
181
244
  }
182
245
  }
183
246
  return html `
184
- <div
185
- class=""
186
- style="padding: 10px 12px;position: relative;${dd.selected
247
+ <div
248
+ style="padding: 10px 12px;position: relative;${fileItem.selected
187
249
  ? `border-radius: 10px;border: 2px solid #393939;background: #F7F7F7;box-shadow: 3px 3px 10px 0px rgba(0, 0, 0, 0.10);`
188
250
  : editArray[index]
189
251
  ? `border-radius: 10px;border: 1px solid #DDD;background: #F7F7F7;`
190
252
  : ``}"
191
- onclick="${gvc.event((e, event) => {
192
- let defaultSelect = dd.selected;
253
+ onclick="${gvc.event((e, event) => {
254
+ let defaultSelect = fileItem.selected;
193
255
  if (vm.type == 'folder') {
194
256
  array = [];
195
257
  vm.type = 'folderView';
196
- vm.tag = dd.title;
258
+ vm.tag = fileItem.title;
197
259
  gvc.notifyDataChange(vm.id);
198
260
  return;
199
261
  }
@@ -201,17 +263,16 @@ export class imageLibrary {
201
263
  return;
202
264
  }
203
265
  if (!cf.mul) {
204
- array.forEach((data) => {
266
+ array.forEach(data => {
205
267
  data.selected = false;
206
268
  });
207
269
  }
208
- dd.selected = !defaultSelect;
270
+ fileItem.selected = !defaultSelect;
209
271
  gvc.notifyDataChange(vm.id);
210
272
  event.stopPropagation();
211
273
  })}"
212
- ${!gvc.glitter.isTouchDevice()
213
- ? `
214
- onmouseenter="${gvc.event(() => {
274
+ ${!gvc.glitter.isTouchDevice()
275
+ ? `onmouseenter="${gvc.event(() => {
215
276
  if ((opt === null || opt === void 0 ? void 0 : opt.onlyRead) || cf.key == 'album') {
216
277
  return;
217
278
  }
@@ -219,16 +280,15 @@ export class imageLibrary {
219
280
  editArray[index] = true;
220
281
  gvc.notifyDataChange(viewID);
221
282
  }
222
- })}"
223
- onmouseleave="${gvc.event((e, event) => {
283
+ })}"onmouseleave="${gvc.event((e, event) => {
224
284
  if (opt === null || opt === void 0 ? void 0 : opt.onlyRead)
225
285
  return;
226
286
  if (isSafari) {
227
287
  const target = event.relatedTarget;
228
288
  const imageBoxClassList = [imageBoxClass];
229
289
  const targetClassList = Array.from(target.classList);
230
- const isOutBorder = imageBoxClassList.every((cls) => targetClassList.includes(cls)) &&
231
- targetClassList.every((cls) => imageBoxClassList.includes(cls));
290
+ const isOutBorder = imageBoxClassList.every(cls => targetClassList.includes(cls)) &&
291
+ targetClassList.every(cls => imageBoxClassList.includes(cls));
232
292
  const isTitle = targetClassList.includes(`${imageBoxClass}-title`);
233
293
  const isInside = targetClassList.length === 0;
234
294
  const isOutOfViewContainer = target.dataset.viewContainer === 'true';
@@ -242,61 +302,63 @@ export class imageLibrary {
242
302
  })}"
243
303
  `
244
304
  : ``}
245
- >
246
- <div
247
- class="${editArray[index] && !dd.selected ? `d-flex` : `d-none`} align-items-center justify-content-center"
248
- style="height:24px;width:24px;border-radius: 3px;background: rgba(0, 0, 0, 0.80);position: absolute;right: 8.15px;top: 8px;"
249
- onclick="${gvc.event((e, event) => {
305
+ >
306
+ <div
307
+ class="${editArray[index] && !fileItem.selected
308
+ ? `d-flex`
309
+ : `d-none`} align-items-center justify-content-center"
310
+ style="height:24px;width:24px;border-radius: 3px;background: rgba(0, 0, 0, 0.80);position: absolute;right: 8.15px;top: 8px;"
311
+ onclick="${gvc.event((e, event) => {
250
312
  event.stopPropagation();
251
313
  itemClick();
252
314
  })}"
253
- >
254
- <svg xmlns="http://www.w3.org/2000/svg" width="12"
255
- height="12" viewBox="0 0 12 12" fill="none">
256
- <g clip-path="url(#clip0_13619_1920)">
257
- <path
258
- d="M0.852963 8.45864L0.3139 10.2891L0.0232751 11.2782C-0.0353187 11.4774 0.0185876 11.6907 0.1639 11.836C0.309213 11.9813 0.522494 12.0352 0.719369 11.979L1.71078 11.686L3.54124 11.1469C3.78499 11.0766 4.01234 10.9594 4.21156 10.8071L4.21859 10.8118L4.23031 10.793C4.26312 10.7672 4.29359 10.7415 4.32406 10.7157C4.35687 10.6875 4.38734 10.6571 4.41781 10.6266L11.5475 3.49927C12.0608 2.98599 12.1241 2.19614 11.7397 1.61255C11.6858 1.53052 11.6202 1.45083 11.5475 1.37817L10.6241 0.452393C10.0381 -0.133545 9.0889 -0.133545 8.50296 0.452393L1.37328 7.58208C1.31468 7.64067 1.25843 7.70395 1.20687 7.76958L1.18812 7.7813L1.19281 7.78833C1.04046 7.98755 0.925619 8.21489 0.852963 8.45864ZM8.9764 4.47661L4.6264 8.82661L3.4639 8.53599L3.17327 7.37349L7.52328 3.02349L8.9764 4.47661ZM2.27328 8.41177L2.45374 9.13833C2.50296 9.33989 2.66234 9.49692 2.8639 9.54849L3.59046 9.72895L3.41703 9.99145C3.35609 10.0243 3.29281 10.0524 3.22718 10.0711L2.67874 10.2329L1.39203 10.6079L1.76937 9.32349L1.93109 8.77505C1.94984 8.70942 1.97796 8.6438 2.01078 8.5852L2.27328 8.41177ZM7.38968 5.12583C7.53499 4.98052 7.53499 4.74145 7.38968 4.59614C7.24437 4.45083 7.00531 4.45083 6.85999 4.59614L4.60999 6.84614C4.46468 6.99146 4.46468 7.23052 4.60999 7.37583C4.75531 7.52114 4.99437 7.52114 5.13968 7.37583L7.38968 5.12583Z"
259
- fill="white"
260
- />
261
- </g>
262
- <defs>
263
- <clipPath id="clip0_13619_1920">
264
- <rect width="12" height="12"
265
- fill="white"/>
266
- </clipPath>
267
- </defs>
268
- </svg>
269
- </div>
270
- <div
271
- class="position-absolute ${dd.selected ? `d-blok` : `d-none`} "
272
- style="transform: translate(-50%,-50%);left: 50%;top:50%;"
273
- >
274
- ${BgWidget.darkButton('編輯圖片', gvc.event(() => {
315
+ >
316
+ <svg
317
+ xmlns="http://www.w3.org/2000/svg"
318
+ width="12"
319
+ height="12"
320
+ viewBox="0 0 12 12"
321
+ fill="none"
322
+ >
323
+ <g clip-path="url(#clip0_13619_1920)">
324
+ <path
325
+ d="M0.852963 8.45864L0.3139 10.2891L0.0232751 11.2782C-0.0353187 11.4774 0.0185876 11.6907 0.1639 11.836C0.309213 11.9813 0.522494 12.0352 0.719369 11.979L1.71078 11.686L3.54124 11.1469C3.78499 11.0766 4.01234 10.9594 4.21156 10.8071L4.21859 10.8118L4.23031 10.793C4.26312 10.7672 4.29359 10.7415 4.32406 10.7157C4.35687 10.6875 4.38734 10.6571 4.41781 10.6266L11.5475 3.49927C12.0608 2.98599 12.1241 2.19614 11.7397 1.61255C11.6858 1.53052 11.6202 1.45083 11.5475 1.37817L10.6241 0.452393C10.0381 -0.133545 9.0889 -0.133545 8.50296 0.452393L1.37328 7.58208C1.31468 7.64067 1.25843 7.70395 1.20687 7.76958L1.18812 7.7813L1.19281 7.78833C1.04046 7.98755 0.925619 8.21489 0.852963 8.45864ZM8.9764 4.47661L4.6264 8.82661L3.4639 8.53599L3.17327 7.37349L7.52328 3.02349L8.9764 4.47661ZM2.27328 8.41177L2.45374 9.13833C2.50296 9.33989 2.66234 9.49692 2.8639 9.54849L3.59046 9.72895L3.41703 9.99145C3.35609 10.0243 3.29281 10.0524 3.22718 10.0711L2.67874 10.2329L1.39203 10.6079L1.76937 9.32349L1.93109 8.77505C1.94984 8.70942 1.97796 8.6438 2.01078 8.5852L2.27328 8.41177ZM7.38968 5.12583C7.53499 4.98052 7.53499 4.74145 7.38968 4.59614C7.24437 4.45083 7.00531 4.45083 6.85999 4.59614L4.60999 6.84614C4.46468 6.99146 4.46468 7.23052 4.60999 7.37583C4.75531 7.52114 4.99437 7.52114 5.13968 7.37583L7.38968 5.12583Z"
326
+ fill="white"
327
+ />
328
+ </g>
329
+ <defs>
330
+ <clipPath id="clip0_13619_1920">
331
+ <rect width="12" height="12" fill="white" />
332
+ </clipPath>
333
+ </defs>
334
+ </svg>
335
+ </div>
336
+ <div
337
+ class="position-absolute ${fileItem.selected ? `d-blok` : `d-none`} "
338
+ style="transform: translate(-50%,-50%);left: 50%;top:50%;"
339
+ >
340
+ ${BgWidget.darkButton('編輯圖片', gvc.event(() => {
275
341
  itemClick();
276
342
  }))}
277
- </div>
278
- <div
279
- class="${dd.selected ? `d-flex` : `d-none`} "
280
- style="height:24px;width:24px;border-radius: 3px;position: absolute;right: 8.15px;top: 8px;"
281
- >
282
- <i class="fa-solid fa-square-check "
283
- style="color: #393939;font-size: 24px;"></i>
284
- </div>
285
-
286
- <div
287
- style="width:100%;padding-top: 100%;background:50%/contain url('${imageUrl}') no-repeat;border-radius: 5px;border: 0.938px solid #DDD;background: ;"
288
- ></div>
289
- <div
290
- class="w-100 text-center font-size: 16px;font-style: normal;font-weight: 400;text-overflow: ellipsis;"
291
- style="overflow:hidden;white-space: nowrap;text-overflow: ellipsis;"
292
- contenteditable="true"
293
- onchange="${gvc.event((e) => {
294
- })}"
295
- >
296
- ${dd.title}
297
- </div>
298
- </div>
299
- `;
343
+ </div>
344
+ <div
345
+ class="${fileItem.selected ? `d-flex` : `d-none`} "
346
+ style="height:24px;width:24px;border-radius: 3px;position: absolute;right: 8.15px;top: 8px;"
347
+ >
348
+ <i class="fa-solid fa-square-check " style="color: #393939;font-size: 24px;"></i>
349
+ </div>
350
+ <div
351
+ style="width:100%;padding-top: 100%;background:50%/contain url('${imageUrl}') no-repeat;border-radius: 5px;border: 0.938px solid #DDD;background: ;"
352
+ ></div>
353
+ <div
354
+ class="w-100 text-center font-size: 16px;font-style: normal;font-weight: 400;text-overflow: ellipsis;"
355
+ style="overflow:hidden;white-space: nowrap;text-overflow: ellipsis;"
356
+ onchange="${gvc.event((e) => { })}"
357
+ >
358
+ ${fileItem.title}
359
+ </div>
360
+ </div>
361
+ `;
300
362
  }
301
363
  catch (e) {
302
364
  console.error(e);
@@ -329,30 +391,27 @@ export class imageLibrary {
329
391
  {
330
392
  src: `https://raw.githack.com/SortableJS/Sortable/master/Sortable.js`,
331
393
  },
332
- ], () => {
333
- }, () => {
334
- });
394
+ ], () => { }, () => { });
335
395
  const interval = setInterval(() => {
336
396
  if (window.Sortable) {
337
397
  try {
338
- gvc.addStyle(`
339
- ul {
340
- list-style: none;
341
- padding: 0;
342
- }
343
- `);
398
+ gvc.addStyle(css `
399
+ ul {
400
+ list-style: none;
401
+ padding: 0;
402
+ }
403
+ `);
344
404
  function swapArr(arr, index1, index2) {
345
405
  const data = arr[index1];
346
406
  arr.splice(index1, 1);
347
407
  arr.splice(index2, 0, data);
348
408
  }
349
409
  let startIndex = 0;
350
- Sortable.create(gvc.getBindViewElem(id).get(0), {
410
+ window.create(gvc.getBindViewElem(id).get(0), {
351
411
  group: id,
352
412
  animation: 100,
353
413
  handle: '.dragItem',
354
- onChange: function (evt) {
355
- },
414
+ onChange: function (evt) { },
356
415
  onEnd: (evt) => {
357
416
  swapArr(array, startIndex, evt.newIndex);
358
417
  gvc.notifyDataChange(id);
@@ -362,8 +421,7 @@ export class imageLibrary {
362
421
  },
363
422
  });
364
423
  }
365
- catch (e) {
366
- }
424
+ catch (e) { }
367
425
  clearInterval(interval);
368
426
  }
369
427
  }, 100);
@@ -380,6 +438,40 @@ export class imageLibrary {
380
438
  view: () => __awaiter(this, void 0, void 0, function* () {
381
439
  var _a, _b, _c;
382
440
  const dialog = new ShareDialog(cf.gvc.glitter);
441
+ gvc.notifyDataChange(vm.footer_id);
442
+ function drawBreadcrumb() {
443
+ return html `
444
+ <div class="d-flex" style="margin: 20px 0">
445
+ <div class="breadcrumb-item">
446
+ <div
447
+ class="cursor_pointer"
448
+ onclick="${gvc.event(() => {
449
+ closeFolderView();
450
+ vm.type = 'file';
451
+ gvc.notifyDataChange(vm.id);
452
+ })}"
453
+ >
454
+ 我的圖庫
455
+ </div>
456
+ </div>
457
+ <div class="breadcrumb-item">
458
+ <div
459
+ class="cursor_pointer"
460
+ onclick="${gvc.event(() => {
461
+ closeFolderView();
462
+ vm.type = 'folder';
463
+ gvc.notifyDataChange(vm.id);
464
+ })}"
465
+ >
466
+ 相簿
467
+ </div>
468
+ </div>
469
+ <div class="breadcrumb-item">
470
+ <div>${vm.tag}</div>
471
+ </div>
472
+ </div>
473
+ `;
474
+ }
383
475
  function pageBTN() {
384
476
  let key = [
385
477
  {
@@ -392,158 +484,120 @@ export class imageLibrary {
392
484
  },
393
485
  ];
394
486
  return key
395
- .map((data) => {
487
+ .map(data => {
396
488
  return html `
397
- <div
398
- style="color:${vm.type == data.key
489
+ <div
490
+ style="color:${vm.type == data.key
399
491
  ? '#393939'
400
- : '#8D8D8D'};display: flex;padding:6px 18px;justify-content: center;align-items: center;border-radius: 10px;border: 2px solid ${vm.type == data.key
492
+ : '#8D8D8D'};display: flex;padding:6px 18px;justify-content: center;align-items: center;border-radius: 10px;border: 2px solid ${vm.type ==
493
+ data.key
401
494
  ? '#393939'
402
- : '#8D8D8D'};background: #FFF;font-weight: ${vm.type == data.key ? '700' : '500'};cursor: pointer;"
403
- onclick="${gvc.event((e) => {
495
+ : '#8D8D8D'};background: #FFF;font-weight: ${vm.type == data.key
496
+ ? '700'
497
+ : '500'};cursor: pointer;"
498
+ onclick="${gvc.event(e => {
404
499
  vm.type = data.key;
405
500
  vm.query = '';
406
501
  gvc.notifyDataChange(vm.id);
407
502
  })}"
408
- >
409
- ${data.value}
410
- </div>
411
- `;
503
+ >
504
+ ${data.value}
505
+ </div>
506
+ `;
412
507
  })
413
508
  .join('');
414
509
  }
510
+ if (vm.type == 'folderViewToEdit') {
511
+ vm.type = 'folderView';
512
+ console.log("vm.link --", vm.link);
513
+ yield that.selectImageLibrary(gvc, selectData => {
514
+ vm.link = selectData;
515
+ gvc.notifyDataChange(vm.id);
516
+ }, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
517
+ key: 'folderEdit',
518
+ mul: true,
519
+ tag: vm.tag,
520
+ });
521
+ }
415
522
  if (vm.type == 'folderADD') {
523
+ function pushFolder(folder, imageArray) {
524
+ console.log('folder -- ', folder);
525
+ console.log('imageArray -- ', imageArray);
526
+ imageArray.forEach(image => {
527
+ image.selected = false;
528
+ });
529
+ return folder.data.push(...imageArray);
530
+ }
531
+ vm.newFolder = {
532
+ selected: false,
533
+ title: '',
534
+ data: [],
535
+ items: [],
536
+ type: 'folder',
537
+ tag: [],
538
+ id: gvc.glitter.getUUID(),
539
+ };
416
540
  return html `
417
- <div class="d-flex flex-column"
418
- style="font-size: 16px;font-style: normal;font-weight: 400;gap:8px;">
419
- 相簿名稱
420
- <input
421
- class="w-100"
422
- value="${(_a = vm.tag) !== null && _a !== void 0 ? _a : ''}"
423
- placeholder="請輸入相簿名稱"
424
- style="height: 40px;padding: 9px 18px;border-radius: 10px;border: 1px solid #DDD;"
425
- onchange="${gvc.event((e) => {
541
+ <div class="d-flex flex-column ${gClass('new-album-title-bar')}">
542
+ 相簿名稱
543
+ <input
544
+ class="w-100"
545
+ value="${(_a = vm.tag) !== null && _a !== void 0 ? _a : ''}"
546
+ placeholder="請輸入相簿名稱"
547
+ onchange="${gvc.event(e => {
426
548
  vm.tag = e.value;
427
549
  })}"
428
- />
429
- </div>
430
- <div
431
- class="w-100 "
432
- style="margin-top:18px;padding: 39px 0;display: flex;justify-content: center;align-items: center;border-radius: 10px;border: 1px solid #DDD;background: #FFF;gap:14px;"
433
- >
434
- <div
435
- style="padding: 10px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);cursor: pointer;"
436
- onclick="${gvc.event(() => {
437
- if (!vm.tag) {
438
- const dialog = new ShareDialog(cf.gvc.glitter);
439
- dialog.errorMessage({ text: '請先輸入相簿名稱' });
440
- return;
441
- }
442
- this.selectImageLibrary(gvc, (selectData) => {
443
- var _a;
444
- const folder = {
445
- title: (_a = vm.tag) !== null && _a !== void 0 ? _a : 'folder',
446
- data: [],
447
- items: selectData,
448
- type: 'folder',
449
- tag: [],
450
- id: gvc.glitter.getUUID(),
451
- };
452
- selectData.map((data) => {
453
- let matchingElement = vm.link.find((item2) => item2.id === data.id);
454
- if (matchingElement) {
455
- if (!matchingElement.tag) {
456
- matchingElement.tag = [];
457
- }
458
- if (!matchingElement.tag.includes(vm.tag)) {
459
- matchingElement.tag.push(vm.tag);
460
- }
461
- }
462
- data.selected = false;
463
- });
464
- vm.link.push(folder);
465
- vm.type = 'folder';
466
- gvc.notifyDataChange(vm.id);
467
- save(() => {
468
- gvc.notifyDataChange(vm.id);
469
- });
550
+ />
551
+ </div>
552
+ <div class="w-100 ${gClass('new-album-add-block')}">
553
+ <div
554
+ class="btn1"
555
+ onclick="${gvc.event(() => {
556
+ this.selectImageLibrary(gvc, selectData => {
557
+ pushFolder(vm.newFolder, selectData);
558
+ gvc.notifyDataChange('folderItemGroup');
470
559
  }, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
471
560
  key: 'album',
472
561
  mul: true,
473
562
  });
474
563
  })}"
475
- >
476
- 從圖庫中選擇
477
- </div>
478
- <div
479
- style="padding: 10px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);cursor: pointer;"
480
- onclick="${gvc.event(() => {
481
- if (!vm.tag) {
482
- const dialog = new ShareDialog(cf.gvc.glitter);
483
- dialog.errorMessage({ text: '請先輸入相簿名稱' });
484
- return;
485
- }
486
- cf.plus(gvc, (fileArray) => {
487
- var _a;
488
- const folder = {
489
- title: (_a = vm.tag) !== null && _a !== void 0 ? _a : 'folder',
490
- data: [],
491
- items: [],
492
- type: 'folder',
493
- tag: [],
494
- id: gvc.glitter.getUUID(),
495
- };
496
- fileArray.forEach((item) => {
497
- item.tag = [];
498
- item.tag.push(vm.tag);
499
- vm.link.push(item);
564
+ >
565
+ 從圖庫中選擇
566
+ </div>
567
+ <div
568
+ class="btn1"
569
+ onclick="${gvc.event(() => {
570
+ cf.plus(gvc, fileArray => {
571
+ pushFolder(vm.newFolder, fileArray);
572
+ save(() => {
573
+ gvc.notifyDataChange('folderItemGroup');
500
574
  });
501
- vm.link.push(folder);
502
- gvc.notifyDataChange(vm.id);
503
575
  }, 'file');
504
576
  })}"
505
- >
506
- 上傳新圖片
507
- </div>
508
- </div>
509
- <div class="">
510
- ${gvc.bindView({
577
+ >
578
+ 上傳新圖片
579
+ </div>
580
+ </div>
581
+ ${gvc.bindView({
511
582
  bind: `folderItemGroup`,
512
583
  view: () => {
513
- if (vm.tag) {
514
- let group = vm.link.filter((item2) => {
515
- var _a;
516
- return item2.tag && item2.tag.includes((_a = vm.tag) !== null && _a !== void 0 ? _a : '');
517
- });
518
- return renderItems(group, { onlyRead: true });
519
- }
520
- return ``;
584
+ return renderItems(vm.newFolder.data, { onlyRead: true });
521
585
  },
522
586
  divCreate: {},
523
587
  })}
524
- </div>
525
- `;
588
+ `;
526
589
  }
527
590
  if (vm.type == 'folderView') {
591
+ changeWindowsName((_b = vm.tag) !== null && _b !== void 0 ? _b : 'folder');
592
+ changeCancelBTNName('返回');
528
593
  return html `
529
- <div class="d-flex flex-column"
530
- style="font-size: 16px;font-style: normal;font-weight: 400;gap:8px;">
531
- <input
532
- class="w-100"
533
- value="${(_b = vm.tag) !== null && _b !== void 0 ? _b : ''}"
534
- placeholder="請輸入相簿名稱"
535
- style="height: 40px;padding: 9px 18px;border-radius: 10px;border: 1px solid #DDD;"
536
- onchange="${gvc.event((e) => {
537
- vm.tag = e.value;
538
- })}"
539
- />
540
- </div>
541
- <div class="d-flex w-100" style="gap:14px;margin-top: 12px;">
542
- ${BgWidget.searchFilter(gvc.event((e) => {
594
+ ${drawBreadcrumb()}
595
+ <div class="d-flex w-100" style="gap:14px;margin-top: 12px;">
596
+ ${BgWidget.searchFilter(gvc.event(e => {
543
597
  vm.query = e.value;
544
598
  gvc.notifyDataChange(vm.id);
545
599
  }), vm.query || '', '搜尋圖片')}
546
- ${BgWidget.updownFilter({
600
+ ${BgWidget.updownFilter({
547
601
  gvc,
548
602
  callback: (value) => {
549
603
  vm.orderString = value;
@@ -552,13 +606,12 @@ export class imageLibrary {
552
606
  default: vm.orderString || 'default',
553
607
  options: FilterOptions.imageLibraryOrderBy,
554
608
  })}
555
- </div>
556
- <div class="">
557
- ${gvc.bindView({
609
+ </div>
610
+ ${gvc.bindView({
558
611
  bind: `folderItemGroup`,
559
612
  view: () => {
560
613
  if (vm.tag) {
561
- let group = vm.link.filter((item2) => {
614
+ let group = vm.link.filter(item2 => {
562
615
  var _a;
563
616
  return item2.tag && item2.tag.includes((_a = vm.tag) !== null && _a !== void 0 ? _a : '');
564
617
  });
@@ -568,30 +621,28 @@ export class imageLibrary {
568
621
  },
569
622
  divCreate: {},
570
623
  })}
571
- </div>
572
- `;
624
+ `;
573
625
  }
574
626
  if (vm.type == 'folderEdit') {
575
627
  return html `
576
- <div class="d-flex flex-column"
577
- style="font-size: 16px;font-style: normal;font-weight: 400;gap:8px;">
578
- 相簿名稱
579
- <input
580
- class="w-100"
581
- value="${(_c = vm.tag) !== null && _c !== void 0 ? _c : ''}"
582
- placeholder="請輸入相簿名稱"
583
- style="height: 40px;padding: 9px 18px;border-radius: 10px;border: 1px solid #DDD;"
584
- onchange="${gvc.event((e) => {
628
+ <div class="d-flex flex-column ${gClass('album-title')}" style="">
629
+ 相簿名稱
630
+ <input
631
+ class="w-100"
632
+ value="${(_c = vm.tag) !== null && _c !== void 0 ? _c : ''}"
633
+ placeholder="請輸入相簿名稱"
634
+ style="height: 40px;padding: 9px 18px;border-radius: 10px;border: 1px solid #DDD;"
635
+ onchange="${gvc.event(e => {
585
636
  vm.tag = e.value;
586
637
  })}"
587
- />
588
- </div>
589
- <div class="d-flex w-100" style="gap:14px;margin-top: 12px;">
590
- ${BgWidget.searchFilter(gvc.event((e) => {
638
+ />
639
+ </div>
640
+ <div class="d-flex w-100" style="gap:14px;margin-top: 12px;">
641
+ ${BgWidget.searchFilter(gvc.event(e => {
591
642
  vm.query = e.value;
592
643
  gvc.notifyDataChange(vm.id);
593
644
  }), vm.query || '', '搜尋圖片')}
594
- ${BgWidget.updownFilter({
645
+ ${BgWidget.updownFilter({
595
646
  gvc,
596
647
  callback: (value) => {
597
648
  vm.orderString = value;
@@ -600,58 +651,64 @@ export class imageLibrary {
600
651
  default: vm.orderString || 'default',
601
652
  options: FilterOptions.imageLibraryOrderBy,
602
653
  })}
603
- </div>
604
- <div class="d-flex w-100 justify-content-end" style="gap:12px;margin-top: 18px;">
605
- <div style="margin-right: auto; color: #393939; font-size: 14px; font-family: Noto Sans; font-weight: 700; word-wrap: break-word">
606
- 已選取${getSelectCount({
654
+ </div>
655
+ <div class="d-flex w-100 justify-content-end" style="gap:12px;margin-top: 18px;">
656
+ <div
657
+ style="margin-right: auto; color: #393939; font-size: 14px; font-family: Noto Sans; font-weight: 700; word-wrap: break-word"
658
+ >
659
+ 已選取${getSelectCount({
607
660
  items: vm.link,
608
661
  })}項
609
- </div>
610
- ${BgWidget.grayButton('刪除', gvc.event(() => {
611
- let selectedData = vm.link.filter((item) => item.selected);
612
- selectedData.forEach((item) => {
662
+ </div>
663
+ ${BgWidget.grayButton('刪除', gvc.event(() => {
664
+ let selectedData = vm.link.filter(item => item.selected);
665
+ selectedData.forEach(item => {
613
666
  item.selected = false;
614
- item.tag = item.tag.filter((tag) => {
667
+ item.tag = item.tag.filter(tag => {
615
668
  return tag !== vm.tag;
616
669
  });
617
670
  });
618
- let folder = vm.link.find((dd) => {
671
+ let folder = vm.link.find(dd => {
619
672
  return dd.title == vm.tag && dd.type == 'folder';
620
673
  });
621
674
  gvc.notifyDataChange(vm.id);
622
675
  }))}
623
- ${BgWidget.grayButton('新增圖片', gvc.event(() => {
676
+ ${BgWidget.grayButton('新增圖片', gvc.event(() => {
624
677
  const thatGVC = gvc;
625
678
  gvc.glitter.innerDialog((gvc) => {
626
679
  return html `
627
- <div style="width: 445px;height: 255px;border-radius: 10px;background: #FFF;">
628
- <div class="d-flex"
629
- style="color:#393939;display: flex;padding: 12px 20px;align-items: center;gap: 10px;">
630
- 新增圖片
631
- <span
632
- class="d-flex align-items-center justify-content-center"
633
- style="margin-left: auto;cursor: pointer;"
634
- onclick="${gvc.event(() => {
680
+ <div style="width: 445px;height: 255px;border-radius: 10px;background: #FFF;">
681
+ <div
682
+ class="d-flex"
683
+ style="color:#393939;display: flex;padding: 12px 20px;align-items: center;gap: 10px;"
684
+ >
685
+ 新增圖片
686
+ <span
687
+ class="d-flex align-items-center justify-content-center"
688
+ style="margin-left: auto;cursor: pointer;"
689
+ onclick="${gvc.event(() => {
635
690
  gvc.glitter.closeDiaLog('add');
636
691
  })}"
637
- >
638
- <svg xmlns="http://www.w3.org/2000/svg" width="14"
639
- height="14" viewBox="0 0 14 14" fill="none">
640
- <path d="M1 1L13 13" stroke="#393939"
641
- stroke-linecap="round"/>
642
- <path d="M13 1L1 13" stroke="#393939"
643
- stroke-linecap="round"/>
644
- </svg>
645
- </span>
646
- </div>
647
- <div class="d-flex justify-content-center"
648
- style="padding-top:61px;gap:14px;">
649
- <div
650
- style="padding: 10px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);cursor: pointer;"
651
- onclick="${gvc.event(() => {
652
- this.selectImageLibrary(gvc, (selectData) => {
653
- selectData.map((data) => {
654
- let matchingElement = vm.link.find((item2) => item2.id === data.id);
692
+ >
693
+ <svg
694
+ xmlns="http://www.w3.org/2000/svg"
695
+ width="14"
696
+ height="14"
697
+ viewBox="0 0 14 14"
698
+ fill="none"
699
+ >
700
+ <path d="M1 1L13 13" stroke="#393939" stroke-linecap="round" />
701
+ <path d="M13 1L1 13" stroke="#393939" stroke-linecap="round" />
702
+ </svg>
703
+ </span>
704
+ </div>
705
+ <div class="d-flex justify-content-center" style="padding-top:61px;gap:14px;">
706
+ <div
707
+ style="padding: 10px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);cursor: pointer;"
708
+ onclick="${gvc.event(() => {
709
+ this.selectImageLibrary(gvc, selectData => {
710
+ selectData.map(data => {
711
+ let matchingElement = vm.link.find(item2 => item2.id === data.id);
655
712
  if (matchingElement) {
656
713
  if (!matchingElement.tag) {
657
714
  matchingElement.tag = [];
@@ -669,14 +726,14 @@ export class imageLibrary {
669
726
  mul: true,
670
727
  });
671
728
  })}"
672
- >
673
- 從圖庫中選擇
674
- </div>
675
- <div
676
- style="padding: 10px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);cursor: pointer;"
677
- onclick="${gvc.event(() => {
678
- cf.plus(gvc, (fileArray) => {
679
- fileArray.forEach((item) => {
729
+ >
730
+ 從圖庫中選擇
731
+ </div>
732
+ <div
733
+ style="padding: 10px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);cursor: pointer;"
734
+ onclick="${gvc.event(() => {
735
+ cf.plus(gvc, fileArray => {
736
+ fileArray.forEach(item => {
680
737
  item.tag = [];
681
738
  item.tag.push(vm.tag);
682
739
  vm.link.push(item);
@@ -685,21 +742,21 @@ export class imageLibrary {
685
742
  thatGVC.notifyDataChange(vm.id);
686
743
  }, 'file');
687
744
  })}"
688
- >
689
- 上傳新圖片
690
- </div>
691
- </div>
692
- </div>
693
- `;
745
+ >
746
+ 上傳新圖片
747
+ </div>
748
+ </div>
749
+ </div>
750
+ `;
694
751
  }, 'add');
695
752
  }))}
696
- </div>
697
- <div class="">
698
- ${gvc.bindView({
753
+ </div>
754
+ <div class="">
755
+ ${gvc.bindView({
699
756
  bind: `folderItemGroup`,
700
757
  view: () => {
701
758
  if (vm.tag) {
702
- return renderItems(vm.link.filter((item2) => {
759
+ return renderItems(vm.link.filter(item2 => {
703
760
  var _a;
704
761
  return item2.tag && item2.tag.includes((_a = vm.tag) !== null && _a !== void 0 ? _a : '');
705
762
  }));
@@ -708,25 +765,117 @@ export class imageLibrary {
708
765
  },
709
766
  divCreate: {},
710
767
  })}
711
- </div>
712
- `;
768
+ </div>
769
+ `;
713
770
  }
714
771
  function drawSelectImg() {
772
+ const css = String.raw;
773
+ gvc.addStyle(css `
774
+ .fixed-top-section {
775
+ display: flex;
776
+ flex-direction: column;
777
+ height: auto; /* 設定一個固定的高度 (或用 auto 讓內容決定) */
778
+ flex-shrink: 0;
779
+ padding: 15px;
780
+ box-sizing: border-box; /* padding 不影響宣告的高度 */
781
+ width: 100%;
782
+ gap: 20px;
783
+ position: sticky;
784
+ background: #fff;
785
+ left: 0;
786
+ top: 0;
787
+ z-index: 2;
788
+ }
789
+
790
+ .scrollable-bottom-section {
791
+ flex-grow: 1; /* 重要:讓此區塊佔滿所有剩餘的垂直空間 */
792
+ overflow-y: auto; /* 關鍵:當內容垂直溢出時,只在此區塊顯示垂直滾動條 */
793
+ width: 100%;
794
+ padding: 15px;
795
+ box-sizing: border-box;
796
+ gap: 20px;
797
+ }
798
+
799
+ .${ids.classPrefix}-content {
800
+ left: 0;
801
+ top: 0;
802
+ position: relative;
803
+ }
804
+
805
+ .${ids.classPrefix}-select-bar {
806
+ height: 40px;
807
+ padding: 12px 18px;
808
+ background: #f7f7f7;
809
+ border-radius: 10px;
810
+ justify-content: flex-end;
811
+ align-items: center;
812
+ gap: 8px;
813
+ display: ${cf.mul ? `inline-flex` : `none`};
814
+ }
815
+
816
+ .${ids.classPrefix}-new-album-title-bar {
817
+ font-size: 16px;
818
+ font-style: normal;
819
+ font-weight: 400;
820
+ gap: 8px;
821
+ padding-top: 12px;
822
+ }
823
+
824
+ .${ids.classPrefix}-new-album-title-bar input {
825
+ height: 40px;
826
+ padding: 9px 18px;
827
+ border-radius: 10px;
828
+ border: 1px solid #ddd;
829
+ }
830
+
831
+ .${ids.classPrefix}-new-album-add-block {
832
+ margin-top: 18px;
833
+ padding: 39px 0;
834
+ display: flex;
835
+ justify-content: center;
836
+ align-items: center;
837
+ border-radius: 10px;
838
+ border: 1px solid #ddd;
839
+ background: #fff;
840
+ gap: 14px;
841
+ }
842
+
843
+ .${ids.classPrefix}-new-album-add-block .btn1 {
844
+ padding: 10px 18px;
845
+ border-radius: 10px;
846
+ border: 1px solid #ddd;
847
+ background: #fff;
848
+ box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
849
+ cursor: pointer;
850
+ }
851
+
852
+ .${ids.classPrefix}-album-title {
853
+ font-size: 16px;
854
+ font-style: normal;
855
+ font-weight: 400;
856
+ gap: 8px;
857
+ padding-top: 12px;
858
+ }
859
+
860
+ .${ids.classPrefix}-album-title input {
861
+ height: 40px;
862
+ padding: 9px 18px;
863
+ border-radius: 10px;
864
+ border: 1px solid #ddd;
865
+ }
866
+ `);
715
867
  return html `
716
- <div style="">
717
- <div style="width: 100%; position: relative">
718
- <div
719
- style="width: 100%; left: 0; top: 0; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 20px; display: inline-flex"
720
- >
721
- <div class=" ${cf.key == 'album' ? `d-none` : `d-flex`}"
722
- style="gap:14px;">${pageBTN()}
723
- </div>
724
- <div class="d-flex w-100" style="gap:14px;">
725
- ${BgWidget.searchFilter(gvc.event((e) => {
868
+ <div
869
+ class="w-100 d-inline-flex flex-column justify-content-start align-items-start ${gClass('content')}"
870
+ >
871
+ <div class="fixed-top-section">
872
+ <div class=" ${cf.key == 'album' ? `d-none` : `d-flex`}" style="gap:14px;">${pageBTN()}</div>
873
+ <div class="d-flex w-100" style="gap:14px;">
874
+ ${BgWidget.searchFilter(gvc.event(e => {
726
875
  vm.query = e.value;
727
876
  gvc.notifyDataChange(vm.id);
728
877
  }), vm.query || '', cf.key == 'album-manager' || vm.type == 'file' ? `搜尋圖片` : `搜尋相簿`)}
729
- ${BgWidget.updownFilter({
878
+ ${BgWidget.updownFilter({
730
879
  gvc,
731
880
  callback: (value) => {
732
881
  vm.orderString = value;
@@ -735,57 +884,72 @@ export class imageLibrary {
735
884
  default: vm.orderString || 'default',
736
885
  options: FilterOptions.imageLibraryOrderBy,
737
886
  })}
738
- </div>
739
- <div
740
- class="w-100 ${getSelectCount({
887
+ </div>
888
+ </div>
889
+ <div class="scrollable-bottom-section d-flex flex-column">
890
+ <div
891
+ class="w-100 ${gClass('select-bar')} ${getSelectCount({
741
892
  items: vm.link,
742
893
  }) > 0 && vm.type == 'file'
743
894
  ? ``
744
895
  : `d-none`}"
745
- style="height: 40px; padding: 12px 18px;background: #F7F7F7; border-radius: 10px; justify-content: flex-end; align-items: center; gap: 8px; display: inline-flex"
746
- >
747
- <div style="flex: 1 1 0; color: #393939; font-size: 14px; font-family: Noto Sans; font-weight: 700; word-wrap: break-word">
748
- 已選取${getSelectCount({
896
+ >
897
+ <div
898
+ style="flex: 1 1 0; color: #393939; font-size: 14px; font-family: Noto Sans; font-weight: 700; word-wrap: break-word"
899
+ >
900
+ 已選取${getSelectCount({
749
901
  items: vm.link,
750
902
  })}項
751
- </div>
752
- </div>
753
- <div style="align-self: stretch; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 18px; display: flex">
754
- ${(() => {
755
- let viewData = vm.link.filter((data) => {
903
+ </div>
904
+ </div>
905
+ <div
906
+ style="align-self: stretch; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 18px; display: flex"
907
+ >
908
+ ${(() => {
909
+ let viewData = vm.link.filter(data => {
756
910
  return data.type == vm.type;
757
911
  });
758
912
  if (viewData.length == 0) {
759
913
  return html `
760
- <div class="w-100 h-100 d-flex flex-column align-items-center justify-content-center"
761
- style="padding-top: 106px;">
762
- ${vm.type == 'file'
763
- ? html `
764
- <svg xmlns="http://www.w3.org/2000/svg"
765
- width="80" height="80"
766
- viewBox="0 0 80 80" fill="none">
767
- <path
768
- d="M10 10C7.23438 10 5 12.2344 5 15V51.4688L15.5781 40.8906C18.0156 38.4531 21.9688 38.4531 24.4219 40.8906L35 51.4688L55.5781 30.8906C58.0156 28.4531 61.9688 28.4531 64.4219 30.8906L75 41.4688V15C75 12.2344 72.7656 10 70 10H10ZM5 58.5312V65C5 67.7656 7.23438 70 10 70H16.4688L31.4688 55L20.8906 44.4219C20.4062 43.9375 19.6094 43.9375 19.125 44.4219L5 58.5312ZM60.8906 34.4219C60.4063 33.9375 59.6094 33.9375 59.125 34.4219L23.5312 70H70C72.7656 70 75 67.7656 75 65V48.5312L60.8906 34.4219ZM0 15C0 9.48438 4.48438 5 10 5H70C75.5156 5 80 9.48438 80 15V65C80 70.5156 75.5156 75 70 75H10C4.48438 75 0 70.5156 0 65V15ZM25 22.5C25 21.837 24.7366 21.2011 24.2678 20.7322C23.7989 20.2634 23.163 20 22.5 20C21.837 20 21.2011 20.2634 20.7322 20.7322C20.2634 21.2011 20 21.837 20 22.5C20 23.163 20.2634 23.7989 20.7322 24.2678C21.2011 24.7366 21.837 25 22.5 25C23.163 25 23.7989 24.7366 24.2678 24.2678C24.7366 23.7989 25 23.163 25 22.5ZM15 22.5C15 20.5109 15.7902 18.6032 17.1967 17.1967C18.6032 15.7902 20.5109 15 22.5 15C24.4891 15 26.3968 15.7902 27.8033 17.1967C29.2098 18.6032 30 20.5109 30 22.5C30 24.4891 29.2098 26.3968 27.8033 27.8033C26.3968 29.2098 24.4891 30 22.5 30C20.5109 30 18.6032 29.2098 17.1967 27.8033C15.7902 26.3968 15 24.4891 15 22.5Z"
769
- fill="#393939"
770
- />
771
- </svg>`
772
- : html `
773
- <svg xmlns="http://www.w3.org/2000/svg"
774
- width="80" height="80"
775
- viewBox="0 0 80 80" fill="none">
776
- <path
777
- d="M10 10C7.23438 10 5 12.2344 5 15V65C5 67.7656 7.23438 70 10 70H70C72.7656 70 75 67.7656 75 65V25C75 22.2344 72.7656 20 70 20H45.6094C42.9531 20 40.4062 18.9531 38.5312 17.0781L32.9219 11.4688C31.9844 10.5312 30.7188 10 29.3906 10H10ZM0 15C0 9.48438 4.48438 5 10 5H29.3906C32.0469 5 34.5938 6.04688 36.4688 7.92188L42.0781 13.5312C43.0156 14.4688 44.2812 15 45.6094 15H70C75.5156 15 80 19.4844 80 25V65C80 70.5156 75.5156 75 70 75H10C4.48438 75 0 70.5156 0 65V15Z"
778
- fill="#393939"
779
- />
780
- </svg>`}
781
- <div style="color: #8D8D8D;font-size: 18px;font-weight: 400;margin-top: 12px;margin-bottom: 24px;">
782
- ${vm.type == 'file' ? `尚未上傳任何圖片` : `尚未建立任何相簿`}
783
- </div>
784
- <div
785
- style="color: #FFF;font-weight: 700;font-size: 16px;padding: 6px 18px;border-radius: 10px;background: #393939;cursor: pointer;"
786
- onclick="${gvc.event(() => {
914
+ <div
915
+ class="w-100 h-100 d-flex flex-column align-items-center justify-content-center"
916
+ style="padding-top: 106px;"
917
+ >
918
+ ${vm.type == 'file'
919
+ ? html ` <svg
920
+ xmlns="http://www.w3.org/2000/svg"
921
+ width="80"
922
+ height="80"
923
+ viewBox="0 0 80 80"
924
+ fill="none"
925
+ >
926
+ <path
927
+ d="M10 10C7.23438 10 5 12.2344 5 15V51.4688L15.5781 40.8906C18.0156 38.4531 21.9688 38.4531 24.4219 40.8906L35 51.4688L55.5781 30.8906C58.0156 28.4531 61.9688 28.4531 64.4219 30.8906L75 41.4688V15C75 12.2344 72.7656 10 70 10H10ZM5 58.5312V65C5 67.7656 7.23438 70 10 70H16.4688L31.4688 55L20.8906 44.4219C20.4062 43.9375 19.6094 43.9375 19.125 44.4219L5 58.5312ZM60.8906 34.4219C60.4063 33.9375 59.6094 33.9375 59.125 34.4219L23.5312 70H70C72.7656 70 75 67.7656 75 65V48.5312L60.8906 34.4219ZM0 15C0 9.48438 4.48438 5 10 5H70C75.5156 5 80 9.48438 80 15V65C80 70.5156 75.5156 75 70 75H10C4.48438 75 0 70.5156 0 65V15ZM25 22.5C25 21.837 24.7366 21.2011 24.2678 20.7322C23.7989 20.2634 23.163 20 22.5 20C21.837 20 21.2011 20.2634 20.7322 20.7322C20.2634 21.2011 20 21.837 20 22.5C20 23.163 20.2634 23.7989 20.7322 24.2678C21.2011 24.7366 21.837 25 22.5 25C23.163 25 23.7989 24.7366 24.2678 24.2678C24.7366 23.7989 25 23.163 25 22.5ZM15 22.5C15 20.5109 15.7902 18.6032 17.1967 17.1967C18.6032 15.7902 20.5109 15 22.5 15C24.4891 15 26.3968 15.7902 27.8033 17.1967C29.2098 18.6032 30 20.5109 30 22.5C30 24.4891 29.2098 26.3968 27.8033 27.8033C26.3968 29.2098 24.4891 30 22.5 30C20.5109 30 18.6032 29.2098 17.1967 27.8033C15.7902 26.3968 15 24.4891 15 22.5Z"
928
+ fill="#393939"
929
+ />
930
+ </svg>`
931
+ : html ` <svg
932
+ xmlns="http://www.w3.org/2000/svg"
933
+ width="80"
934
+ height="80"
935
+ viewBox="0 0 80 80"
936
+ fill="none"
937
+ >
938
+ <path
939
+ d="M10 10C7.23438 10 5 12.2344 5 15V65C5 67.7656 7.23438 70 10 70H70C72.7656 70 75 67.7656 75 65V25C75 22.2344 72.7656 20 70 20H45.6094C42.9531 20 40.4062 18.9531 38.5312 17.0781L32.9219 11.4688C31.9844 10.5312 30.7188 10 29.3906 10H10ZM0 15C0 9.48438 4.48438 5 10 5H29.3906C32.0469 5 34.5938 6.04688 36.4688 7.92188L42.0781 13.5312C43.0156 14.4688 44.2812 15 45.6094 15H70C75.5156 15 80 19.4844 80 25V65C80 70.5156 75.5156 75 70 75H10C4.48438 75 0 70.5156 0 65V15Z"
940
+ fill="#393939"
941
+ />
942
+ </svg>`}
943
+ <div
944
+ style="color: #8D8D8D;font-size: 18px;font-weight: 400;margin-top: 12px;margin-bottom: 24px;"
945
+ >
946
+ ${vm.type == 'file' ? `尚未上傳任何圖片` : `尚未建立任何相簿`}
947
+ </div>
948
+ <div
949
+ style="color: #FFF;font-weight: 700;font-size: 16px;padding: 6px 18px;border-radius: 10px;background: #393939;cursor: pointer;"
950
+ onclick="${gvc.event(() => {
787
951
  if (vm.type == 'file') {
788
- cf.plus(gvc, (file) => {
952
+ cf.plus(gvc, file => {
789
953
  vm.link.push(...file);
790
954
  save(() => {
791
955
  gvc.notifyDataChange(vm.id);
@@ -798,22 +962,24 @@ export class imageLibrary {
798
962
  gvc.notifyDataChange(vm.id);
799
963
  }
800
964
  })}"
801
- >
802
- ${vm.type == 'file' ? `上傳圖片` : `建立相簿`}
803
- </div>
804
- </div>
805
- `;
965
+ >
966
+ ${vm.type == 'file' ? `上傳圖片` : `建立相簿`}
967
+ </div>
968
+ </div>
969
+ `;
806
970
  }
807
971
  return html `
808
- <div
809
- class="w-100 ${cf.key == 'album' ? `d-none` : `d-flex`} align-items-center justify-content-center"
810
- style="padding: 39px 0;border-radius: 10px;border: 1px solid #DDD;background: #FFF;"
811
- >
812
- <div
813
- style="padding:6px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);font-size: 16px;font-weight: 400;cursor:pointer;"
814
- onclick="${gvc.event(() => {
972
+ <div
973
+ class="w-100 ${cf.key == 'album'
974
+ ? `d-none`
975
+ : `d-flex`} align-items-center justify-content-center"
976
+ style="padding: 39px 0;border-radius: 10px;border: 1px solid #DDD;background: #FFF;"
977
+ >
978
+ <div
979
+ style="padding:6px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);font-size: 16px;font-weight: 400;cursor:pointer;"
980
+ onclick="${gvc.event(() => {
815
981
  if (vm.type == 'file') {
816
- cf.plus(gvc, (file) => {
982
+ cf.plus(gvc, file => {
817
983
  vm.link.push(...file);
818
984
  save(() => {
819
985
  gvc.notifyDataChange(vm.id);
@@ -826,18 +992,17 @@ export class imageLibrary {
826
992
  gvc.notifyDataChange(vm.id);
827
993
  }
828
994
  })}"
829
- >
830
- ${vm.type == 'file' ? '上傳新照片' : '上傳相簿'}
831
- </div>
832
- </div>
833
- ${renderItems(viewData)}
834
- `;
995
+ >
996
+ ${vm.type == 'file' ? '上傳新照片' : '新增相簿'}
997
+ </div>
998
+ </div>
999
+ ${renderItems(viewData)}
1000
+ `;
835
1001
  })()}
836
- </div>
837
- </div>
838
- </div>
839
- </div>
840
- `;
1002
+ </div>
1003
+ </div>
1004
+ </div>
1005
+ `;
841
1006
  }
842
1007
  if (vm.loading) {
843
1008
  dialog.dataLoading({
@@ -851,6 +1016,7 @@ export class imageLibrary {
851
1016
  return drawSelectImg();
852
1017
  }),
853
1018
  divCreate: {
1019
+ class: `w-100 h-100`,
854
1020
  style: ``,
855
1021
  },
856
1022
  };
@@ -859,7 +1025,7 @@ export class imageLibrary {
859
1025
  footer_html: (gvc) => {
860
1026
  const dialog = new ShareDialog(cf.gvc.glitter);
861
1027
  function clearNoNeedData(items) {
862
- items.map((dd) => {
1028
+ items.map(dd => {
863
1029
  if (dd.selected) {
864
1030
  dd.selected = undefined;
865
1031
  }
@@ -873,109 +1039,173 @@ export class imageLibrary {
873
1039
  key: 'image-manager',
874
1040
  value: vm.link,
875
1041
  user_id: 'manager',
876
- }).then((data) => {
1042
+ }).then(data => {
877
1043
  dialog.dataLoading({ visible: false });
878
1044
  dialog.successMessage({ text: text !== null && text !== void 0 ? text : '儲存成功' });
1045
+ changeWindowsName('圖片庫');
879
1046
  finish();
880
1047
  });
881
1048
  }
882
- switch (cf.key) {
883
- case 'folderEdit': {
884
- return [
885
- BgWidget.cancel(gvc.event(() => {
1049
+ function getFolderEditButtons(gvc, save) {
1050
+ return [
1051
+ {
1052
+ type: 'cancel',
1053
+ label: '返回',
1054
+ onClick: () => {
886
1055
  if (cf.cancelEvent) {
1056
+ changeWindowsName('圖片庫');
887
1057
  cf.cancelEvent();
888
1058
  }
889
1059
  gvc.closeDialog();
890
- })),
891
- BgWidget.danger(gvc.event(() => {
892
- const dialog = new ShareDialog(gvc.glitter);
893
- dialog.checkYesOrNot({
894
- text: `刪除後使用此資源的內容將被取消關聯,是否確認刪除?`,
895
- callback: (response) => {
896
- if (response) {
897
- let selectedData = vm.link.filter((item) => { var _a, _b; return (item === null || item === void 0 ? void 0 : item.tag) && ((_a = item === null || item === void 0 ? void 0 : item.tag) === null || _a === void 0 ? void 0 : _a.includes((_b = vm.tag) !== null && _b !== void 0 ? _b : '')); });
898
- selectedData.forEach((item) => {
1060
+ },
1061
+ },
1062
+ {
1063
+ type: 'danger',
1064
+ label: '刪除相簿',
1065
+ onClick: () => {
1066
+ new ShareDialog(gvc.glitter).checkYesOrNot({
1067
+ text: `您確定要永久刪除此資料夾嗎?刪除後將取消這些照片間的關聯。`,
1068
+ callback: yes => {
1069
+ if (!yes)
1070
+ return;
1071
+ vm.link.forEach(item => {
1072
+ var _a;
1073
+ if ((_a = item.tag) === null || _a === void 0 ? void 0 : _a.includes(vm.tag)) {
899
1074
  item.selected = false;
900
- item.tag = item.tag.filter((tag) => {
901
- return tag !== vm.tag;
902
- });
903
- });
904
- let folder = vm.link.findIndex((dd) => {
905
- return dd.title == vm.tag && dd.type == 'folder';
906
- });
907
- vm.link.splice(folder, 1);
908
- cf.getSelect(vm.link);
909
- save(() => {
910
- gvc.closeDialog();
911
- }, '刪除成功');
912
- }
1075
+ item.tag = item.tag.filter(t => t !== vm.tag);
1076
+ }
1077
+ });
1078
+ const idx = vm.link.findIndex(d => d.title === vm.tag && d.type === 'folder');
1079
+ vm.link.splice(idx, 1);
1080
+ cf.getSelect(vm.link);
1081
+ save(() => {
1082
+ changeWindowsName('圖片庫');
1083
+ gvc.closeDialog();
1084
+ }, '刪除成功');
913
1085
  },
914
1086
  });
915
- }), '刪除相簿'),
916
- BgWidget.save(gvc.event(() => {
1087
+ },
1088
+ },
1089
+ {
1090
+ type: 'save',
1091
+ label: '確定變更',
1092
+ onClick: () => {
917
1093
  cf.getSelect(vm.link);
918
- save(() => {
919
- gvc.closeDialog();
920
- });
921
- }), '確定變更'),
922
- ].join('');
923
- }
924
- default: {
925
- let finishBTN = cf.key == 'album' ? '建立' : '完成';
926
- return [
927
- BgWidget.cancel(gvc.event(() => {
928
- if (cf.cancelEvent) {
1094
+ save(() => gvc.closeDialog());
1095
+ },
1096
+ },
1097
+ ];
1098
+ }
1099
+ function getDefaultButtons(gvc, save, dialog) {
1100
+ const finishLabel = cf.key === 'album' ? '建立' : '完成';
1101
+ const cancelLabel = cf.key === 'album' ? '返回' : '取消';
1102
+ return [
1103
+ {
1104
+ type: 'cancel',
1105
+ label: cancelLabel,
1106
+ onClick: () => {
1107
+ if (cf.cancelEvent)
929
1108
  cf.cancelEvent();
930
- }
931
- if (vm.type == 'folderView' || vm.type == 'folderADD') {
1109
+ if (vm.type === 'folderView' || vm.type === 'folderADD') {
1110
+ closeFolderView();
932
1111
  vm.type = 'folder';
933
1112
  gvc.notifyDataChange(vm.id);
934
1113
  }
935
1114
  else {
936
1115
  gvc.closeDialog();
937
1116
  }
938
- })),
939
- BgWidget.save(gvc.event(() => {
940
- let select = [];
941
- function loop(array) {
942
- array.map((dd) => {
943
- if (dd.type === 'folder') {
944
- loop(dd.items || []);
945
- }
946
- else {
947
- if (dd.selected) {
948
- select.push(dd);
949
- }
1117
+ },
1118
+ },
1119
+ {
1120
+ type: 'edit',
1121
+ label: '編輯',
1122
+ onClick: () => {
1123
+ vm.type = 'folderViewToEdit';
1124
+ gvc.notifyDataChange(vm.id);
1125
+ },
1126
+ },
1127
+ {
1128
+ type: 'save',
1129
+ label: finishLabel,
1130
+ onClick: () => {
1131
+ const selected = [];
1132
+ (function walk(arr) {
1133
+ arr.forEach(d => {
1134
+ if (d.type === 'folder')
1135
+ walk(d.items || []);
1136
+ else if (d.selected)
1137
+ selected.push(d);
1138
+ });
1139
+ })(vm.link);
1140
+ if (vm.type === 'folderADD') {
1141
+ if (!vm.tag) {
1142
+ dialog.infoMessage({ text: '相簿尚未命名' });
1143
+ return;
1144
+ }
1145
+ vm.newFolder.title = vm.tag;
1146
+ vm.newFolder.data.forEach((data) => {
1147
+ var _a;
1148
+ const findImage = vm.link.find(image => image.id === data.id);
1149
+ if (findImage) {
1150
+ findImage.tag.push((_a = vm.tag) !== null && _a !== void 0 ? _a : '');
950
1151
  }
951
1152
  });
952
- }
953
- loop(vm.link);
954
- if (cf.key == 'album') {
955
- dialog.successMessage({
956
- text: '相簿建立成功',
1153
+ vm.newFolder.data = [];
1154
+ vm.link.push(vm.newFolder);
1155
+ save(() => {
1156
+ vm.type = 'folder';
1157
+ gvc.notifyDataChange(vm.id);
957
1158
  });
1159
+ return;
958
1160
  }
959
- if (cf.key == 'image-manager' || cf.key == 'folderEdit') {
960
- if (select.length > 0 || cf.edit_only) {
1161
+ if (cf.key === 'album') {
1162
+ dialog.successMessage({ text: '相簿建立成功' });
1163
+ cf.getSelect(selected);
1164
+ gvc.closeDialog();
1165
+ return;
1166
+ }
1167
+ if (['image-manager', 'folderEdit'].includes(cf.key)) {
1168
+ if (selected.length || cf.edit_only) {
961
1169
  save(() => {
962
- cf.getSelect(select);
1170
+ cf.getSelect(selected);
963
1171
  gvc.closeDialog();
964
1172
  });
965
1173
  }
966
1174
  else {
967
- const dialog = new ShareDialog(gvc.glitter);
968
1175
  dialog.errorMessage({ text: '請選擇至少一張圖片' });
969
1176
  }
970
1177
  }
971
1178
  else {
972
- cf.getSelect(select);
1179
+ cf.getSelect(selected);
973
1180
  gvc.closeDialog();
974
1181
  }
975
- }), finishBTN),
976
- ].join('');
977
- }
1182
+ },
1183
+ },
1184
+ ];
978
1185
  }
1186
+ const defs = vm.type === 'folderEdit' ? getFolderEditButtons(gvc, save) : getDefaultButtons(gvc, save, dialog);
1187
+ return gvc.bindView({
1188
+ bind: vm.footer_id,
1189
+ view: () => {
1190
+ return defs
1191
+ .map(d => {
1192
+ const widget = (d.type === 'cancel' || d.type === 'edit') ? BgWidget.cancel : d.type === 'danger' ? BgWidget.danger : BgWidget.save;
1193
+ if (d.type == 'edit') {
1194
+ if (vm.type == 'folderView') {
1195
+ return widget(gvc.event(d.onClick), d.label);
1196
+ }
1197
+ return '';
1198
+ }
1199
+ else {
1200
+ return widget(gvc.event(d.onClick), d.label);
1201
+ }
1202
+ })
1203
+ .join('');
1204
+ }, divCreate: {
1205
+ class: 'w-100 d-flex align-items-center justify-content-end',
1206
+ style: 'gap:14px'
1207
+ }
1208
+ });
979
1209
  },
980
1210
  closeCallback: () => {
981
1211
  if (cf.cancelEvent) {
@@ -997,21 +1227,25 @@ export class imageLibrary {
997
1227
  title: cf.title,
998
1228
  innerHTML: (gvc) => {
999
1229
  let editArray = [];
1000
- imageArray.forEach((item) => {
1230
+ imageArray.forEach(item => {
1001
1231
  editArray.push(false);
1002
1232
  });
1003
1233
  return html `
1004
- <div class="w-100 d-flex flex-column">
1005
- <div style="font-size: 13px;">您只能選擇圖片當作子類媒體</div>
1006
- <div class="d-flex flex-wrap w-100" style="gap: 0.5rem;margin-top:1rem;">
1007
- ${gvc.bindView({
1008
- bind: "imageArray",
1234
+ <div class="w-100 d-flex flex-column">
1235
+ <div style="font-size: 13px;">您只能選擇圖片當作子類媒體</div>
1236
+ <div class="d-flex flex-wrap w-100" style="gap: 0.5rem;margin-top:1rem;">
1237
+ ${gvc.bindView({
1238
+ bind: 'imageArray',
1009
1239
  view: () => {
1010
1240
  const isSafari = (() => {
1011
1241
  const userAgent = navigator.userAgent.toLowerCase();
1012
1242
  return userAgent.includes('safari') && !userAgent.includes('chrome') && !userAgent.includes('edg');
1013
1243
  })();
1014
- return [html `<div class="col-2 d-flex align-items-center justify-content-center " style="border-radius:10px;cursor: pointer;border:1px solid #DDD;" onclick="${gvc.event(() => {
1244
+ return [
1245
+ html ` <div
1246
+ class="col-2 d-flex align-items-center justify-content-center "
1247
+ style="border-radius:10px;cursor: pointer;border:1px solid #DDD;"
1248
+ onclick="${gvc.event(() => {
1015
1249
  EditorElem.uploadFileFunction({
1016
1250
  gvc: gvc,
1017
1251
  callback: (text) => {
@@ -1026,7 +1260,7 @@ export class imageLibrary {
1026
1260
  };
1027
1261
  const dialog = new ShareDialog(gvc.glitter);
1028
1262
  dialog.dataLoading({
1029
- visible: true
1263
+ visible: true,
1030
1264
  });
1031
1265
  function getPublicConfig(callback) {
1032
1266
  ApiUser.getPublicConfig('image-manager', 'manager').then((data) => {
@@ -1034,7 +1268,7 @@ export class imageLibrary {
1034
1268
  allData = data.response.value;
1035
1269
  function loop(array) {
1036
1270
  if (array.length > 0) {
1037
- array.map((dd) => {
1271
+ array.map(dd => {
1038
1272
  var _a;
1039
1273
  if (dd.type === 'folder') {
1040
1274
  loop((_a = dd.items) !== null && _a !== void 0 ? _a : []);
@@ -1056,10 +1290,10 @@ export class imageLibrary {
1056
1290
  key: 'image-manager',
1057
1291
  value: allData,
1058
1292
  user_id: 'manager',
1059
- }).then((data) => {
1293
+ }).then(data => {
1060
1294
  imageArray.push(text[0]);
1061
1295
  dialog.dataLoading({
1062
- visible: false
1296
+ visible: false,
1063
1297
  });
1064
1298
  gvc.notifyDataChange('imageArray');
1065
1299
  });
@@ -1068,33 +1302,42 @@ export class imageLibrary {
1068
1302
  return_array: true,
1069
1303
  multiple: true,
1070
1304
  });
1071
- })}">
1072
- <div style="padding:6px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);font-size: 16px;font-weight: 400;cursor:pointer;">新增圖片</div>
1073
- </div>`,
1074
- imageArray.map((image, index) => {
1305
+ })}"
1306
+ >
1307
+ <div
1308
+ style="padding:6px 18px;border-radius: 10px;border: 1px solid #DDD;background: #FFF;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);font-size: 16px;font-weight: 400;cursor:pointer;"
1309
+ >
1310
+ 新增圖片
1311
+ </div>
1312
+ </div>`,
1313
+ imageArray
1314
+ .map((image, index) => {
1075
1315
  return html `
1076
- <div class="col-2 position-relative imageHover" style="padding: 10px 12px;position: relative;${selected == index
1316
+ <div
1317
+ class="col-2 position-relative imageHover"
1318
+ style="padding: 10px 12px;position: relative;${selected == index
1077
1319
  ? `border-radius: 10px;border: 2px solid #393939;background: #F7F7F7;box-shadow: 3px 3px 10px 0px rgba(0, 0, 0, 0.10);`
1078
1320
  : editArray[index]
1079
1321
  ? `border-radius: 10px;border: 1px solid #DDD;background: #F7F7F7;`
1080
- : ``}" onclick="${gvc.event(() => {
1322
+ : ``}"
1323
+ onclick="${gvc.event(() => {
1081
1324
  selected = index;
1082
- gvc.notifyDataChange("imageArray");
1325
+ gvc.notifyDataChange('imageArray');
1083
1326
  })}"
1084
- onmouseenter="${gvc.event(() => {
1327
+ onmouseenter="${gvc.event(() => {
1085
1328
  if (!editArray[index]) {
1086
1329
  editArray[index] = true;
1087
1330
  gvc.notifyDataChange('imageArray');
1088
1331
  }
1089
1332
  })}"
1090
- onmouseleave="${gvc.event((e, event) => {
1333
+ onmouseleave="${gvc.event((e, event) => {
1091
1334
  if (isSafari) {
1092
1335
  const imageBoxClass = Tool.randomString(5);
1093
1336
  const target = event.relatedTarget;
1094
1337
  const imageBoxClassList = [imageBoxClass];
1095
1338
  const targetClassList = Array.from(target.classList);
1096
- const isOutBorder = imageBoxClassList.every((cls) => targetClassList.includes(cls)) &&
1097
- targetClassList.every((cls) => imageBoxClassList.includes(cls));
1339
+ const isOutBorder = imageBoxClassList.every(cls => targetClassList.includes(cls)) &&
1340
+ targetClassList.every(cls => imageBoxClassList.includes(cls));
1098
1341
  const isTitle = targetClassList.includes(`${imageBoxClass}-title`);
1099
1342
  const isInside = targetClassList.length === 0;
1100
1343
  const isOutOfViewContainer = target.dataset.viewContainer === 'true';
@@ -1106,18 +1349,22 @@ export class imageLibrary {
1106
1349
  editArray[index] = false;
1107
1350
  gvc.notifyDataChange('imageArray');
1108
1351
  })}"
1109
- >
1110
- <div class="w-100"
1111
- style="background: url('${image}') 50%/cover;padding-bottom:100%;border-radius: 10px;"></div>
1112
- </div>
1113
- `;
1114
- }).join(``)
1352
+ >
1353
+ <div
1354
+ class="w-100"
1355
+ style="background: url('${image}') 50%/cover;padding-bottom:100%;border-radius: 10px;"
1356
+ ></div>
1357
+ </div>
1358
+ `;
1359
+ })
1360
+ .join(``),
1115
1361
  ].join(``);
1116
- }, divCreate: { class: `d-flex flex-wrap w-100`, style: `gap: 0.5rem;margin-top:1rem;` }
1362
+ },
1363
+ divCreate: { class: `d-flex flex-wrap w-100`, style: `gap: 0.5rem;margin-top:1rem;` },
1117
1364
  })}
1118
- </div>
1119
- </div>
1120
- `;
1365
+ </div>
1366
+ </div>
1367
+ `;
1121
1368
  },
1122
1369
  footer_html: (gvc) => {
1123
1370
  const dialog = new ShareDialog(cf.gvc.glitter);
@@ -1137,8 +1384,7 @@ export class imageLibrary {
1137
1384
  var _a, _b, _c;
1138
1385
  return __awaiter(this, void 0, void 0, function* () {
1139
1386
  let alt = '';
1140
- let saveAlt = function () {
1141
- };
1387
+ let saveAlt = function () { };
1142
1388
  function editorView(gvc, item) {
1143
1389
  var _a, _b;
1144
1390
  if (item.type === 'folder') {
@@ -1147,7 +1393,7 @@ export class imageLibrary {
1147
1393
  title: `資料夾標題`,
1148
1394
  default: item.title,
1149
1395
  placeHolder: `請輸入資料夾標題`,
1150
- callback: (text) => {
1396
+ callback: text => {
1151
1397
  item.title = text;
1152
1398
  },
1153
1399
  });
@@ -1160,7 +1406,7 @@ export class imageLibrary {
1160
1406
  title: `圖片標題`,
1161
1407
  default: item.title,
1162
1408
  placeHolder: `請輸入圖片標題`,
1163
- callback: (text) => {
1409
+ callback: text => {
1164
1410
  item.title = text;
1165
1411
  },
1166
1412
  }),
@@ -1168,7 +1414,7 @@ export class imageLibrary {
1168
1414
  gvc: gvc,
1169
1415
  title: `圖片資源`,
1170
1416
  def: (_b = item.data) !== null && _b !== void 0 ? _b : '',
1171
- callback: (text) => {
1417
+ callback: text => {
1172
1418
  item.data = text;
1173
1419
  },
1174
1420
  }),
@@ -1191,7 +1437,7 @@ export class imageLibrary {
1191
1437
  title: `ALT描述`,
1192
1438
  default: alt.alt,
1193
1439
  placeHolder: `請輸入ALT描述`,
1194
- callback: (text) => {
1440
+ callback: text => {
1195
1441
  alt.alt = text;
1196
1442
  },
1197
1443
  });
@@ -1205,12 +1451,13 @@ export class imageLibrary {
1205
1451
  getSelect: callback,
1206
1452
  edit_only: edit_only,
1207
1453
  gvc: gvc,
1208
- key: opt ? (_a = opt.key) !== null && _a !== void 0 ? _a : 'image-manager' : 'image-manager',
1454
+ key: opt ? ((_a = opt.key) !== null && _a !== void 0 ? _a : 'image-manager') : 'image-manager',
1209
1455
  title: title,
1210
1456
  tag: (_b = opt === null || opt === void 0 ? void 0 : opt.tag) !== null && _b !== void 0 ? _b : '',
1211
- mul: opt ? (_c = opt.mul) !== null && _c !== void 0 ? _c : false : false,
1457
+ mul: opt ? ((_c = opt.mul) !== null && _c !== void 0 ? _c : false) : false,
1212
1458
  plus: (gvc, callback) => {
1213
1459
  const item = {
1460
+ selected: false,
1214
1461
  title: '',
1215
1462
  data: {},
1216
1463
  items: [],
@@ -1224,7 +1471,7 @@ export class imageLibrary {
1224
1471
  callback: (text) => {
1225
1472
  callback(text.map((item) => {
1226
1473
  return {
1227
- title: item.split('_')[3],
1474
+ title: item.split('_')[item.split('_').length - 1],
1228
1475
  data: item,
1229
1476
  items: [],
1230
1477
  type: 'file',
@@ -1237,7 +1484,7 @@ export class imageLibrary {
1237
1484
  multiple: true,
1238
1485
  });
1239
1486
  },
1240
- edit: (item, callback) => {
1487
+ edit: (item, callback, obj) => {
1241
1488
  item = JSON.parse(JSON.stringify(item));
1242
1489
  BgWidget.settingDialog({
1243
1490
  gvc: gvc,
@@ -1249,15 +1496,119 @@ export class imageLibrary {
1249
1496
  return [
1250
1497
  BgWidget.danger(gvc.event(() => {
1251
1498
  const dialog = new ShareDialog(gvc.glitter);
1252
- dialog.checkYesOrNot({
1253
- text: `刪除後使用此資源的內容將被取消關聯,是否確認刪除?`,
1254
- callback: (response) => {
1255
- if (response) {
1256
- callback(undefined);
1257
- gvc.closeDialog();
1258
- }
1259
- },
1260
- });
1499
+ function deleteImage() {
1500
+ dialog.checkYesOrNotWithCustomWidth({
1501
+ width: '432',
1502
+ text: '刪除此圖片後,所有使用它的頁面與商品將無法顯示。<br>是否確定?',
1503
+ icon: '<i class="fa-solid fa-info"></i>',
1504
+ callback: response => {
1505
+ if (response) {
1506
+ callback(undefined);
1507
+ gvc.closeDialog();
1508
+ }
1509
+ },
1510
+ });
1511
+ }
1512
+ function deleteAlbumTag() {
1513
+ item.tag = item.tag.filter(t => t !== (obj === null || obj === void 0 ? void 0 : obj.tag));
1514
+ callback(item);
1515
+ gvc.closeDialog();
1516
+ }
1517
+ switch (obj === null || obj === void 0 ? void 0 : obj.deleteStyle) {
1518
+ case 1: {
1519
+ gvc.glitter.innerDialog(() => {
1520
+ const prefixClass = 'deleteWindows';
1521
+ function closeThisDialog() {
1522
+ gvc.glitter.closeDiaLog('deleteWindows');
1523
+ }
1524
+ function gClass(className) {
1525
+ return prefixClass + '-' + className;
1526
+ }
1527
+ gvc.addStyle(css `
1528
+ .${prefixClass}-window {
1529
+ width: 452px;
1530
+ height: 281px;
1531
+ border-radius: 10px;
1532
+ background: #fff;
1533
+ position: relative;
1534
+ display: inline-flex;
1535
+ flex-direction: column;
1536
+ align-items: center;
1537
+ gap: 24px;
1538
+ padding: 36px 46px;
1539
+ }
1540
+
1541
+ .${prefixClass}-window .fa-xmark-large {
1542
+ position: absolute;
1543
+ top: 17px;
1544
+ right: 20px;
1545
+ cursor: pointer;
1546
+ }
1547
+
1548
+ .${prefixClass}-text-block {
1549
+ display: flex;
1550
+ flex-direction: column;
1551
+ align-items: center;
1552
+ gap: 8px;
1553
+ text-align: center;
1554
+ font-size: 16px;
1555
+ font-weight: 400;
1556
+ line-height: 160%; /* 25.6px */
1557
+ }
1558
+
1559
+ .${prefixClass}-text-block .button {
1560
+ display: flex;
1561
+ padding: 6px 18px;
1562
+ justify-content: center;
1563
+ align-items: center;
1564
+ gap: 8px;
1565
+ border-radius: 10px;
1566
+ border: 1px solid #ddd;
1567
+ background: #fff;
1568
+ color: #393939;
1569
+ cursor: pointer;
1570
+ }
1571
+ `);
1572
+ return html `
1573
+ <div class="${gClass('window')}">
1574
+ <i
1575
+ class="fa-regular fa-xmark-large"
1576
+ onclick="${gvc.event(() => {
1577
+ closeThisDialog();
1578
+ })}"
1579
+ ></i>
1580
+ <i class="fa-regular fa-circle-exclamation mb-1" style="font-size: 4rem;"></i>
1581
+ <div class="${gClass('text-block')}">
1582
+ <div>請選擇刪除方式:</div>
1583
+ <div
1584
+ class="button"
1585
+ onclick="${gvc.event(() => {
1586
+ deleteAlbumTag();
1587
+ closeThisDialog();
1588
+ })}"
1589
+ >
1590
+ 僅從此相簿移除
1591
+ </div>
1592
+ <div
1593
+ class="button"
1594
+ onclick="${gvc.event(() => {
1595
+ deleteImage();
1596
+ closeThisDialog();
1597
+ })}"
1598
+ >
1599
+ 從圖庫中永久刪除
1600
+ </div>
1601
+ </div>
1602
+ </div>
1603
+ `;
1604
+ }, `deleteWindows`);
1605
+ break;
1606
+ }
1607
+ default: {
1608
+ deleteImage();
1609
+ break;
1610
+ }
1611
+ }
1261
1612
  })),
1262
1613
  BgWidget.cancel(gvc.event(() => {
1263
1614
  gvc.closeDialog();
@@ -1269,8 +1620,7 @@ export class imageLibrary {
1269
1620
  }), '確定'),
1270
1621
  ].join('');
1271
1622
  },
1272
- closeCallback: () => {
1273
- },
1623
+ closeCallback: () => { },
1274
1624
  });
1275
1625
  },
1276
1626
  cancelEvent: () => {