plutosdk 1.0.2-beta.7 → 1.0.2-beta.9
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/dist/pluto-sdk.js +23 -23
- package/lib/components/Login/index.js +3 -1
- package/lib/components/Purchase/index.js +2 -2
- package/lib/sdk.d.ts +6 -3
- package/lib/sdk.js +24 -10
- package/lib/utils/Platform.d.ts +6 -1
- package/lib/utils/Platform.js +12 -1
- package/lib/utils/Utils.d.ts +1 -5
- package/lib/utils/Utils.js +1 -11
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import Box from '@mui/material/Box';
|
|
|
5
5
|
import Slide from '@mui/material/Slide';
|
|
6
6
|
import { PS_SWITCH_PAGE, PAGE_ID, PS_PLAY_BUTTON_CLICKED } from '../../utils/constant';
|
|
7
7
|
import { getRes, onMobile } from '../../utils/Utils';
|
|
8
|
+
import platform from '../../utils/Platform';
|
|
8
9
|
import ContentBg from '../ContentBg';
|
|
9
10
|
import Introduction from '../Introduction';
|
|
10
11
|
import GameInfo from '../GameInfo';
|
|
@@ -46,6 +47,7 @@ export default class Login extends PureComponent {
|
|
|
46
47
|
*/
|
|
47
48
|
render() {
|
|
48
49
|
const { showSlide } = this.state;
|
|
49
|
-
|
|
50
|
+
const hideShare = platform.hideShare;
|
|
51
|
+
return (_jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative', backgroundColor: '#FEF8E2' } }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'relative', backgroundImage: `url(${getRes('bg_1.png')})` } }), _jsx(Introduction, {}), _jsx(Box, Object.assign({ sx: { width: 1, bottom: onMobile() ? 40 : 20, position: 'absolute' } }, { children: _jsx(Slide, Object.assign({ direction: 'up', in: showSlide, mountOnEnter: true, unmountOnExit: true, timeout: { enter: 600, exit: 600 }, onExited: this.onExited }, { children: _jsxs(Box, { children: [_jsxs(InfoLayout, { children: [_jsx(ContentBg, {}), _jsxs(Box, Object.assign({ sx: { position: 'relative', px: 4, pt: 1, pb: 4 } }, { children: [_jsx(GameInfo, {}), !hideShare ? _jsx(ShareButton, {}) : null] }))] }), _jsx(InfoLayout, Object.assign({ sx: { paddingTop: 2 } }, { children: _jsx(PlayButton, { onClick: this.onClickPlay }) }))] }) })) }))] })));
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -6,7 +6,7 @@ import Stack from '@mui/material/Stack';
|
|
|
6
6
|
import PubSub from 'pubsub-js';
|
|
7
7
|
import { CHAIN } from '@tonconnect/ui';
|
|
8
8
|
import { CODE, CURRENCY, PS_PURCHASE_COMPLETED, PS_SWITCH_PAGE, PAGE_ID, PAY_TYPE, TOKEN_NAME } from '../../utils/constant';
|
|
9
|
-
import { onTelegramAndroid, onTelegramApple,
|
|
9
|
+
import { onTelegramAndroid, onTelegramApple, onTelegramEnvironment } from '../../utils/Utils';
|
|
10
10
|
import Config from '../../utils/Config';
|
|
11
11
|
import user from '../../utils/User';
|
|
12
12
|
import platform from '../../utils/Platform';
|
|
@@ -210,7 +210,7 @@ export default class Purchase extends PureComponent {
|
|
|
210
210
|
*
|
|
211
211
|
*/
|
|
212
212
|
showStarPay() {
|
|
213
|
-
if (!
|
|
213
|
+
if (!onTelegramEnvironment()) {
|
|
214
214
|
return false;
|
|
215
215
|
}
|
|
216
216
|
//
|
package/lib/sdk.d.ts
CHANGED
|
@@ -30,16 +30,19 @@ export declare const purchase: (productId: string, name: string, orderId: string
|
|
|
30
30
|
export declare const checkIn: (name: string, orderId: string, customData?: string, callback?: Function) => Promise<void>;
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
|
+
* @param customData
|
|
33
34
|
*/
|
|
34
|
-
export declare const share: () => void;
|
|
35
|
+
export declare const share: (customData?: string) => void;
|
|
35
36
|
/**
|
|
36
37
|
*
|
|
38
|
+
* @param customData
|
|
37
39
|
*/
|
|
38
|
-
export declare const getShareLink: () => string;
|
|
40
|
+
export declare const getShareLink: (customData?: string) => string;
|
|
39
41
|
/**
|
|
40
42
|
*
|
|
43
|
+
* @param customData
|
|
41
44
|
*/
|
|
42
|
-
export declare const copyShareLink: () => Promise<void>;
|
|
45
|
+
export declare const copyShareLink: (customData?: string) => Promise<void>;
|
|
43
46
|
/**
|
|
44
47
|
*
|
|
45
48
|
* @param key
|
package/lib/sdk.js
CHANGED
|
@@ -48,21 +48,24 @@ export const checkIn = (name, orderId, customData = '', callback = null) => {
|
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
*
|
|
51
|
+
* @param customData
|
|
51
52
|
*/
|
|
52
|
-
export const share = () => {
|
|
53
|
-
sdk.share();
|
|
53
|
+
export const share = (customData = '') => {
|
|
54
|
+
sdk.share(customData);
|
|
54
55
|
};
|
|
55
56
|
/**
|
|
56
57
|
*
|
|
58
|
+
* @param customData
|
|
57
59
|
*/
|
|
58
|
-
export const getShareLink = () => {
|
|
59
|
-
return sdk.getShareLink();
|
|
60
|
+
export const getShareLink = (customData = '') => {
|
|
61
|
+
return sdk.getShareLink(customData);
|
|
60
62
|
};
|
|
61
63
|
/**
|
|
62
64
|
*
|
|
65
|
+
* @param customData
|
|
63
66
|
*/
|
|
64
|
-
export const copyShareLink = () => {
|
|
65
|
-
return sdk.copyShareLink();
|
|
67
|
+
export const copyShareLink = (customData = '') => {
|
|
68
|
+
return sdk.copyShareLink(customData);
|
|
66
69
|
};
|
|
67
70
|
/**
|
|
68
71
|
*
|
|
@@ -309,30 +312,37 @@ class Sdk {
|
|
|
309
312
|
}
|
|
310
313
|
/**
|
|
311
314
|
*
|
|
315
|
+
* @param customData
|
|
312
316
|
*/
|
|
313
|
-
share() {
|
|
317
|
+
share(customData) {
|
|
314
318
|
if (!this._logined) {
|
|
315
319
|
return console.log('pluto sdk not login');
|
|
316
320
|
}
|
|
317
321
|
console.log('pluto sdk share');
|
|
318
|
-
platform.share();
|
|
322
|
+
platform.share(customData);
|
|
319
323
|
}
|
|
320
324
|
/**
|
|
321
325
|
*
|
|
326
|
+
* @param customData
|
|
322
327
|
*/
|
|
323
|
-
getShareLink() {
|
|
328
|
+
getShareLink(customData) {
|
|
324
329
|
if (!this._logined) {
|
|
325
330
|
console.log('pluto sdk not login');
|
|
326
331
|
return "";
|
|
327
332
|
}
|
|
328
333
|
//
|
|
334
|
+
let reg = /^[A-Za-z0-9]*$/;
|
|
329
335
|
let link = `${user.gameInfo.appUrl}?startapp=g_${Config.GAME_ID}_${user.plutoId}`;
|
|
336
|
+
if (customData && reg.test(customData)) {
|
|
337
|
+
link += `_${customData}`;
|
|
338
|
+
}
|
|
330
339
|
return link;
|
|
331
340
|
}
|
|
332
341
|
/**
|
|
333
342
|
*
|
|
343
|
+
* @param customData
|
|
334
344
|
*/
|
|
335
|
-
copyShareLink() {
|
|
345
|
+
copyShareLink(customData) {
|
|
336
346
|
return new Promise((resolve, reject) => {
|
|
337
347
|
if (!this._logined) {
|
|
338
348
|
return reject({
|
|
@@ -341,7 +351,11 @@ class Sdk {
|
|
|
341
351
|
});
|
|
342
352
|
}
|
|
343
353
|
//
|
|
354
|
+
let reg = /^[A-Za-z0-9]*$/;
|
|
344
355
|
let link = `${user.gameInfo.appUrl}?startapp=g_${Config.GAME_ID}_${user.plutoId}`;
|
|
356
|
+
if (customData && reg.test(customData)) {
|
|
357
|
+
link += `_${customData}`;
|
|
358
|
+
}
|
|
345
359
|
clipboard(link).then(() => {
|
|
346
360
|
resolve();
|
|
347
361
|
}).catch(error => {
|
package/lib/utils/Platform.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { CURRENCY, PAY_TYPE } from './constant';
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
declare class Platform {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
get hideShare(): boolean;
|
|
7
11
|
/**
|
|
8
12
|
*
|
|
9
13
|
*/
|
|
@@ -82,8 +86,9 @@ declare class Platform {
|
|
|
82
86
|
openInvoice(url: string): Promise<void>;
|
|
83
87
|
/**
|
|
84
88
|
*
|
|
89
|
+
* @param customData
|
|
85
90
|
*/
|
|
86
|
-
share(): void;
|
|
91
|
+
share(customData?: string): void;
|
|
87
92
|
/**
|
|
88
93
|
*
|
|
89
94
|
*/
|
package/lib/utils/Platform.js
CHANGED
|
@@ -16,6 +16,12 @@ import user from './User';
|
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
18
|
class Platform {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
get hideShare() {
|
|
23
|
+
return Config.GAME_ID == '1002';
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
26
|
*
|
|
21
27
|
*/
|
|
@@ -278,11 +284,16 @@ class Platform {
|
|
|
278
284
|
}
|
|
279
285
|
/**
|
|
280
286
|
*
|
|
287
|
+
* @param customData
|
|
281
288
|
*/
|
|
282
|
-
share() {
|
|
289
|
+
share(customData = '') {
|
|
283
290
|
let link = `${user.gameInfo.appUrl}?startapp=g_${Config.GAME_ID}_${user.plutoId}`;
|
|
284
291
|
let text = encodeURIComponent(SHARE_TEXT[Config.GAME_ID] || SHARE_TEXT[1000]);
|
|
285
292
|
let url = `https://t.me/share/url?url=${link}&text=${text}`;
|
|
293
|
+
let reg = /^[A-Za-z0-9]*$/;
|
|
294
|
+
if (customData && reg.test(customData)) {
|
|
295
|
+
url += `_${customData}`;
|
|
296
|
+
}
|
|
286
297
|
if (onTelegramClient() && onMobile()) {
|
|
287
298
|
this.openTelegramLink(url);
|
|
288
299
|
return;
|
package/lib/utils/Utils.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const getRes: (name: string) => string;
|
|
|
17
17
|
/**
|
|
18
18
|
* 是否在Telegram小游戏环境
|
|
19
19
|
*/
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const onTelegramEnvironment: () => boolean;
|
|
21
21
|
/**
|
|
22
22
|
* 是否在Telegram客户端版的小游戏环境
|
|
23
23
|
*/
|
|
@@ -34,10 +34,6 @@ export declare const onTelegramAndroid: () => boolean;
|
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
36
|
export declare const onMobile: () => boolean;
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
export declare const onAppleClient: () => boolean;
|
|
41
37
|
/**
|
|
42
38
|
*
|
|
43
39
|
* @param text
|
package/lib/utils/Utils.js
CHANGED
|
@@ -31,7 +31,7 @@ export const getRes = (name) => {
|
|
|
31
31
|
/**
|
|
32
32
|
* 是否在Telegram小游戏环境
|
|
33
33
|
*/
|
|
34
|
-
export const
|
|
34
|
+
export const onTelegramEnvironment = () => {
|
|
35
35
|
const pf = Telegram.WebApp.platform;
|
|
36
36
|
const ver = Telegram.WebApp.version;
|
|
37
37
|
if (!pf || pf == 'unknown') {
|
|
@@ -77,16 +77,6 @@ export const onMobile = () => {
|
|
|
77
77
|
const type = ua.getDevice().type;
|
|
78
78
|
return type == 'mobile' || type == 'tablet';
|
|
79
79
|
};
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
|
-
export const onAppleClient = () => {
|
|
84
|
-
var _a, _b;
|
|
85
|
-
const ua = new UAParser();
|
|
86
|
-
const browserName = (_a = ua.getBrowser().name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase();
|
|
87
|
-
const osName = (_b = ua.getOS().name) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase();
|
|
88
|
-
return browserName == 'webkit' && (osName == 'mac os' || osName == 'ios');
|
|
89
|
-
};
|
|
90
80
|
/**
|
|
91
81
|
*
|
|
92
82
|
* @param text
|