@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.
- package/.vscode/settings.json +5 -0
- package/README.md +1 -0
- package/antd.less.overwrite.js +56 -0
- package/color.js +140 -0
- package/dark-variable.less +1449 -0
- package/package.json +74 -0
- package/scripts/gen-localize-file.mjs +56 -0
- package/src/App.less +156 -0
- package/src/App.tsx +87 -0
- package/src/api/index.ts +52 -0
- package/src/api/req.ts +23 -0
- package/src/api/res.ts +29 -0
- package/src/api/urls.ts +30 -0
- package/src/api/utils.ts +41 -0
- package/src/assets/imgs/404.svg +194 -0
- package/src/assets/imgs/reLogin.png +0 -0
- package/src/components/404/index.tsx +44 -0
- package/src/components/500/index.tsx +49 -0
- package/src/components/BCustomNav/index.module.less +17 -0
- package/src/components/BCustomNav/index.tsx +108 -0
- package/src/components/BForgot/index.module.less +5 -0
- package/src/components/BForgot/index.tsx +96 -0
- package/src/components/BHeaderUser/account.png +0 -0
- package/src/components/BHeaderUser/app-scan-en.png +0 -0
- package/src/components/BHeaderUser/app-scan-zh.png +0 -0
- package/src/components/BHeaderUser/app-scan.png +0 -0
- package/src/components/BHeaderUser/components/BSwitchLang/index.module.less +6 -0
- package/src/components/BHeaderUser/components/BSwitchLang/index.tsx +56 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/Content.tsx +199 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.module.less +11 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.tsx +27 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/hooks.ts +104 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/index.module.less +70 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/index.tsx +184 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/table/index.tsx +184 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/table/read.tsx +67 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/tools/index.tsx +116 -0
- package/src/components/BHeaderUser/components/Badge/index.module.less +99 -0
- package/src/components/BHeaderUser/components/Badge/index.tsx +179 -0
- package/src/components/BHeaderUser/index.module.less +105 -0
- package/src/components/BHeaderUser/index.tsx +261 -0
- package/src/components/BHeaderUser/logout.tsx +26 -0
- package/src/components/BLayout/components/Header/index.module.less +27 -0
- package/src/components/BLayout/components/Header/index.tsx +36 -0
- package/src/components/BLayout/components/Layout/empty.tsx +35 -0
- package/src/components/BLayout/components/Layout/emptyPage.png +0 -0
- package/src/components/BLayout/components/Layout/index.tsx +72 -0
- package/src/components/BLayout/components/Logo.tsx +6 -0
- package/src/components/BLayout/components/Menu/collapse.tsx +41 -0
- package/src/components/BLayout/components/Menu/image/close.tsx +26 -0
- package/src/components/BLayout/components/Menu/image/closedefault.tsx +26 -0
- package/src/components/BLayout/components/Menu/image/open.tsx +38 -0
- package/src/components/BLayout/components/Menu/image/opendefault.tsx +38 -0
- package/src/components/BLayout/components/Menu/index.module.less +125 -0
- package/src/components/BLayout/components/Menu/index.tsx +244 -0
- package/src/components/BLayout/components/MenuIcon.module.less +5 -0
- package/src/components/BLayout/components/MenuIcon.tsx +46 -0
- package/src/components/BLayout/components/MultiSider/index.module.less +104 -0
- package/src/components/BLayout/components/MultiSider/index.tsx +172 -0
- package/src/components/BLayout/components/Sider/index.less +64 -0
- package/src/components/BLayout/components/Sider/index.module.less +17 -0
- package/src/components/BLayout/components/Sider/index.tsx +34 -0
- package/src/components/BLayout/index.tsx +78 -0
- package/src/components/BLayoutLogin/index.module.less +65 -0
- package/src/components/BLayoutLogin/index.tsx +68 -0
- package/src/components/BLayoutLogin/login.jpg +0 -0
- package/src/components/BLogin/component/Clause/index.module.less +25 -0
- package/src/components/BLogin/component/Clause/index.tsx +58 -0
- package/src/components/BLogin/component/ForgotBtn/index.module.less +9 -0
- package/src/components/BLogin/component/ForgotBtn/index.tsx +18 -0
- package/src/components/BLogin/component/Password/index.tsx +39 -0
- package/src/components/BLogin/component/SubmitBtn/index.tsx +30 -0
- package/src/components/BLogin/component/TenanSpace/index.tsx +28 -0
- package/src/components/BLogin/component/Title/index.module.less +6 -0
- package/src/components/BLogin/component/Title/index.tsx +12 -0
- package/src/components/BLogin/component/UserName/index.tsx +48 -0
- package/src/components/BLogin/component/VerifyCode/index.module.less +11 -0
- package/src/components/BLogin/component/VerifyCode/index.tsx +165 -0
- package/src/components/BLogin/index.module.less +31 -0
- package/src/components/BLogin/index.tsx +210 -0
- package/src/components/BRegister/components/TenantName/index.tsx +26 -0
- package/src/components/BRegister/index.module.less +5 -0
- package/src/components/BRegister/index.tsx +71 -0
- package/src/components/Back/index.tsx +25 -0
- package/src/components/IconFont/font.js +66 -0
- package/src/components/IconFont/index.tsx +18 -0
- package/src/components/MicroComponent/Header/index.module.less +7 -0
- package/src/components/MicroComponent/Header/index.tsx +220 -0
- package/src/components/PForgot/index.tsx +10 -0
- package/src/components/PLogin/index.tsx +12 -0
- package/src/components/PRegister/index.tsx +10 -0
- package/src/components/PSetting/index.module.less +53 -0
- package/src/components/PSetting/index.tsx +420 -0
- package/src/constant/chargeStatus.ts +6 -0
- package/src/constant/imgs.ts +6 -0
- package/src/constant/index.ts +293 -0
- package/src/dark-variable.less +1449 -0
- package/src/global.d.ts +54 -0
- package/src/hooks/index.ts +133 -0
- package/src/index.css +1493 -0
- package/src/index.tsx +105 -0
- package/src/lang/en.json +266 -0
- package/src/lang/index.ts +44 -0
- package/src/lang/utils.ts +285 -0
- package/src/lang/zh.json +270 -0
- package/src/micro-script/theme/index.ts +29 -0
- package/src/micro-script/theme/theme-css/static.js +73 -0
- package/src/micro-script/theme/theme-css/subscriber.ts +201 -0
- package/src/micro-script/theme/util/index.ts +58 -0
- package/src/mqtt/index.ts +121 -0
- package/src/pages/403.tsx +18 -0
- package/src/pages/404.tsx +17 -0
- package/src/pages/expiration.tsx +23 -0
- package/src/pages/forgot.tsx +9 -0
- package/src/pages/home/index.tsx +172 -0
- package/src/pages/home/setting/index.tsx +7 -0
- package/src/pages/index.ts +50 -0
- package/src/pages/login.tsx +46 -0
- package/src/pages/register.tsx +9 -0
- package/src/pages/relogin/index.module.less +0 -0
- package/src/pages/relogin/index.tsx +54 -0
- package/src/plugins/index.ts +11 -0
- package/src/public-path.js +8 -0
- package/src/qiankun/globalState.ts +6 -0
- package/src/qiankun/index.ts +174 -0
- package/src/qiankun/utils/index.ts +69 -0
- package/src/qiankun/xhook/index.ts +193 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/sentry/index.ts +33 -0
- package/src/sky/index.ts +57 -0
- package/src/theme/custom-dark.less +64 -0
- package/src/theme/custom-light.less +48 -0
- package/src/theme/index.less +327 -0
- package/src/theme/variable.less +13 -0
- package/src/utils/checkPass.ts +21 -0
- package/src/utils/common.ts +195 -0
- package/src/utils/eventBus.ts +112 -0
- package/src/utils/gt.js +293 -0
- package/src/utils/index.ts +89 -0
- package/src/utils/theme/base.ts +110 -0
- package/src/utils/theme/changeCssVariable.ts +157 -0
- package/src/utils/theme/changeMenuCssVariable.ts +176 -0
- package/src/utils/theme/index.ts +85 -0
- package/src/utils/theme/store.ts +37 -0
- package/tsconfig.json +28 -0
- package/typings.d.ts +10 -0
- 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,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,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;
|
|
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
|
+
}
|