ts-glitter 13.8.813 → 13.8.814
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/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-widget.js +1 -1
- package/lowcode/backend-manager/bg-widget.ts +1 -1
- package/lowcode/cms-plugin/shopping-product-setting.js +1 -0
- package/lowcode/cms-plugin/shopping-product-setting.ts +1 -0
- package/lowcode/glitter-base/route/user.js +7 -0
- package/lowcode/glitter-base/route/user.ts +6 -0
- package/lowcode/glitterBundle/Glitter.js +12 -3
- package/lowcode/glitterBundle/Glitter.ts +12 -3
- package/lowcode/glitterBundle/GlitterInitial.js +22 -0
- package/lowcode/glitterBundle/GlitterInitial.ts +22 -0
- package/lowcode/glitterBundle/html-component/widget.js +1 -9
- package/lowcode/glitterBundle/html-component/widget.ts +1 -12
- package/lowcode/modules/image-library.js +164 -123
- package/lowcode/modules/image-library.ts +90 -44
- package/package.json +1 -1
package/lowcode/Entry.js
CHANGED
|
@@ -70,7 +70,7 @@ export class Entry {
|
|
|
70
70
|
}
|
|
71
71
|
window.renderClock = (_a = window.renderClock) !== null && _a !== void 0 ? _a : clockF();
|
|
72
72
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
73
|
-
glitter.share.editerVersion = 'V_13.8.
|
|
73
|
+
glitter.share.editerVersion = 'V_13.8.814';
|
|
74
74
|
glitter.share.start = new Date();
|
|
75
75
|
const vm = {
|
|
76
76
|
appConfig: [],
|
package/lowcode/Entry.ts
CHANGED
|
@@ -71,7 +71,7 @@ export class Entry {
|
|
|
71
71
|
}
|
|
72
72
|
(window as any).renderClock = (window as any).renderClock ?? clockF();
|
|
73
73
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
74
|
-
glitter.share.editerVersion = 'V_13.8.
|
|
74
|
+
glitter.share.editerVersion = 'V_13.8.814';
|
|
75
75
|
glitter.share.start = new Date();
|
|
76
76
|
const vm: {
|
|
77
77
|
appConfig: any;
|
|
@@ -2601,7 +2601,7 @@ ${(_c = obj.default) !== null && _c !== void 0 ? _c : ''}</textarea
|
|
|
2601
2601
|
id: obj.gvc.glitter.getUUID(),
|
|
2602
2602
|
loading: false,
|
|
2603
2603
|
};
|
|
2604
|
-
return html ` <div class="bg-white shadow rounded-3" style="overflow-y: auto; width: calc(100% - ${document.body.clientWidth > 768 ? 70 : 0}px); height: calc(100% - 70px);">
|
|
2604
|
+
return html ` <div class="bg-white shadow ${document.body.clientWidth < 800 ? `` : `rounded-3`}" style="overflow-y: auto; width: calc(100% - ${document.body.clientWidth > 768 ? 70 : 0}px); ${document.body.clientWidth > 768 ? `height: calc(100% - 70px);` : `height:${window.parent.innerHeight}px;`};padding-top:${gvc.glitter.share.top_inset || 0}px;">
|
|
2605
2605
|
${gvc.bindView({
|
|
2606
2606
|
bind: vm.id,
|
|
2607
2607
|
view: () => {
|
|
@@ -3067,7 +3067,7 @@ ${obj.default ?? ''}</textarea
|
|
|
3067
3067
|
loading: false,
|
|
3068
3068
|
};
|
|
3069
3069
|
|
|
3070
|
-
return html` <div class="bg-white shadow rounded-3" style="overflow-y: auto; width: calc(100% - ${document.body.clientWidth > 768 ? 70 : 0}px); height: calc(100% - 70px);">
|
|
3070
|
+
return html` <div class="bg-white shadow ${document.body.clientWidth<800 ? ``:`rounded-3`}" style="overflow-y: auto; width: calc(100% - ${document.body.clientWidth > 768 ? 70 : 0}px); ${document.body.clientWidth > 768 ? `height: calc(100% - 70px);`:`height:${(window.parent as any).innerHeight}px;`};padding-top:${gvc.glitter.share.top_inset || 0}px;">
|
|
3071
3071
|
${gvc.bindView({
|
|
3072
3072
|
bind: vm.id,
|
|
3073
3073
|
view: () => {
|
|
@@ -594,6 +594,10 @@ export class ApiUser {
|
|
|
594
594
|
});
|
|
595
595
|
}
|
|
596
596
|
static setPublicConfig(cf) {
|
|
597
|
+
var _a;
|
|
598
|
+
window.glitter.share._public_config = (_a = window.glitter.share._public_config) !== null && _a !== void 0 ? _a : {};
|
|
599
|
+
const config = window.glitter.share._public_config;
|
|
600
|
+
config[cf.key + cf.user_id] = undefined;
|
|
597
601
|
return BaseApi.create({
|
|
598
602
|
url: getBaseUrl() + `/api-public/v1/user/public/config`,
|
|
599
603
|
type: 'PUT',
|
|
@@ -635,6 +639,9 @@ export class ApiUser {
|
|
|
635
639
|
config[key + user_id] = res;
|
|
636
640
|
break;
|
|
637
641
|
}
|
|
642
|
+
if (key.indexOf('alt_') === 0) {
|
|
643
|
+
config[key + user_id] = res;
|
|
644
|
+
}
|
|
638
645
|
resolve(res);
|
|
639
646
|
});
|
|
640
647
|
});
|
|
@@ -645,6 +645,9 @@ export class ApiUser {
|
|
|
645
645
|
}
|
|
646
646
|
|
|
647
647
|
public static setPublicConfig(cf: { key: string; value: any; user_id?: string; token?: string }) {
|
|
648
|
+
(window as any).glitter.share._public_config = (window as any).glitter.share._public_config ?? {};
|
|
649
|
+
const config = (window as any).glitter.share._public_config;
|
|
650
|
+
config[cf.key + cf.user_id]=undefined;
|
|
648
651
|
return BaseApi.create({
|
|
649
652
|
url: getBaseUrl() + `/api-public/v1/user/public/config`,
|
|
650
653
|
type: 'PUT',
|
|
@@ -686,6 +689,9 @@ export class ApiUser {
|
|
|
686
689
|
config[key + user_id] = res;
|
|
687
690
|
break;
|
|
688
691
|
}
|
|
692
|
+
if(key.indexOf('alt_')===0){
|
|
693
|
+
config[key + user_id] = res;
|
|
694
|
+
}
|
|
689
695
|
resolve(res);
|
|
690
696
|
});
|
|
691
697
|
});
|
|
@@ -76,6 +76,15 @@ export class Glitter {
|
|
|
76
76
|
this.ut = {
|
|
77
77
|
glitter: this,
|
|
78
78
|
queue: {},
|
|
79
|
+
resize_img_url: (link) => {
|
|
80
|
+
let rela_link = link;
|
|
81
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
82
|
+
if (document.body.clientWidth < dd) {
|
|
83
|
+
rela_link = link.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return rela_link;
|
|
87
|
+
},
|
|
79
88
|
clock() {
|
|
80
89
|
return {
|
|
81
90
|
start: new Date(),
|
|
@@ -933,15 +942,15 @@ ${(!error.message) ? `` : `錯誤訊息:${error.message}`}${(!error.lineNumber)
|
|
|
933
942
|
glitter.runJsInterFace("closeAPP", {}, function (response) {
|
|
934
943
|
});
|
|
935
944
|
}
|
|
936
|
-
generateCheckSum(str) {
|
|
945
|
+
generateCheckSum(str, count) {
|
|
937
946
|
let hash = 0;
|
|
938
947
|
for (let i = 0; i < str.length; i++) {
|
|
939
948
|
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
940
949
|
hash = hash & hash;
|
|
941
950
|
}
|
|
942
951
|
hash = Math.abs(hash);
|
|
943
|
-
let checksum = hash.toString().slice(0, 6);
|
|
944
|
-
while (checksum.length < 6) {
|
|
952
|
+
let checksum = hash.toString().slice(0, (count !== null && count !== void 0 ? count : 6));
|
|
953
|
+
while (checksum.length < (count !== null && count !== void 0 ? count : 6)) {
|
|
945
954
|
checksum = '0' + checksum;
|
|
946
955
|
}
|
|
947
956
|
return checksum;
|
|
@@ -495,7 +495,7 @@ ${(!error.message) ? `` : `錯誤訊息:${error.message}`}${(!error.lineNumber)
|
|
|
495
495
|
})
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
public generateCheckSum(str: string) {
|
|
498
|
+
public generateCheckSum(str: string,count?:number) {
|
|
499
499
|
let hash = 0;
|
|
500
500
|
|
|
501
501
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -507,10 +507,10 @@ ${(!error.message) ? `` : `錯誤訊息:${error.message}`}${(!error.lineNumber)
|
|
|
507
507
|
hash = Math.abs(hash);
|
|
508
508
|
|
|
509
509
|
// 將hash轉換為6碼字串
|
|
510
|
-
let checksum = hash.toString().slice(0, 6);
|
|
510
|
+
let checksum = hash.toString().slice(0, (count ?? 6));
|
|
511
511
|
|
|
512
512
|
// 如果不足6碼,則補零
|
|
513
|
-
while (checksum.length < 6) {
|
|
513
|
+
while (checksum.length < (count ?? 6)) {
|
|
514
514
|
checksum = '0' + checksum;
|
|
515
515
|
}
|
|
516
516
|
|
|
@@ -674,6 +674,15 @@ ${(!error.message) ? `` : `錯誤訊息:${error.message}`}${(!error.lineNumber)
|
|
|
674
674
|
public ut = {
|
|
675
675
|
glitter: this,
|
|
676
676
|
queue: {},
|
|
677
|
+
resize_img_url:(link:string)=>{
|
|
678
|
+
let rela_link=link;
|
|
679
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
680
|
+
if (document.body.clientWidth < dd) {
|
|
681
|
+
rela_link = link.replace('size1440_s*px$_', `size${dd}_s*px$_`)
|
|
682
|
+
}
|
|
683
|
+
})
|
|
684
|
+
return rela_link
|
|
685
|
+
},
|
|
677
686
|
clock() {
|
|
678
687
|
return {
|
|
679
688
|
start: new Date(),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Entry } from '../Entry.js';
|
|
3
3
|
import { Glitter } from './Glitter.js';
|
|
4
4
|
import { GVCType } from './module/PageManager.js';
|
|
5
|
+
import { ApiUser } from "../glitter-base/route/user.js";
|
|
5
6
|
const glitter = new Glitter(window);
|
|
6
7
|
window.glitter = glitter;
|
|
7
8
|
window.rootGlitter = glitter;
|
|
@@ -74,6 +75,27 @@ function traverseHTML(element, document) {
|
|
|
74
75
|
traverseHTML(children[j], document);
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
if ((element.tagName || '').toLowerCase() === 'img') {
|
|
79
|
+
const src = element.getAttribute('src');
|
|
80
|
+
if (src) {
|
|
81
|
+
try {
|
|
82
|
+
const tag = glitter.generateCheckSum(src, 9);
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
if (element) {
|
|
85
|
+
ApiUser.getPublicConfig(`alt_` + tag, 'manager').then((res) => {
|
|
86
|
+
if (res && res.response.value) {
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
element.setAttribute('alt', res.response.value.alt);
|
|
89
|
+
}, 10);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}, 10);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
77
99
|
if (element && element.getAttribute && element.getAttribute('glem') === 'bindView') {
|
|
78
100
|
const id = element.getAttribute('gvc-id');
|
|
79
101
|
glitter.elementCallback[id].element = element;
|
|
@@ -3,6 +3,7 @@ import {Entry} from '../Entry.js';
|
|
|
3
3
|
import {Glitter} from './Glitter.js';
|
|
4
4
|
import {GVC} from './GVController.js';
|
|
5
5
|
import {GVCType} from './module/PageManager.js';
|
|
6
|
+
import {ApiUser} from "../glitter-base/route/user.js";
|
|
6
7
|
|
|
7
8
|
const glitter = new Glitter(window); // glitter變數
|
|
8
9
|
(window as any).glitter = glitter;
|
|
@@ -90,7 +91,28 @@ function traverseHTML(element: any, document: any) {
|
|
|
90
91
|
traverseHTML(children[j], document);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
if((element.tagName || '').toLowerCase() === 'img' ){
|
|
95
|
+
const src=element.getAttribute('src');
|
|
96
|
+
if(src){
|
|
97
|
+
try {
|
|
98
|
+
const tag=glitter.generateCheckSum(src,9)
|
|
99
|
+
setTimeout(()=>{
|
|
100
|
+
if(element){
|
|
101
|
+
ApiUser.getPublicConfig(`alt_`+tag,'manager').then((res)=>{
|
|
102
|
+
if(res && res.response.value){
|
|
103
|
+
setTimeout(()=>{
|
|
104
|
+
element.setAttribute('alt', res.response.value.alt);
|
|
105
|
+
},10)
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
},10)
|
|
110
|
+
}catch (e) {
|
|
93
111
|
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
94
116
|
if (element && element.getAttribute && element.getAttribute('glem') === 'bindView') {
|
|
95
117
|
const id = element.getAttribute('gvc-id') as string;
|
|
96
118
|
glitter.elementCallback[id].element = element;
|
|
@@ -131,15 +131,7 @@ export const widgetComponent = {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
if (widget.data.elem === 'img') {
|
|
134
|
-
|
|
135
|
-
if (innerText.includes(`size1440_s*px$_`)) {
|
|
136
|
-
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
137
|
-
if (document.body.clientWidth < dd) {
|
|
138
|
-
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
option.push({ key: 'src', value: rela_link });
|
|
134
|
+
option.push({ key: 'src', value: gvc.glitter.ut.resize_img_url(innerText) });
|
|
143
135
|
}
|
|
144
136
|
else if (widget.data.elem === 'input') {
|
|
145
137
|
option.push({ key: 'value', value: innerText });
|
|
@@ -130,18 +130,7 @@ export const widgetComponent = {
|
|
|
130
130
|
})
|
|
131
131
|
}
|
|
132
132
|
if (widget.data.elem === 'img') {
|
|
133
|
-
|
|
134
|
-
let rela_link = innerText
|
|
135
|
-
if (innerText.includes(`size1440_s*px$_`)) {
|
|
136
|
-
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
137
|
-
if (document.body.clientWidth < dd) {
|
|
138
|
-
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`)
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
option.push({key: 'src', value: rela_link})
|
|
133
|
+
option.push({key: 'src', value: gvc.glitter.ut.resize_img_url(innerText)})
|
|
145
134
|
} else if (widget.data.elem === 'input') {
|
|
146
135
|
option.push({key: 'value', value: innerText})
|
|
147
136
|
}
|
|
@@ -140,6 +140,39 @@ export class imageLibrary {
|
|
|
140
140
|
const imageUrl = (passType.includes(vm.type))
|
|
141
141
|
? dd.data
|
|
142
142
|
: ((_b = (_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) !== null && _b !== void 0 ? _b : noImageURL);
|
|
143
|
+
function itemClick() {
|
|
144
|
+
if (vm.type == "folder") {
|
|
145
|
+
vm.tag = dd.title;
|
|
146
|
+
that.selectImageLibrary(gvc, (selectData) => {
|
|
147
|
+
vm.link = selectData;
|
|
148
|
+
gvc.notifyDataChange(vm.id);
|
|
149
|
+
}, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
|
|
150
|
+
key: 'folderEdit',
|
|
151
|
+
mul: true,
|
|
152
|
+
tag: dd.title,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
cf.edit(dd, (replace) => {
|
|
157
|
+
if (!replace) {
|
|
158
|
+
let selectData = vm.link.findIndex(data => {
|
|
159
|
+
return data.id == dd.id;
|
|
160
|
+
});
|
|
161
|
+
vm.link.splice(selectData, 1);
|
|
162
|
+
save(() => {
|
|
163
|
+
gvc.notifyDataChange(vm.id);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
let replaceIndex = vm.link.findIndex(data => data.id == replace.id);
|
|
168
|
+
vm.link[replaceIndex] = replace;
|
|
169
|
+
save(() => {
|
|
170
|
+
gvc.notifyDataChange(vm.id);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
143
176
|
return html `
|
|
144
177
|
<div class=""
|
|
145
178
|
style="padding: 10px 12px;position: relative;${(dd.selected) ? `border-radius: 10px;border: 2px solid #393939;background: #F7F7F7;box-shadow: 3px 3px 10px 0px rgba(0, 0, 0, 0.10);` : editArray[index] ? `border-radius: 10px;border: 1px solid #DDD;background: #F7F7F7;` : ``}"
|
|
@@ -187,37 +220,7 @@ export class imageLibrary {
|
|
|
187
220
|
style="height:24px;width:24px;border-radius: 3px;background: rgba(0, 0, 0, 0.80);position: absolute;right: 8.15px;top: 8px;"
|
|
188
221
|
onclick="${gvc.event((e, event) => {
|
|
189
222
|
event.stopPropagation();
|
|
190
|
-
|
|
191
|
-
vm.tag = dd.title;
|
|
192
|
-
that.selectImageLibrary(gvc, (selectData) => {
|
|
193
|
-
vm.link = selectData;
|
|
194
|
-
gvc.notifyDataChange(vm.id);
|
|
195
|
-
}, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
|
|
196
|
-
key: 'folderEdit',
|
|
197
|
-
mul: true,
|
|
198
|
-
tag: dd.title,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
cf.edit(dd, (replace) => {
|
|
203
|
-
if (!replace) {
|
|
204
|
-
let selectData = vm.link.findIndex(data => {
|
|
205
|
-
return data.id == dd.id;
|
|
206
|
-
});
|
|
207
|
-
vm.link.splice(selectData, 1);
|
|
208
|
-
save(() => {
|
|
209
|
-
gvc.notifyDataChange(vm.id);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
let replaceIndex = vm.link.findIndex(data => data.id == replace.id);
|
|
214
|
-
vm.link[replaceIndex] = replace;
|
|
215
|
-
save(() => {
|
|
216
|
-
gvc.notifyDataChange(vm.id);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
223
|
+
itemClick();
|
|
221
224
|
})}">
|
|
222
225
|
<svg xmlns="http://www.w3.org/2000/svg"
|
|
223
226
|
width="12"
|
|
@@ -238,6 +241,11 @@ export class imageLibrary {
|
|
|
238
241
|
</defs>
|
|
239
242
|
</svg>
|
|
240
243
|
</div>
|
|
244
|
+
<div class="position-absolute ${(dd.selected) ? `d-blok` : `d-none`} " style="transform: translate(-50%,-50%);left: 50%;top:50%;">
|
|
245
|
+
${BgWidget.darkButton('編輯圖片', gvc.event(() => {
|
|
246
|
+
itemClick();
|
|
247
|
+
}))}
|
|
248
|
+
</div>
|
|
241
249
|
<div class="${(dd.selected) ? `d-flex` : `d-none`} "
|
|
242
250
|
style="height:24px;width:24px;border-radius: 3px;position: absolute;right: 8.15px;top: 8px;"
|
|
243
251
|
>
|
|
@@ -265,7 +273,7 @@ export class imageLibrary {
|
|
|
265
273
|
divCreate: {
|
|
266
274
|
style: `${gvc.glitter.ut.frSize({
|
|
267
275
|
sm: `width:15%;`
|
|
268
|
-
}, `width:
|
|
276
|
+
}, `width:49%;`)}cursor:pointer;`
|
|
269
277
|
}
|
|
270
278
|
});
|
|
271
279
|
}).join('');
|
|
@@ -280,7 +288,7 @@ export class imageLibrary {
|
|
|
280
288
|
class: `w-100 my-2 flex-wrap `,
|
|
281
289
|
style: `display:flex;gap:${gvc.glitter.ut.frSize({
|
|
282
290
|
sm: `17`
|
|
283
|
-
}, `0`)}px
|
|
291
|
+
}, `0`)}px;${(document.body.clientWidth < 800) ? `justify-content: space-between;` : ``}`,
|
|
284
292
|
},
|
|
285
293
|
onCreate: () => {
|
|
286
294
|
gvc.glitter.addMtScript([
|
|
@@ -879,105 +887,138 @@ export class imageLibrary {
|
|
|
879
887
|
}
|
|
880
888
|
static selectImageLibrary(gvc, callback, title, opt) {
|
|
881
889
|
var _a, _b, _c;
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
callback: (text) => {
|
|
891
|
-
item.title = text;
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
item.data = (_a = item.data) !== null && _a !== void 0 ? _a : {};
|
|
897
|
-
return [BgWidget.editeInput({
|
|
890
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
891
|
+
let alt = '';
|
|
892
|
+
let saveAlt = function () {
|
|
893
|
+
};
|
|
894
|
+
function editorView(gvc, item) {
|
|
895
|
+
var _a, _b;
|
|
896
|
+
if (item.type === 'folder') {
|
|
897
|
+
return BgWidget.editeInput({
|
|
898
898
|
gvc: gvc,
|
|
899
|
-
title:
|
|
899
|
+
title: `資料夾標題`,
|
|
900
900
|
default: item.title,
|
|
901
|
-
placeHolder:
|
|
901
|
+
placeHolder: `請輸入資料夾標題`,
|
|
902
902
|
callback: (text) => {
|
|
903
903
|
item.title = text;
|
|
904
904
|
}
|
|
905
|
-
})
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
item.data = (_a = item.data) !== null && _a !== void 0 ? _a : {};
|
|
909
|
+
return `<div>${[BgWidget.editeInput({
|
|
910
|
+
gvc: gvc,
|
|
911
|
+
title: `圖片標題`,
|
|
912
|
+
default: item.title,
|
|
913
|
+
placeHolder: `請輸入圖片標題`,
|
|
914
|
+
callback: (text) => {
|
|
915
|
+
item.title = text;
|
|
916
|
+
}
|
|
917
|
+
}),
|
|
918
|
+
EditorElem.uploadImageContainer({
|
|
919
|
+
gvc: gvc,
|
|
920
|
+
title: `圖片資源`,
|
|
921
|
+
def: (_b = item.data) !== null && _b !== void 0 ? _b : '',
|
|
922
|
+
callback: (text) => {
|
|
923
|
+
item.data = text;
|
|
924
|
+
},
|
|
925
|
+
}),
|
|
926
|
+
gvc.bindView(() => {
|
|
927
|
+
const id = gvc.glitter.getUUID();
|
|
928
|
+
return {
|
|
929
|
+
bind: id,
|
|
930
|
+
view: () => __awaiter(this, void 0, void 0, function* () {
|
|
931
|
+
const tag = gvc.glitter.generateCheckSum(item.data, 9);
|
|
932
|
+
alt = (yield ApiUser.getPublicConfig(`alt_` + tag, 'manager')).response.value || { alt: '' };
|
|
933
|
+
saveAlt = () => __awaiter(this, void 0, void 0, function* () {
|
|
934
|
+
ApiUser.setPublicConfig({
|
|
935
|
+
key: `alt_` + tag,
|
|
936
|
+
value: alt,
|
|
937
|
+
user_id: 'manager'
|
|
938
|
+
});
|
|
939
|
+
});
|
|
940
|
+
return BgWidget.textArea({
|
|
941
|
+
gvc: gvc,
|
|
942
|
+
title: `ALT描述`,
|
|
943
|
+
default: alt.alt,
|
|
944
|
+
placeHolder: `請輸入ALT描述`,
|
|
945
|
+
callback: (text) => {
|
|
946
|
+
alt.alt = text;
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
})
|
|
950
|
+
};
|
|
951
|
+
})].join('<div class="my-2"></div>')}</div>`;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
imageLibrary.fileSystem({
|
|
955
|
+
getSelect: callback,
|
|
956
|
+
gvc: gvc,
|
|
957
|
+
key: opt ? ((_a = opt.key) !== null && _a !== void 0 ? _a : 'image-manager') : 'image-manager',
|
|
958
|
+
title: title,
|
|
959
|
+
tag: (_b = opt === null || opt === void 0 ? void 0 : opt.tag) !== null && _b !== void 0 ? _b : "",
|
|
960
|
+
mul: opt ? ((_c = opt.mul) !== null && _c !== void 0 ? _c : false) : false,
|
|
961
|
+
plus: (gvc, callback) => {
|
|
962
|
+
const item = {
|
|
963
|
+
title: '',
|
|
964
|
+
data: {},
|
|
965
|
+
items: [],
|
|
966
|
+
type: 'file',
|
|
967
|
+
tag: [],
|
|
968
|
+
id: gvc.glitter.getUUID()
|
|
969
|
+
};
|
|
970
|
+
let count = 1;
|
|
971
|
+
EditorElem.uploadFileFunction({
|
|
906
972
|
gvc: gvc,
|
|
907
|
-
title: `圖片內容`,
|
|
908
|
-
def: (_b = item.data) !== null && _b !== void 0 ? _b : '',
|
|
909
973
|
callback: (text) => {
|
|
910
|
-
item
|
|
974
|
+
callback(text.map((item) => {
|
|
975
|
+
return {
|
|
976
|
+
title: item.split('_')[3],
|
|
977
|
+
data: item,
|
|
978
|
+
items: [],
|
|
979
|
+
type: 'file',
|
|
980
|
+
tag: [],
|
|
981
|
+
id: gvc.glitter.getUUID()
|
|
982
|
+
};
|
|
983
|
+
}));
|
|
911
984
|
},
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
callback: (text) => {
|
|
935
|
-
callback(text.map((item) => {
|
|
936
|
-
return {
|
|
937
|
-
title: item.split('_')[3],
|
|
938
|
-
data: item,
|
|
939
|
-
items: [],
|
|
940
|
-
type: 'file',
|
|
941
|
-
tag: [],
|
|
942
|
-
id: gvc.glitter.getUUID()
|
|
943
|
-
};
|
|
944
|
-
}));
|
|
945
|
-
},
|
|
946
|
-
return_array: true,
|
|
947
|
-
multiple: true
|
|
948
|
-
});
|
|
949
|
-
},
|
|
950
|
-
edit: (item, callback) => {
|
|
951
|
-
item = JSON.parse(JSON.stringify(item));
|
|
952
|
-
BgWidget.settingDialog({
|
|
953
|
-
gvc: gvc,
|
|
954
|
-
title: '更新圖片',
|
|
955
|
-
innerHTML: (gvc) => {
|
|
956
|
-
return editorView(gvc, item);
|
|
957
|
-
},
|
|
958
|
-
footer_html: (gvc) => {
|
|
959
|
-
return [BgWidget.danger(gvc.event(() => {
|
|
960
|
-
const dialog = new ShareDialog(gvc.glitter);
|
|
961
|
-
dialog.checkYesOrNot({
|
|
962
|
-
text: `刪除後使用此資源的內容將被取消關聯,是否確認刪除?`,
|
|
963
|
-
callback: (response) => {
|
|
964
|
-
if (response) {
|
|
965
|
-
callback(undefined);
|
|
966
|
-
gvc.closeDialog();
|
|
985
|
+
return_array: true,
|
|
986
|
+
multiple: true
|
|
987
|
+
});
|
|
988
|
+
},
|
|
989
|
+
edit: (item, callback) => {
|
|
990
|
+
item = JSON.parse(JSON.stringify(item));
|
|
991
|
+
BgWidget.settingDialog({
|
|
992
|
+
gvc: gvc,
|
|
993
|
+
title: '更新圖片',
|
|
994
|
+
innerHTML: (gvc) => {
|
|
995
|
+
return editorView(gvc, item);
|
|
996
|
+
},
|
|
997
|
+
footer_html: (gvc) => {
|
|
998
|
+
return [BgWidget.danger(gvc.event(() => {
|
|
999
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1000
|
+
dialog.checkYesOrNot({
|
|
1001
|
+
text: `刪除後使用此資源的內容將被取消關聯,是否確認刪除?`,
|
|
1002
|
+
callback: (response) => {
|
|
1003
|
+
if (response) {
|
|
1004
|
+
callback(undefined);
|
|
1005
|
+
gvc.closeDialog();
|
|
1006
|
+
}
|
|
967
1007
|
}
|
|
968
|
-
}
|
|
969
|
-
})
|
|
970
|
-
|
|
971
|
-
gvc.
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1008
|
+
});
|
|
1009
|
+
})), BgWidget.cancel(gvc.event(() => {
|
|
1010
|
+
gvc.closeDialog();
|
|
1011
|
+
})), BgWidget.save(gvc.event(() => {
|
|
1012
|
+
callback(item);
|
|
1013
|
+
saveAlt();
|
|
1014
|
+
gvc.closeDialog();
|
|
1015
|
+
}), '確定')].join('');
|
|
1016
|
+
},
|
|
1017
|
+
closeCallback: () => {
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
981
1022
|
});
|
|
982
1023
|
}
|
|
983
1024
|
}
|
|
@@ -184,6 +184,44 @@ export class imageLibrary {
|
|
|
184
184
|
: (vm.link.find(data => data?.tag?.includes(dd.title))?.data ?? noImageURL);
|
|
185
185
|
|
|
186
186
|
|
|
187
|
+
function itemClick(){
|
|
188
|
+
if (vm.type == "folder") {
|
|
189
|
+
//編輯資料夾內容
|
|
190
|
+
vm.tag = dd.title;
|
|
191
|
+
that.selectImageLibrary(gvc, (selectData) => {
|
|
192
|
+
vm.link = selectData;
|
|
193
|
+
gvc.notifyDataChange(vm.id);
|
|
194
|
+
|
|
195
|
+
}, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
|
|
196
|
+
key: 'folderEdit',
|
|
197
|
+
mul: true,
|
|
198
|
+
tag: dd.title,
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
} else {
|
|
202
|
+
cf.edit(dd, (replace) => {
|
|
203
|
+
if (!replace) {
|
|
204
|
+
let selectData = vm.link.findIndex(data => {
|
|
205
|
+
return data.id == dd.id
|
|
206
|
+
})
|
|
207
|
+
vm.link.splice(selectData, 1)
|
|
208
|
+
save(() => {
|
|
209
|
+
gvc.notifyDataChange(vm.id);
|
|
210
|
+
})
|
|
211
|
+
} else {
|
|
212
|
+
let replaceIndex = vm.link.findIndex(data => data.id == replace.id)
|
|
213
|
+
vm.link[replaceIndex] = replace;
|
|
214
|
+
// console.log("vm.link -- " , vm.link);
|
|
215
|
+
save(() => {
|
|
216
|
+
gvc.notifyDataChange(vm.id);
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
}
|
|
187
225
|
return html`
|
|
188
226
|
<div class=""
|
|
189
227
|
style="padding: 10px 12px;position: relative;${((dd as any).selected) ? `border-radius: 10px;border: 2px solid #393939;background: #F7F7F7;box-shadow: 3px 3px 10px 0px rgba(0, 0, 0, 0.10);` : editArray[index] ? `border-radius: 10px;border: 1px solid #DDD;background: #F7F7F7;` : ``}"
|
|
@@ -232,42 +270,7 @@ export class imageLibrary {
|
|
|
232
270
|
style="height:24px;width:24px;border-radius: 3px;background: rgba(0, 0, 0, 0.80);position: absolute;right: 8.15px;top: 8px;"
|
|
233
271
|
onclick="${gvc.event((e, event) => {
|
|
234
272
|
event.stopPropagation();
|
|
235
|
-
|
|
236
|
-
//編輯資料夾內容
|
|
237
|
-
vm.tag = dd.title;
|
|
238
|
-
that.selectImageLibrary(gvc, (selectData) => {
|
|
239
|
-
vm.link = selectData;
|
|
240
|
-
gvc.notifyDataChange(vm.id);
|
|
241
|
-
|
|
242
|
-
}, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">${vm.tag}</div>`, {
|
|
243
|
-
key: 'folderEdit',
|
|
244
|
-
mul: true,
|
|
245
|
-
tag: dd.title,
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
} else {
|
|
249
|
-
cf.edit(dd, (replace) => {
|
|
250
|
-
if (!replace) {
|
|
251
|
-
let selectData = vm.link.findIndex(data => {
|
|
252
|
-
return data.id == dd.id
|
|
253
|
-
})
|
|
254
|
-
vm.link.splice(selectData, 1)
|
|
255
|
-
save(() => {
|
|
256
|
-
gvc.notifyDataChange(vm.id);
|
|
257
|
-
})
|
|
258
|
-
} else {
|
|
259
|
-
let replaceIndex = vm.link.findIndex(data => data.id == replace.id)
|
|
260
|
-
vm.link[replaceIndex] = replace;
|
|
261
|
-
// console.log("vm.link -- " , vm.link);
|
|
262
|
-
save(() => {
|
|
263
|
-
gvc.notifyDataChange(vm.id);
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
})
|
|
269
|
-
}
|
|
270
|
-
|
|
273
|
+
itemClick()
|
|
271
274
|
})}">
|
|
272
275
|
<svg xmlns="http://www.w3.org/2000/svg"
|
|
273
276
|
width="12"
|
|
@@ -288,6 +291,11 @@ export class imageLibrary {
|
|
|
288
291
|
</defs>
|
|
289
292
|
</svg>
|
|
290
293
|
</div>
|
|
294
|
+
<div class="position-absolute ${((dd as any).selected) ? `d-blok` : `d-none`} " style="transform: translate(-50%,-50%);left: 50%;top:50%;">
|
|
295
|
+
${BgWidget.darkButton('編輯圖片',gvc.event(()=>{
|
|
296
|
+
itemClick()
|
|
297
|
+
}))}
|
|
298
|
+
</div>
|
|
291
299
|
<div class="${((dd as any).selected) ? `d-flex` : `d-none`} "
|
|
292
300
|
style="height:24px;width:24px;border-radius: 3px;position: absolute;right: 8.15px;top: 8px;"
|
|
293
301
|
>
|
|
@@ -314,7 +322,7 @@ export class imageLibrary {
|
|
|
314
322
|
divCreate: {
|
|
315
323
|
style: `${gvc.glitter.ut.frSize({
|
|
316
324
|
sm: `width:15%;`
|
|
317
|
-
}, `width:
|
|
325
|
+
}, `width:49%;`)}cursor:pointer;`
|
|
318
326
|
}
|
|
319
327
|
})
|
|
320
328
|
}).join('')
|
|
@@ -328,7 +336,7 @@ export class imageLibrary {
|
|
|
328
336
|
class: `w-100 my-2 flex-wrap `,
|
|
329
337
|
style: `display:flex;gap:${gvc.glitter.ut.frSize({
|
|
330
338
|
sm: `17`
|
|
331
|
-
}, `0`)}px
|
|
339
|
+
}, `0`)}px;${(document.body.clientWidth<800) ? `justify-content: space-between;`:``}`,
|
|
332
340
|
},
|
|
333
341
|
onCreate: () => {
|
|
334
342
|
gvc.glitter.addMtScript(
|
|
@@ -990,12 +998,22 @@ export class imageLibrary {
|
|
|
990
998
|
|
|
991
999
|
}
|
|
992
1000
|
|
|
993
|
-
public static selectImageLibrary(gvc: GVC, callback: (id: FileItem[]) => void, title: string, opt?: {
|
|
1001
|
+
public static async selectImageLibrary(gvc: GVC, callback: (id: FileItem[]) => void, title: string, opt?: {
|
|
994
1002
|
key?: string;
|
|
995
1003
|
mul?: boolean;
|
|
996
1004
|
tag?: string;
|
|
997
1005
|
}) {
|
|
998
|
-
|
|
1006
|
+
|
|
1007
|
+
let alt:any=''
|
|
1008
|
+
let saveAlt=function (){
|
|
1009
|
+
|
|
1010
|
+
}
|
|
1011
|
+
function editorView(gvc: GVC, item: FileItem) {
|
|
1012
|
+
|
|
1013
|
+
// ApiUser.setPublicConfig({
|
|
1014
|
+
// key:'alt_'+
|
|
1015
|
+
// })
|
|
1016
|
+
// alert(JSON.stringify(item))
|
|
999
1017
|
if (item.type === 'folder') {
|
|
1000
1018
|
return BgWidget.editeInput({
|
|
1001
1019
|
gvc: gvc,
|
|
@@ -1008,7 +1026,7 @@ export class imageLibrary {
|
|
|
1008
1026
|
})
|
|
1009
1027
|
} else {
|
|
1010
1028
|
item.data = item.data ?? {}
|
|
1011
|
-
return [BgWidget.editeInput({
|
|
1029
|
+
return `<div>${[BgWidget.editeInput({
|
|
1012
1030
|
gvc: gvc,
|
|
1013
1031
|
title: `圖片標題`,
|
|
1014
1032
|
default: item.title,
|
|
@@ -1016,14 +1034,41 @@ export class imageLibrary {
|
|
|
1016
1034
|
callback: (text) => {
|
|
1017
1035
|
item.title = text
|
|
1018
1036
|
}
|
|
1019
|
-
}),
|
|
1037
|
+
}),
|
|
1038
|
+
EditorElem.uploadImageContainer({
|
|
1020
1039
|
gvc: gvc,
|
|
1021
|
-
title:
|
|
1040
|
+
title: `圖片資源`,
|
|
1022
1041
|
def: item.data ?? '',
|
|
1023
1042
|
callback: (text) => {
|
|
1024
1043
|
item.data = text;
|
|
1025
1044
|
},
|
|
1026
|
-
})
|
|
1045
|
+
}),
|
|
1046
|
+
gvc.bindView(()=>{
|
|
1047
|
+
const id=gvc.glitter.getUUID()
|
|
1048
|
+
return {
|
|
1049
|
+
bind:id,
|
|
1050
|
+
view:async ()=>{
|
|
1051
|
+
const tag=gvc.glitter.generateCheckSum(item.data,9)
|
|
1052
|
+
alt=(await ApiUser.getPublicConfig(`alt_`+tag,'manager')).response.value || {alt:''};
|
|
1053
|
+
saveAlt=async ()=>{
|
|
1054
|
+
ApiUser.setPublicConfig({
|
|
1055
|
+
key:`alt_`+tag,
|
|
1056
|
+
value:alt,
|
|
1057
|
+
user_id:'manager'
|
|
1058
|
+
})
|
|
1059
|
+
}
|
|
1060
|
+
return BgWidget.textArea({
|
|
1061
|
+
gvc: gvc,
|
|
1062
|
+
title: `ALT描述`,
|
|
1063
|
+
default: alt.alt,
|
|
1064
|
+
placeHolder: `請輸入ALT描述`,
|
|
1065
|
+
callback: (text) => {
|
|
1066
|
+
alt.alt = text
|
|
1067
|
+
}
|
|
1068
|
+
})
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
})].join('<div class="my-2"></div>')}</div>`
|
|
1027
1072
|
}
|
|
1028
1073
|
}
|
|
1029
1074
|
|
|
@@ -1112,6 +1157,7 @@ export class imageLibrary {
|
|
|
1112
1157
|
gvc.closeDialog()
|
|
1113
1158
|
})), BgWidget.save(gvc.event(() => {
|
|
1114
1159
|
callback(item);
|
|
1160
|
+
saveAlt()
|
|
1115
1161
|
gvc.closeDialog();
|
|
1116
1162
|
|
|
1117
1163
|
}), '確定')].join('')
|