@tuya-sat/sdf-main-sdk 0.0.1-beta.1

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.
Files changed (147) hide show
  1. package/.vscode/settings.json +5 -0
  2. package/README.md +1 -0
  3. package/antd.less.overwrite.js +56 -0
  4. package/color.js +140 -0
  5. package/dark-variable.less +1449 -0
  6. package/package.json +74 -0
  7. package/scripts/gen-localize-file.mjs +56 -0
  8. package/src/App.less +156 -0
  9. package/src/App.tsx +87 -0
  10. package/src/api/index.ts +52 -0
  11. package/src/api/req.ts +23 -0
  12. package/src/api/res.ts +29 -0
  13. package/src/api/urls.ts +30 -0
  14. package/src/api/utils.ts +41 -0
  15. package/src/assets/imgs/404.svg +194 -0
  16. package/src/assets/imgs/reLogin.png +0 -0
  17. package/src/components/404/index.tsx +44 -0
  18. package/src/components/500/index.tsx +49 -0
  19. package/src/components/BCustomNav/index.module.less +17 -0
  20. package/src/components/BCustomNav/index.tsx +108 -0
  21. package/src/components/BForgot/index.module.less +5 -0
  22. package/src/components/BForgot/index.tsx +96 -0
  23. package/src/components/BHeaderUser/account.png +0 -0
  24. package/src/components/BHeaderUser/app-scan-en.png +0 -0
  25. package/src/components/BHeaderUser/app-scan-zh.png +0 -0
  26. package/src/components/BHeaderUser/app-scan.png +0 -0
  27. package/src/components/BHeaderUser/components/BSwitchLang/index.module.less +6 -0
  28. package/src/components/BHeaderUser/components/BSwitchLang/index.tsx +56 -0
  29. package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/Content.tsx +199 -0
  30. package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.module.less +11 -0
  31. package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.tsx +27 -0
  32. package/src/components/BHeaderUser/components/Badge/components/Notice/hooks.ts +104 -0
  33. package/src/components/BHeaderUser/components/Badge/components/Notice/index.module.less +70 -0
  34. package/src/components/BHeaderUser/components/Badge/components/Notice/index.tsx +184 -0
  35. package/src/components/BHeaderUser/components/Badge/components/Notice/table/index.tsx +184 -0
  36. package/src/components/BHeaderUser/components/Badge/components/Notice/table/read.tsx +67 -0
  37. package/src/components/BHeaderUser/components/Badge/components/Notice/tools/index.tsx +116 -0
  38. package/src/components/BHeaderUser/components/Badge/index.module.less +99 -0
  39. package/src/components/BHeaderUser/components/Badge/index.tsx +179 -0
  40. package/src/components/BHeaderUser/index.module.less +105 -0
  41. package/src/components/BHeaderUser/index.tsx +261 -0
  42. package/src/components/BHeaderUser/logout.tsx +26 -0
  43. package/src/components/BLayout/components/Header/index.module.less +27 -0
  44. package/src/components/BLayout/components/Header/index.tsx +36 -0
  45. package/src/components/BLayout/components/Layout/empty.tsx +35 -0
  46. package/src/components/BLayout/components/Layout/emptyPage.png +0 -0
  47. package/src/components/BLayout/components/Layout/index.tsx +72 -0
  48. package/src/components/BLayout/components/Logo.tsx +6 -0
  49. package/src/components/BLayout/components/Menu/collapse.tsx +41 -0
  50. package/src/components/BLayout/components/Menu/image/close.tsx +26 -0
  51. package/src/components/BLayout/components/Menu/image/closedefault.tsx +26 -0
  52. package/src/components/BLayout/components/Menu/image/open.tsx +38 -0
  53. package/src/components/BLayout/components/Menu/image/opendefault.tsx +38 -0
  54. package/src/components/BLayout/components/Menu/index.module.less +125 -0
  55. package/src/components/BLayout/components/Menu/index.tsx +244 -0
  56. package/src/components/BLayout/components/MenuIcon.module.less +5 -0
  57. package/src/components/BLayout/components/MenuIcon.tsx +46 -0
  58. package/src/components/BLayout/components/MultiSider/index.module.less +104 -0
  59. package/src/components/BLayout/components/MultiSider/index.tsx +172 -0
  60. package/src/components/BLayout/components/Sider/index.less +64 -0
  61. package/src/components/BLayout/components/Sider/index.module.less +17 -0
  62. package/src/components/BLayout/components/Sider/index.tsx +34 -0
  63. package/src/components/BLayout/index.tsx +78 -0
  64. package/src/components/BLayoutLogin/index.module.less +65 -0
  65. package/src/components/BLayoutLogin/index.tsx +68 -0
  66. package/src/components/BLayoutLogin/login.jpg +0 -0
  67. package/src/components/BLogin/component/Clause/index.module.less +25 -0
  68. package/src/components/BLogin/component/Clause/index.tsx +58 -0
  69. package/src/components/BLogin/component/ForgotBtn/index.module.less +9 -0
  70. package/src/components/BLogin/component/ForgotBtn/index.tsx +18 -0
  71. package/src/components/BLogin/component/Password/index.tsx +39 -0
  72. package/src/components/BLogin/component/SubmitBtn/index.tsx +30 -0
  73. package/src/components/BLogin/component/TenanSpace/index.tsx +28 -0
  74. package/src/components/BLogin/component/Title/index.module.less +6 -0
  75. package/src/components/BLogin/component/Title/index.tsx +12 -0
  76. package/src/components/BLogin/component/UserName/index.tsx +48 -0
  77. package/src/components/BLogin/component/VerifyCode/index.module.less +11 -0
  78. package/src/components/BLogin/component/VerifyCode/index.tsx +165 -0
  79. package/src/components/BLogin/index.module.less +31 -0
  80. package/src/components/BLogin/index.tsx +210 -0
  81. package/src/components/BRegister/components/TenantName/index.tsx +26 -0
  82. package/src/components/BRegister/index.module.less +5 -0
  83. package/src/components/BRegister/index.tsx +71 -0
  84. package/src/components/Back/index.tsx +25 -0
  85. package/src/components/IconFont/font.js +66 -0
  86. package/src/components/IconFont/index.tsx +18 -0
  87. package/src/components/MicroComponent/Header/index.module.less +7 -0
  88. package/src/components/MicroComponent/Header/index.tsx +220 -0
  89. package/src/components/PForgot/index.tsx +10 -0
  90. package/src/components/PLogin/index.tsx +12 -0
  91. package/src/components/PRegister/index.tsx +10 -0
  92. package/src/components/PSetting/index.module.less +53 -0
  93. package/src/components/PSetting/index.tsx +420 -0
  94. package/src/constant/chargeStatus.ts +6 -0
  95. package/src/constant/imgs.ts +6 -0
  96. package/src/constant/index.ts +293 -0
  97. package/src/dark-variable.less +1449 -0
  98. package/src/global.d.ts +54 -0
  99. package/src/hooks/index.ts +133 -0
  100. package/src/index.css +1493 -0
  101. package/src/index.tsx +105 -0
  102. package/src/lang/en.json +266 -0
  103. package/src/lang/index.ts +44 -0
  104. package/src/lang/utils.ts +285 -0
  105. package/src/lang/zh.json +270 -0
  106. package/src/micro-script/theme/index.ts +29 -0
  107. package/src/micro-script/theme/theme-css/static.js +73 -0
  108. package/src/micro-script/theme/theme-css/subscriber.ts +201 -0
  109. package/src/micro-script/theme/util/index.ts +58 -0
  110. package/src/mqtt/index.ts +121 -0
  111. package/src/pages/403.tsx +18 -0
  112. package/src/pages/404.tsx +17 -0
  113. package/src/pages/expiration.tsx +23 -0
  114. package/src/pages/forgot.tsx +9 -0
  115. package/src/pages/home/index.tsx +172 -0
  116. package/src/pages/home/setting/index.tsx +7 -0
  117. package/src/pages/index.ts +50 -0
  118. package/src/pages/login.tsx +46 -0
  119. package/src/pages/register.tsx +9 -0
  120. package/src/pages/relogin/index.module.less +0 -0
  121. package/src/pages/relogin/index.tsx +54 -0
  122. package/src/plugins/index.ts +11 -0
  123. package/src/public-path.js +8 -0
  124. package/src/qiankun/globalState.ts +6 -0
  125. package/src/qiankun/index.ts +174 -0
  126. package/src/qiankun/utils/index.ts +69 -0
  127. package/src/qiankun/xhook/index.ts +193 -0
  128. package/src/reportWebVitals.ts +15 -0
  129. package/src/sentry/index.ts +33 -0
  130. package/src/sky/index.ts +57 -0
  131. package/src/theme/custom-dark.less +64 -0
  132. package/src/theme/custom-light.less +48 -0
  133. package/src/theme/index.less +327 -0
  134. package/src/theme/variable.less +13 -0
  135. package/src/utils/checkPass.ts +21 -0
  136. package/src/utils/common.ts +195 -0
  137. package/src/utils/eventBus.ts +112 -0
  138. package/src/utils/gt.js +293 -0
  139. package/src/utils/index.ts +89 -0
  140. package/src/utils/theme/base.ts +110 -0
  141. package/src/utils/theme/changeCssVariable.ts +157 -0
  142. package/src/utils/theme/changeMenuCssVariable.ts +176 -0
  143. package/src/utils/theme/index.ts +85 -0
  144. package/src/utils/theme/store.ts +37 -0
  145. package/tsconfig.json +28 -0
  146. package/typings.d.ts +10 -0
  147. package/webpack.config.js +103 -0
