@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/src/index.tsx
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import './utils/gt.js';
|
|
3
|
+
import './public-path.js';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
7
|
+
import { initialPlugins } from './plugins';
|
|
8
|
+
import reportWebVitals from './reportWebVitals';
|
|
9
|
+
import { initSky } from './sky';
|
|
10
|
+
import App from './App';
|
|
11
|
+
|
|
12
|
+
console.log('sdf-main-sdk');
|
|
13
|
+
import './sentry';
|
|
14
|
+
export { runQiankun } from './qiankun';
|
|
15
|
+
export { apiIntercept } from './qiankun/xhook';
|
|
16
|
+
export { isSupportMobileWithFallback } from './qiankun/utils';
|
|
17
|
+
export { getMicroAppId, curMicroAppName, curMicroAppCode } from './utils';
|
|
18
|
+
|
|
19
|
+
export { api, URLS } from './api';
|
|
20
|
+
|
|
21
|
+
export { default as i18n } from './lang';
|
|
22
|
+
export {
|
|
23
|
+
dynamicHeaderMenu,
|
|
24
|
+
switchLang,
|
|
25
|
+
langList,
|
|
26
|
+
gLang,
|
|
27
|
+
oemSaasAy,
|
|
28
|
+
getMenus,
|
|
29
|
+
} from './lang/utils';
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
WhitePathList,
|
|
33
|
+
EVENT_NOTICE,
|
|
34
|
+
CHARGE_STATUS,
|
|
35
|
+
TENANT_ID_REGEXP,
|
|
36
|
+
US_TELE_REGEXP,
|
|
37
|
+
EMAIL_REGEXP,
|
|
38
|
+
ExpirationLogo,
|
|
39
|
+
SafePath,
|
|
40
|
+
} from './constant';
|
|
41
|
+
|
|
42
|
+
export { default as Page403 } from './pages/403';
|
|
43
|
+
export { default as Page404 } from './pages/404';
|
|
44
|
+
export { default as Expiration } from './pages/expiration';
|
|
45
|
+
export { default as ReLogin } from './pages/relogin';
|
|
46
|
+
export { default as Forget } from './pages/forgot';
|
|
47
|
+
export { default as Register } from './pages/register';
|
|
48
|
+
export { default as Login } from './pages/login';
|
|
49
|
+
export { default as Home } from './pages/home';
|
|
50
|
+
export { default as Setting } from './pages/home/setting';
|
|
51
|
+
|
|
52
|
+
export { default as pages } from './pages';
|
|
53
|
+
|
|
54
|
+
export { useSaasInfo, micApps, permissions, apis } from './hooks';
|
|
55
|
+
|
|
56
|
+
export interface IHooks {
|
|
57
|
+
enterAppHook: () => void;
|
|
58
|
+
httpHook: () => void;
|
|
59
|
+
unLoginSaaSHook: (saas) => void;
|
|
60
|
+
loginApiHook: () => void;
|
|
61
|
+
beforeLoginApiHook: () => void;
|
|
62
|
+
afterLoginApiHook: () => void;
|
|
63
|
+
beforeHomeHook: () => void;
|
|
64
|
+
qiankunHook: () => void;
|
|
65
|
+
enterBeforeMenuHook: () => void;
|
|
66
|
+
enterNavMenuhook: () => void;
|
|
67
|
+
enterBeforeBdbHook: () => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface IMainConfig {
|
|
71
|
+
pages?: {
|
|
72
|
+
[key: string]: {
|
|
73
|
+
name: string;
|
|
74
|
+
component: React.FC;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
lang?: {
|
|
78
|
+
zh: Object;
|
|
79
|
+
en: Object;
|
|
80
|
+
};
|
|
81
|
+
hooks: IHooks;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export let gMainConfig;
|
|
85
|
+
|
|
86
|
+
export const bootStrapSDF = async (mainConfig: IMainConfig) => {
|
|
87
|
+
console.log('bootStrapSDF');
|
|
88
|
+
window._SDF?.saas?.skyEyeEnable && initSky();
|
|
89
|
+
console.log('mainConfig', mainConfig);
|
|
90
|
+
gMainConfig = mainConfig;
|
|
91
|
+
mainConfig?.hooks?.enterAppHook && (await mainConfig.hooks.enterAppHook());
|
|
92
|
+
await initialPlugins();
|
|
93
|
+
mainConfig?.hooks?.unLoginSaaSHook &&
|
|
94
|
+
(await mainConfig.hooks.unLoginSaaSHook(window._SDF.saas));
|
|
95
|
+
await initialPlugins();
|
|
96
|
+
ReactDOM.render(
|
|
97
|
+
<BrowserRouter basename={window.location.pathname.match(/\/g\/\d*/)?.[0]}>
|
|
98
|
+
<React.StrictMode>
|
|
99
|
+
<App />
|
|
100
|
+
</React.StrictMode>
|
|
101
|
+
</BrowserRouter>,
|
|
102
|
+
document.getElementById('root')
|
|
103
|
+
);
|
|
104
|
+
reportWebVitals();
|
|
105
|
+
};
|
package/src/lang/en.json
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
{
|
|
2
|
+
"translation": {
|
|
3
|
+
"login": {
|
|
4
|
+
"title": "SaaS Framework Demo",
|
|
5
|
+
"tabs": {
|
|
6
|
+
"tele": "Phone Number",
|
|
7
|
+
"email": "Email"
|
|
8
|
+
},
|
|
9
|
+
"form": {
|
|
10
|
+
"username": {
|
|
11
|
+
"label": "Account",
|
|
12
|
+
"validate": {
|
|
13
|
+
"require": "Please input account",
|
|
14
|
+
"pattern": "Please enter the correct mobile number or email",
|
|
15
|
+
"emailPattern": "Email address format is incorrect",
|
|
16
|
+
"phonePattern": "Phone number format is incorrect"
|
|
17
|
+
},
|
|
18
|
+
"placeholder": "Please enter e-mail/phone number"
|
|
19
|
+
},
|
|
20
|
+
"password": {
|
|
21
|
+
"label": "Password",
|
|
22
|
+
"validate": {
|
|
23
|
+
"require": "Please input password",
|
|
24
|
+
"pattern": "Password length is 8-20 and contains at least three character types (numbers, uppercase letters, lowercase letters and English symbols)"
|
|
25
|
+
},
|
|
26
|
+
"placeholder": "Please enter password"
|
|
27
|
+
},
|
|
28
|
+
"newPassword": {
|
|
29
|
+
"label": "New Password"
|
|
30
|
+
},
|
|
31
|
+
"phone": {
|
|
32
|
+
"label": "Phone number",
|
|
33
|
+
"phonePattern": "Phone number format is incorrect"
|
|
34
|
+
},
|
|
35
|
+
"code": {
|
|
36
|
+
"require": "Confirmation code",
|
|
37
|
+
"requireAccount": "Please enter the address to receive the verification code",
|
|
38
|
+
"placeholder": "confirmation code",
|
|
39
|
+
"getCode": "verification code",
|
|
40
|
+
"len": "Please enter the 6-digit verification code",
|
|
41
|
+
"countdown": "after "
|
|
42
|
+
},
|
|
43
|
+
"tenantId": {
|
|
44
|
+
"label": "Tenant ID",
|
|
45
|
+
"placeholder": "Please enter tenant ID",
|
|
46
|
+
"require": "Please enter tenant ID",
|
|
47
|
+
"pattern": "The tenant ID is 4-16 characters long and must start with a lowercase letter (lowercase letters, numbers, and hyphens are supported)"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"signIn": "Sign In",
|
|
51
|
+
"forgot": "Forgot password?",
|
|
52
|
+
"back2login": "Back to login",
|
|
53
|
+
"resetPwd": "Reset Password",
|
|
54
|
+
"resetPwdSuccess": "Password changed successfully, please use the new password to log in",
|
|
55
|
+
"text": "Agree to ",
|
|
56
|
+
"service": "Terms of Use",
|
|
57
|
+
"legal": "Legal Statement",
|
|
58
|
+
"privacy": "Privacy Policy",
|
|
59
|
+
"admin_account_login": "Admin Login",
|
|
60
|
+
"sub_account_login": "User Login",
|
|
61
|
+
"lang": "English",
|
|
62
|
+
"thirdLoginError": "Third-party login failed"
|
|
63
|
+
},
|
|
64
|
+
"menu": {
|
|
65
|
+
"title": {
|
|
66
|
+
"default": "SaaS Framework Demo",
|
|
67
|
+
"assets": "Asset Management",
|
|
68
|
+
"devices": "Device Management",
|
|
69
|
+
"setting": "Account Settings",
|
|
70
|
+
"permission": "Role & Permission",
|
|
71
|
+
"account": "Users"
|
|
72
|
+
},
|
|
73
|
+
"edition": {
|
|
74
|
+
"preview": "PREVIEW",
|
|
75
|
+
"latest": "LATEST",
|
|
76
|
+
"stable": "STABLE",
|
|
77
|
+
"trial": "TRIAL"
|
|
78
|
+
},
|
|
79
|
+
"logout": "Sign out"
|
|
80
|
+
},
|
|
81
|
+
"setting": {
|
|
82
|
+
"title": "Settings",
|
|
83
|
+
"account": "User Account",
|
|
84
|
+
"phone": "Phone Number",
|
|
85
|
+
"email": "Mail",
|
|
86
|
+
"bind": "Bind",
|
|
87
|
+
"unBind": "Unbind",
|
|
88
|
+
"bindPhone": "Bind Phone Number",
|
|
89
|
+
"bindEmail": "Bind Email Address",
|
|
90
|
+
"modify": "Modify",
|
|
91
|
+
"modifyPhone": "Modify",
|
|
92
|
+
"modifyEmail": "Modify",
|
|
93
|
+
"phoneLable": "Enter the mobile number.",
|
|
94
|
+
"emailLable": "Enter your email address.",
|
|
95
|
+
"accountLable": "User Account (Login Account)",
|
|
96
|
+
"name": "Name",
|
|
97
|
+
"username": "Username",
|
|
98
|
+
"password": "Password",
|
|
99
|
+
"role": "",
|
|
100
|
+
"modifyPwd": "Change Password",
|
|
101
|
+
"language": "Language",
|
|
102
|
+
"form": {
|
|
103
|
+
"oldPassword": {
|
|
104
|
+
"label": "Old password",
|
|
105
|
+
"validate": {
|
|
106
|
+
"require": "Please enter the old password",
|
|
107
|
+
"pattern": "Password length is 8-20 and contains at least three character types (numbers, uppercase letters, lowercase letters and English symbols)"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"newPassword": {
|
|
111
|
+
"label": "New password",
|
|
112
|
+
"validate": {
|
|
113
|
+
"require": "Please enter a new password",
|
|
114
|
+
"pattern": "Password length is 8-20 and contains at least three character types (numbers, uppercase letters, lowercase letters and English symbols)"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"confirm": {
|
|
118
|
+
"label": "Confirm new password",
|
|
119
|
+
"validate": {
|
|
120
|
+
"require": "Please enter the new password again",
|
|
121
|
+
"pattern": "Password length is 8-20 and contains at least three character types (numbers, uppercase letters, lowercase letters and English symbols)",
|
|
122
|
+
"unanimous": "The two password entries are inconsistent"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"modifySuccess": "Password successfully changed"
|
|
127
|
+
},
|
|
128
|
+
"notice": {
|
|
129
|
+
"title": "Message Details",
|
|
130
|
+
"typeSelect": {
|
|
131
|
+
"placeholder": " Type",
|
|
132
|
+
"all": "All",
|
|
133
|
+
"message": "Message Notification",
|
|
134
|
+
"alert": "Alarm Message"
|
|
135
|
+
},
|
|
136
|
+
"originSelect": {
|
|
137
|
+
"placeholder": "Source",
|
|
138
|
+
"all": "All",
|
|
139
|
+
"center": "Message Center",
|
|
140
|
+
"app": "App Push",
|
|
141
|
+
"short": "SMS",
|
|
142
|
+
"email": "Email",
|
|
143
|
+
"telephone": "Voice"
|
|
144
|
+
},
|
|
145
|
+
"StatusSelect": {
|
|
146
|
+
"placeholder": "Status",
|
|
147
|
+
"all": "All",
|
|
148
|
+
"readed": "Read",
|
|
149
|
+
"unread": "Unread"
|
|
150
|
+
},
|
|
151
|
+
"badge": {
|
|
152
|
+
"title": "Message Notifications",
|
|
153
|
+
"type": "Notification Types",
|
|
154
|
+
"message": "View all messages"
|
|
155
|
+
},
|
|
156
|
+
"tools": {
|
|
157
|
+
"button": {
|
|
158
|
+
"read": "Mark as Read",
|
|
159
|
+
"unread": "Mark as Unread",
|
|
160
|
+
"delete": "Delete",
|
|
161
|
+
"allRead": "Mark All as Read"
|
|
162
|
+
},
|
|
163
|
+
"checkbox": {
|
|
164
|
+
"onlyViewUnread": "Unread Only"
|
|
165
|
+
},
|
|
166
|
+
"select": {
|
|
167
|
+
"all": "All",
|
|
168
|
+
"system": "System Notification",
|
|
169
|
+
"device": "Device Message",
|
|
170
|
+
"work": "Business Message"
|
|
171
|
+
},
|
|
172
|
+
"popconfirm": {
|
|
173
|
+
"title": "Are you sure to delete the selected message(s)?",
|
|
174
|
+
"content": "Unrecoverable after deletion",
|
|
175
|
+
"cancel": "Cancel",
|
|
176
|
+
"ok": "OK"
|
|
177
|
+
},
|
|
178
|
+
"selectedAllContent": "Everything in message has been selected",
|
|
179
|
+
"itemsNums": "All {{num}} message on this page are selected",
|
|
180
|
+
"totalNums": "Select all {{num}} messages ",
|
|
181
|
+
"cancelSelect": "Cancel",
|
|
182
|
+
"pread": "Mark as read",
|
|
183
|
+
"punread": "Mark as unread",
|
|
184
|
+
"pdelete": "Delete"
|
|
185
|
+
},
|
|
186
|
+
"table": {
|
|
187
|
+
"column": {
|
|
188
|
+
"content": "Message Content",
|
|
189
|
+
"status": "Message Status",
|
|
190
|
+
"type": "Message Type",
|
|
191
|
+
"source": "Message Source",
|
|
192
|
+
"time": "Time"
|
|
193
|
+
},
|
|
194
|
+
"render": {
|
|
195
|
+
"status": {
|
|
196
|
+
"read": "Read",
|
|
197
|
+
"unread": "Unread"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"hover": {
|
|
201
|
+
"read": "Mark as read",
|
|
202
|
+
"unread": "Mark as unread",
|
|
203
|
+
"del": "Delete"
|
|
204
|
+
},
|
|
205
|
+
"delTip": "Are you sure to delete?"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"httpCodeText": {
|
|
209
|
+
"400": "Request error",
|
|
210
|
+
"401": "Unauthorized, please log in again",
|
|
211
|
+
"403": "access denied",
|
|
212
|
+
"404": "Request error",
|
|
213
|
+
"408": "Request timed out",
|
|
214
|
+
"500": "Server Error",
|
|
215
|
+
"501": "Service not implemented",
|
|
216
|
+
"502": "Network Error",
|
|
217
|
+
"503": "service is not available",
|
|
218
|
+
"504": "network timeout",
|
|
219
|
+
"505": "HTTP version is not supported",
|
|
220
|
+
"default": "Service exception({{status}})",
|
|
221
|
+
"timeout": "Request timed out",
|
|
222
|
+
"abort": "Connection failed",
|
|
223
|
+
"callBack": "Network exception"
|
|
224
|
+
},
|
|
225
|
+
"appHint1": "Scan the QR code with Smart Industry App",
|
|
226
|
+
"appHint2": "explorer more features",
|
|
227
|
+
"backLoginPage": "Back to Page Login",
|
|
228
|
+
"backHome": "Back Home",
|
|
229
|
+
"pageError": "Sorry, you are not authorized to access this page.",
|
|
230
|
+
"page404": "Sorry, the page you visited does not exist.",
|
|
231
|
+
"page500": "System error, try again later",
|
|
232
|
+
"emptyPage": "No authority, please contact the administrator to add permissions",
|
|
233
|
+
"expirationPage": "The SaaS experience service has expired, please contact the developer to pay",
|
|
234
|
+
"trial": "Trial Version",
|
|
235
|
+
"admin": "Administrator",
|
|
236
|
+
"forgot": {
|
|
237
|
+
"title": "Retrive password",
|
|
238
|
+
"resetPwd": "Reset Password",
|
|
239
|
+
"tenantRole": "Tenant user",
|
|
240
|
+
"managerRole": "Tanant admin",
|
|
241
|
+
"noAccount": "No account yet?",
|
|
242
|
+
"toRegister": "Tenant register"
|
|
243
|
+
},
|
|
244
|
+
"register": {
|
|
245
|
+
"form": {
|
|
246
|
+
"enterprise": {
|
|
247
|
+
"label": "Name of organization",
|
|
248
|
+
"validate": {
|
|
249
|
+
"require": "Please enter name of organization"
|
|
250
|
+
},
|
|
251
|
+
"placeholder": "Please enter name of organization"
|
|
252
|
+
},
|
|
253
|
+
"username": {
|
|
254
|
+
"label": "Tanant admin"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"register": "Register",
|
|
258
|
+
"registerSuccess": "Tenant registered"
|
|
259
|
+
},
|
|
260
|
+
"relogin": {
|
|
261
|
+
"tip": "The account has been logged in on another device (browser) or has expired",
|
|
262
|
+
"btn": "Re-Login",
|
|
263
|
+
"pwd": "If it is not your operation, it is recommended to go to the account settings to change the password"
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
4
|
+
import Cookies from 'js-cookie';
|
|
5
|
+
import { getLangResourceForMain, initLang } from './utils';
|
|
6
|
+
import en from './en.json';
|
|
7
|
+
import zh from './zh.json';
|
|
8
|
+
import { gMainConfig } from '@/index';
|
|
9
|
+
|
|
10
|
+
const rLang = getLangResourceForMain();
|
|
11
|
+
|
|
12
|
+
let lang;
|
|
13
|
+
if (gMainConfig?.lang) {
|
|
14
|
+
lang = {
|
|
15
|
+
en: {
|
|
16
|
+
translation: { ...en.translation, ...gMainConfig.lang.en },
|
|
17
|
+
},
|
|
18
|
+
zh: {
|
|
19
|
+
translation: { ...zh.translation, ...gMainConfig.lang.zh },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
} else {
|
|
23
|
+
lang = { en, zh };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
i18n
|
|
27
|
+
.use(LanguageDetector)
|
|
28
|
+
.use(initReactI18next)
|
|
29
|
+
.init({
|
|
30
|
+
lng: Cookies.get('main-i18next'),
|
|
31
|
+
detection: {
|
|
32
|
+
order: ['cookie'],
|
|
33
|
+
lookupCookie: 'main-i18next',
|
|
34
|
+
},
|
|
35
|
+
resources: rLang || lang,
|
|
36
|
+
fallbackLng: 'en',
|
|
37
|
+
interpolation: {
|
|
38
|
+
escapeValue: false,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
initLang();
|
|
43
|
+
|
|
44
|
+
export default i18n;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import Cookies from 'js-cookie';
|
|
2
|
+
|
|
3
|
+
export const switchLang = (lang: string, reload = true) => {
|
|
4
|
+
if (Cookies.get('main-i18next') !== lang) {
|
|
5
|
+
// 登录三要素:服务条款,法律声明,隐藏政策,多语言支持
|
|
6
|
+
Cookies.remove('gTyPlatLang', { path: '/' });
|
|
7
|
+
Cookies.set('gTyPlatLang', lang, { expires: 365 });
|
|
8
|
+
|
|
9
|
+
// 利用 i18n ,通过修改 cookie 实现语言切换
|
|
10
|
+
Cookies.set('main-i18next', lang, { expires: 365 });
|
|
11
|
+
|
|
12
|
+
// 利用 i18n ,通过修改 cookie 兼容微应用语言切换
|
|
13
|
+
Cookies.set('i18next', lang === 'zh' ? 'zh-CN' : 'en-US', { expires: 365 });
|
|
14
|
+
localStorage.setItem('i18nextLng', lang === 'zh' ? 'zh-CN' : 'en-US');
|
|
15
|
+
localStorage.setItem('main-i18next', lang === 'zh' ? 'zh-CN' : 'en-US');
|
|
16
|
+
reload && window.location.reload();
|
|
17
|
+
modifyHtmlLang(lang);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const initLang = () => {
|
|
22
|
+
// 多语言初始化,兼容微应用多语言
|
|
23
|
+
const lang = Cookies.get('main-i18next') === 'zh' ? 'zh-CN' : 'en-US';
|
|
24
|
+
Cookies.set('i18next', lang, { expires: 365 });
|
|
25
|
+
localStorage.setItem('i18nextLng', lang);
|
|
26
|
+
//多窗口语言同步
|
|
27
|
+
window.addEventListener('storage', function (ev) {
|
|
28
|
+
if (ev.key === 'main-i18next') {
|
|
29
|
+
window.location.reload();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
modifyHtmlLang(Cookies.get('main-i18next'));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function modifyHtmlLang(lang: string) {
|
|
36
|
+
window.document.getElementsByTagName('html')[0].setAttribute('lang', lang);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 获取当前微应用的语言包
|
|
40
|
+
export function getLangResource(id: string) {
|
|
41
|
+
const langCollection = window._SDF.saas.saas_locales;
|
|
42
|
+
if (!langCollection) return;
|
|
43
|
+
const langkey =
|
|
44
|
+
Object.keys(langCollection).find((key) => key.includes(id)) || '';
|
|
45
|
+
|
|
46
|
+
const microLang = langCollection[langkey];
|
|
47
|
+
const microUiLang = getLangFromPrefix(microLang);
|
|
48
|
+
return normalizeLang(microUiLang);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getLangResourceForMain() {
|
|
52
|
+
const langCollection = window._SDF.saas.saas_locales;
|
|
53
|
+
if (!langCollection) return;
|
|
54
|
+
const id = Object.keys(langCollection).find((key) =>
|
|
55
|
+
key.startsWith('main-app_')
|
|
56
|
+
);
|
|
57
|
+
const macroLang = langCollection[id];
|
|
58
|
+
if (!macroLang || Object.keys(macroLang).length === 0) return;
|
|
59
|
+
return normalizeLang(macroLang, 'translation');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getLangFromPrefix(
|
|
63
|
+
lang: Record<string, Record<LangKey, string>>,
|
|
64
|
+
prefix = 'ui.'
|
|
65
|
+
) {
|
|
66
|
+
const expectLang = {};
|
|
67
|
+
Object.entries(lang).forEach(([key, value]) => {
|
|
68
|
+
if (!key.startsWith(prefix)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const [_, realKey] = key.split(prefix);
|
|
72
|
+
expectLang[realKey] = value;
|
|
73
|
+
});
|
|
74
|
+
return expectLang;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function normalizeLang(
|
|
78
|
+
langResource: Record<string, Record<LangKey, string>>,
|
|
79
|
+
namespace?: string
|
|
80
|
+
) {
|
|
81
|
+
const wrapNamespace = (
|
|
82
|
+
obj: Record<string, any>,
|
|
83
|
+
key: string,
|
|
84
|
+
value: string
|
|
85
|
+
) => {
|
|
86
|
+
if (namespace) {
|
|
87
|
+
key = key.replace(new RegExp(`^${namespace}\\.`), '');
|
|
88
|
+
|
|
89
|
+
if (!obj[namespace]) {
|
|
90
|
+
obj[namespace] = {};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
obj = obj[namespace];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
obj[key] = value;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return Object.entries(langResource).reduce((result, [key, langInfo]) => {
|
|
100
|
+
Object.entries(langInfo).forEach(([langType, text]) => {
|
|
101
|
+
if (!result[langType]) {
|
|
102
|
+
result[langType] = {};
|
|
103
|
+
}
|
|
104
|
+
wrapNamespace(result[langType], key, text);
|
|
105
|
+
});
|
|
106
|
+
return result;
|
|
107
|
+
}, {});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const langList = () => {
|
|
111
|
+
const supported_language = window._SDF?.saas?.supported_language;
|
|
112
|
+
if (supported_language) {
|
|
113
|
+
return Object.keys(supported_language).map((key) => {
|
|
114
|
+
return {
|
|
115
|
+
label: supported_language[key],
|
|
116
|
+
value: key,
|
|
117
|
+
};
|
|
118
|
+
}) as any;
|
|
119
|
+
} else {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
label: '简体中文',
|
|
123
|
+
value: 'zh',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: 'English',
|
|
127
|
+
value: 'en',
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const gLang = () => {
|
|
134
|
+
const supportedLanguages = langList();
|
|
135
|
+
const langKeys = supportedLanguages.map((item) => item.value);
|
|
136
|
+
const cookieLang = Cookies.get('main-i18next');
|
|
137
|
+
|
|
138
|
+
if (langKeys.includes(cookieLang)) {
|
|
139
|
+
return cookieLang;
|
|
140
|
+
} else {
|
|
141
|
+
switchLang('en', false);
|
|
142
|
+
return 'en';
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const oemSaasAy = () => {
|
|
147
|
+
const lang = gLang();
|
|
148
|
+
|
|
149
|
+
let oemSaasLang;
|
|
150
|
+
if (window._SDF?.saas?.saas_locales) {
|
|
151
|
+
const key = Object.keys(window._SDF?.saas?.saas_locales).find((k) =>
|
|
152
|
+
k.includes(`oem-saas_${window._SDF?.saas?.saas_id}`)
|
|
153
|
+
);
|
|
154
|
+
oemSaasLang = window._SDF?.saas?.saas_locales[key];
|
|
155
|
+
const getProperty = (property) => {
|
|
156
|
+
const langVal =
|
|
157
|
+
oemSaasLang[property] &&
|
|
158
|
+
(oemSaasLang[property][lang] || oemSaasLang[property]['en']);
|
|
159
|
+
return langVal;
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
background_image:
|
|
163
|
+
getProperty('OEM-SAAS-BG_IMAGE') || window._SDF?.saas?.background_image,
|
|
164
|
+
logo: getProperty('OEM-SAAS-LOGO') || window._SDF?.saas?.logo,
|
|
165
|
+
title: getProperty('OEM-SAAS-TITLE') || window._SDF?.saas?.title,
|
|
166
|
+
legal_notice:
|
|
167
|
+
getProperty('LEGAL_STATEMENT') || window._SDF?.saas?.legal_notice,
|
|
168
|
+
privacy_policy:
|
|
169
|
+
getProperty('PRIVACY_POLICY') || window._SDF?.saas?.privacy_policy,
|
|
170
|
+
service_terms:
|
|
171
|
+
getProperty('TERMS_OF_USE') || window._SDF?.saas?.service_terms,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
background_image: window._SDF?.saas?.background_image,
|
|
176
|
+
logo: window._SDF?.saas?.logo,
|
|
177
|
+
title: window._SDF?.saas?.title,
|
|
178
|
+
legal_notice: window._SDF?.saas?.legal_notice,
|
|
179
|
+
privacy_policy: window._SDF?.saas?.privacy_policy,
|
|
180
|
+
service_terms: window._SDF?.saas?.service_terms,
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const dynamicHeaderMenu = () => {
|
|
185
|
+
const lang = gLang();
|
|
186
|
+
const saasLocales = window._SDF?.saas?.saas_locales || {};
|
|
187
|
+
const key = Object.keys(saasLocales).find((k) =>
|
|
188
|
+
k.includes(`oem-saas_${window._SDF?.saas?.saas_id}`)
|
|
189
|
+
);
|
|
190
|
+
const oemSaasLang = saasLocales[key];
|
|
191
|
+
|
|
192
|
+
const getNameLang = (v) => {
|
|
193
|
+
if (!oemSaasLang) {
|
|
194
|
+
return lang === 'zh' ? v.text_zh : v.text_en;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (oemSaasLang[v.sub_menu_text_lang_key]) {
|
|
198
|
+
if (oemSaasLang[v.sub_menu_text_lang_key][lang]) {
|
|
199
|
+
return oemSaasLang[v.sub_menu_text_lang_key][lang];
|
|
200
|
+
} else {
|
|
201
|
+
return oemSaasLang[v.sub_menu_text_lang_key]['en'] || v.text_en;
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
return v.text_en;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const getOptionsLang = (options) => {
|
|
209
|
+
return options.map((item) => {
|
|
210
|
+
return {
|
|
211
|
+
...item,
|
|
212
|
+
name: getNameLang(item),
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const result =
|
|
218
|
+
window._SDF.saas.custom_configs
|
|
219
|
+
?.find((u) => u.config_key === 'dynamic_header_menu')
|
|
220
|
+
?.config_value?.map((v) => {
|
|
221
|
+
if (v.type === 'text' || v.type === 'icon_text') {
|
|
222
|
+
return {
|
|
223
|
+
...v,
|
|
224
|
+
name: getNameLang(v),
|
|
225
|
+
};
|
|
226
|
+
} else if (v.type === 'icon_text_select' || v.type === 'text_select') {
|
|
227
|
+
return {
|
|
228
|
+
...v,
|
|
229
|
+
options: getOptionsLang(v.options),
|
|
230
|
+
name: getNameLang(v),
|
|
231
|
+
};
|
|
232
|
+
} else {
|
|
233
|
+
return v;
|
|
234
|
+
}
|
|
235
|
+
}) || [];
|
|
236
|
+
|
|
237
|
+
return result;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const walkEntrys = (entrys) => {
|
|
241
|
+
const lang = gLang();
|
|
242
|
+
|
|
243
|
+
const localLang = (v) => {
|
|
244
|
+
return lang === 'zh' ? v.entry_name_zh : v.entry_name_en;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const getNameLang = (v) => {
|
|
248
|
+
if (v['lang_package_biz_id'] && v.entry_name_lang_key) {
|
|
249
|
+
if (window._SDF?.saas?.saas_locales) {
|
|
250
|
+
const oemSaasLang =
|
|
251
|
+
window._SDF?.saas?.saas_locales[v['lang_package_biz_id']];
|
|
252
|
+
if (oemSaasLang[v.entry_name_lang_key]) {
|
|
253
|
+
if (oemSaasLang[v.entry_name_lang_key][lang]) {
|
|
254
|
+
return oemSaasLang[v.entry_name_lang_key][lang];
|
|
255
|
+
} else {
|
|
256
|
+
return localLang(v);
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
return localLang(v);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
return localLang(v);
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
return localLang(v);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
return entrys.map((entry) => {
|
|
270
|
+
const name = getNameLang(entry);
|
|
271
|
+
return {
|
|
272
|
+
...entry,
|
|
273
|
+
name,
|
|
274
|
+
sub_entry_list: walkEntrys(entry.sub_entry_list),
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export const getMenus = (entry_info) => {
|
|
280
|
+
entry_info &&
|
|
281
|
+
entry_info.entries &&
|
|
282
|
+
(entry_info.entries = walkEntrys(entry_info.entries));
|
|
283
|
+
|
|
284
|
+
return entry_info;
|
|
285
|
+
};
|