ts-glitter 16.2.4 → 16.2.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.
- package/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/glitter-base/global/currency.d.ts +19 -0
- package/lowcode/glitter-base/global/currency.js.map +1 -0
- package/lowcode/glitter-base/global/global-user.d.ts +5 -0
- package/lowcode/glitter-base/global/global-user.js.map +1 -1
- package/lowcode/glitter-base/global/language.d.ts +22 -0
- package/lowcode/glitter-base/global/language.js.map +1 -0
- package/lowcode/glitter-base/route/shopping.d.ts +28 -2
- package/lowcode/glitter-base/route/shopping.js.map +1 -1
- package/lowcode/glitterBundle/api/base.js.map +1 -1
- package/package.json +5 -2
- package/src/api-public/services/shopping.d.ts +1 -1
- package/src/api-public/services/shopping.js +1 -0
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +1 -0
- package/src/helper/glitter-util.d.ts +4 -2
- package/src/helper/glitter-util.js +20 -11
- package/src/helper/glitter-util.js.map +1 -1
- package/src/helper/glitter-util.ts +22 -12
- package/src/index.js +255 -433
- package/src/index.js.map +1 -1
- package/src/index.ts +246 -441
- package/src/seo-config.d.ts +40 -0
- package/src/seo-config.js +303 -0
- package/src/seo-config.js.map +1 -0
- package/src/seo-config.ts +357 -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,289 +253,170 @@ 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
|
-
appName: appName,
|
|
412
|
-
key: 'collection',
|
|
413
|
-
language: language,
|
|
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 });
|
|
423
267
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
<head>
|
|
430
|
-
${(() => {
|
|
431
|
-
var _a, _b, _c, _d, _e;
|
|
432
|
-
if (req.query.type === 'editor') {
|
|
433
|
-
return html `<title>SHOPNEX後台系統</title>
|
|
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
|
-
/>`;
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
return html `<title>${(_a = d.title) !== null && _a !== void 0 ? _a : '尚未設定標題'}</title>
|
|
462
|
-
<link
|
|
463
|
-
rel="canonical"
|
|
464
|
-
href="${(() => {
|
|
465
|
-
if (data.tag === 'index') {
|
|
466
|
-
return `https://${brandAndMemberType.domain}`;
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
return `https://${brandAndMemberType.domain}/${data.tag}`;
|
|
470
|
-
}
|
|
471
|
-
})()}"
|
|
472
|
-
/>
|
|
473
|
-
${data.tag !== req.query.page ? `<meta name="robots" content="noindex">` : ``}
|
|
474
|
-
<meta name="keywords"
|
|
475
|
-
content="${((_b = d.keywords) !== null && _b !== void 0 ? _b : '尚未設定關鍵字').replace(/"/g, '"')}"/>
|
|
476
|
-
<link id="appImage" rel="shortcut icon"
|
|
477
|
-
href="${d.logo || home_seo.logo || ''}" type="image/x-icon"/>
|
|
478
|
-
<link rel="icon" href="${d.logo || home_seo.logo || ''}"
|
|
479
|
-
type="image/png" sizes="128x128"/>
|
|
480
|
-
<meta property="og:image" content="${d.image || home_seo.image || ''}"/>
|
|
481
|
-
<meta property="og:title"
|
|
482
|
-
content="${((_c = d.title) !== null && _c !== void 0 ? _c : '').replace(/\n/g, '').replace(/"/g, '"')}"/>
|
|
483
|
-
<meta name="description"
|
|
484
|
-
content="${((_d = d.content) !== null && _d !== void 0 ? _d : '').replace(/\n/g, '').replace(/"/g, '"')}"/>
|
|
485
|
-
<meta name="og:description"
|
|
486
|
-
content="${((_e = d.content) !== null && _e !== void 0 ? _e : '').replace(/\n/g, '').replace(/"/g, '"')}"/>`;
|
|
487
|
-
}
|
|
488
|
-
})()}
|
|
489
|
-
${(_a = d.code) !== null && _a !== void 0 ? _a : ''}
|
|
490
|
-
${(() => {
|
|
268
|
+
if (FBCode) {
|
|
269
|
+
seo_content.push(seo_config_js_1.SeoConfig.fbCode(FBCode));
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
head: (() => {
|
|
491
273
|
var _a;
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
/>`;
|
|
274
|
+
const d = data.page_config.seo;
|
|
275
|
+
const home_seo = home_page_data.page_config.seo;
|
|
276
|
+
return html `
|
|
277
|
+
${(() => {
|
|
278
|
+
var _a, _b, _c;
|
|
279
|
+
if (req.query.type === 'editor') {
|
|
280
|
+
return seo_config_js_1.SeoConfig.editorSeo;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
return html `<title>${d.title || '尚未設定標題'}</title>
|
|
284
|
+
<link
|
|
285
|
+
rel="canonical"
|
|
286
|
+
href="${(() => {
|
|
287
|
+
if (data.tag === 'index') {
|
|
288
|
+
return `https://${brandAndMemberType.domain}`;
|
|
508
289
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
290
|
+
else {
|
|
291
|
+
return `https://${brandAndMemberType.domain}/${data.tag}`;
|
|
292
|
+
}
|
|
293
|
+
})()}"
|
|
294
|
+
/>
|
|
295
|
+
${data.tag !== req.query.page ? `<meta name="robots" content="noindex">` : `<meta name="robots" content="index, follow"/>`}
|
|
296
|
+
<meta name="keywords"
|
|
297
|
+
content="${(d.keywords || '尚未設定關鍵字').replace(/"/g, '"')}"/>
|
|
298
|
+
<link id="appImage" rel="shortcut icon"
|
|
299
|
+
href="${d.logo || home_seo.logo || ''}" type="image/x-icon"/>
|
|
300
|
+
<link rel="icon" href="${d.logo || home_seo.logo || ''}"
|
|
301
|
+
type="image/png" sizes="128x128"/>
|
|
302
|
+
<meta property="og:image" content="${d.image || home_seo.image || ''}"/>
|
|
303
|
+
<meta property="og:title"
|
|
304
|
+
content="${((_a = d.title) !== null && _a !== void 0 ? _a : '').replace(/\n/g, '').replace(/"/g, '"')}"/>
|
|
305
|
+
<meta name="description"
|
|
306
|
+
content="${((_b = d.content) !== null && _b !== void 0 ? _b : '').replace(/\n/g, '').replace(/"/g, '"')}"/>
|
|
307
|
+
<meta name="og:description"
|
|
308
|
+
content="${((_c = d.content) !== null && _c !== void 0 ? _c : '').replace(/\n/g, '').replace(/"/g, '"')}"/>`;
|
|
309
|
+
}
|
|
310
|
+
})()}
|
|
311
|
+
${(_a = d.code) !== null && _a !== void 0 ? _a : ''}
|
|
312
|
+
${(() => {
|
|
313
|
+
var _a;
|
|
314
|
+
if (req.query.type === 'editor') {
|
|
315
|
+
return ``;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
return `${((_a = data.config.globalStyle) !== null && _a !== void 0 ? _a : [])
|
|
319
|
+
.map((dd) => {
|
|
320
|
+
try {
|
|
321
|
+
if (dd.data.elem === 'link') {
|
|
322
|
+
return html `
|
|
323
|
+
<link
|
|
324
|
+
type="text/css"
|
|
325
|
+
rel="stylesheet"
|
|
326
|
+
href="${dd.data.attr.find((dd) => {
|
|
327
|
+
return dd.attr === 'href';
|
|
328
|
+
}).value}"
|
|
329
|
+
/>`;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
catch (e) {
|
|
333
|
+
return ``;
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
.join('')}`;
|
|
337
|
+
}
|
|
338
|
+
})()}
|
|
518
339
|
`;
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
window.login_config = ${JSON.stringify(login_config)}
|
|
523
|
-
window.appName = '${appName}'
|
|
524
|
-
window.glitterBase = '${brandAndMemberType.brand}'
|
|
525
|
-
window.memberType = '${brandAndMemberType.memberType}'
|
|
526
|
-
window.glitterBackend = '${config_1.config.domain}'
|
|
527
|
-
window.preloadData = ${JSON.stringify(preload)
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
window.
|
|
531
|
-
window.
|
|
532
|
-
window.
|
|
533
|
-
window.
|
|
534
|
-
|
|
535
|
-
${
|
|
536
|
-
window.
|
|
537
|
-
window.
|
|
538
|
-
|
|
340
|
+
})() + `<script>
|
|
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
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
366
|
+
{ src: 'glitterBundle/GlitterInitial.js', type: 'module' },
|
|
367
|
+
{ src: 'glitterBundle/module/html-generate.js', type: 'module' },
|
|
368
|
+
{ src: 'glitterBundle/html-component/widget.js', type: 'module' },
|
|
369
|
+
{ src: 'glitterBundle/plugins/trigger-event.js', type: 'module' },
|
|
370
|
+
{ src: 'api/pageConfig.js', type: 'module' },
|
|
371
|
+
]
|
|
372
|
+
.map((dd) => {
|
|
373
|
+
return html `
|
|
549
374
|
<script src="/${link_prefix && `${link_prefix}/`}${dd.src}"
|
|
550
375
|
type="${dd.type}"></script>`;
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
${((
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
})
|
|
566
|
-
.join('')}
|
|
567
|
-
</head>
|
|
376
|
+
})
|
|
377
|
+
.join('')}
|
|
378
|
+
${((_f = preload.event) !== null && _f !== void 0 ? _f : [])
|
|
379
|
+
.filter((dd) => {
|
|
380
|
+
return dd;
|
|
381
|
+
})
|
|
382
|
+
.map((dd) => {
|
|
383
|
+
const link = dd.fun.replace(`TriggerEvent.setEventRouter(import.meta.url, '.`, 'official_event');
|
|
384
|
+
return link.substring(0, link.length - 2);
|
|
385
|
+
})
|
|
386
|
+
.map((dd) => html `
|
|
387
|
+
<script src="/${link_prefix && `${link_prefix}/`}${dd}"
|
|
388
|
+
type="module"></script>`)
|
|
389
|
+
.join('')}
|
|
568
390
|
${(() => {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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
|
-
: ''}
|
|
391
|
+
if (req.query.type === 'editor') {
|
|
392
|
+
return ``;
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
return html `
|
|
396
|
+
${seo_config_js_1.SeoConfig.gA4(customCode.ga4)}
|
|
397
|
+
${seo_config_js_1.SeoConfig.gTag(customCode.g_tag)}
|
|
398
|
+
${seo_content.map((dd) => {
|
|
399
|
+
return dd.trim();
|
|
400
|
+
}).join('\n')}
|
|
641
401
|
`;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
402
|
+
}
|
|
403
|
+
})()}`,
|
|
404
|
+
body: ``
|
|
405
|
+
};
|
|
645
406
|
}
|
|
646
407
|
else {
|
|
647
|
-
|
|
648
|
-
|
|
408
|
+
return {
|
|
409
|
+
head: await seo_js_1.Seo.redirectToHomePage(appName, req),
|
|
410
|
+
body: ``
|
|
411
|
+
};
|
|
649
412
|
}
|
|
650
413
|
}
|
|
651
414
|
catch (e) {
|
|
652
415
|
console.error(e);
|
|
653
|
-
return
|
|
416
|
+
return {
|
|
417
|
+
head: ``,
|
|
418
|
+
body: `${e}`
|
|
419
|
+
};
|
|
654
420
|
}
|
|
655
421
|
},
|
|
656
422
|
sitemap: async (req, resp) => {
|
|
@@ -671,10 +437,29 @@ async function createAPP(dd) {
|
|
|
671
437
|
const cols = (_a = (await database_2.default.query(`SELECT *
|
|
672
438
|
FROM \`${appName}\`.public_config
|
|
673
439
|
WHERE \`key\` = 'collection';`, []))[0]) !== null && _a !== void 0 ? _a : {};
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
440
|
+
const language_setting = (await new user_js_1.User(appName).getConfigV2({
|
|
441
|
+
key: 'store-information',
|
|
442
|
+
user_id: 'manager',
|
|
443
|
+
})).language_setting;
|
|
444
|
+
const product = (await new shopping_js_1.Shopping(appName).getProduct({
|
|
445
|
+
page: 0,
|
|
446
|
+
limit: 100000,
|
|
447
|
+
collection: '',
|
|
448
|
+
accurate_search_text: false,
|
|
449
|
+
accurate_search_collection: true,
|
|
450
|
+
min_price: undefined,
|
|
451
|
+
max_price: undefined,
|
|
452
|
+
status: undefined,
|
|
453
|
+
channel: undefined,
|
|
454
|
+
id_list: undefined,
|
|
455
|
+
order_by: 'order by id desc',
|
|
456
|
+
with_hide_index: undefined,
|
|
457
|
+
is_manger: true,
|
|
458
|
+
productType: 'product',
|
|
459
|
+
filter_visible: 'true',
|
|
460
|
+
language: 'zh-TW',
|
|
461
|
+
currency_code: 'TWD'
|
|
462
|
+
})).data;
|
|
678
463
|
const stream = new sitemap_1.SitemapStream({ hostname: `https://${domain}` });
|
|
679
464
|
const xml = await (0, sitemap_1.streamToPromise)(stream_1.Readable.from([
|
|
680
465
|
...(await database_2.default.query(`select page_config, tag, updated_time
|
|
@@ -698,20 +483,57 @@ async function createAPP(dd) {
|
|
|
698
483
|
.map((d2) => {
|
|
699
484
|
return { url: `https://${domain}/${d2.url}`, changefreq: 'weekly' };
|
|
700
485
|
}),
|
|
701
|
-
...
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
486
|
+
...(() => {
|
|
487
|
+
let array = [];
|
|
488
|
+
(0, seo_config_js_1.extractCols)(cols)
|
|
489
|
+
.map((item) => {
|
|
490
|
+
array = array.concat((language_setting.support).map((d1) => {
|
|
491
|
+
const seo = (item.language_data && item.language_data[d1] && item.language_data[d1].seo && item.language_data[d1].seo.domain) || item.code || item.title;
|
|
492
|
+
if (d1 === language_setting.def) {
|
|
493
|
+
return { url: `https://${domain}/collections/${seo}`, changefreq: 'weekly' };
|
|
494
|
+
}
|
|
495
|
+
else if (d1 === 'zh-TW') {
|
|
496
|
+
return { url: `https://${domain}/tw/collections/${seo}`, changefreq: 'weekly' };
|
|
497
|
+
}
|
|
498
|
+
else if (d1 === 'zh-CN') {
|
|
499
|
+
return { url: `https://${domain}/cn/collections/${seo}`, changefreq: 'weekly' };
|
|
500
|
+
}
|
|
501
|
+
else if (d1 === 'en-US') {
|
|
502
|
+
return { url: `https://${domain}/en/collections/${seo}`, changefreq: 'weekly' };
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
return { url: `https://${domain}/${d1}/collections/${seo}`, changefreq: 'weekly' };
|
|
506
|
+
}
|
|
507
|
+
}));
|
|
508
|
+
});
|
|
509
|
+
console.log(array);
|
|
510
|
+
return array;
|
|
511
|
+
})(),
|
|
512
|
+
...(() => {
|
|
513
|
+
let array = [];
|
|
514
|
+
product.map((dd) => {
|
|
515
|
+
dd = dd.content;
|
|
516
|
+
array = array.concat((language_setting.support).map((d1) => {
|
|
517
|
+
const seo = (dd.language_data && dd.language_data[d1] && dd.language_data[d1].seo && dd.language_data[d1].seo.domain) || dd.seo.domain;
|
|
518
|
+
if (d1 === language_setting.def) {
|
|
519
|
+
return { url: `https://${domain}/products/${seo}`, changefreq: 'weekly' };
|
|
520
|
+
}
|
|
521
|
+
else if (d1 === 'zh-TW') {
|
|
522
|
+
return { url: `https://${domain}/tw/products/${seo}`, changefreq: 'weekly' };
|
|
523
|
+
}
|
|
524
|
+
else if (d1 === 'zh-CN') {
|
|
525
|
+
return { url: `https://${domain}/cn/products/${seo}`, changefreq: 'weekly' };
|
|
526
|
+
}
|
|
527
|
+
else if (d1 === 'en-US') {
|
|
528
|
+
return { url: `https://${domain}/en/products/${seo}`, changefreq: 'weekly' };
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
return { url: `https://${domain}/${d1}/products/${seo}`, changefreq: 'weekly' };
|
|
532
|
+
}
|
|
533
|
+
}));
|
|
534
|
+
});
|
|
535
|
+
return array;
|
|
536
|
+
})()
|
|
715
537
|
]).pipe(stream)).then((data) => data.toString());
|
|
716
538
|
return xml;
|
|
717
539
|
},
|