ts-glitter 13.4.6 → 13.4.8

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.
@@ -68,17 +68,23 @@ export class Editor {
68
68
  glitter.share.editor_vm.close();
69
69
  }
70
70
  else {
71
- if (Storage.select_function !== 'backend-manger') {
72
- const url = new URL(location.href);
73
- url.searchParams.set('function', 'backend-manger');
74
- location.href = url.href;
71
+ if (glitter.pageConfig.length > 1) {
72
+ glitter.setUrlParameter('function', 'backend-manger');
73
+ glitter.goBack();
75
74
  }
76
75
  else {
77
- const url = new URL(location.href);
78
- url.searchParams.delete('appName');
79
- url.searchParams.delete('type');
80
- url.searchParams.set('page', 'backend_manager');
81
- location.href = url.href.replace(url.search, '');
76
+ if (Storage.select_function !== 'backend-manger') {
77
+ const url = new URL(location.href);
78
+ url.searchParams.set('function', 'backend-manger');
79
+ location.href = url.href;
80
+ }
81
+ else {
82
+ const url = new URL(location.href);
83
+ url.searchParams.delete('appName');
84
+ url.searchParams.delete('type');
85
+ url.searchParams.set('page', 'backend_manager');
86
+ location.href = url.href.replace(url.search, '');
87
+ }
82
88
  }
83
89
  }
84
90
  }
