ts-glitter 21.4.5 → 21.4.7

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.
@@ -28,6 +28,7 @@ export class Blogs01 {
28
28
  class: `${bid}`,
29
29
  },
30
30
  onCreate: () => __awaiter(this, void 0, void 0, function* () {
31
+ var _a;
31
32
  if (!initial) {
32
33
  try {
33
34
  initial = true;
@@ -39,136 +40,159 @@ export class Blogs01 {
39
40
  });
40
41
  })
41
42
  ]);
43
+ let ogHeaderView = new gvc.glitter.htmlGenerate(o_header.response.result[0].config, [], {}).render(gvc, {
44
+ class: `w-100`,
45
+ style: `position:relative;`,
46
+ containerID: gvc.glitter.getUUID(),
47
+ tag: gvc.glitter.getUUID(),
48
+ jsFinish: () => { },
49
+ onCreate: () => { },
50
+ document: document,
51
+ }, {});
42
52
  console.log(`o_header===>`, o_header);
43
- subData.content.config = subData.content.config.filter((dd) => dd.data.tag !== 'c_header');
44
- const view = (() => {
45
- if (subData.content.generator !== 'page_editor') {
46
- const dd = subData.content;
47
- return html ` <div
53
+ console.log(`subData===>`, subData);
54
+ subData.content.config = (_a = subData.content.config) !== null && _a !== void 0 ? _a : [];
55
+ try {
56
+ subData.content.config = subData.content.config.filter((dd) => dd.data.tag !== 'c_header');
57
+ const view = (() => {
58
+ if (subData.content.generator !== 'page_editor') {
59
+ const dd = subData.content;
60
+ return html ` <div
48
61
  class="container mx-auto fr-view mb-5"
49
62
  style="max-width: 1100px;font-family: 'Source Sans Pro', 'Open Sans', 'Helvetica Neue', Helvetica, Arial, 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', 'STHeiti', 'WenQuanYi Micro Hei', SimSun, sans-serif;"
50
63
  >
51
64
  <h1
52
65
  class="my-5 w-100 text-center p-0"
53
66
  style="color:${subData.content.title};font-size:${document.body.clientWidth > 800
54
- ? `32px`
55
- : `24px`};font-weight: 600;"
67
+ ? `32px`
68
+ : `24px`};font-weight: 600;"
56
69
  >
57
70
  ${(dd.language_data && dd.language_data[Language.getLanguage()].title) || dd.title}
58
71
  </h1>
59
72
  ${(dd.language_data && dd.language_data[Language.getLanguage()].text) || dd.text}
60
73
  </div>`;
61
- }
62
- else {
63
- function startRender() {
64
- if (subData.content.relative_data &&
65
- ['shopping', 'hidden'].includes(subData.content.page_type) &&
66
- localStorage.getItem('block-refresh-cart') !== 'true') {
67
- const clock = gvc.glitter.ut.clock();
68
- const interVal = setInterval(() => {
69
- if (clock.stop() < 2000) {
70
- new ApiCart(ApiCart.globalCart).setCart(cart => {
71
- subData.content.relative_data.map((dd) => {
72
- const line_item = cart.line_items.find((d1) => {
73
- return (`${d1.id}-${d1.spec.join('-')}` === `${dd.product_id}-${dd.variant.spec.join('-')}`);
74
- });
75
- if (!line_item) {
76
- cart.line_items.push({
77
- id: dd.product_id,
78
- spec: dd.variant.spec,
79
- count: 1,
74
+ }
75
+ else {
76
+ function startRender() {
77
+ if (subData.content.relative_data &&
78
+ ['shopping', 'hidden'].includes(subData.content.page_type) &&
79
+ localStorage.getItem('block-refresh-cart') !== 'true') {
80
+ const clock = gvc.glitter.ut.clock();
81
+ const interVal = setInterval(() => {
82
+ if (clock.stop() < 2000) {
83
+ new ApiCart(ApiCart.globalCart).setCart(cart => {
84
+ subData.content.relative_data.map((dd) => {
85
+ const line_item = cart.line_items.find((d1) => {
86
+ return (`${d1.id}-${d1.spec.join('-')}` === `${dd.product_id}-${dd.variant.spec.join('-')}`);
80
87
  });
81
- }
88
+ if (!line_item) {
89
+ cart.line_items.push({
90
+ id: dd.product_id,
91
+ spec: dd.variant.spec,
92
+ count: 1,
93
+ });
94
+ }
95
+ });
82
96
  });
83
- });
84
- }
85
- else {
86
- gvc.notifyDataChange(['js-cart-count']);
87
- gvc.glitter.share.reloadCartData && gvc.glitter.share.reloadCartData();
88
- if (document.querySelector('.customer-message')) {
89
- document.querySelector('.customer-message').remove();
90
97
  }
91
- clearInterval(interVal);
92
- }
93
- }, 300);
94
- }
95
- else {
96
- localStorage.setItem('block-refresh-cart', 'false');
97
- }
98
- return new gvc.glitter.htmlGenerate(subData.content.config, [], subData.content).render(gvc, {
99
- class: `w-100`,
100
- style: `position:relative;`,
101
- containerID: gvc.glitter.getUUID(),
102
- tag: gvc.glitter.getUUID(),
103
- jsFinish: () => { },
104
- onCreate: () => { },
105
- document: document,
106
- }, {});
107
- }
108
- if (subData.content.page_type === 'hidden') {
109
- if (subData.content.show_auth.auth === 'all') {
110
- return startRender();
98
+ else {
99
+ gvc.notifyDataChange(['js-cart-count']);
100
+ gvc.glitter.share.reloadCartData && gvc.glitter.share.reloadCartData();
101
+ if (document.querySelector('.customer-message')) {
102
+ document.querySelector('.customer-message').remove();
103
+ }
104
+ clearInterval(interVal);
105
+ }
106
+ }, 300);
107
+ }
108
+ else {
109
+ localStorage.setItem('block-refresh-cart', 'false');
110
+ }
111
+ return new gvc.glitter.htmlGenerate(subData.content.config, [], subData.content).render(gvc, {
112
+ class: `w-100`,
113
+ style: `position:relative;`,
114
+ containerID: gvc.glitter.getUUID(),
115
+ tag: gvc.glitter.getUUID(),
116
+ jsFinish: () => { },
117
+ onCreate: () => { },
118
+ document: document,
119
+ }, {});
111
120
  }
112
- else if (subData.content.show_auth.auth === 'password') {
113
- if (localStorage.getItem('password_to_see_' + subData.content.tag) ===
114
- subData.content.show_auth.value) {
121
+ if (subData.content.page_type === 'hidden') {
122
+ if (subData.content.show_auth.auth === 'all') {
115
123
  return startRender();
116
124
  }
117
- return gvc.bindView(() => {
118
- const rid = gvc.glitter.getUUID();
119
- return {
120
- bind: rid,
121
- view: () => {
122
- return ``;
123
- },
124
- divCreate: {
125
- option: [{ key: 'id', value: rid }],
126
- },
127
- onCreate: () => {
128
- function checkPwd() {
129
- const pwd = window.prompt(Language.text('enter_website_password'), '');
130
- localStorage.setItem('password_to_see_' + subData.content.tag, pwd !== null && pwd !== void 0 ? pwd : '');
131
- if (subData.content.show_auth.value === pwd) {
132
- document.querySelector(`#${rid}`).outerHTML = startRender();
133
- }
134
- else {
135
- const dialog = new ShareDialog(gvc.glitter);
136
- dialog.checkYesOrNot({
137
- text: Language.text('incorrect_website_password'),
138
- callback: () => {
139
- gvc.glitter.closeDiaLog();
140
- checkPwd();
141
- },
142
- });
143
- }
144
- }
145
- checkPwd();
146
- },
147
- };
148
- });
149
- }
150
- else if (subData.content.show_auth.auth === 'member_type') {
151
- return gvc.bindView(() => {
152
- const rid = gvc.glitter.getUUID();
153
- return {
154
- bind: rid,
155
- view: () => {
156
- return ``;
157
- },
158
- divCreate: {
159
- option: [{ key: 'id', value: rid }],
160
- },
161
- onCreate: () => {
162
- const dialog = new ShareDialog(gvc.glitter);
163
- UmClass.getUserData(gvc).then((resp) => {
164
- try {
165
- const mem = resp.member.find((d) => {
166
- return d.trigger;
167
- });
168
- if (subData.content.show_auth.value.includes(mem.id)) {
125
+ else if (subData.content.show_auth.auth === 'password') {
126
+ if (localStorage.getItem('password_to_see_' + subData.content.tag) ===
127
+ subData.content.show_auth.value) {
128
+ return startRender();
129
+ }
130
+ return gvc.bindView(() => {
131
+ const rid = gvc.glitter.getUUID();
132
+ return {
133
+ bind: rid,
134
+ view: () => {
135
+ return ``;
136
+ },
137
+ divCreate: {
138
+ option: [{ key: 'id', value: rid }],
139
+ },
140
+ onCreate: () => {
141
+ function checkPwd() {
142
+ const pwd = window.prompt(Language.text('enter_website_password'), '');
143
+ localStorage.setItem('password_to_see_' + subData.content.tag, pwd !== null && pwd !== void 0 ? pwd : '');
144
+ if (subData.content.show_auth.value === pwd) {
169
145
  document.querySelector(`#${rid}`).outerHTML = startRender();
170
146
  }
171
147
  else {
148
+ const dialog = new ShareDialog(gvc.glitter);
149
+ dialog.checkYesOrNot({
150
+ text: Language.text('incorrect_website_password'),
151
+ callback: () => {
152
+ gvc.glitter.closeDiaLog();
153
+ checkPwd();
154
+ },
155
+ });
156
+ }
157
+ }
158
+ checkPwd();
159
+ },
160
+ };
161
+ });
162
+ }
163
+ else if (subData.content.show_auth.auth === 'member_type') {
164
+ return gvc.bindView(() => {
165
+ const rid = gvc.glitter.getUUID();
166
+ return {
167
+ bind: rid,
168
+ view: () => {
169
+ return ``;
170
+ },
171
+ divCreate: {
172
+ option: [{ key: 'id', value: rid }],
173
+ },
174
+ onCreate: () => {
175
+ const dialog = new ShareDialog(gvc.glitter);
176
+ UmClass.getUserData(gvc).then((resp) => {
177
+ try {
178
+ const mem = resp.member.find((d) => {
179
+ return d.trigger;
180
+ });
181
+ if (subData.content.show_auth.value.includes(mem.id)) {
182
+ document.querySelector(`#${rid}`).outerHTML = startRender();
183
+ }
184
+ else {
185
+ if (GlobalUser.token) {
186
+ dialog.errorMessage({ text: Language.text('no_access_permission') });
187
+ gvc.glitter.href = '/index';
188
+ }
189
+ else {
190
+ GlobalUser.loginRedirect = location.href;
191
+ gvc.glitter.href = '/login';
192
+ }
193
+ }
194
+ }
195
+ catch (e) {
172
196
  if (GlobalUser.token) {
173
197
  dialog.errorMessage({ text: Language.text('no_access_permission') });
174
198
  gvc.glitter.href = '/index';
@@ -178,44 +202,27 @@ export class Blogs01 {
178
202
  gvc.glitter.href = '/login';
179
203
  }
180
204
  }
181
- }
182
- catch (e) {
183
- if (GlobalUser.token) {
184
- dialog.errorMessage({ text: Language.text('no_access_permission') });
185
- gvc.glitter.href = '/index';
186
- }
187
- else {
188
- GlobalUser.loginRedirect = location.href;
189
- gvc.glitter.href = '/login';
190
- }
191
- }
192
- });
193
- },
194
- };
195
- });
205
+ });
206
+ },
207
+ };
208
+ });
209
+ }
210
+ else {
211
+ return startRender();
212
+ }
196
213
  }
197
214
  else {
198
215
  return startRender();
199
216
  }
200
217
  }
201
- else {
202
- return startRender();
203
- }
204
- }
205
- })();
206
- let ogHeaderView = new gvc.glitter.htmlGenerate(o_header.response.result[0].config, [], {}).render(gvc, {
207
- class: `w-100`,
208
- style: `position:relative;`,
209
- containerID: gvc.glitter.getUUID(),
210
- tag: gvc.glitter.getUUID(),
211
- jsFinish: () => { },
212
- onCreate: () => { },
213
- document: document,
214
- }, {});
215
- document.querySelector(`.${bid}`).outerHTML = [
216
- ogHeaderView,
217
- view
218
- ].join('');
218
+ })();
219
+ document.querySelector(`.${bid}`).outerHTML = [
220
+ ogHeaderView,
221
+ view
222
+ ].join('');
223
+ }
224
+ catch (e) {
225
+ }
219
226
  initial = true;