@@ -0,0 +1,121 @@
1
+ import * as Sentry from '@sentry/react';
2
+ import * as mqttClient from 'mqtt';
3
+ import { api, URLS } from '@/api';
4
+
5
+ function handleError(label: string, info: any) {
6
+ console.error(`---${label}---\n`, info);
7
+ if (window._SDF_CONFIG?.sentry?.ENABLE) {
8
+ Sentry.addBreadcrumb({
9
+ category: label,
10
+ });
11
+ Sentry.captureException(info);
12
+ }
13
+ }
14
+
15
+ interface IMessage {
16
+ data: any;
17
+ protocol: number;
18
+ t: number;
19
+ type: string;
20
+ v: number;
21
+ }
22
+
23
+ const SDF_PROTOCOL = 4099;
24
+ let uid = '';
25
+ let isInit = false;
26
+ let micTopics = [];
27
+ const mqtt = (() => {
28
+ const topicsMap = new Map();
29
+ let client;
30
+ const init = (cb) => {
31
+ api.get(URLS.MQTT).then((data) => {
32
+ const clientId = data.client_id;
33
+ const username = data.username;
34
+ const password = data.password;
35
+ uid = data.uid;
36
+
37
+ client = mqttClient.connect(data.ws_url, {
38
+ clientId,
39
+ username,
40
+ password,
41
+ });
42
+ client.on('connect', () => {
43
+ isInit = true;
44
+ cb && cb();
45
+ });
46
+
47
+ client.on('reconnect', function () {
48
+ client.end();
49
+ client = null;
50
+ init(() => {});
51
+ });
52
+
53
+ client.on('error', function (a) {
54
+ handleError('mqtt error', a);
55
+ });
56
+
57
+ // client.on('offline', function () {});
58
+
59
+ // client.on('close', function () {});
60
+
61
+ client.on('message', function (topic: string, message) {
62
+ const result = JSON.parse(message.toString()) as IMessage;
63
+ if (result?.protocol === SDF_PROTOCOL && topicsMap.has(topic)) {
64
+ dispatchTopic(topic, result.data);
65
+ }
66
+ });
67
+ });
68
+ };
69
+
70
+ const subscribeTopic = (
71
+ bizType: string,
72
+ cbFn: (msg: string) => void,
73
+ option: { isGlobal: boolean }
74
+ ) => {
75
+ const toSubscribe = () => {
76
+ const topic = `sdf/${uid}/${bizType}`;
77
+ client.subscribe(topic);
78
+ const cbFns = topicsMap.get(topic) || [];
79
+ topicsMap.set(topic, [...cbFns, cbFn]);
80
+ !option?.isGlobal && micTopics.push(topic);
81
+ };
82
+
83
+ if (isInit) {
84
+ toSubscribe();
85
+ } else {
86
+ init(() => {
87
+ toSubscribe();
88
+ });
89
+ }
90
+ };
91
+
92
+ const unsubscribeMicTopics = () => {
93
+ for (const topic of micTopics) {
94
+ client.unsubscribe(topic);
95
+ topicsMap.delete(topic);
96
+ }
97
+ micTopics = [];
98
+ };
99
+
100
+ const unsubscribeTopic = (bizType) => {
101
+ const topic = `sdf/${uid}/${bizType}`;
102
+ client.unsubscribe(topic);
103
+ topicsMap.delete(topic);
104
+ micTopics = micTopics.filter((t) => t !== topic);
105
+ };
106
+
107
+ const dispatchTopic = (topic: string, message: IMessage) => {
108
+ topicsMap.get(topic).forEach((cbFn) => {
109
+ cbFn(message);
110
+ });
111
+ };
112
+
113
+ return {
114
+ init,
115
+ subscribeTopic,
116
+ unsubscribeMicTopics,
117
+ unsubscribeTopic,
118
+ };
119
+ })();
120
+
121
+ export default mqtt;
@@ -0,0 +1,18 @@
1
+ import { Result, Empty } from '@tuya-sat/galaxy';
2
+
3
+ const Page403 = () => {
4
+ return (
5
+ <Result
6
+ type={403}
7
+ icon={Empty.IMAGE_PERMISSION_COLORFUL}
8
+ style={{
9
+ display: 'flex',
10
+ justifyContent: 'center',
11
+ alignItems: 'center',
12
+ height: 'calc(100vh - 48px)',
13
+ }}
14
+ />
15
+ );
16
+ };
17
+
18
+ export default Page403;
@@ -0,0 +1,17 @@
1
+ import { Result, Empty } from '@tuya-sat/galaxy';
2
+ const Page404 = () => {
3
+ return (
4
+ <Result
5
+ type={404}
6
+ icon={Empty.IMAGE_404_COLORFUL}
7
+ style={{
8
+ display: 'flex',
9
+ justifyContent: 'center',
10
+ alignItems: 'center',
11
+ height: 'calc(100vh - 48px)',
12
+ }}
13
+ />
14
+ );
15
+ };
16
+
17
+ export default Page404;
@@ -0,0 +1,23 @@
1
+ import { ExpirationLogo } from '@/constant';
2
+ import { useTranslation } from 'react-i18next';
3
+
4
+ export default function Expiration() {
5
+ const { t } = useTranslation();
6
+
7
+ return (
8
+ <div
9
+ style={{
10
+ display: 'flex',
11
+ flexDirection: 'column',
12
+ alignItems: 'center',
13
+ justifyContent: 'center',
14
+ height: '100%',
15
+ }}
16
+ >
17
+ <img width="500px" src={ExpirationLogo} />
18
+ <div style={{ fontSize: '18px', fontWeight: 'bold' }}>
19
+ {t('expirationPage')}
20
+ </div>
21
+ </div>
22
+ );
23
+ }
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import PForgot from '@/components/PForgot';
3
+ import { RouteComponentProps } from 'react-router';
4
+
5
+ const Forget: FC<RouteComponentProps> = () => {
6
+ return <PForgot />;
7
+ };
8
+
9
+ export default Forget;
@@ -0,0 +1,172 @@
1
+ import BLayout from '@/components/BLayout';
2
+ import { useState, useEffect } from 'react';
3
+ import { useLocation, useHistory } from 'react-router-dom';
4
+ import { useSaasInfo } from '@/hooks';
5
+ import { runQiankun } from '@/qiankun';
6
+ import { getMenus } from '@/lang/utils';
7
+
8
+ import { Spin } from 'antd';
9
+ import Header, {
10
+ useHeader,
11
+ initHeaderInfoWithRouterChange,
12
+ } from '@/components/MicroComponent/Header';
13
+
14
+ //声明一个全局的变量,作为一些setBreadcrumb的代码挂载
15
+ const dynamicProps = {
16
+ setBreadcrumb: null,
17
+ };
18
+
19
+ const getEntries = (entryInfo) => {
20
+ const { entry_mode, entries } = entryInfo;
21
+ if (entry_mode === 'normal') {
22
+ return entries;
23
+ } else if (entry_mode === 'group') {
24
+ return entries.reduce((total, cur) => {
25
+ const { entry_type, sub_entry_list } = cur;
26
+ if (entry_type === 'group') {
27
+ return total.concat(sub_entry_list);
28
+ } else if (entry_type === 'entry') {
29
+ return total.concat(cur);
30
+ }
31
+ return total;
32
+ }, []);
33
+ }
34
+ };
35
+
36
+ export let mainHistory;
37
+ const Home = () => {
38
+ const [height, setHeight] = useState('0px');
39
+ const { pathname } = useLocation();
40
+
41
+ const history = useHistory();
42
+ const { entryInfo, appIds, apps, saasIdInfoList } = useSaasInfo();
43
+ const { headerInfo, setBreadcrumb, prevMicroAppInfo } = useHeader();
44
+ const [isMicroApp, setIsMicroApp] = useState<boolean>(true);
45
+ const [loading, setLoading] = useState(false);
46
+ dynamicProps.setBreadcrumb = setBreadcrumb;
47
+
48
+ mainHistory = {
49
+ ...history,
50
+ push: (path, state?) => {
51
+ const uuid = state?.universal_id;
52
+ const appId =
53
+ saasIdInfoList.find((item) => item.universal_id === uuid)
54
+ ?.oem_micro_app_id || '';
55
+ if (appId) {
56
+ history.push(`/apps/${appId}${path}`, state);
57
+ } else {
58
+ history.push(path, state);
59
+ }
60
+ },
61
+ replace: (path, state?) => {
62
+ const uuid = state?.universal_id;
63
+ const appId =
64
+ saasIdInfoList.find((item) => item.universal_id === uuid)
65
+ ?.oem_micro_app_id || '';
66
+ if (appId) {
67
+ history.replace(`/apps/${appId}${path}`, state);
68
+ } else {
69
+ history.replace(path, state);
70
+ }
71
+ },
72
+ go: (n: number) => {
73
+ history.go(n);
74
+ },
75
+ goBack: () => {
76
+ history.goBack();
77
+ },
78
+ goForward: () => {
79
+ history.goForward();
80
+ },
81
+ };
82
+ useEffect(() => {
83
+ setTimeout(() => {
84
+ runQiankun({
85
+ mainHistory,
86
+ appList: apps,
87
+ getOwnMenu: () => {
88
+ return getEntries(entryInfo).find(({ path }) =>
89
+ window.location.pathname.includes(path)
90
+ );
91
+ },
92
+ setLoading,
93
+ dynamicProps: dynamicProps,
94
+ });
95
+ });
96
+ }, [saasIdInfoList, entryInfo]);
97
+
98
+ useEffect(() => {
99
+ if (pathname && apps.length > 0) {
100
+ const paths = pathname.split('/');
101
+ if (paths.length > 2) {
102
+ const cur_oem_micro_app_id = paths[2];
103
+ if (
104
+ !apps
105
+ .map((item) => item.oem_micro_app_id)
106
+ .includes(cur_oem_micro_app_id) &&
107
+ appIds.includes(cur_oem_micro_app_id)
108
+ ) {
109
+ console.log('403');
110
+ history.push('/403');
111
+ }
112
+ }
113
+ }
114
+ }, [apps, pathname]);
115
+
116
+ useEffect(() => {
117
+ const entries = getEntries(entryInfo);
118
+ if (entries && entries.length > 0) {
119
+ if (
120
+ pathname.includes('/apps') &&
121
+ appIds.includes(pathname.split('/')[2])
122
+ ) {
123
+ setHeight('calc(100vh - 48px)');
124
+ setIsMicroApp(true);
125
+ } else {
126
+ setHeight('0px');
127
+ setIsMicroApp(false);
128
+ }
129
+ if (pathname === '/application/setting') {
130
+ setIsMicroApp(true);
131
+ }
132
+ initHeaderInfoWithRouterChange(
133
+ pathname,
134
+ prevMicroAppInfo,
135
+ entries.find(({ path }) => window.location.pathname.includes(path)),
136
+ setBreadcrumb
137
+ );
138
+ }
139
+ }, [pathname, entryInfo, appIds]);
140
+
141
+ return (
142
+ <BLayout
143
+ entryInfo={getMenus(entryInfo)}
144
+ isMicroApp={isMicroApp}
145
+ apps={apps}
146
+ >
147
+ <Spin spinning={loading}>
148
+ <div
149
+ style={{
150
+ height: height,
151
+ display: 'flex',
152
+ flexDirection: 'column',
153
+ overflow: 'hidden',
154
+ }}
155
+ >
156
+ <Header headerInfo={headerInfo} style={{ flex: '0 0 auto' }} />
157
+ <div
158
+ id="container"
159
+ className="main-app-containter"
160
+ style={{
161
+ flex: '1 1 auto',
162
+ height: '100%',
163
+ overflowY: 'auto',
164
+ }}
165
+ />
166
+ </div>
167
+ </Spin>
168
+ </BLayout>
169
+ );
170
+ };
171
+
172
+ export default Home;
@@ -0,0 +1,7 @@
1
+ import PSetting from '@/components/PSetting';
2
+
3
+ const Setting = () => {
4
+ return <PSetting />;
5
+ };
6
+
7
+ export default Setting;
@@ -0,0 +1,50 @@
1
+ import { FC } from 'react';
2
+ import { RouteComponentProps } from 'react-router';
3
+ import HomePage from './home';
4
+ import LoginPage from './login';
5
+ import ForgotPage from './forgot';
6
+ import RegisterPage from './register';
7
+ import Page404 from './404';
8
+ import ReLogin from './relogin';
9
+ import { gMainConfig } from '@/index';
10
+
11
+ interface Props {
12
+ backPath?: string;
13
+ }
14
+
15
+ export interface IPage {
16
+ name: string;
17
+ path: string;
18
+ exact: boolean;
19
+ page: FC<Props | RouteComponentProps>;
20
+ }
21
+
22
+ const index: IPage[] = [
23
+ { name: '登录页', path: '/login', exact: true, page: LoginPage },
24
+ {
25
+ name: '登录页',
26
+ path: '/application/relogin',
27
+ exact: true,
28
+ page: ReLogin,
29
+ },
30
+ { name: '忘记密码', path: '/forgot', exact: true, page: ForgotPage },
31
+ {
32
+ name: '注册',
33
+ path: '/register',
34
+ exact: true,
35
+ page:
36
+ window._SDF.saas.tenant_type === 'MULTI_TENANT' ? RegisterPage : Page404,
37
+ },
38
+ { name: '首页', path: '/', exact: false, page: HomePage },
39
+ ].map((item) => {
40
+ if (
41
+ gMainConfig?.pages &&
42
+ Object.keys(gMainConfig?.pages).includes(item.name)
43
+ ) {
44
+ return { ...item, page: gMainConfig.pages[item.name] };
45
+ } else {
46
+ return item;
47
+ }
48
+ });
49
+
50
+ export default index;
@@ -0,0 +1,46 @@
1
+ import { FC, useEffect, useState } from 'react';
2
+ import PLogin from '@/components/PLogin';
3
+ import { RouteComponentProps } from 'react-router';
4
+ import { hookFirst } from '@tuya-fe/sdf-plugin-runtime';
5
+ import { getPlugins } from '@/plugins';
6
+ import { useTranslation } from 'react-i18next';
7
+
8
+ function getParams(key: string) {
9
+ const searchParams = new URLSearchParams(window.location.search);
10
+ return searchParams.get(key);
11
+ }
12
+
13
+ const Login: FC<RouteComponentProps> = () => {
14
+ const { t } = useTranslation();
15
+ const [initial, setInitial] = useState(false);
16
+ const [err, setErr] = useState(null);
17
+
18
+ useEffect(() => {
19
+ (async () => {
20
+ const plugins = getPlugins();
21
+ const result = await hookFirst(plugins, 'thirdLogin');
22
+ if (result) {
23
+ const from = getParams('from');
24
+ from && window.location.replace(from);
25
+ } else {
26
+ setInitial(true);
27
+ }
28
+ })().catch((err) => {
29
+ setInitial(true);
30
+ setErr(err);
31
+ return Promise.reject(err);
32
+ });
33
+ }, []);
34
+
35
+ if (!initial) {
36
+ return <div></div>;
37
+ }
38
+
39
+ if (err) {
40
+ return <div>{t('login.thirdLoginError')}</div>;
41
+ }
42
+
43
+ return <PLogin />;
44
+ };
45
+
46
+ export default Login;
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import PRegister from '@/components/PRegister';
3
+ import { RouteComponentProps } from 'react-router';
4
+
5
+ const Register: FC<RouteComponentProps> = () => {
6
+ return <PRegister />;
7
+ };
8
+
9
+ export default Register;
File without changes
@@ -0,0 +1,54 @@
1
+ import { useTranslation } from 'react-i18next';
2
+ import ReLoginLogo from '@/assets/imgs/reLogin.png';
3
+ import { Button, Typography } from 'antd';
4
+ import { useHistory } from 'react-router-dom';
5
+ import { auth } from '@/utils/common';
6
+ import { useEffect } from 'react';
7
+
8
+ const { Text } = Typography;
9
+
10
+ export default function ReLogin() {
11
+ const { t } = useTranslation();
12
+ const history = useHistory();
13
+
14
+ useEffect(() => {
15
+ if (window._SDF.user) {
16
+ }
17
+ });
18
+
19
+ return (
20
+ <div
21
+ style={{
22
+ display: 'flex',
23
+ width: '100%',
24
+ height: '100vh',
25
+ flexDirection: 'column',
26
+ alignItems: 'center',
27
+ }}
28
+ >
29
+ <img src={ReLoginLogo} width="490" style={{ marginTop: '115px' }} />
30
+ <Text
31
+ style={{
32
+ fontSize: '18px',
33
+ lineHeight: '25px',
34
+ marginTop: '16px',
35
+ fontWeight: '400',
36
+ }}
37
+ >
38
+ {t('relogin.tip')}
39
+ </Text>
40
+ <Button
41
+ type="primary"
42
+ style={{ width: '320px', marginTop: '37px', marginBottom: '16px' }}
43
+ onClick={() => {
44
+ auth(history);
45
+ }}
46
+ >
47
+ {t('relogin.btn')}
48
+ </Button>
49
+ <Text style={{ fontSize: '14px', lineHeight: '20px' }} type="secondary">
50
+ {t('relogin.pwd')}
51
+ </Text>
52
+ </div>
53
+ );
54
+ }
@@ -0,0 +1,11 @@
1
+ import { creatPlugin } from '@tuya-fe/sdf-plugin-runtime';
2
+
3
+ let plugins = [];
4
+
5
+ export function getPlugins() {
6
+ return plugins;
7
+ }
8
+
9
+ export async function initialPlugins() {
10
+ plugins = await creatPlugin();
11
+ }
@@ -0,0 +1,8 @@
1
+ /* eslint-disable no-undef */
2
+ if (window.__MAIN_APP_PUBLIC_PATH) {
3
+ if (process.env.NODE_ENV === 'development' && !process.env.SDF) {
4
+ __webpack_public_path__ = '/';
5
+ } else {
6
+ __webpack_public_path__ = window.__MAIN_APP_PUBLIC_PATH;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ const globalState = {
2
+ isLogin: false,
3
+ lang: 'zh',
4
+ };
5
+
6
+ export default globalState;