@@ -68,17 +68,23 @@ export class Editor {
68
68
  if (glitter.share.editor_vm) {
69
69
  glitter.share.editor_vm.close();
70
70
  } else {
71
- if (Storage.select_function !== 'backend-manger') {
72
- const url = new URL(location.href);
73
- url.searchParams.set('function', 'backend-manger');
74
- location.href = url.href;
75
- } else {
76
- const url = new URL(location.href);
77
- url.searchParams.delete('appName');
78
- url.searchParams.delete('type');
79
- url.searchParams.set('page', 'backend_manager');
80
- location.href = url.href.replace(url.search, '');
71
+ if(glitter.pageConfig.length>1){
72
+ glitter.setUrlParameter('function','backend-manger')
73
+ glitter.goBack()
74
+ }else{
75
+ if (Storage.select_function !== 'backend-manger') {
76
+ const url = new URL(location.href);
77
+ url.searchParams.set('function', 'backend-manger');
78
+ location.href = url.href;
79
+ } else {
80
+ const url = new URL(location.href);
81
+ url.searchParams.delete('appName');
82
+ url.searchParams.delete('type');
83
+ url.searchParams.set('page', 'backend_manager');
84
+ location.href = url.href.replace(url.search, '');
85
+ }
81
86
  }
87
+
82
88
  }
83
89
  }
84
90
 
@@ -37,6 +37,7 @@ import { BgWidget } from "../backend-manager/bg-widget.js";
37
37
  import { ApiUser } from "../glitter-base/route/user.js";
38
38
  import { BaseApi } from "../glitterBundle/api/base.js";
39
39
  import { GlobalUser } from "../glitter-base/global/global-user.js";
40
+ import { Article } from "../glitter-base/route/article.js";
40
41
  const html = String.raw;
41
42
  const editorContainerID = `HtmlEditorContainer`;
42
43
  init(import.meta.url, (gvc, glitter, gBundle) => {
@@ -44,7 +45,7 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
44
45
  glitter.share.loading_dialog = (new ShareDialog(gvc.glitter));
45
46
  const css = String.raw;
46
47
  gvc.addStyle(css `
47
-
48
+
48
49
  .hoverHidden div {
49
50
  display: none;
50
51
  }
@@ -231,7 +232,19 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
231
232
  tag: glitter.getUrlParameter('page'),
232
233
  appName: gBundle.appName
233
234
  }, (d2) => {
234
- resolve(d2.response.result[0]);
235
+ if (glitter.getUrlParameter('page').startsWith('pages')) {
236
+ Article.get({
237
+ page: 0,
238
+ limit: 1,
239
+ tag: glitter.getUrlParameter('page').split('/')[1]
240
+ }).then((data) => __awaiter(this, void 0, void 0, function* () {
241
+ d2.response.result[0].config = data.response.data[0].content.config;
242
+ resolve(d2.response.result[0]);
243
+ }));
244
+ }
245
+ else {
246
+ resolve(d2.response.result[0]);
247
+ }
235
248
  });
236
249
  });
237
250
  if (!glitter.share.editor_vm) {
@@ -370,7 +383,6 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
370
383
  gvc.notifyDataChange(editorContainerID);
371
384
  });
372
385
  }
373
- console.log(`start-load:==>load`);
374
386
  lod().then(() => {
375
387
  const dialog = new ShareDialog(gvc.glitter);
376
388
  dialog.dataLoading({ visible: false });
@@ -419,20 +431,34 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
419
431
  else {
420
432
  return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
421
433
  let result = true;
422
- ApiPageConfig.setPage({
423
- id: viewModel.data.id,
424
- appName: gBundle.appName,
425
- tag: viewModel.data.tag,
426
- name: viewModel.data.name,
427
- config: config,
428
- group: viewModel.data.group,
429
- page_config: viewModel.data.page_config,
430
- page_type: viewModel.data.page_type,
431
- preview_image: viewModel.data.preview_image,
432
- favorite: viewModel.data.favorite,
433
- }).then((api) => {
434
- resolve(result && api.result);
435
- });
434
+ if (glitter.getUrlParameter('page').startsWith('pages')) {
435
+ Article.get({
436
+ page: 0,
437
+ limit: 1,
438
+ tag: glitter.getUrlParameter('page').split('/')[1]
439
+ }).then((data) => __awaiter(this, void 0, void 0, function* () {
440
+ data.response.data[0].content.config = config;
441
+ Article.put(data.response.data[0]).then((response) => {
442
+ resolve(response && response.result);
443
+ });
444
+ }));
445
+ }
446
+ else {
447
+ ApiPageConfig.setPage({
448
+ id: viewModel.data.id,
449
+ appName: gBundle.appName,
450
+ tag: viewModel.data.tag,
451
+ name: viewModel.data.name,
452
+ config: config,
453
+ group: viewModel.data.group,
454
+ page_config: viewModel.data.page_config,
455
+ page_type: viewModel.data.page_type,
456
+ preview_image: viewModel.data.preview_image,
457
+ favorite: viewModel.data.favorite,
458
+ }).then((api) => {
459
+ resolve(result && api.result);
460
+ });
461
+ }
436
462
  }));
437
463
  }
438
464
  }),
@@ -605,13 +631,7 @@ ${Storage.page_setting_item === `${da.index}` ? `background:${EditorConfig.edito
605
631
  case 'user-editor':
606
632
  if (Storage.select_function === 'user-editor') {
607
633
  if (!viewModel.data.page_config || viewModel.data.page_config.support_editor !== 'true') {
608
- const redirect = viewModel.dataList.find((dd) => {
609
- return dd.page_config && dd.page_config.support_editor === 'true';
610
- });
611
- if (redirect) {
612
- const url = new URL(glitter.root_path + `${redirect.tag}${location.search}`);
613
- location.href = url.href;
614
- }
634
+ console.log(glitter.root_path);
615
635
  }
616
636
  }
617
637
  return Main_editor.left(gvc, viewModel, editorContainerID, gBundle);
@@ -706,6 +726,14 @@ ${Storage.page_setting_item === `${da.index}` ? `background:${EditorConfig.edito
706
726
  function initialEditor(gvc, viewModel) {
707
727
  var _a;
708
728
  const glitter = gvc.glitter;
729
+ glitter.share.switch_to_web_builder = (page) => {
730
+ glitter.setUrlParameter('function', 'user-editor');
731
+ glitter.changePage('jspage/main.js', page, true, {
732
+ appName: window.parent.glitter.getUrlParameter('appName'),
733
+ }, {
734
+ backGroundColor: `transparent;`,
735
+ });
736
+ };
709
737
  glitter.share.subscription = (title) => __awaiter(this, void 0, void 0, function* () {
710
738
  const dialog = new ShareDialog(glitter);
711
739
  const vm = {
@@ -33,6 +33,7 @@ import {AiPointsApi} from "../glitter-base/route/ai-points-api.js";
33
33
  import {ApiCart} from "../glitter-base/route/api-cart.js";
34
34
  import {BaseApi} from "../glitterBundle/api/base.js";
35
35
  import {GlobalUser} from "../glitter-base/global/global-user.js";
36
+ import {Article} from "../glitter-base/route/article.js";
36
37
 
37
38
  const html = String.raw;
38
39
  //
@@ -43,7 +44,7 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
43
44
 
44
45
  const css = String.raw;
45
46
  gvc.addStyle(css`
46
-
47
+
47
48
  .hoverHidden div {
48
49
  display: none;
49
50
  }
@@ -197,13 +198,14 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
197
198
  (window.parent as any).glitter.share.refreshMainRightEditor = () => {
198
199
  gvc.notifyDataChange('MainEditorRight');
199
200
  };
200
- const dialog=new ShareDialog(glitter)
201
+ const dialog = new ShareDialog(glitter)
202
+
201
203
  //載入頁面資料
202
204
  async function lod() {
203
205
  if (gvc.glitter.getUrlParameter('function') !== 'backend-manger') {
204
206
  glitter.share.loading_dialog.dataLoading({text: '模組加載中...', visible: true})
205
207
  } else {
206
- dialog.dataLoading({visible:true})
208
+ dialog.dataLoading({visible: true})
207
209
  }
208
210
  glitter.share.top_inset = await new Promise((resolve, reject) => {
209
211
  glitter.runJsInterFace(
@@ -247,7 +249,6 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
247
249
  })
248
250
 
249
251
 
250
-
251
252
  const waitGetData = [
252
253
  async () => {
253
254
  return await new Promise(async (resolve, reject) => {
@@ -266,18 +267,31 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
266
267
  },
267
268
  async () => {
268
269
  return await new Promise(async (resolve) => {
270
+
271
+
269
272
  viewModel.data = await new Promise((resolve, reject) => {
270
273
  ((window as any).glitterInitialHelper).getPageData({
271
274
  tag: glitter.getUrlParameter('page'),
272
275
  appName: gBundle.appName
273
276
  }, (d2: any) => {
274
- resolve(d2.response.result[0])
277
+ if(glitter.getUrlParameter('page').startsWith('pages')){
278
+ Article.get({
279
+ page: 0,
280
+ limit: 1,
281
+ tag: glitter.getUrlParameter('page').split('/')[1]
282
+ }).then(async (data) => {
283
+ d2.response.result[0].config=data.response.data[0].content.config
284
+ resolve(d2.response.result[0])
285
+ })
286
+ }else{
287
+ resolve(d2.response.result[0])
288
+ }
275
289
  })
276
290
  })
277
291
  if (!glitter.share.editor_vm) {
278
- if(glitter.getUrlParameter('function')==='backend-manger'){
292
+ if (glitter.getUrlParameter('function') === 'backend-manger') {
279
293
  resolve(true)
280
- return
294
+ return
281
295
  }
282
296
  const data = await ApiPageConfig.getPage({
283
297
  appName: gBundle.appName,
@@ -401,12 +415,12 @@ return
401
415
  await lod();
402
416
  return;
403
417
  }
404
- dialog.dataLoading({visible:false})
418
+ dialog.dataLoading({visible: false})
405
419
  viewModel.loading = false;
406
420
  //推播訂閱
407
421
  gvc.glitter.runJsInterFace("getFireBaseToken", {}, (response) => {
408
422
  if (response.token) {
409
- ApiUser.registerFCM(viewModel.app_config_original.user,response.token,(window as any).glitterBase)
423
+ ApiUser.registerFCM(viewModel.app_config_original.user, response.token, (window as any).glitterBase)
410
424
  }
411
425
  }, {
412
426
  webFunction(data: any, callback: (data: any) => void): any {
@@ -415,16 +429,16 @@ return
415
429
  })
416
430
  gvc.notifyDataChange(editorContainerID);
417
431
  }
418
- console.log(`start-load:==>load`)
432
+
419
433
  lod().then(() => {
420
- const dialog=new ShareDialog(gvc.glitter)
421
- dialog.dataLoading({visible:false})
434
+ const dialog = new ShareDialog(gvc.glitter)
435
+ dialog.dataLoading({visible: false})
422
436
  //設定儲存事件
423
437
  glitter.htmlGenerate.saveEvent = (refresh: boolean = true, callback?: () => void) => {
424
438
  glitter.closeDiaLog();
425
439
  glitter.setCookie('jumpToNavScroll', $(`#jumpToNav`).scrollTop());
426
440
 
427
- dialog.dataLoading({visible:true,text:'更新中..'})
441
+ dialog.dataLoading({visible: true, text: '更新中..'})
428
442
 
429
443
  async function saveEvent() {
430
444
  for (const b of Object.keys(glitter.share.editorViewModel.saveArray)) {
@@ -435,7 +449,6 @@ console.log(`start-load:==>load`)
435
449
  async () => {
436
450
  let haveID: string[] = [];
437
451
  const config = JSON.parse(JSON.stringify((viewModel.data as any).config))
438
-
439
452
  function getID(set: any) {
440
453
  set.map((dd: any) => {
441
454
  dd.js = dd.js.replace(`${location.origin}/${(window as any).appName}/`, './');
@@ -458,7 +471,6 @@ console.log(`start-load:==>load`)
458
471
  }
459
472
  });
460
473
  }
461
-
462
474
  getID(config);
463
475
  if (glitter.share.editor_vm) {
464
476
  return new Promise((resolve, reject) => {
@@ -467,20 +479,33 @@ console.log(`start-load:==>load`)
467
479
  } else {
468
480
  return new Promise(async (resolve) => {
469
481
  let result = true;
470
- ApiPageConfig.setPage({
471
- id: (viewModel.data! as any).id,
472
- appName: gBundle.appName,
473
- tag: (viewModel.data! as any).tag,
474
- name: (viewModel.data! as any).name,
475
- config: config,
476
- group: (viewModel.data! as any).group,
477
- page_config: (viewModel.data! as any).page_config,
478
- page_type: (viewModel.data! as any).page_type,
479
- preview_image: (viewModel.data! as any).preview_image,
480
- favorite: (viewModel.data! as any).favorite,
481
- }).then((api) => {
482
- resolve(result && api.result);
483
- });
482
+ if(glitter.getUrlParameter('page').startsWith('pages')){
483
+ Article.get({
484
+ page: 0,
485
+ limit: 1,
486
+ tag: glitter.getUrlParameter('page').split('/')[1]
487
+ }).then(async (data) => {
488
+ data.response.data[0].content.config=config
489
+ Article.put(data.response.data[0]).then((response)=>{
490
+ resolve(response && response.result);
491
+ })
492
+ })
493
+ }else{
494
+ ApiPageConfig.setPage({
495
+ id: (viewModel.data! as any).id,
496
+ appName: gBundle.appName,
497
+ tag: (viewModel.data! as any).tag,
498
+ name: (viewModel.data! as any).name,
499
+ config: config,
500
+ group: (viewModel.data! as any).group,
501
+ page_config: (viewModel.data! as any).page_config,
502
+ page_type: (viewModel.data! as any).page_type,
503
+ preview_image: (viewModel.data! as any).preview_image,
504
+ favorite: (viewModel.data! as any).favorite,
505
+ }).then((api) => {
506
+ resolve(result && api.result);
507
+ });
508
+ }
484
509
  });
485
510
  }
486
511
  },
@@ -497,13 +522,13 @@ console.log(`start-load:==>load`)
497
522
  ];
498
523
  for (const a of waitSave) {
499
524
  if (!(await a())) {
500
- dialog.dataLoading({visible:false})
501
- dialog.errorMessage({text:'伺服器錯誤'})
525
+ dialog.dataLoading({visible: false})
526
+ dialog.errorMessage({text: '伺服器錯誤'})
502
527
  return;
503
528
  }
504
529
  }
505
- dialog.dataLoading({visible:false})
506
- dialog.successMessage({text:'儲存成功'})
530
+ dialog.dataLoading({visible: false})
531
+ dialog.successMessage({text: '儲存成功'})
507
532
  if (refresh) {
508
533
  viewModel.originalConfig = JSON.parse(JSON.stringify(viewModel.appConfig));
509
534
  (window as any).preloadData = {};
@@ -660,13 +685,14 @@ ${Storage.page_setting_item === `${da.index}` ? `background:${EditorConfig.edito
660
685
  //內容編輯模式不允許特定頁面,自動重導向。
661
686
  if (Storage.select_function === 'user-editor') {
662
687
  if (!viewModel.data.page_config || viewModel.data.page_config.support_editor !== 'true') {
663
- const redirect = viewModel.dataList.find((dd: any) => {
664
- return dd.page_config && dd.page_config.support_editor === 'true';
665
- });
666
- if (redirect) {
667
- const url = new URL(glitter.root_path + `${redirect.tag}${location.search}`);
668
- location.href = url.href;
669
- }
688
+ console.log(glitter.root_path)
689
+ // const redirect = viewModel.dataList.find((dd: any) => {
690
+ // return dd.page_config && dd.page_config.support_editor === 'true';
691
+ // });
692
+ // if (redirect) {
693
+ // const url = new URL(glitter.root_path + `${redirect.tag}${location.search}`);
694
+ // location.href = url.href;
695
+ // }
670
696
  }
671
697
  }
672
698
  return Main_editor.left(gvc, viewModel, editorContainerID, gBundle);
@@ -739,7 +765,7 @@ ${Storage.page_setting_item === `${da.index}` ? `background:${EditorConfig.edito
739
765
  switch (Storage.select_function) {
740
766
  case 'backend-manger': {
741
767
  let bgGuide = new BgGuide(gvc, 0);
742
- if (document.body.clientWidth>1000){
768
+ if (document.body.clientWidth > 1000) {
743
769
 
744
770
  ApiShop.getGuideable().then(r => {
745
771
  if (!r.response.value || !r.response.value.view) {
@@ -751,7 +777,7 @@ ${Storage.page_setting_item === `${da.index}` ? `background:${EditorConfig.edito
751
777
  }
752
778
  case 'user-editor': {
753
779
  ApiShop.getFEGuideable().then(r => {
754
- console.log( " r--- " , r)
780
+ console.log(" r--- ", r)
755
781
  if (!r.response.value || !r.response.value.view) {
756
782
  // bgGuide.drawGuide();
757
783
 
@@ -777,6 +803,21 @@ ${Storage.page_setting_item === `${da.index}` ? `background:${EditorConfig.edito
777
803
 
778
804
  function initialEditor(gvc: GVC, viewModel: any) {
779
805
  const glitter = gvc.glitter;
806
+ //跳轉至編輯器頁面功能
807
+ glitter.share.switch_to_web_builder=(page:string)=>{
808
+ glitter.setUrlParameter('function','user-editor');
809
+ glitter.changePage(
810
+ 'jspage/main.js',
811
+ page,
812
+ true,
813
+ {
814
+ appName: (window.parent as any).glitter.getUrlParameter('appName'),
815
+ },
816
+ {
817
+ backGroundColor: `transparent;`,
818
+ }
819
+ )
820
+ }
780
821
  //續費功能
781
822
  glitter.share.subscription = async (title: string) => {
782
823
  const dialog = new ShareDialog(glitter)
@@ -822,13 +863,13 @@ function initialEditor(gvc: GVC, viewModel: any) {
822
863
  case '旗艦電商方案':
823
864
  return 'flagship-year'
824
865
  }
825
- return ``
866
+ return ``
826
867
  })()
827
868
  if (gvc.glitter.deviceType === gvc.glitter.deviceTypeEnum.Ios) {
828
869
  dialog.dataLoading({visible: true});
829
870
  gvc.glitter.runJsInterFace("in_app_product", {
830
- total: `${sku.replace('-','_')}_apple`,
831
- qty:(()=>{
871
+ total: `${sku.replace('-', '_')}_apple`,
872
+ qty: (() => {
832
873
  switch (title) {
833
874
  case '輕便電商方案':
834
875
  return 1
@@ -845,11 +886,11 @@ function initialEditor(gvc: GVC, viewModel: any) {
845
886
  }, async (res) => {
846
887
  console.log(`res.receipt_data=>`, res.receipt_data);
847
888
  if (res.receipt_data) {
848
- await ApiShop.app_subscription(res.receipt_data,(window as any).appName);
889
+ await ApiShop.app_subscription(res.receipt_data, (window as any).appName);
849
890
  window.parent.location.reload();
850
891
  } else {
851
892
  dialog.dataLoading({visible: false});
852
- dialog.errorMessage({text:'儲值失敗'})
893
+ dialog.errorMessage({text: '儲值失敗'})
853
894
  }
854
895
  })
855
896
  return
@@ -975,7 +1016,7 @@ function initialEditor(gvc: GVC, viewModel: any) {
975
1016
  window.parent.location.reload()
976
1017
  })
977
1018
  } else {
978
- (window as any).$('body').append(`<div id="${id}" style="display: none;">${res.response.form}</div>`);
1019
+ (window as any).$('body').append(`<div id="${id}" style="display: none;">${res.response.form}</div>`);
979
1020
  (window as any).document.querySelector(`#${id} #submit`).click();
980
1021
  }
981
1022
  gvc.closeDialog()
@@ -1109,8 +1150,8 @@ function initialEditor(gvc: GVC, viewModel: any) {
1109
1150
  //添加Component至當前頁面
1110
1151
  glitter.share.addComponent = (data: any) => {
1111
1152
  glitter.share.loading_dialog.dataLoading({text: '模組添加中...', visible: true})
1112
- if(gvc.glitter.getUrlParameter('toggle-message')==='true'){
1113
- gvc.glitter.setUrlParameter('toggle-message',undefined)
1153
+ if (gvc.glitter.getUrlParameter('toggle-message') === 'true') {
1154
+ gvc.glitter.setUrlParameter('toggle-message', undefined)
1114
1155
  BgCustomerMessage.toggle(true, gvc);
1115
1156
  }
1116
1157
  if (!viewModel.selectContainer) {
@@ -1048,6 +1048,11 @@ font-weight: 700;" onclick="${gvc.event(() => {
1048
1048
  const array_string = [html `
1049
1049
  <div class="hoverF2 d-flex align-items-center p-3 guide-user-editor-8"
1050
1050
  onclick="${gvc.event(() => {
1051
+ if (vm_c.toggle) {
1052
+ vm_c.toggle = false;
1053
+ gvc.notifyDataChange(vm_c.id);
1054
+ return;
1055
+ }
1051
1056
  setting_option.map((dd) => {
1052
1057
  if (dd.vm_c.toggle) {
1053
1058
  dd.vm_c.toggle = false;
@@ -1076,6 +1076,11 @@ font-weight: 700;" onclick="${gvc.event(() => {
1076
1076
  const array_string = [html`
1077
1077
  <div class="hoverF2 d-flex align-items-center p-3 guide-user-editor-8"
1078
1078
  onclick="${gvc.event(() => {
1079
+ if( vm_c.toggle){
1080
+ vm_c.toggle=false
1081
+ gvc.notifyDataChange(vm_c.id)
1082
+ return
1083
+ }
1079
1084
  (setting_option as any).map((dd: any) => {
1080
1085
  if (dd.vm_c.toggle) {
1081
1086
  dd.vm_c.toggle = false