ts-glitter 20.4.2 → 20.4.3
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 +26 -1
- package/lowcode/Entry.ts +26 -1
- package/lowcode/glitter-base/route/user.js +23 -10
- package/lowcode/glitter-base/route/user.ts +23 -11
- package/lowcode/official_event/page/change-page.js +1 -0
- package/lowcode/official_event/page/change-page.ts +1 -0
- package/lowcode/public-components/blogs/blogs-01.ts +1 -0
- package/package.json +1 -1
- package/src/api-public/services/phone-verify.d.ts +3 -0
- package/src/api-public/services/phone-verify.js +20 -0
- package/src/api-public/services/phone-verify.js.map +1 -0
- package/src/api-public/services/phone-verify.ts +13 -0
- package/src/api-public/services/user.d.ts +4 -0
- package/src/api-public/services/user.js +15 -5
- package/src/api-public/services/user.js.map +1 -1
- package/src/api-public/services/user.ts +12 -3
- package/src/controllers/template.js +6 -1
- package/src/controllers/template.js.map +1 -1
- package/src/controllers/template.ts +6 -1
- package/src/index.js +2 -420
- package/src/index.js.map +1 -1
- package/src/index.ts +3 -444
- package/src/seo-config.d.ts +17 -0
- package/src/seo-config.js +431 -0
- package/src/seo-config.js.map +1 -1
- package/src/seo-config.ts +463 -0
package/lowcode/Entry.js
CHANGED
|
@@ -144,7 +144,7 @@ export class Entry {
|
|
|
144
144
|
}
|
|
145
145
|
window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : createClock();
|
|
146
146
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
147
|
-
glitter.share.editerVersion = 'V_20.4.
|
|
147
|
+
glitter.share.editerVersion = 'V_20.4.3';
|
|
148
148
|
glitter.share.start = new Date();
|
|
149
149
|
const vm = { appConfig: [] };
|
|
150
150
|
window.saasConfig = {
|
|
@@ -329,6 +329,31 @@ export class Entry {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
+
Entry.checkSeoInfo(glitter);
|
|
333
|
+
}
|
|
334
|
+
static checkSeoInfo(glitter) {
|
|
335
|
+
var _a, _b, _c;
|
|
336
|
+
glitter.share.last_seo_config = (_a = glitter.share.last_seo_config) !== null && _a !== void 0 ? _a : {
|
|
337
|
+
title: document.title,
|
|
338
|
+
description: (_b = document.querySelector('meta[name="description"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content'),
|
|
339
|
+
ogImage: (_c = document.querySelector('meta[property="og:image"]')) === null || _c === void 0 ? void 0 : _c.getAttribute('content')
|
|
340
|
+
};
|
|
341
|
+
window.glitterInitialHelper.getPageData(glitter.getUrlParameter('page'), (data) => {
|
|
342
|
+
var _a, _b;
|
|
343
|
+
if ((data.response.seo_config && (data.response.seo_config.title && data.response.seo_config.content)) && ([data.response.seo_config.title, data.response.seo_config.content].join('') !== [
|
|
344
|
+
glitter.share.last_seo_config.title,
|
|
345
|
+
glitter.share.last_seo_config.description,
|
|
346
|
+
].join(''))) {
|
|
347
|
+
glitter.share.last_seo_config.title = data.response.seo_config.title;
|
|
348
|
+
glitter.share.last_seo_config.description = data.response.seo_config.content;
|
|
349
|
+
(_a = document.querySelector('meta[name="description"]')) === null || _a === void 0 ? void 0 : _a.setAttribute('content', data.response.seo_config.content);
|
|
350
|
+
(_b = document.querySelector('meta[name="og:description"]')) === null || _b === void 0 ? void 0 : _b.setAttribute('content', data.response.seo_config.content);
|
|
351
|
+
document.title = data.response.seo_config.title;
|
|
352
|
+
}
|
|
353
|
+
setTimeout(() => {
|
|
354
|
+
Entry.checkSeoInfo(glitter);
|
|
355
|
+
}, 500);
|
|
356
|
+
});
|
|
332
357
|
}
|
|
333
358
|
static checkIframe(glitter) {
|
|
334
359
|
if (glitter.getUrlParameter('isIframe') === 'true') {
|
package/lowcode/Entry.ts
CHANGED
|
@@ -25,6 +25,7 @@ export class Entry {
|
|
|
25
25
|
return originalReplaceState.apply(history, arguments);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
//進入時就要提供堆棧,避免頁面返回問題
|
|
28
29
|
window.history.pushState({}, glitter.document.title,location.href);
|
|
29
30
|
function next(){
|
|
30
31
|
//判斷結帳成功清空購物車紀錄
|
|
@@ -145,7 +146,7 @@ export class Entry {
|
|
|
145
146
|
}
|
|
146
147
|
(window as any).renderClock = (window as any).renderClock ?? createClock();
|
|
147
148
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
148
|
-
glitter.share.editerVersion = 'V_20.4.
|
|
149
|
+
glitter.share.editerVersion = 'V_20.4.3';
|
|
149
150
|
glitter.share.start = new Date();
|
|
150
151
|
const vm = { appConfig: [] };
|
|
151
152
|
(window as any).saasConfig = {
|
|
@@ -334,7 +335,31 @@ export class Entry {
|
|
|
334
335
|
})
|
|
335
336
|
}
|
|
336
337
|
}
|
|
338
|
+
Entry.checkSeoInfo(glitter)
|
|
339
|
+
}
|
|
337
340
|
|
|
341
|
+
//定期確認SEO資訊並更新
|
|
342
|
+
public static checkSeoInfo(glitter:Glitter){
|
|
343
|
+
glitter.share.last_seo_config=glitter.share.last_seo_config ?? {
|
|
344
|
+
title:document.title,
|
|
345
|
+
description:document.querySelector('meta[name="description"]')?.getAttribute('content'),
|
|
346
|
+
ogImage:document.querySelector('meta[property="og:image"]')?.getAttribute('content')
|
|
347
|
+
};
|
|
348
|
+
(window as any).glitterInitialHelper.getPageData(glitter.getUrlParameter('page'), (data: any) => {
|
|
349
|
+
if((data.response.seo_config && (data.response.seo_config.title && data.response.seo_config.content)) && ([data.response.seo_config.title,data.response.seo_config.content].join('') !== [
|
|
350
|
+
glitter.share.last_seo_config.title,
|
|
351
|
+
glitter.share.last_seo_config.description,
|
|
352
|
+
].join(''))){
|
|
353
|
+
glitter.share.last_seo_config.title=data.response.seo_config.title;
|
|
354
|
+
glitter.share.last_seo_config.description=data.response.seo_config.content;
|
|
355
|
+
document.querySelector('meta[name="description"]')?.setAttribute('content',data.response.seo_config.content);
|
|
356
|
+
document.querySelector('meta[name="og:description"]')?.setAttribute('content',data.response.seo_config.content);
|
|
357
|
+
document.title=data.response.seo_config.title;
|
|
358
|
+
}
|
|
359
|
+
setTimeout(()=>{
|
|
360
|
+
Entry.checkSeoInfo(glitter)
|
|
361
|
+
},500)
|
|
362
|
+
})
|
|
338
363
|
}
|
|
339
364
|
|
|
340
365
|
// 判斷是否為 Iframe 來覆寫 Glitter 代碼
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { BaseApi } from '../../glitterBundle/api/base.js';
|
|
11
11
|
import { GlobalUser } from '../global/global-user.js';
|
|
12
12
|
import { ApiShop } from './shopping.js';
|
|
13
|
+
import { ShareDialog } from '../../dialog/ShareDialog.js';
|
|
13
14
|
export class ApiUser {
|
|
14
15
|
static register(json) {
|
|
15
16
|
return BaseApi.create({
|
|
@@ -208,16 +209,28 @@ export class ApiUser {
|
|
|
208
209
|
});
|
|
209
210
|
}
|
|
210
211
|
static phoneVerify(phone_number) {
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
212
|
+
return new Promise((resolve, reject) => {
|
|
213
|
+
BaseApi.create({
|
|
214
|
+
url: getBaseUrl() + `/api-public/v1/user/phone-verify`,
|
|
215
|
+
type: 'POST',
|
|
216
|
+
headers: {
|
|
217
|
+
'g-app': getConfig().config.appName,
|
|
218
|
+
'Content-Type': 'application/json',
|
|
219
|
+
},
|
|
220
|
+
data: JSON.stringify({
|
|
221
|
+
phone_number: phone_number,
|
|
222
|
+
}),
|
|
223
|
+
}).then((res) => {
|
|
224
|
+
if (res.response.out_limit) {
|
|
225
|
+
const dialog = new ShareDialog(window.glitter);
|
|
226
|
+
dialog.errorMessage({
|
|
227
|
+
text: '連續驗證失敗超過三次,請聯絡客服進行修改'
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
resolve(res);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
221
234
|
});
|
|
222
235
|
}
|
|
223
236
|
static registerFCM(userID, deviceToken, app_name) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseApi } from '../../glitterBundle/api/base.js';
|
|
2
2
|
import { GlobalUser } from '../global/global-user.js';
|
|
3
3
|
import { ApiShop } from './shopping.js';
|
|
4
|
+
import { ShareDialog } from '../../dialog/ShareDialog.js';
|
|
4
5
|
|
|
5
6
|
export class ApiUser {
|
|
6
7
|
public static register(json: { account: string; pwd: string; userData: any }) {
|
|
@@ -219,17 +220,28 @@ export class ApiUser {
|
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
public static phoneVerify(phone_number: string) {
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
223
|
+
return new Promise<{result:boolean,response:any}>((resolve, reject) => {
|
|
224
|
+
BaseApi.create({
|
|
225
|
+
url: getBaseUrl() + `/api-public/v1/user/phone-verify`,
|
|
226
|
+
type: 'POST',
|
|
227
|
+
headers: {
|
|
228
|
+
'g-app': getConfig().config.appName,
|
|
229
|
+
'Content-Type': 'application/json',
|
|
230
|
+
},
|
|
231
|
+
data: JSON.stringify({
|
|
232
|
+
phone_number: phone_number,
|
|
233
|
+
}),
|
|
234
|
+
}).then((res)=>{
|
|
235
|
+
if(res.response.out_limit){
|
|
236
|
+
const dialog=new ShareDialog((window as any).glitter);
|
|
237
|
+
dialog.errorMessage({
|
|
238
|
+
text:'連續驗證失敗超過三次,請聯絡客服進行修改'
|
|
239
|
+
})
|
|
240
|
+
}else{
|
|
241
|
+
resolve(res)
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
})
|
|
233
245
|
}
|
|
234
246
|
|
|
235
247
|
public static registerFCM(userID: string, deviceToken: string, app_name?: string) {
|
|
@@ -20,6 +20,7 @@ class ChangePage {
|
|
|
20
20
|
url.searchParams.set('page', link);
|
|
21
21
|
const saasConfig = window.saasConfig;
|
|
22
22
|
window.glitterInitialHelper.getPageData(link, (data) => {
|
|
23
|
+
console.log(`seo_config==>`, data.response.seo_config);
|
|
23
24
|
if (data.response.result.length === 0) {
|
|
24
25
|
const url = new URL("./", location.href);
|
|
25
26
|
url.searchParams.set('page', data.response.redirect);
|
|
@@ -17,6 +17,7 @@ class ChangePage {
|
|
|
17
17
|
appConfig: any
|
|
18
18
|
} = (window as any).saasConfig;
|
|
19
19
|
(window as any).glitterInitialHelper.getPageData(link, (data: any) => {
|
|
20
|
+
console.log(`seo_config==>`,data.response.seo_config)
|
|
20
21
|
if (data.response.result.length === 0) {
|
|
21
22
|
const url = new URL("./", location.href)
|
|
22
23
|
url.searchParams.set('page', data.response.redirect)
|
|
@@ -8,6 +8,7 @@ import { GlobalUser } from '../../glitter-base/global/global-user.js';
|
|
|
8
8
|
|
|
9
9
|
export class Blogs01 {
|
|
10
10
|
static main(gvc: GVC, subData: any) {
|
|
11
|
+
|
|
11
12
|
if (subData.content.generator !== 'page_editor') {
|
|
12
13
|
const dd = subData.content;
|
|
13
14
|
return `<div class="container mx-auto fr-view mb-5" 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;">
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PhoneVerify = void 0;
|
|
7
|
+
const redis_js_1 = __importDefault(require("../../modules/redis.js"));
|
|
8
|
+
class PhoneVerify {
|
|
9
|
+
static async verify(phone, code) {
|
|
10
|
+
if (await redis_js_1.default.getValue(`verify-phone-${phone}`) === code) {
|
|
11
|
+
await redis_js_1.default.deleteKey(`verify-phone-${phone}-last-count`);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.PhoneVerify = PhoneVerify;
|
|
20
|
+
//# sourceMappingURL=phone-verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-verify.js","sourceRoot":"","sources":["phone-verify.ts"],"names":[],"mappings":";;;;;;AAAA,sEAA2C;AAE3C,MAAa,WAAW;IACf,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAY,EAAC,IAAW;QACjD,IAAG,MAAM,kBAAK,CAAC,QAAQ,CAAC,gBAAgB,KAAK,EAAE,CAAC,KAAG,IAAI,EAAC,CAAC;YACvD,MAAM,kBAAK,CAAC,SAAS,CAAC,gBAAgB,KAAK,aAAa,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC;QACd,CAAC;aAAI,CAAC;YACJ,OAAO,KAAK,CAAC;QACf,CAAC;IAEH,CAAC;CACF;AAVD,kCAUC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import redis from '../../modules/redis.js';
|
|
2
|
+
|
|
3
|
+
export class PhoneVerify{
|
|
4
|
+
public static async verify(phone:string,code:string){
|
|
5
|
+
if(await redis.getValue(`verify-phone-${phone}`)===code){
|
|
6
|
+
await redis.deleteKey(`verify-phone-${phone}-last-count`);
|
|
7
|
+
return true;
|
|
8
|
+
}else{
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -60,7 +60,11 @@ export declare class User {
|
|
|
60
60
|
result: boolean;
|
|
61
61
|
}>;
|
|
62
62
|
phoneVerify(account: string): Promise<{
|
|
63
|
+
out_limit: boolean;
|
|
64
|
+
result?: undefined;
|
|
65
|
+
} | {
|
|
63
66
|
result: boolean;
|
|
67
|
+
out_limit?: undefined;
|
|
64
68
|
}>;
|
|
65
69
|
createUser(account: string, pwd: string, userData: any, req: any, pass_verify?: boolean): Promise<any>;
|
|
66
70
|
createUserHook(userID: string): Promise<void>;
|
|
@@ -58,6 +58,7 @@ const user_update_js_1 = require("./user-update.js");
|
|
|
58
58
|
const public_table_check_js_1 = require("./public-table-check.js");
|
|
59
59
|
const ut_timer_1 = require("../utils/ut-timer");
|
|
60
60
|
const auto_fcm_js_1 = require("../../public-config-initial/auto-fcm.js");
|
|
61
|
+
const phone_verify_js_1 = require("./phone-verify.js");
|
|
61
62
|
class User {
|
|
62
63
|
constructor(app, token) {
|
|
63
64
|
this.normalMember = {
|
|
@@ -119,6 +120,14 @@ class User {
|
|
|
119
120
|
}
|
|
120
121
|
async phoneVerify(account) {
|
|
121
122
|
const time = await redis_js_1.default.getValue(`verify-phone-${account}-last-time`);
|
|
123
|
+
let last_count = parseInt(`${(await redis_js_1.default.getValue(`verify-phone-${account}-last-count`)) || '0'}`, 10);
|
|
124
|
+
last_count++;
|
|
125
|
+
if (last_count > 3) {
|
|
126
|
+
return {
|
|
127
|
+
out_limit: true,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
await redis_js_1.default.setValue(`verify-phone-${account}-last-count`, last_count);
|
|
122
131
|
if (!time || new Date().getTime() - new Date(time).getTime() > 1000 * 30) {
|
|
123
132
|
await redis_js_1.default.setValue(`verify-phone-${account}-last-time`, new Date().toISOString());
|
|
124
133
|
const data = await auto_send_email_js_1.AutoSendEmail.getDefCompare(this.app, 'auto-phone-verify-update', 'zh-TW');
|
|
@@ -183,7 +192,7 @@ class User {
|
|
|
183
192
|
});
|
|
184
193
|
}
|
|
185
194
|
if (login_config.phone_verify &&
|
|
186
|
-
|
|
195
|
+
!(await phone_verify_js_1.PhoneVerify.verify(userData.phone, userData.verify_code_phone)) &&
|
|
187
196
|
register_form.list.find((dd) => {
|
|
188
197
|
return dd.key === 'phone' && `${dd.hidden}` !== 'true';
|
|
189
198
|
})) {
|
|
@@ -1701,10 +1710,11 @@ class User {
|
|
|
1701
1710
|
});
|
|
1702
1711
|
}
|
|
1703
1712
|
if (login_config.phone_verify &&
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1713
|
+
!(await phone_verify_js_1.PhoneVerify.verify(par.userData.phone, par.userData.verify_code_phone))
|
|
1714
|
+
&&
|
|
1715
|
+
register_form.list.find((dd) => {
|
|
1716
|
+
return dd.key === 'phone' && `${dd.hidden}` !== 'true';
|
|
1717
|
+
})) {
|
|
1708
1718
|
throw exception_1.default.BadRequestError('BAD_REQUEST', 'Verify code error.', {
|
|
1709
1719
|
msg: 'phone-verify-false',
|
|
1710
1720
|
});
|