ts-glitter 16.2.4 → 16.2.6
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/package.json +5 -2
- package/src/api-public/services/shopping.d.ts +1 -1
- package/src/helper/glitter-util.d.ts +0 -1
- package/src/helper/glitter-util.js +19 -11
- package/src/helper/glitter-util.js.map +1 -1
- package/src/helper/glitter-util.ts +20 -11
- package/src/index.js +107 -346
- package/src/index.js.map +1 -1
- package/src/index.ts +145 -395
- package/src/seo-config.d.ts +45 -0
- package/src/seo-config.js +307 -0
- package/src/seo-config.js.map +1 -0
- package/src/seo-config.ts +358 -0
package/src/index.js
CHANGED
|
@@ -66,9 +66,9 @@ const ai_js_1 = require("./services/ai.js");
|
|
|
66
66
|
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
67
67
|
const express_session_1 = __importDefault(require("express-session"));
|
|
68
68
|
const monitor_js_1 = require("./api-public/services/monitor.js");
|
|
69
|
-
const manager_js_1 = require("./api-public/services/manager.js");
|
|
70
69
|
const sitemap_1 = require("sitemap");
|
|
71
70
|
const stream_1 = require("stream");
|
|
71
|
+
const seo_config_js_1 = require("./seo-config.js");
|
|
72
72
|
exports.app = (0, express_1.default)();
|
|
73
73
|
const logger = new logger_1.default();
|
|
74
74
|
exports.app.options('/*', (req, res) => {
|
|
@@ -135,61 +135,7 @@ async function createAppRoute() {
|
|
|
135
135
|
await createAPP(dd);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
function extractCols(data) {
|
|
139
|
-
const items = [];
|
|
140
|
-
const updated_at = new Date(data.updated_at).toISOString().replace(/\.\d{3}Z$/, '+00:00');
|
|
141
|
-
data.value.map((item) => {
|
|
142
|
-
items.push({
|
|
143
|
-
code: item.code,
|
|
144
|
-
updated_at,
|
|
145
|
-
seo_title: item.seo_title,
|
|
146
|
-
seo_image: item.seo_image,
|
|
147
|
-
seo_content: item.seo_content,
|
|
148
|
-
});
|
|
149
|
-
if (item.array && item.array.length > 0) {
|
|
150
|
-
item.array.map((child) => {
|
|
151
|
-
items.push({
|
|
152
|
-
code: child.code,
|
|
153
|
-
updated_at,
|
|
154
|
-
seo_title: child.seo_title,
|
|
155
|
-
seo_image: child.seo_image,
|
|
156
|
-
seo_content: child.seo_content,
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return items;
|
|
162
|
-
}
|
|
163
|
-
function extractProds(data) {
|
|
164
|
-
const items = [];
|
|
165
|
-
data.map((item) => {
|
|
166
|
-
const code = (() => {
|
|
167
|
-
try {
|
|
168
|
-
return item.content.seo.domain;
|
|
169
|
-
}
|
|
170
|
-
catch (error) {
|
|
171
|
-
return '';
|
|
172
|
-
}
|
|
173
|
-
})();
|
|
174
|
-
const updated_at = new Date(item.updated_time).toISOString().replace(/\.\d{3}Z$/, '+00:00');
|
|
175
|
-
items.push({ code, updated_at });
|
|
176
|
-
});
|
|
177
|
-
return items;
|
|
178
|
-
}
|
|
179
138
|
exports.app.set('trust proxy', true);
|
|
180
|
-
function isCurrentTimeWithinRange(data) {
|
|
181
|
-
const now = new Date();
|
|
182
|
-
now.setTime(now.getTime() + 8 * 3600 * 1000);
|
|
183
|
-
const startDateTime = new Date(`${data.startDate}T${data.startTime}`);
|
|
184
|
-
const hasEnd = data.endDate && data.endTime;
|
|
185
|
-
const endDateTime = hasEnd ? new Date(`${data.endDate}T${data.endTime}`) : null;
|
|
186
|
-
if (hasEnd) {
|
|
187
|
-
return now >= startDateTime && now <= endDateTime;
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
return now >= startDateTime;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
139
|
async function createAPP(dd) {
|
|
194
140
|
const html = String.raw;
|
|
195
141
|
live_source_1.Live_source.liveAPP.push(dd.appName);
|
|
@@ -202,7 +148,7 @@ async function createAPP(dd) {
|
|
|
202
148
|
app_name: dd.appName,
|
|
203
149
|
root_path: '/' + encodeURI(dd.appName) + '/',
|
|
204
150
|
seoManager: async (req) => {
|
|
205
|
-
var _a, _b, _c, _d, _e, _f
|
|
151
|
+
var _a, _b, _c, _d, _e, _f;
|
|
206
152
|
try {
|
|
207
153
|
if (req.query.state === 'google_login') {
|
|
208
154
|
req.query.page = 'login';
|
|
@@ -214,7 +160,8 @@ async function createAPP(dd) {
|
|
|
214
160
|
req.headers['g-app'] = appName;
|
|
215
161
|
const start = new Date().getTime();
|
|
216
162
|
console.log(`getPageInfo==>`, (new Date().getTime() - start) / 1000);
|
|
217
|
-
let
|
|
163
|
+
let seo_content = [];
|
|
164
|
+
let [customCode, FBCode, store_info, language_label, check_schema, brandAndMemberType, login_config, ip_country] = await Promise.all([new user_js_1.User(appName).getConfigV2({
|
|
218
165
|
key: 'ga4_config',
|
|
219
166
|
user_id: 'manager',
|
|
220
167
|
}), new user_js_1.User(appName).getConfigV2({
|
|
@@ -226,52 +173,17 @@ async function createAPP(dd) {
|
|
|
226
173
|
}), new user_js_1.User(appName).getConfigV2({
|
|
227
174
|
key: 'language-label',
|
|
228
175
|
user_id: 'manager',
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return `${req.query.page}`.startsWith(`${lan}/`) || req.query.page === lan;
|
|
236
|
-
}
|
|
237
|
-
function replace(lan) {
|
|
238
|
-
if (req.query.page === lan) {
|
|
239
|
-
req.query.page = '';
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
req.query.page = `${req.query.page}`.replace(lan + '/', '');
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (checkEqual('en') && checkIncludes('en-US')) {
|
|
246
|
-
replace('en');
|
|
247
|
-
return `en-US`;
|
|
248
|
-
}
|
|
249
|
-
else if (checkEqual('cn') && checkIncludes('zh-CN')) {
|
|
250
|
-
replace('cn');
|
|
251
|
-
return `zh-CN`;
|
|
252
|
-
}
|
|
253
|
-
else if (checkEqual('tw') && checkIncludes('zh-TW')) {
|
|
254
|
-
replace('tw');
|
|
255
|
-
return `zh-TW`;
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
return store_info.language_setting.def;
|
|
259
|
-
}
|
|
260
|
-
})();
|
|
261
|
-
console.log(`req.query.page===>`, req.query.page);
|
|
176
|
+
}), public_table_check_js_1.ApiPublic.createScheme(appName),
|
|
177
|
+
app_js_1.App.checkBrandAndMemberType(appName), new user_js_1.User(req.get('g-app'), req.body.token).getConfigV2({
|
|
178
|
+
key: 'login_config',
|
|
179
|
+
user_id: 'manager',
|
|
180
|
+
}), user_js_1.User.ipInfo((req.query.ip || req.headers['x-real-ip'] || req.ip))]);
|
|
181
|
+
const language = await seo_config_js_1.SeoConfig.language(store_info, req);
|
|
262
182
|
monitor_js_1.Monitor.insertHistory({
|
|
263
183
|
req_type: 'file',
|
|
264
184
|
req: req,
|
|
265
185
|
});
|
|
266
|
-
console.log(`
|
|
267
|
-
await public_table_check_js_1.ApiPublic.createScheme(appName);
|
|
268
|
-
console.log(`createScheme==>`, (new Date().getTime() - start) / 1000);
|
|
269
|
-
const brandAndMemberType = await app_js_1.App.checkBrandAndMemberType(appName);
|
|
270
|
-
console.log(`brandAndMemberType==>`, (new Date().getTime() - start) / 1000);
|
|
271
|
-
const login_config = await new user_js_1.User(req.get('g-app'), req.body.token).getConfigV2({
|
|
272
|
-
key: 'login_config',
|
|
273
|
-
user_id: 'manager',
|
|
274
|
-
});
|
|
186
|
+
console.log(`req.query.page==>`, req.query.page);
|
|
275
187
|
let data = await seo_js_1.Seo.getPageInfo(appName, req.query.page, language);
|
|
276
188
|
let home_page_data = await (async () => {
|
|
277
189
|
if (data && data.config) {
|
|
@@ -281,67 +193,40 @@ async function createAPP(dd) {
|
|
|
281
193
|
return await seo_js_1.Seo.getPageInfo(appName, 'index', language);
|
|
282
194
|
}
|
|
283
195
|
})();
|
|
196
|
+
console.log(`req.query.page==>`, req.query.page);
|
|
284
197
|
if (data && data.page_config) {
|
|
285
198
|
data.page_config = (_a = data.page_config) !== null && _a !== void 0 ? _a : {};
|
|
286
199
|
const d = (_b = data.page_config.seo) !== null && _b !== void 0 ? _b : {};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
: {
|
|
297
|
-
page: 0,
|
|
298
|
-
limit: 1,
|
|
299
|
-
id: req.query.product_id,
|
|
300
|
-
language: language,
|
|
301
|
-
});
|
|
302
|
-
if (pd.data.content) {
|
|
303
|
-
pd.data.content.language_data = (_c = pd.data.content.language_data) !== null && _c !== void 0 ? _c : {};
|
|
304
|
-
const productSeo = (pd.data.content.language_data[language] && pd.data.content.language_data[language].seo) || ((_d = pd.data.content.seo) !== null && _d !== void 0 ? _d : {});
|
|
305
|
-
data = await seo_js_1.Seo.getPageInfo(appName, data.config.homePage, language);
|
|
306
|
-
data.page_config = (_e = data.page_config) !== null && _e !== void 0 ? _e : {};
|
|
307
|
-
data.page_config.seo = (_f = data.page_config.seo) !== null && _f !== void 0 ? _f : {};
|
|
308
|
-
data.page_config.seo.title = productSeo.title;
|
|
309
|
-
data.page_config.seo.image = pd.data.content.preview_image[0];
|
|
310
|
-
data.page_config.seo.content = productSeo.content;
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
data = await seo_js_1.Seo.getPageInfo(appName, data.config.homePage, language);
|
|
314
|
-
}
|
|
200
|
+
console.log(`req.query.page`);
|
|
201
|
+
if (`${req.query.page}`.startsWith('products/')) {
|
|
202
|
+
await seo_config_js_1.SeoConfig.productSEO({
|
|
203
|
+
data,
|
|
204
|
+
language,
|
|
205
|
+
appName,
|
|
206
|
+
product_id: req.query.product_id,
|
|
207
|
+
page: (req.query.page)
|
|
208
|
+
});
|
|
315
209
|
}
|
|
316
|
-
else if (
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
210
|
+
else if (`${req.query.page}`.startsWith('blogs/')) {
|
|
211
|
+
await seo_config_js_1.SeoConfig.articleSeo({
|
|
212
|
+
article: req.query.article,
|
|
213
|
+
page: req.query.page,
|
|
214
|
+
language, appName, data
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
else if (`${req.query.page}`.startsWith('pages/')) {
|
|
218
|
+
await seo_config_js_1.SeoConfig.articleSeo({
|
|
219
|
+
article: req.query.article,
|
|
220
|
+
page: req.query.page,
|
|
221
|
+
language, appName, data
|
|
322
222
|
});
|
|
323
|
-
data = await seo_js_1.Seo.getPageInfo(appName, data.config.homePage, language);
|
|
324
|
-
data.page_config = (_g = data.page_config) !== null && _g !== void 0 ? _g : {};
|
|
325
|
-
data.page_config.seo = (_h = data.page_config.seo) !== null && _h !== void 0 ? _h : {};
|
|
326
|
-
if (article.data[0]) {
|
|
327
|
-
if (article.data[0].content.language_data && article.data[0].content.language_data[language]) {
|
|
328
|
-
data.page_config.seo.title = article.data[0].content.language_data[language].seo.title;
|
|
329
|
-
data.page_config.seo.content = article.data[0].content.language_data[language].seo.content;
|
|
330
|
-
data.page_config.seo.keywords = article.data[0].content.language_data[language].seo.keywords;
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
data.page_config.seo.title = article.data[0].content.seo.title;
|
|
334
|
-
data.page_config.seo.content = article.data[0].content.seo.content;
|
|
335
|
-
data.page_config.seo.keywords = article.data[0].content.seo.keywords;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
223
|
}
|
|
339
224
|
else if (d.type !== 'custom') {
|
|
340
225
|
data = home_page_data;
|
|
341
226
|
}
|
|
342
227
|
const preload = req.query.isIframe === 'true' ? {} : await app_js_1.App.preloadPageData(appName, req.query.page, language);
|
|
343
|
-
data.page_config = (
|
|
344
|
-
data.page_config.seo = (
|
|
228
|
+
data.page_config = (_c = data.page_config) !== null && _c !== void 0 ? _c : {};
|
|
229
|
+
data.page_config.seo = (_d = data.page_config.seo) !== null && _d !== void 0 ? _d : {};
|
|
345
230
|
const seo_detail = await getSeoDetail(appName, req);
|
|
346
231
|
if (seo_detail) {
|
|
347
232
|
Object.keys(seo_detail).map((dd) => {
|
|
@@ -368,100 +253,36 @@ async function createAPP(dd) {
|
|
|
368
253
|
`;
|
|
369
254
|
}
|
|
370
255
|
if (req.query.page.split('/')[0] === 'distribution' && req.query.page.split('/')[1]) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const article = await new ut_database_js_1.UtDatabase(appName, `t_manager_post`).querySql(query, {
|
|
380
|
-
page: 0,
|
|
381
|
-
limit: 1,
|
|
382
|
-
});
|
|
383
|
-
data = await seo_js_1.Seo.getPageInfo(appName, data.config.homePage, language);
|
|
384
|
-
data.page_config = (_l = data.page_config) !== null && _l !== void 0 ? _l : {};
|
|
385
|
-
data.page_config.seo = (_m = data.page_config.seo) !== null && _m !== void 0 ? _m : {};
|
|
386
|
-
if (article.data[0]) {
|
|
387
|
-
if (article.data[0].content.language_data[language]) {
|
|
388
|
-
data.page_config.seo.title = article.data[0].content.language_data[language].seo.title;
|
|
389
|
-
data.page_config.seo.content = article.data[0].content.language_data[language].seo.content;
|
|
390
|
-
data.page_config.seo.keywords = article.data[0].content.language_data[language].seo.keywords;
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
data.page_config.seo.title = article.data[0].content.seo.title;
|
|
394
|
-
data.page_config.seo.content = article.data[0].content.seo.content;
|
|
395
|
-
data.page_config.seo.keywords = article.data[0].content.seo.keywords;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
distribution_code = `
|
|
399
|
-
localStorage.setItem('distributionCode','${page.code}');
|
|
400
|
-
location.href = '${link_prefix ? `/` : ``}${link_prefix}${page.redirect}${redURL.search}';
|
|
401
|
-
`;
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
distribution_code = `
|
|
405
|
-
location.href = '/';
|
|
406
|
-
`;
|
|
407
|
-
}
|
|
256
|
+
distribution_code = await seo_config_js_1.SeoConfig.distributionSEO({
|
|
257
|
+
appName: appName,
|
|
258
|
+
url: req.url,
|
|
259
|
+
page: req.query.page,
|
|
260
|
+
link_prefix: link_prefix,
|
|
261
|
+
data,
|
|
262
|
+
language
|
|
263
|
+
});
|
|
408
264
|
}
|
|
409
265
|
if (req.query.page.split('/')[0] === 'collections' && req.query.page.split('/')[1]) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}))[0]) !== null && _o !== void 0 ? _o : {};
|
|
415
|
-
const colJson = extractCols(cols);
|
|
416
|
-
const urlCode = decodeURI(req.query.page.split('/')[1]);
|
|
417
|
-
const colData = colJson.find((item) => item.code === urlCode);
|
|
418
|
-
if (colData) {
|
|
419
|
-
data.page_config.seo.title = colData.seo_title;
|
|
420
|
-
data.page_config.seo.content = colData.seo_content;
|
|
421
|
-
data.page_config.seo.keywords = colData.seo_keywords;
|
|
422
|
-
}
|
|
266
|
+
await seo_config_js_1.SeoConfig.collectionSeo({ appName, language, data, page: req.query.page });
|
|
267
|
+
}
|
|
268
|
+
if (FBCode) {
|
|
269
|
+
seo_content.push(seo_config_js_1.SeoConfig.fbCode(FBCode));
|
|
423
270
|
}
|
|
424
271
|
return html `${(() => {
|
|
425
272
|
var _a;
|
|
426
273
|
const d = data.page_config.seo;
|
|
427
274
|
const home_seo = home_page_data.page_config.seo;
|
|
428
275
|
return html `
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
var _a, _b, _c, _d, _e;
|
|
276
|
+
${(() => {
|
|
277
|
+
var _a, _b, _c;
|
|
432
278
|
if (req.query.type === 'editor') {
|
|
433
|
-
return
|
|
434
|
-
<link rel="canonical" href="/index"/>
|
|
435
|
-
<meta name="keywords" content="SHOPNEX,電商平台"/>
|
|
436
|
-
<link
|
|
437
|
-
id="appImage"
|
|
438
|
-
rel="shortcut icon"
|
|
439
|
-
href="https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/size1440_s*px$_sas0s9s0s1sesas0_1697354801736-Glitterlogo.png"
|
|
440
|
-
type="image/x-icon"
|
|
441
|
-
/>
|
|
442
|
-
<link
|
|
443
|
-
rel="icon"
|
|
444
|
-
href="https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/size1440_s*px$_sas0s9s0s1sesas0_1697354801736-Glitterlogo.png"
|
|
445
|
-
type="image/png"
|
|
446
|
-
sizes="128x128"
|
|
447
|
-
/>
|
|
448
|
-
<meta property="og:image"
|
|
449
|
-
content="https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1718778766524-shopnex_banner.jpg"/>
|
|
450
|
-
<meta property="og:title" content="SHOPNEX後台系統"/>
|
|
451
|
-
<meta
|
|
452
|
-
name="description"
|
|
453
|
-
content="SHOPNEX電商開店平台,零抽成、免手續費。提供精美模板和豐富插件,操作簡單,3分鐘內快速打造專屬商店。購物車、金物流、SEO行銷、資料分析一站搞定。支援APP上架,並提供100%客製化設計,立即免費體驗30天。"
|
|
454
|
-
/>
|
|
455
|
-
<meta
|
|
456
|
-
name="og:description"
|
|
457
|
-
content="SHOPNEX電商開店平台,零抽成、免手續費。提供精美模板和豐富插件,操作簡單,3分鐘內快速打造專屬商店。購物車、金物流、SEO行銷、資料分析一站搞定。支援APP上架,並提供100%客製化設計,立即免費體驗30天。"
|
|
458
|
-
/>`;
|
|
279
|
+
return seo_config_js_1.SeoConfig.editorSeo;
|
|
459
280
|
}
|
|
460
281
|
else {
|
|
461
|
-
return html `<title>${
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
282
|
+
return html `<title>${d.title || '尚未設定標題'}</title>
|
|
283
|
+
<link
|
|
284
|
+
rel="canonical"
|
|
285
|
+
href="${(() => {
|
|
465
286
|
if (data.tag === 'index') {
|
|
466
287
|
return `https://${brandAndMemberType.domain}`;
|
|
467
288
|
}
|
|
@@ -469,25 +290,25 @@ async function createAPP(dd) {
|
|
|
469
290
|
return `https://${brandAndMemberType.domain}/${data.tag}`;
|
|
470
291
|
}
|
|
471
292
|
})()}"
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
293
|
+
/>
|
|
294
|
+
${data.tag !== req.query.page ? `<meta name="robots" content="noindex">` : `<meta name="robots" content="index, follow"/>`}
|
|
295
|
+
<meta name="keywords"
|
|
296
|
+
content="${(d.keywords || '尚未設定關鍵字').replace(/"/g, '"')}"/>
|
|
297
|
+
<link id="appImage" rel="shortcut icon"
|
|
298
|
+
href="${d.logo || home_seo.logo || ''}" type="image/x-icon"/>
|
|
299
|
+
<link rel="icon" href="${d.logo || home_seo.logo || ''}"
|
|
300
|
+
type="image/png" sizes="128x128"/>
|
|
301
|
+
<meta property="og:image" content="${d.image || home_seo.image || ''}"/>
|
|
302
|
+
<meta property="og:title"
|
|
303
|
+
content="${((_a = d.title) !== null && _a !== void 0 ? _a : '').replace(/\n/g, '').replace(/"/g, '"')}"/>
|
|
304
|
+
<meta name="description"
|
|
305
|
+
content="${((_b = d.content) !== null && _b !== void 0 ? _b : '').replace(/\n/g, '').replace(/"/g, '"')}"/>
|
|
306
|
+
<meta name="og:description"
|
|
307
|
+
content="${((_c = d.content) !== null && _c !== void 0 ? _c : '').replace(/\n/g, '').replace(/"/g, '"')}"/>`;
|
|
487
308
|
}
|
|
488
309
|
})()}
|
|
489
|
-
|
|
490
|
-
|
|
310
|
+
${(_a = d.code) !== null && _a !== void 0 ? _a : ''}
|
|
311
|
+
${(() => {
|
|
491
312
|
var _a;
|
|
492
313
|
if (req.query.type === 'editor') {
|
|
493
314
|
return ``;
|
|
@@ -498,13 +319,13 @@ async function createAPP(dd) {
|
|
|
498
319
|
try {
|
|
499
320
|
if (dd.data.elem === 'link') {
|
|
500
321
|
return html `
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
322
|
+
<link
|
|
323
|
+
type="text/css"
|
|
324
|
+
rel="stylesheet"
|
|
325
|
+
href="${dd.data.attr.find((dd) => {
|
|
505
326
|
return dd.attr === 'href';
|
|
506
327
|
}).value}"
|
|
507
|
-
|
|
328
|
+
/>`;
|
|
508
329
|
}
|
|
509
330
|
}
|
|
510
331
|
catch (e) {
|
|
@@ -514,28 +335,32 @@ async function createAPP(dd) {
|
|
|
514
335
|
.join('')}`;
|
|
515
336
|
}
|
|
516
337
|
})()}
|
|
517
|
-
</head>
|
|
518
338
|
`;
|
|
519
339
|
})()}
|
|
520
340
|
<script>
|
|
521
|
-
${
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
341
|
+
${[
|
|
342
|
+
(_e = d.custom_script) !== null && _e !== void 0 ? _e : '',
|
|
343
|
+
`window.login_config = ${JSON.stringify(login_config)};`,
|
|
344
|
+
`window.appName = '${appName}';`,
|
|
345
|
+
`window.glitterBase = '${brandAndMemberType.brand}';`,
|
|
346
|
+
`window.memberType = '${brandAndMemberType.memberType}';`,
|
|
347
|
+
`window.glitterBackend = '${config_1.config.domain}';`,
|
|
348
|
+
`window.preloadData = ${JSON.stringify(preload)
|
|
349
|
+
.replace(/<\/script>/g, 'sdjuescript_prepand')
|
|
350
|
+
.replace(/<script>/g, 'sdjuescript_prefix')};`,
|
|
351
|
+
`window.glitter_page = '${req.query.page}';`,
|
|
352
|
+
`window.store_info = ${JSON.stringify(store_info)};`,
|
|
353
|
+
`window.server_execute_time = ${(new Date().getTime() - start) / 1000};`,
|
|
354
|
+
`window.language = '${language}';`,
|
|
355
|
+
`${distribution_code}`,
|
|
356
|
+
`window.ip_country = '${(ip_country).country || 'TW'}';`,
|
|
357
|
+
`window.currency_covert = ${JSON.stringify(await shopping_js_1.Shopping.currencyCovert((req.query.base || 'TWD')))};`,
|
|
358
|
+
`window.language_list = ${JSON.stringify(language_label.label)};`
|
|
359
|
+
].map((dd) => {
|
|
360
|
+
return dd.trim();
|
|
361
|
+
}).filter((dd) => {
|
|
362
|
+
return dd;
|
|
363
|
+
}).join('\n')}
|
|
539
364
|
</script>
|
|
540
365
|
${[
|
|
541
366
|
{ src: 'glitterBundle/GlitterInitial.js', type: 'module' },
|
|
@@ -550,7 +375,7 @@ async function createAPP(dd) {
|
|
|
550
375
|
type="${dd.type}"></script>`;
|
|
551
376
|
})
|
|
552
377
|
.join('')}
|
|
553
|
-
${((
|
|
378
|
+
${((_f = preload.event) !== null && _f !== void 0 ? _f : [])
|
|
554
379
|
.filter((dd) => {
|
|
555
380
|
return dd;
|
|
556
381
|
})
|
|
@@ -564,87 +389,23 @@ async function createAPP(dd) {
|
|
|
564
389
|
type="module"></script>`;
|
|
565
390
|
})
|
|
566
391
|
.join('')}
|
|
567
|
-
</head>
|
|
568
392
|
${(() => {
|
|
569
393
|
if (req.query.type === 'editor') {
|
|
570
394
|
return ``;
|
|
571
395
|
}
|
|
572
396
|
else {
|
|
573
397
|
return html `
|
|
574
|
-
${(customCode.ga4
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
<script>
|
|
580
|
-
window.dataLayer = window.dataLayer || [];
|
|
581
|
-
|
|
582
|
-
function gtag() {
|
|
583
|
-
dataLayer.push(arguments);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
gtag('js', new Date());
|
|
587
|
-
|
|
588
|
-
gtag('config', '${dd.code}');
|
|
589
|
-
</script>`;
|
|
590
|
-
})
|
|
591
|
-
.join('')}
|
|
592
|
-
${(customCode.g_tag || [])
|
|
593
|
-
.map((dd) => {
|
|
594
|
-
return html `<!-- Google tag (gtag.js) -->
|
|
595
|
-
<!-- Google Tag Manager -->
|
|
596
|
-
<script>
|
|
597
|
-
(function (w, d, s, l, i) {
|
|
598
|
-
w[l] = w[l] || [];
|
|
599
|
-
w[l].push({
|
|
600
|
-
'gtm.start': new Date().getTime(),
|
|
601
|
-
event: 'gtm.js',
|
|
602
|
-
});
|
|
603
|
-
var f = d.getElementsByTagName(s)[0],
|
|
604
|
-
j = d.createElement(s),
|
|
605
|
-
dl = l != 'dataLayer' ? '&l=' + l : '';
|
|
606
|
-
j.async = true;
|
|
607
|
-
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
|
|
608
|
-
f.parentNode.insertBefore(j, f);
|
|
609
|
-
})(window, document, 'script', 'dataLayer', '${dd.code}');
|
|
610
|
-
</script>
|
|
611
|
-
<!-- End Google Tag Manager -->`;
|
|
612
|
-
})
|
|
613
|
-
.join('')}
|
|
614
|
-
${FBCode && FBCode.pixel
|
|
615
|
-
? html `<!-- Meta Pixel Code -->
|
|
616
|
-
<script>
|
|
617
|
-
!(function (f, b, e, v, n, t, s) {
|
|
618
|
-
if (f.fbq) return;
|
|
619
|
-
n = f.fbq = function () {
|
|
620
|
-
n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
|
|
621
|
-
};
|
|
622
|
-
if (!f._fbq) f._fbq = n;
|
|
623
|
-
n.push = n;
|
|
624
|
-
n.loaded = !0;
|
|
625
|
-
n.version = '2.0';
|
|
626
|
-
n.queue = [];
|
|
627
|
-
t = b.createElement(e);
|
|
628
|
-
t.async = !0;
|
|
629
|
-
t.src = v;
|
|
630
|
-
s = b.getElementsByTagName(e)[0];
|
|
631
|
-
s.parentNode.insertBefore(t, s);
|
|
632
|
-
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
633
|
-
fbq('init', '${FBCode.pixel}');
|
|
634
|
-
fbq('track', 'PageView');
|
|
635
|
-
</script>
|
|
636
|
-
<noscript><img height="1" width="1" style="display:none"
|
|
637
|
-
src="https://www.facebook.com/tr?id=617830100580621&ev=PageView&noscript=1"/>
|
|
638
|
-
</noscript>
|
|
639
|
-
<!-- End Meta Pixel Code -->`
|
|
640
|
-
: ''}
|
|
398
|
+
${seo_config_js_1.SeoConfig.gA4(customCode.ga4)}
|
|
399
|
+
${seo_config_js_1.SeoConfig.gTag(customCode.g_tag)}
|
|
400
|
+
${seo_content.map((dd) => {
|
|
401
|
+
return dd.trim();
|
|
402
|
+
}).join('\n')}
|
|
641
403
|
`;
|
|
642
404
|
}
|
|
643
405
|
})()}
|
|
644
406
|
`;
|
|
645
407
|
}
|
|
646
408
|
else {
|
|
647
|
-
console.log(`brandAndMemberType==>redirect`);
|
|
648
409
|
return await seo_js_1.Seo.redirectToHomePage(appName, req);
|
|
649
410
|
}
|
|
650
411
|
}
|
|
@@ -698,14 +459,14 @@ async function createAPP(dd) {
|
|
|
698
459
|
.map((d2) => {
|
|
699
460
|
return { url: `https://${domain}/${d2.url}`, changefreq: 'weekly' };
|
|
700
461
|
}),
|
|
701
|
-
...extractCols(cols)
|
|
462
|
+
...(0, seo_config_js_1.extractCols)(cols)
|
|
702
463
|
.filter((item) => {
|
|
703
464
|
return item.code;
|
|
704
465
|
})
|
|
705
466
|
.map((item) => {
|
|
706
467
|
return { url: `https://${domain}/collections/${item.code}`, changefreq: 'weekly' };
|
|
707
468
|
}),
|
|
708
|
-
...extractProds(products)
|
|
469
|
+
...(0, seo_config_js_1.extractProds)(products)
|
|
709
470
|
.filter((item) => {
|
|
710
471
|
return item.code;
|
|
711
472
|
})
|