@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
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tuya-sat/sdf-main-sdk",
|
|
3
|
+
"version": "0.0.1-beta.1",
|
|
4
|
+
"main": "./dist/main.bundle.js",
|
|
5
|
+
"types": "./index.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "webpack",
|
|
9
|
+
"dev": "webpack watch ",
|
|
10
|
+
"ts": "tsc --emitDeclarationOnly ",
|
|
11
|
+
"lint": "eslint *.ts*"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@babel/core": "^7.20.2",
|
|
15
|
+
"@babel/preset-env": "^7.20.2",
|
|
16
|
+
"@babel/preset-react": "^7.18.6",
|
|
17
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
18
|
+
"@sentry/tracing": "^6.13.3",
|
|
19
|
+
"@types/js-cookie": "^3.0.2",
|
|
20
|
+
"@types/react": "^17.0.0",
|
|
21
|
+
"@types/react-dom": "^17.0.0",
|
|
22
|
+
"@types/react-router": "^5.1.19",
|
|
23
|
+
"@types/react-router-dom": "^5.1.7",
|
|
24
|
+
"autoprefixer": "^10.4.13",
|
|
25
|
+
"babel-loader": "^9.1.0",
|
|
26
|
+
"buffer": "^6.0.3",
|
|
27
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
28
|
+
"core-js": "^3.26.1",
|
|
29
|
+
"css-loader": "^6.7.2",
|
|
30
|
+
"css-minimizer-webpack-plugin": "^4.2.2",
|
|
31
|
+
"eslint": "^7.32.0",
|
|
32
|
+
"file-loader": "^6.2.0",
|
|
33
|
+
"less": "^4.1.1",
|
|
34
|
+
"less-loader": "^8.1.1",
|
|
35
|
+
"mini-css-extract-plugin": "^2.7.0",
|
|
36
|
+
"postcss": "^8.4.19",
|
|
37
|
+
"postcss-loader": "^7.0.1",
|
|
38
|
+
"style-loader": "^3.3.1",
|
|
39
|
+
"typescript": "^4.5.2",
|
|
40
|
+
"typescript-declaration-webpack-plugin": "^0.2.2",
|
|
41
|
+
"webpack": "^5.75.0",
|
|
42
|
+
"webpack-bundle-analyzer": "^4.6.1",
|
|
43
|
+
"webpack-cli": "^4.10.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@ant-design/colors": "^6.0.0",
|
|
47
|
+
"@ant-design/icons": "^4.7.0",
|
|
48
|
+
"@ctrl/tinycolor": "^3.4.1",
|
|
49
|
+
"@sentry/react": "^6.13.3",
|
|
50
|
+
"@tuya-fe/sdf-plugin-runtime": "1.0.12",
|
|
51
|
+
"@tuya-sat/galaxy": "^1.0.8",
|
|
52
|
+
"antd": "4.19.5",
|
|
53
|
+
"axios": "^0.21.1",
|
|
54
|
+
"classnames": "^2.3.1",
|
|
55
|
+
"events": "^3.3.0",
|
|
56
|
+
"i18next": "^20.2.2",
|
|
57
|
+
"i18next-browser-languagedetector": "^6.1.0",
|
|
58
|
+
"js-cookie": "^3.0.1",
|
|
59
|
+
"js-sha256": "^0.9.0",
|
|
60
|
+
"mqtt": "^4.3.7",
|
|
61
|
+
"process": "^0.11.10",
|
|
62
|
+
"pubsub-js": "^1.9.4",
|
|
63
|
+
"qiankun": "github:tuya-sat/qiankun#86d94a0",
|
|
64
|
+
"qrcode.react": "^1.0.1",
|
|
65
|
+
"rc-util": "^5.24.4",
|
|
66
|
+
"react": "^17.0.2",
|
|
67
|
+
"react-dom": "^17.0.2",
|
|
68
|
+
"react-i18next": "^11.18.6",
|
|
69
|
+
"react-router-dom": "5.2.0",
|
|
70
|
+
"url": "^0.11.0",
|
|
71
|
+
"web-vitals": "^1.0.1",
|
|
72
|
+
"xhook": "^1.4.9"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
function normalizeLang(langKey, content) {
|
|
5
|
+
let obj = {};
|
|
6
|
+
|
|
7
|
+
function attachTo(prev, next) {
|
|
8
|
+
return `${prev === '' ? '' : prev + '.'}${next}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toSingleKey(lang, prevKey = '') {
|
|
12
|
+
Object.keys(lang).forEach((key) => {
|
|
13
|
+
let oneLevelKey = attachTo(prevKey, key);
|
|
14
|
+
if (typeof lang[key] !== 'object') {
|
|
15
|
+
obj[oneLevelKey] = lang[key];
|
|
16
|
+
} else {
|
|
17
|
+
toSingleKey(lang[key], oneLevelKey);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toSingleKey(content);
|
|
23
|
+
|
|
24
|
+
obj = {
|
|
25
|
+
[langKey]: obj,
|
|
26
|
+
};
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
(function run() {
|
|
31
|
+
const dir = './src/lang/';
|
|
32
|
+
|
|
33
|
+
const nowTime = new Date().valueOf();
|
|
34
|
+
|
|
35
|
+
const files = fs
|
|
36
|
+
.readdirSync(dir)
|
|
37
|
+
.filter((filename) => !filename.endsWith('.ts'));
|
|
38
|
+
|
|
39
|
+
let outputLang = {};
|
|
40
|
+
|
|
41
|
+
files.forEach(async (file) => {
|
|
42
|
+
const abosultePath = path.resolve(dir, file);
|
|
43
|
+
const basename = path.basename(file, '.json');
|
|
44
|
+
console.log(abosultePath, basename);
|
|
45
|
+
const content = JSON.parse(fs.readFileSync(abosultePath, 'utf-8'));
|
|
46
|
+
const lang = normalizeLang(basename, content);
|
|
47
|
+
outputLang = {
|
|
48
|
+
...outputLang,
|
|
49
|
+
...lang,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
fs.writeFileSync(
|
|
53
|
+
`lang_${nowTime}.json`,
|
|
54
|
+
JSON.stringify(outputLang, undefined, 2),
|
|
55
|
+
);
|
|
56
|
+
})();
|
package/src/App.less
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
@import 'antd/dist/antd.variable.less';
|
|
2
|
+
@import './theme/index.less';
|
|
3
|
+
|
|
4
|
+
.main-pro-menu-item {
|
|
5
|
+
height: 30px !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.main-pro-global-header-logo a h1 {
|
|
9
|
+
color: #000;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
font-size: 14px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.main-menu-inline-collapsed .main-pro-menu-item-title {
|
|
15
|
+
opacity: 0;
|
|
16
|
+
}
|
|
17
|
+
.main-form h3 {
|
|
18
|
+
margin: 0;
|
|
19
|
+
}
|
|
20
|
+
.init-loading {
|
|
21
|
+
width: 100vw;
|
|
22
|
+
height: 100vh;
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.main-primary-hover:hover {
|
|
27
|
+
color: @primary-color-hover;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@main-variable-prefix: main-app;
|
|
31
|
+
|
|
32
|
+
// js会默认往dom里面嵌入css变量,所以不需要在less里重复写一份
|
|
33
|
+
// html {
|
|
34
|
+
// // 主菜单
|
|
35
|
+
// --@{main-variable-prefix}-menu-bg: #fff; //底色
|
|
36
|
+
// --@{main-variable-prefix}-menu-text: rgba(0, 0, 0, 0.85); //文案&icon色值
|
|
37
|
+
// --@{main-variable-prefix}-menu-bg-expand: #fff; //展开底色
|
|
38
|
+
// --@{main-variable-prefix}-menu-text-expand: rgba(
|
|
39
|
+
// 0,
|
|
40
|
+
// 0,
|
|
41
|
+
// 0,
|
|
42
|
+
// 0.85
|
|
43
|
+
// ); //展开文案&icon色值
|
|
44
|
+
// --@{main-variable-prefix}-menu-bg-actived: #e6f6ff; //选中底色
|
|
45
|
+
// --@{main-variable-prefix}-menu-text-actived: @primary-color; //选中文案&icon色值
|
|
46
|
+
// // 分组菜单
|
|
47
|
+
// --@{main-variable-prefix}-menu-slide-bg: #fff;
|
|
48
|
+
// --@{main-variable-prefix}-menu-slide-text: rgba(0, 0, 0, 0.85);
|
|
49
|
+
// --@{main-variable-prefix}-menu-slide-bg-actived: #e6f6ff;
|
|
50
|
+
// --@{main-variable-prefix}-menu-slide-text-actived: @primary-color;
|
|
51
|
+
// --@{main-variable-prefix}-menu-slide-boundary: #f0f0f0;
|
|
52
|
+
// // 顶部导航
|
|
53
|
+
// --@{main-variable-prefix}-navigate-bg: #fff;
|
|
54
|
+
// --@{main-variable-prefix}-navigate-text: rgba(0, 0, 0, 0.85);
|
|
55
|
+
// --@{main-variable-prefix}-navigate-text-hover: @primary-color;
|
|
56
|
+
// --@{main-variable-prefix}-navigate-boundary: #f0f0f0;
|
|
57
|
+
// }
|
|
58
|
+
@menu-text: ~'var(--@{main-variable-prefix}-menu-text)';
|
|
59
|
+
@menu-slide-bg: ~'var(--@{main-variable-prefix}-menu-slide-bg)';
|
|
60
|
+
@nav-text-color: ~'var(--@{main-variable-prefix}-navigate-text)';
|
|
61
|
+
@nav-text-color-hover:~ 'var(--@{main-variable-prefix}-navigate-text-hover)';
|
|
62
|
+
|
|
63
|
+
//导航栏改写
|
|
64
|
+
.main-app-layout-header {
|
|
65
|
+
color: @nav-text-color !important;
|
|
66
|
+
background-color: ~'var(--@{main-variable-prefix}-navigate-bg)' !important;
|
|
67
|
+
border-bottom: 1px solid ~'var(--@{main-variable-prefix}-navigate-boundary)' !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.main-app-custom-nav-navItem {
|
|
71
|
+
color: @nav-text-color !important;
|
|
72
|
+
&:hover {
|
|
73
|
+
color: @nav-text-color-hover !important;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.main-nav-title {
|
|
78
|
+
color: @nav-text-color;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.main-nav-text-color {
|
|
82
|
+
color: @nav-text-color !important;
|
|
83
|
+
&:hover {
|
|
84
|
+
color: @nav-text-color-hover !important;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//分组菜单改写
|
|
89
|
+
.main-group-cover {
|
|
90
|
+
background: @menu-slide-bg;
|
|
91
|
+
border-right: 1px solid ~'var(--@{main-variable-prefix}-menu-slide-boundary)';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.main-group-item {
|
|
95
|
+
color: ~'var(--@{main-variable-prefix}-menu-slide-text)' !important;
|
|
96
|
+
background-color: @menu-slide-bg !important;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.main-group-active,
|
|
100
|
+
.main-group-item:hover {
|
|
101
|
+
color: ~'var(--@{main-variable-prefix}-menu-slide-text-actived)' !important;
|
|
102
|
+
background-color: ~'var(--@{main-variable-prefix}-menu-slide-bg-actived)' !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//菜单改写
|
|
106
|
+
.main-app-menu-group-mode,
|
|
107
|
+
.main-menu {
|
|
108
|
+
color: @menu-text !important;
|
|
109
|
+
background-color: ~'var(--@{main-variable-prefix}-menu-bg)' !important;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.main-menu-item {
|
|
113
|
+
color: @menu-text;
|
|
114
|
+
a {
|
|
115
|
+
color: @menu-text;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.main-menu-sub.main-menu-inline {
|
|
120
|
+
color: ~'var(--@{main-variable-prefix}-menu-text-expand)';
|
|
121
|
+
background-color: ~'var(--@{main-variable-prefix}-menu-bg-expand)';
|
|
122
|
+
.main-menu-item {
|
|
123
|
+
color: ~'var(--@{main-variable-prefix}-menu-text-expand)';
|
|
124
|
+
a {
|
|
125
|
+
color: ~'var(--@{main-variable-prefix}-menu-text-expand)';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.main-app-menu-group-mode > .main-menu {
|
|
131
|
+
border-top: 1px solid ~'var(--@{main-variable-prefix}-menu-slide-boundary)';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.main-menu-item:hover,
|
|
135
|
+
.main-menu-item:hover a,
|
|
136
|
+
.main-menu-item-selected,
|
|
137
|
+
.main-menu-item-selected a {
|
|
138
|
+
color: ~'var(--@{main-variable-prefix}-menu-text-actived)' !important;
|
|
139
|
+
background-color: ~'var(--@{main-variable-prefix}-menu-bg-actived)' !important;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.main-menu-submenu-selected,
|
|
143
|
+
.main-menu-submenu-selected .main-menu-submenu-arrow,
|
|
144
|
+
.main-menu-light .main-menu-submenu-title:hover,
|
|
145
|
+
.main-menu-submenu:hover > .main-menu-submenu-title > .main-menu-submenu-arrow {
|
|
146
|
+
color: ~'var(--@{main-variable-prefix}-menu-text-actived)' !important;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.main-menu-submenu-arrow {
|
|
150
|
+
color: ~'var(--@{main-variable-prefix}-menu-text)' !important;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.main-menu-submenu-selected .main-menu-submenu-arrow,
|
|
154
|
+
.main-menu-submenu:hover .main-menu-submenu-arrow {
|
|
155
|
+
color: ~'var(--@{main-variable-prefix}-menu-text-actived)' !important;
|
|
156
|
+
}
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useEffect, useState, useLayoutEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
BrowserRouter as Router,
|
|
4
|
+
Switch,
|
|
5
|
+
Route,
|
|
6
|
+
useHistory,
|
|
7
|
+
useLocation,
|
|
8
|
+
} from 'react-router-dom';
|
|
9
|
+
import { ConfigProvider } from 'antd';
|
|
10
|
+
import enUS from 'antd/lib/locale/en_US';
|
|
11
|
+
import zhCN from 'antd/lib/locale/zh_CN';
|
|
12
|
+
import { skyReport } from '@/sky';
|
|
13
|
+
import { apiIntercept } from '@/qiankun/xhook';
|
|
14
|
+
import { getMicroAppId, curMicroAppCode } from '@/utils';
|
|
15
|
+
import { WhitePathList } from '@/constant';
|
|
16
|
+
import i18n from '@/lang';
|
|
17
|
+
import './App.less';
|
|
18
|
+
import pages from './pages';
|
|
19
|
+
import { auth, getCurrentUser } from '@/utils/common';
|
|
20
|
+
import { initalTheme } from './utils/theme';
|
|
21
|
+
import { GalaxyProvider } from '@tuya-sat/galaxy';
|
|
22
|
+
|
|
23
|
+
export const thirdLoginUrl = '';
|
|
24
|
+
|
|
25
|
+
const App = () => {
|
|
26
|
+
const mainHistory = useHistory();
|
|
27
|
+
const location = useLocation();
|
|
28
|
+
const currentUser = getCurrentUser();
|
|
29
|
+
const needAuth = !WhitePathList.includes(mainHistory.location.pathname);
|
|
30
|
+
const isOem = window?._SDF.saas?.saas_id;
|
|
31
|
+
const [isThemeOK, setIsThemeOK] = useState(true);
|
|
32
|
+
|
|
33
|
+
let appId = '';
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (appId !== getMicroAppId()) {
|
|
37
|
+
performance.mark(`${getMicroAppId()}-start`);
|
|
38
|
+
appId = getMicroAppId();
|
|
39
|
+
}
|
|
40
|
+
}, [location.pathname]);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
apiIntercept({ mainHistory });
|
|
44
|
+
}, [mainHistory]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
skyReport(curMicroAppCode());
|
|
48
|
+
}, [location.pathname]);
|
|
49
|
+
|
|
50
|
+
useLayoutEffect(() => {
|
|
51
|
+
initalTheme(() => {
|
|
52
|
+
setIsThemeOK(true);
|
|
53
|
+
if (needAuth && isOem) {
|
|
54
|
+
// 非例外布局,均需校验登录状态
|
|
55
|
+
if (!Boolean(currentUser)) {
|
|
56
|
+
auth(mainHistory);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<ConfigProvider
|
|
64
|
+
locale={i18n.language === 'zh' ? zhCN : enUS}
|
|
65
|
+
prefixCls="main"
|
|
66
|
+
>
|
|
67
|
+
<GalaxyProvider
|
|
68
|
+
globalPrefixCls="main"
|
|
69
|
+
lang={i18n.language.includes('zh') ? 'zh' : 'en'}
|
|
70
|
+
>
|
|
71
|
+
{isThemeOK && (
|
|
72
|
+
<Switch>
|
|
73
|
+
{pages.map((item) => {
|
|
74
|
+
return (
|
|
75
|
+
<Route key={item.name} {...item}>
|
|
76
|
+
<item.page />
|
|
77
|
+
</Route>
|
|
78
|
+
);
|
|
79
|
+
})}
|
|
80
|
+
</Switch>
|
|
81
|
+
)}
|
|
82
|
+
</GalaxyProvider>
|
|
83
|
+
</ConfigProvider>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default App;
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import req from './req';
|
|
3
|
+
import res from './res';
|
|
4
|
+
|
|
5
|
+
export { URLS } from './urls';
|
|
6
|
+
|
|
7
|
+
export interface ResData<T> {
|
|
8
|
+
code: number;
|
|
9
|
+
msg?: string;
|
|
10
|
+
result?: T;
|
|
11
|
+
[keys: string]: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// see: https://github.com/axios/axios/issues/1510
|
|
15
|
+
export interface IAxiosInstance extends AxiosInstance {
|
|
16
|
+
request<T = any, R = ResData<T>>(config: AxiosRequestConfig): Promise<R>;
|
|
17
|
+
get<T = any, R = ResData<T>>(
|
|
18
|
+
url: string,
|
|
19
|
+
config?: AxiosRequestConfig
|
|
20
|
+
): Promise<R>;
|
|
21
|
+
delete<T = any, R = ResData<T>>(
|
|
22
|
+
url: string,
|
|
23
|
+
config?: AxiosRequestConfig
|
|
24
|
+
): Promise<R>;
|
|
25
|
+
head<T = any, R = ResData<T>>(
|
|
26
|
+
url: string,
|
|
27
|
+
config?: AxiosRequestConfig
|
|
28
|
+
): Promise<R>;
|
|
29
|
+
post<T = any, R = ResData<T>>(
|
|
30
|
+
url: string,
|
|
31
|
+
data?: any,
|
|
32
|
+
config?: AxiosRequestConfig
|
|
33
|
+
): Promise<R>;
|
|
34
|
+
put<T = any, R = ResData<T>>(
|
|
35
|
+
url: string,
|
|
36
|
+
data?: any,
|
|
37
|
+
config?: AxiosRequestConfig
|
|
38
|
+
): Promise<R>;
|
|
39
|
+
patch<T = any, R = ResData<T>>(
|
|
40
|
+
url: string,
|
|
41
|
+
data?: any,
|
|
42
|
+
config?: AxiosRequestConfig
|
|
43
|
+
): Promise<R>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const api: IAxiosInstance = axios.create();
|
|
47
|
+
|
|
48
|
+
//请求拦截
|
|
49
|
+
api.interceptors.request.use(req.onFulfilled, req.onRejected);
|
|
50
|
+
|
|
51
|
+
//响应拦截
|
|
52
|
+
api.interceptors.response.use(res.onFulfilled, res.onRejected);
|
package/src/api/req.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { UNLOGIN_APIS } from './urls';
|
|
3
|
+
|
|
4
|
+
const onFulfilled = (config: AxiosRequestConfig) => {
|
|
5
|
+
config.headers = {
|
|
6
|
+
...config.headers,
|
|
7
|
+
'micro-app-id': 'main-app',
|
|
8
|
+
'Content-Type': 'application/json;charset=utf-8',
|
|
9
|
+
};
|
|
10
|
+
if (Object.values(UNLOGIN_APIS).includes(config.url)) {
|
|
11
|
+
config.headers = {
|
|
12
|
+
...config.headers,
|
|
13
|
+
'skip-sdf-check-token': true,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const onRejected = (error) => Promise.reject(error);
|
|
20
|
+
|
|
21
|
+
const req = { onFulfilled, onRejected };
|
|
22
|
+
|
|
23
|
+
export default req;
|
package/src/api/res.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
// import { message } from 'antd';
|
|
3
|
+
import { ResData } from 'src/api';
|
|
4
|
+
import { getErrorMsg } from './utils';
|
|
5
|
+
import { URLS } from './urls';
|
|
6
|
+
|
|
7
|
+
const isShowMsg = (url) => {
|
|
8
|
+
return ![URLS.LOGOUT].includes(url);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFulfilled = (response: AxiosResponse<ResData<any>>) => {
|
|
12
|
+
const res = response.data;
|
|
13
|
+
//统一业务异常处理(主要根据错误码)
|
|
14
|
+
if (!res.success && isShowMsg(response.config.url)) {
|
|
15
|
+
// message.error(res.msg);
|
|
16
|
+
return Promise.reject(res);
|
|
17
|
+
}
|
|
18
|
+
return res.result;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const onRejected = (error) => {
|
|
22
|
+
// const msg = getErrorMsg(error);
|
|
23
|
+
// msg && message.error(msg);
|
|
24
|
+
return Promise.reject(error);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const res = { onFulfilled, onRejected };
|
|
28
|
+
|
|
29
|
+
export default res;
|
package/src/api/urls.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const LOGIN_APIS = {
|
|
2
|
+
RESET_PWD: '/open-api/v1.0/user/password',
|
|
3
|
+
SAAS_INFO: '/api/saas-info',
|
|
4
|
+
QRCODE: '/open-api/v1.0/device/app/qrcode/account/set',
|
|
5
|
+
MQTT: '/open-api/v1.0/mqtt',
|
|
6
|
+
ModifyPhoneAndEmail: '/open-api/v1.0/users/self',
|
|
7
|
+
USER_INFO: '/open-api/v1.0/current/user',
|
|
8
|
+
USER_INFO_V1: '/open-api/v1.1/current/user',
|
|
9
|
+
NOTICE_QUERY_LIST_GET: '/open-api/v1.0/notifications/messages',
|
|
10
|
+
NOTICE_HANDLE_READ_PUT: '/open-api/v1.0/notifications/messages/action/read',
|
|
11
|
+
NOTICE_DELETE_DELETE: '/open-api/v1.0/notifications/messages?message_ids=',
|
|
12
|
+
NOTICE_UNREAD_COUNT_GET:
|
|
13
|
+
'/open-api/v1.0/notifications/messages/unread/counts',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const UNLOGIN_APIS = {
|
|
17
|
+
FORGET_PWD: '/open-api/v1.0/user/password/reset',
|
|
18
|
+
CODE: '/open-api/v1.0/user/password/reset/captcha',
|
|
19
|
+
TENANDCODE: '/open-api/v1.0/tenant/register/captcha',
|
|
20
|
+
REGISTER: '/open-api/v1.0/tenant/register',
|
|
21
|
+
CAPTCHA: '/open-api/v1.0/captcha',
|
|
22
|
+
SAAS: '/open-api/v1.0/saas', //未登录白名单
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const URLS = {
|
|
26
|
+
LOGIN: '/api/login',
|
|
27
|
+
LOGOUT: '/api/logout',
|
|
28
|
+
...LOGIN_APIS,
|
|
29
|
+
...UNLOGIN_APIS,
|
|
30
|
+
};
|
package/src/api/utils.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import Cookies from 'js-cookie';
|
|
3
|
+
|
|
4
|
+
const httpCodeHasTextSet = new Set([
|
|
5
|
+
400, 401, 403, 404, 408, 500, 501, 502, 503, 504, 505,
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
const langRange = ['en', 'zh'];
|
|
9
|
+
|
|
10
|
+
export const getLangKey = () => {
|
|
11
|
+
const currentLng = Cookies.get('main-i18next');
|
|
12
|
+
const langKey = langRange.includes(currentLng) ? currentLng : langRange[0];
|
|
13
|
+
return langKey;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getErrorMsg = (error) => {
|
|
17
|
+
const { response, message, code, __CANCEL__ } = error || {};
|
|
18
|
+
const langKey = getLangKey();
|
|
19
|
+
const { httpCodeText } = i18n.getDataByLanguage(langKey).translation;
|
|
20
|
+
let msg = '';
|
|
21
|
+
if (__CANCEL__) {
|
|
22
|
+
//不处理cancellation
|
|
23
|
+
return msg;
|
|
24
|
+
}
|
|
25
|
+
if (response) {
|
|
26
|
+
const { status, data } = response;
|
|
27
|
+
msg =
|
|
28
|
+
data?.msg ||
|
|
29
|
+
(httpCodeHasTextSet.has(status)
|
|
30
|
+
? httpCodeText[status]
|
|
31
|
+
: httpCodeText['default'].replace('{{status}}', status));
|
|
32
|
+
} else if (['ECONNABORTED', 'ETIMEDOUT'].includes(code)) {
|
|
33
|
+
msg =
|
|
34
|
+
message === 'Request aborted'
|
|
35
|
+
? httpCodeText['abort']
|
|
36
|
+
: httpCodeText['timeout'];
|
|
37
|
+
} else {
|
|
38
|
+
msg = httpCodeText['callBack'];
|
|
39
|
+
}
|
|
40
|
+
return msg;
|
|
41
|
+
};
|