220
227
  }
221
228
  catch (e) {
@@ -12,6 +12,7 @@ const html = String.raw;
12
12
 
13
13
  export class Blogs01 {
14
14
  static main(gvc: GVC, subData: any) {
15
+
15
16
  let initial = false;
16
17
  return gvc.bindView(() => {
17
18
  const bid = gvc.glitter.getUUID();
@@ -36,8 +37,26 @@ export class Blogs01 {
36
37
  })
37
38
  })
38
39
  ]);
40
+ //取得HeaderView
41
+ let ogHeaderView = new gvc.glitter.htmlGenerate(o_header.response.result[0].config, [], {}).render(
42
+ gvc,
43
+ {
44
+ class: `w-100`,
45
+ style: `position:relative;`,
46
+ containerID: gvc.glitter.getUUID(),
47
+ tag: gvc.glitter.getUUID(),
48
+ jsFinish: () => {},
49
+ onCreate: () => {},
50
+ document: document,
51
+ },
52
+ {}
53
+ );
54
+
39
55
  console.log(`o_header===>`,o_header)
40
- subData.content.config=subData.content.config.filter((dd:any)=> dd.data.tag!=='c_header')
56
+ console.log(`subData===>`,subData)
57
+ subData.content.config=subData.content.config??[]
58
+ try {
59
+ subData.content.config=subData.content.config.filter((dd:any)=> dd.data.tag!=='c_header')
41
60
  //pages的自訂View
42
61
  const view = (() => {
43
62
  if (subData.content.generator !== 'page_editor') {
@@ -49,8 +68,8 @@ export class Blogs01 {
49
68
  <h1
50
69
  class="my-5 w-100 text-center p-0"
51
70
  style="color:${subData.content.title};font-size:${document.body.clientWidth > 800
52
- ? `32px`
53
- : `24px`};font-weight: 600;"
71
+ ? `32px`
72
+ : `24px`};font-weight: 600;"
54
73
  >
55
74
  ${(dd.language_data && dd.language_data[Language.getLanguage()].title) || dd.title}
56
75
  </h1>
@@ -203,20 +222,6 @@ export class Blogs01 {
203
222
  }
204
223
  }
205
224
  })();
206
- //取得HeaderView
207
- let ogHeaderView = new gvc.glitter.htmlGenerate(o_header.response.result[0].config, [], {}).render(
208
- gvc,
209
- {
210
- class: `w-100`,
211
- style: `position:relative;`,
212
- containerID: gvc.glitter.getUUID(),
213
- tag: gvc.glitter.getUUID(),
214
- jsFinish: () => {},
215
- onCreate: () => {},
216
- document: document,
217
- },
218
- {}
219
- );
220
225
  // //判斷有自訂Header調整自訂選單內容
221
226
  // if (c_header.response.value && c_header.response.value[0] && c_header.response.value[0].header_refer!=='def') {
222
227
  // ogHeaderView=new gvc.glitter.htmlGenerate([c_header.response.value[0]], [], {}).render(
@@ -237,6 +242,9 @@ export class Blogs01 {
237
242
  ogHeaderView,
238
243
  view
239
244
  ].join('');
245
+ }catch (e) {
246
+
247
+ }
240
248
  initial = true;
241
249
  } catch (e) {
242
250
  console.log(e)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-glitter",
3
- "version": "21.4.5",
3
+ "version": "21.4.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {