ts-glitter 13.8.813 → 13.8.815
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 +11 -7
- package/lowcode/cms-plugin/shopping-product-setting.ts +16 -8
- 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/glitterBundle/plugins/editor-elem.js +785 -604
- package/lowcode/glitterBundle/plugins/editor-elem.ts +1616 -1315
- 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.815';
|
|
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.815';
|
|
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: () => {
|
|
@@ -1379,19 +1379,22 @@ export class ShoppingProductSetting {
|
|
|
1379
1379
|
obj.gvc.glitter.openDiaLog(new URL('../dialog/image-preview.js', import.meta.url).href, 'preview', variant.preview_image || BgWidget.noImageURL);
|
|
1380
1380
|
})}"
|
|
1381
1381
|
></i>
|
|
1382
|
+
|
|
1382
1383
|
</div>
|
|
1383
1384
|
</div>
|
|
1384
1385
|
<div
|
|
1385
1386
|
style="width: 136px;text-align: center;color: #36B;cursor: pointer;"
|
|
1386
1387
|
onclick="${obj.gvc.event(() => {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
variant.preview_image = text;
|
|
1388
|
+
imageLibrary.selectImageLibrary(gvc, (urlArray) => {
|
|
1389
|
+
if (urlArray.length > 0) {
|
|
1390
|
+
variant.preview_image = urlArray[0].data;
|
|
1391
1391
|
gvc.notifyDataChange(id);
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1392
|
+
}
|
|
1393
|
+
else {
|
|
1394
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1395
|
+
dialog.errorMessage({ text: '請選擇至少一張圖片' });
|
|
1396
|
+
}
|
|
1397
|
+
}, html ` <div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">圖片庫</div>`, { mul: false });
|
|
1395
1398
|
})}"
|
|
1396
1399
|
>
|
|
1397
1400
|
變更
|
|
@@ -1645,6 +1648,7 @@ export class ShoppingProductSetting {
|
|
|
1645
1648
|
const dialog = new ShareDialog(gvc.glitter);
|
|
1646
1649
|
if (!variant.barcode) {
|
|
1647
1650
|
dialog.errorMessage({ text: '請先設定商品條碼' });
|
|
1651
|
+
return;
|
|
1648
1652
|
}
|
|
1649
1653
|
window.parent.glitter.addMtScript([
|
|
1650
1654
|
{
|
|
@@ -1649,19 +1649,26 @@ export class ShoppingProductSetting {
|
|
|
1649
1649
|
);
|
|
1650
1650
|
})}"
|
|
1651
1651
|
></i>
|
|
1652
|
+
|
|
1652
1653
|
</div>
|
|
1653
1654
|
</div>
|
|
1654
1655
|
<div
|
|
1655
1656
|
style="width: 136px;text-align: center;color: #36B;cursor: pointer;"
|
|
1656
1657
|
onclick="${obj.gvc.event(() => {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1658
|
+
imageLibrary.selectImageLibrary(
|
|
1659
|
+
gvc,
|
|
1660
|
+
(urlArray) => {
|
|
1661
|
+
if (urlArray.length > 0) {
|
|
1662
|
+
variant.preview_image = urlArray[0].data;
|
|
1663
|
+
gvc.notifyDataChange(id);
|
|
1664
|
+
} else {
|
|
1665
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1666
|
+
dialog.errorMessage({ text: '請選擇至少一張圖片' });
|
|
1667
|
+
}
|
|
1668
|
+
},
|
|
1669
|
+
html` <div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">圖片庫</div>`,
|
|
1670
|
+
{ mul: false }
|
|
1671
|
+
)
|
|
1665
1672
|
})}"
|
|
1666
1673
|
>
|
|
1667
1674
|
變更
|
|
@@ -1925,6 +1932,7 @@ export class ShoppingProductSetting {
|
|
|
1925
1932
|
const dialog = new ShareDialog(gvc.glitter);
|
|
1926
1933
|
if (!variant.barcode) {
|
|
1927
1934
|
dialog.errorMessage({ text: '請先設定商品條碼' });
|
|
1935
|
+
return
|
|
1928
1936
|
}
|
|
1929
1937
|
(window.parent as any).glitter.addMtScript(
|
|
1930
1938
|
[
|
|
@@ -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
|
}
|