@oinone/kunlun-vue-admin-base 6.3.5 → 6.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/oinone-kunlun-vue-admin-base.css +1 -1
- package/dist/oinone-kunlun-vue-admin-base.esm.js +2151 -1669
- package/dist/oinone-kunlun-vue-admin-base.scss +1 -1
- package/dist/types/src/basic/BaseI18nRouterWidget.d.ts +1 -1
- package/dist/types/src/icon-manage/view/search/IconSearch.vue.d.ts +20 -0
- package/dist/types/src/provider/RootWidget.d.ts +3 -2
- package/dist/types/src/view/login/BaseLoginWidget.d.ts +58 -0
- package/dist/types/src/view/login/LoginWidget.d.ts +3 -56
- package/dist/types/src/view/login/SSOLogin.vue.d.ts +154 -0
- package/dist/types/src/view/login/SSOLoginWidget.d.ts +12 -0
- package/dist/types/src/view/login/index.d.ts +2 -0
- package/package.json +8 -8
- package/src/basic/BaseI18nRouterWidget.ts +1 -1
- package/src/provider/RootWidget.ts +9 -3
- package/src/view/login/BaseLoginWidget.ts +278 -0
- package/src/view/login/LoginWidget.ts +6 -272
- package/src/view/login/SSOLogin.vue +312 -0
- package/src/view/login/SSOLoginWidget.ts +103 -0
- package/src/view/login/index.ts +2 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BASIC_CONFIG_KEY,
|
|
3
|
+
ConfigHelper,
|
|
4
|
+
CurrentLanguage,
|
|
5
|
+
getLoginTheme,
|
|
6
|
+
MajorConfig,
|
|
7
|
+
OioProvider,
|
|
8
|
+
systemMajorConfig
|
|
9
|
+
} from '@oinone/kunlun-engine';
|
|
10
|
+
import { RuntimeConfig, SYSTEM_MODULE_NAME } from '@oinone/kunlun-meta';
|
|
11
|
+
import { gql } from '@oinone/kunlun-request';
|
|
12
|
+
import { Matched, Router, useMatched } from '@oinone/kunlun-router';
|
|
13
|
+
import { http } from '@oinone/kunlun-service';
|
|
14
|
+
import { useRouter } from '@oinone/kunlun-vue-router';
|
|
15
|
+
import {
|
|
16
|
+
defaultLoginErrorMessages,
|
|
17
|
+
defaultLoginPageSettings,
|
|
18
|
+
EN_US_CODE,
|
|
19
|
+
LOGIN_LANGUAGE_ISO_STORAGE_KEY,
|
|
20
|
+
LOGIN_LANGUAGE_STORAGE_KEY,
|
|
21
|
+
LoginConfig,
|
|
22
|
+
LoginData,
|
|
23
|
+
RuntimeLanguage
|
|
24
|
+
} from '@oinone/kunlun-vue-ui-common';
|
|
25
|
+
import { Widget } from '@oinone/kunlun-vue-widget';
|
|
26
|
+
import { BaseI18nRouterWidget } from '../../basic';
|
|
27
|
+
|
|
28
|
+
export class BaseLoginWidget extends BaseI18nRouterWidget {
|
|
29
|
+
protected matched: Matched | undefined;
|
|
30
|
+
|
|
31
|
+
protected router!: Router;
|
|
32
|
+
|
|
33
|
+
public errorMessages = defaultLoginErrorMessages;
|
|
34
|
+
|
|
35
|
+
protected getLoginConfig(): LoginConfig {
|
|
36
|
+
return ConfigHelper.getConfig(RuntimeConfig.getConfig('login'));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Widget.Reactive()
|
|
40
|
+
protected authForm = {
|
|
41
|
+
login: '',
|
|
42
|
+
password: '',
|
|
43
|
+
phone: '',
|
|
44
|
+
verificationCode: '',
|
|
45
|
+
picCode: '',
|
|
46
|
+
email: '',
|
|
47
|
+
emailCode: ''
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
@Widget.Reactive()
|
|
51
|
+
protected error: LoginData = {};
|
|
52
|
+
|
|
53
|
+
@Widget.Method()
|
|
54
|
+
protected clearErrorMessage() {
|
|
55
|
+
this.error = {};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Widget.Reactive()
|
|
59
|
+
protected get systemMajorConfig(): MajorConfig {
|
|
60
|
+
return systemMajorConfig;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Widget.Reactive()
|
|
64
|
+
protected get loginLabel(): string {
|
|
65
|
+
return this.getLoginConfig()?.loginLabel ?? defaultLoginPageSettings.loginLabel;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Widget.Reactive()
|
|
69
|
+
protected get forgetPassword(): boolean {
|
|
70
|
+
return !!(this.getLoginConfig()?.forgetPassword ?? defaultLoginPageSettings.forgetPassword);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Widget.Reactive()
|
|
74
|
+
protected get forgetPasswordLabel(): string {
|
|
75
|
+
return this.getLoginConfig()?.forgetPasswordLabel ?? defaultLoginPageSettings.forgetPasswordLabel;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Widget.Reactive()
|
|
79
|
+
protected get register(): boolean {
|
|
80
|
+
return !!(this.getLoginConfig()?.register ?? defaultLoginPageSettings.register);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Widget.Reactive()
|
|
84
|
+
protected get codeLogin(): boolean {
|
|
85
|
+
return !!(this.getLoginConfig()?.codeLogin ?? defaultLoginPageSettings.codeLogin);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Widget.Reactive()
|
|
89
|
+
protected get accountLoginLabel(): string {
|
|
90
|
+
return this.getLoginConfig()?.accountLoginLabel ?? defaultLoginPageSettings.accountLoginLabel;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Widget.Reactive()
|
|
94
|
+
protected get codeLoginLabel(): string {
|
|
95
|
+
return this.getLoginConfig()?.codeLoginLabel ?? defaultLoginPageSettings.codeLoginLabel;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Widget.Reactive()
|
|
99
|
+
protected get registerLabel(): string {
|
|
100
|
+
return this.getLoginConfig()?.registerLabel ?? defaultLoginPageSettings.registerLabel;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Widget.Reactive()
|
|
104
|
+
protected get accountPlaceholder(): string {
|
|
105
|
+
return this.getLoginConfig()?.accountPlaceholder ?? defaultLoginPageSettings.accountPlaceholder;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@Widget.Reactive()
|
|
109
|
+
protected get passwordPlaceholder(): string {
|
|
110
|
+
return this.getLoginConfig()?.passwordPlaceholder ?? defaultLoginPageSettings.passwordPlaceholder;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@Widget.Reactive()
|
|
114
|
+
protected get phonePlaceholder(): string {
|
|
115
|
+
return this.getLoginConfig()?.phonePlaceholder ?? defaultLoginPageSettings.phonePlaceholder;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@Widget.Reactive()
|
|
119
|
+
protected get codePlaceholder(): string {
|
|
120
|
+
return this.getLoginConfig()?.codePlaceholder ?? defaultLoginPageSettings.codePlaceholder;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Widget.Reactive()
|
|
124
|
+
protected get email(): boolean {
|
|
125
|
+
return this.getLoginConfig()?.email ?? defaultLoginPageSettings.email;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Widget.Reactive()
|
|
129
|
+
protected get emailLoginLabel(): string {
|
|
130
|
+
return this.getLoginConfig()?.emailLoginLabel ?? defaultLoginPageSettings.emailLoginLabel;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Widget.Reactive()
|
|
134
|
+
protected get emailPlaceholder(): string {
|
|
135
|
+
return this.getLoginConfig()?.emailPlaceholder ?? defaultLoginPageSettings.emailPlaceholder;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Widget.Reactive()
|
|
139
|
+
protected get emailCodePlaceholder(): string {
|
|
140
|
+
return this.getLoginConfig()?.emailCodePlaceholder ?? defaultLoginPageSettings.emailCodePlaceholder;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@Widget.Reactive()
|
|
144
|
+
protected get currentLoginTheme() {
|
|
145
|
+
return getLoginTheme();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@Widget.Reactive()
|
|
149
|
+
protected get copyrightYear(): string {
|
|
150
|
+
return new Date().getFullYear().toString();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Widget.Reactive()
|
|
154
|
+
protected get enableI18n(): boolean | undefined {
|
|
155
|
+
return OioProvider.getConfig().enableI18n;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@Widget.Reactive()
|
|
159
|
+
protected languages: RuntimeLanguage[] = [];
|
|
160
|
+
|
|
161
|
+
@Widget.Reactive()
|
|
162
|
+
protected currentLanguage: RuntimeLanguage = {} as RuntimeLanguage;
|
|
163
|
+
|
|
164
|
+
protected async getCurrentLanguage() {
|
|
165
|
+
return localStorage.getItem(LOGIN_LANGUAGE_STORAGE_KEY) ?? CurrentLanguage.DEFAULT_LANGUAGE;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
protected async getCurrentLanguageIsoCode() {
|
|
169
|
+
return localStorage.getItem(LOGIN_LANGUAGE_ISO_STORAGE_KEY);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
protected async setCurrentLanguage(language: RuntimeLanguage) {
|
|
173
|
+
localStorage.setItem(LOGIN_LANGUAGE_STORAGE_KEY, language.code);
|
|
174
|
+
localStorage.setItem(LOGIN_LANGUAGE_ISO_STORAGE_KEY, language.isoCode);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
protected initCurrentLanguage(code: string) {
|
|
178
|
+
Reflect.set(window, '__lang', code);
|
|
179
|
+
if (!this.currentLanguage || this.currentLanguage?.code !== code) {
|
|
180
|
+
const language = this.languages!.find((v) => v.code === code);
|
|
181
|
+
if (language) {
|
|
182
|
+
this.currentLanguage = language;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
protected async queryLanguageSetting(langCode) {
|
|
188
|
+
const mutation = `
|
|
189
|
+
{
|
|
190
|
+
appConfigQuery {
|
|
191
|
+
queryListByWrapper(queryWrapper: { rsql: "1==1 and scope==GLOBAL" }) {
|
|
192
|
+
extend
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
const result = await http.mutate(SYSTEM_MODULE_NAME.BASE, mutation, {
|
|
198
|
+
lang: langCode,
|
|
199
|
+
translationOnlyGlobal: true
|
|
200
|
+
});
|
|
201
|
+
return result.data.appConfigQuery.queryListByWrapper;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
protected async initLanguages(): Promise<void> {
|
|
205
|
+
if (!this.languages?.length) {
|
|
206
|
+
const languages = await this.queryLanguageList();
|
|
207
|
+
this.languages = languages.map((v) => {
|
|
208
|
+
if (!v.icon) {
|
|
209
|
+
if (v.code === EN_US_CODE) {
|
|
210
|
+
v.icon = 'oinone-yingguo';
|
|
211
|
+
} else {
|
|
212
|
+
v.icon = 'oinone-zhongguo';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return v;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
protected async queryLanguageList() {
|
|
221
|
+
const body = gql`
|
|
222
|
+
{
|
|
223
|
+
resourceLangQuery {
|
|
224
|
+
queryLoginLanguage {
|
|
225
|
+
id
|
|
226
|
+
name
|
|
227
|
+
code
|
|
228
|
+
isoCode
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
`;
|
|
233
|
+
try {
|
|
234
|
+
const res = await http.mutate<RuntimeLanguage[]>(SYSTEM_MODULE_NAME.RESOURCE, body, {
|
|
235
|
+
lang: await this.getCurrentLanguage()
|
|
236
|
+
});
|
|
237
|
+
return res.data.resourceLangQuery.queryLoginLanguage;
|
|
238
|
+
} catch (e) {
|
|
239
|
+
console.error('error query language list.', e);
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
@Widget.Method()
|
|
245
|
+
protected onLanguageChange(value: RuntimeLanguage) {
|
|
246
|
+
if (!value || value.code === this.currentLanguage?.code) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.currentLanguage = value;
|
|
250
|
+
this.setCurrentLanguage(value);
|
|
251
|
+
window.location.reload();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 用来处理点击「登录」之前的事件,可以做二次确定或者其他的逻辑
|
|
256
|
+
* 只有return true,才会继续往下执行
|
|
257
|
+
*/
|
|
258
|
+
public async beforeClick(): Promise<Boolean | null | undefined> {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
protected beforeCreated() {
|
|
263
|
+
sessionStorage.removeItem(BASIC_CONFIG_KEY);
|
|
264
|
+
const { matched } = useMatched();
|
|
265
|
+
this.matched = matched;
|
|
266
|
+
this.router = useRouter().router;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
protected async beforeMount() {
|
|
270
|
+
this.isoStorageKey = LOGIN_LANGUAGE_ISO_STORAGE_KEY;
|
|
271
|
+
this.initLanguages().then(async () => {
|
|
272
|
+
const language = await this.getCurrentLanguage();
|
|
273
|
+
await this.queryLanguageSetting(language);
|
|
274
|
+
this.initCurrentLanguage(language);
|
|
275
|
+
super.beforeMount();
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ConfigHelper,
|
|
4
|
-
CurrentLanguage,
|
|
5
|
-
getLoginTheme,
|
|
6
|
-
MajorConfig,
|
|
7
|
-
OINONE_HOMEPAGE_KEY,
|
|
8
|
-
OioProvider,
|
|
9
|
-
systemMajorConfig,
|
|
10
|
-
translateValueByKey
|
|
11
|
-
} from '@oinone/kunlun-engine';
|
|
12
|
-
import { RuntimeConfig, SYSTEM_MODULE_NAME } from '@oinone/kunlun-meta';
|
|
1
|
+
import { BASIC_CONFIG_KEY, OINONE_HOMEPAGE_KEY, translateValueByKey } from '@oinone/kunlun-engine';
|
|
2
|
+
import { SYSTEM_MODULE_NAME } from '@oinone/kunlun-meta';
|
|
13
3
|
import {
|
|
14
4
|
gql,
|
|
15
5
|
HttpClientError,
|
|
@@ -18,26 +8,14 @@ import {
|
|
|
18
8
|
isPicCodeError,
|
|
19
9
|
useMessageHub
|
|
20
10
|
} from '@oinone/kunlun-request';
|
|
21
|
-
import { Router } from '@oinone/kunlun-router';
|
|
22
11
|
import { http } from '@oinone/kunlun-service';
|
|
23
12
|
import { SPI } from '@oinone/kunlun-spi';
|
|
24
|
-
import { RouterWidget
|
|
13
|
+
import { RouterWidget } from '@oinone/kunlun-vue-router';
|
|
25
14
|
import { OioNotification } from '@oinone/kunlun-vue-ui-antd';
|
|
26
|
-
import {
|
|
27
|
-
defaultLoginErrorMessages,
|
|
28
|
-
defaultLoginPageSettings,
|
|
29
|
-
EN_US_CODE,
|
|
30
|
-
LOGIN_LANGUAGE_ISO_STORAGE_KEY,
|
|
31
|
-
LOGIN_LANGUAGE_STORAGE_KEY,
|
|
32
|
-
LoginConfig,
|
|
33
|
-
LoginData,
|
|
34
|
-
loginMessageHubName,
|
|
35
|
-
LoginMode,
|
|
36
|
-
RuntimeLanguage
|
|
37
|
-
} from '@oinone/kunlun-vue-ui-common';
|
|
15
|
+
import { loginMessageHubName, LoginMode } from '@oinone/kunlun-vue-ui-common';
|
|
38
16
|
import { Widget } from '@oinone/kunlun-vue-widget';
|
|
39
|
-
import { BaseI18nRouterWidget } from '../../basic/BaseI18nRouterWidget';
|
|
40
17
|
import { encrypt, homepageMaybeRuntimeContext } from '../../util';
|
|
18
|
+
import { BaseLoginWidget } from './BaseLoginWidget';
|
|
41
19
|
import LoginComponent from './Login.vue';
|
|
42
20
|
|
|
43
21
|
@SPI.ClassFactory(
|
|
@@ -45,103 +23,9 @@ import LoginComponent from './Login.vue';
|
|
|
45
23
|
widget: 'Login'
|
|
46
24
|
})
|
|
47
25
|
)
|
|
48
|
-
export class LoginWidget extends
|
|
26
|
+
export class LoginWidget extends BaseLoginWidget {
|
|
49
27
|
protected moduleName = SYSTEM_MODULE_NAME.USER;
|
|
50
28
|
|
|
51
|
-
public errorMessages = defaultLoginErrorMessages;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 用来处理点击「登录」之前的事件,可以做二次确定或者其他的逻辑
|
|
55
|
-
* 只有return true,才会继续往下执行
|
|
56
|
-
*/
|
|
57
|
-
public async beforeClick(): Promise<Boolean | null | undefined> {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
protected getLoginConfig(): LoginConfig {
|
|
62
|
-
return ConfigHelper.getConfig(RuntimeConfig.getConfig('login'));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Widget.Reactive()
|
|
66
|
-
protected get loginLabel(): string {
|
|
67
|
-
return this.getLoginConfig()?.loginLabel ?? defaultLoginPageSettings.loginLabel;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@Widget.Reactive()
|
|
71
|
-
protected get forgetPassword(): boolean {
|
|
72
|
-
return !!(this.getLoginConfig()?.forgetPassword ?? defaultLoginPageSettings.forgetPassword);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Widget.Reactive()
|
|
76
|
-
protected get forgetPasswordLabel(): string {
|
|
77
|
-
return this.getLoginConfig()?.forgetPasswordLabel ?? defaultLoginPageSettings.forgetPasswordLabel;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@Widget.Reactive()
|
|
81
|
-
protected get register(): boolean {
|
|
82
|
-
return !!(this.getLoginConfig()?.register ?? defaultLoginPageSettings.register);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@Widget.Reactive()
|
|
86
|
-
protected get codeLogin(): boolean {
|
|
87
|
-
return !!(this.getLoginConfig()?.codeLogin ?? defaultLoginPageSettings.codeLogin);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@Widget.Reactive()
|
|
91
|
-
protected get accountLoginLabel(): string {
|
|
92
|
-
return this.getLoginConfig()?.accountLoginLabel ?? defaultLoginPageSettings.accountLoginLabel;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@Widget.Reactive()
|
|
96
|
-
protected get codeLoginLabel(): string {
|
|
97
|
-
return this.getLoginConfig()?.codeLoginLabel ?? defaultLoginPageSettings.codeLoginLabel;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@Widget.Reactive()
|
|
101
|
-
protected get registerLabel(): string {
|
|
102
|
-
return this.getLoginConfig()?.registerLabel ?? defaultLoginPageSettings.registerLabel;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@Widget.Reactive()
|
|
106
|
-
protected get accountPlaceholder(): string {
|
|
107
|
-
return this.getLoginConfig()?.accountPlaceholder ?? defaultLoginPageSettings.accountPlaceholder;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@Widget.Reactive()
|
|
111
|
-
protected get passwordPlaceholder(): string {
|
|
112
|
-
return this.getLoginConfig()?.passwordPlaceholder ?? defaultLoginPageSettings.passwordPlaceholder;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@Widget.Reactive()
|
|
116
|
-
protected get phonePlaceholder(): string {
|
|
117
|
-
return this.getLoginConfig()?.phonePlaceholder ?? defaultLoginPageSettings.phonePlaceholder;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@Widget.Reactive()
|
|
121
|
-
protected get codePlaceholder(): string {
|
|
122
|
-
return this.getLoginConfig()?.codePlaceholder ?? defaultLoginPageSettings.codePlaceholder;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Widget.Reactive()
|
|
126
|
-
protected get email(): boolean {
|
|
127
|
-
return this.getLoginConfig()?.email ?? defaultLoginPageSettings.email;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@Widget.Reactive()
|
|
131
|
-
protected get emailLoginLabel(): string {
|
|
132
|
-
return this.getLoginConfig()?.emailLoginLabel ?? defaultLoginPageSettings.emailLoginLabel;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
@Widget.Reactive()
|
|
136
|
-
protected get emailPlaceholder(): string {
|
|
137
|
-
return this.getLoginConfig()?.emailPlaceholder ?? defaultLoginPageSettings.emailPlaceholder;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@Widget.Reactive()
|
|
141
|
-
protected get emailCodePlaceholder(): string {
|
|
142
|
-
return this.getLoginConfig()?.emailCodePlaceholder ?? defaultLoginPageSettings.emailCodePlaceholder;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
29
|
@Widget.Method()
|
|
146
30
|
protected handleRegister() {
|
|
147
31
|
console.error('you should to overwrite function `handleRegister` in LoginPageWidget if you want register working');
|
|
@@ -159,39 +43,6 @@ export class LoginWidget extends BaseI18nRouterWidget {
|
|
|
159
43
|
return true;
|
|
160
44
|
}
|
|
161
45
|
|
|
162
|
-
@Widget.Reactive()
|
|
163
|
-
protected get copyrightYear(): string {
|
|
164
|
-
return new Date().getFullYear().toString();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@Widget.Reactive()
|
|
168
|
-
protected get currentLoginTheme() {
|
|
169
|
-
return getLoginTheme();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@Widget.Reactive()
|
|
173
|
-
protected get systemMajorConfig(): MajorConfig {
|
|
174
|
-
return systemMajorConfig;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@Widget.Reactive()
|
|
178
|
-
protected get enableI18n(): boolean | undefined {
|
|
179
|
-
return OioProvider.getConfig().enableI18n;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
@Widget.Reactive()
|
|
183
|
-
protected authForm = {
|
|
184
|
-
login: '',
|
|
185
|
-
password: '',
|
|
186
|
-
phone: '',
|
|
187
|
-
verificationCode: '',
|
|
188
|
-
picCode: '',
|
|
189
|
-
email: '',
|
|
190
|
-
emailCode: ''
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
protected router!: Router;
|
|
194
|
-
|
|
195
46
|
@Widget.Reactive()
|
|
196
47
|
protected year: string = new Date().getFullYear().toString();
|
|
197
48
|
|
|
@@ -238,15 +89,6 @@ export class LoginWidget extends BaseI18nRouterWidget {
|
|
|
238
89
|
@Widget.Reactive()
|
|
239
90
|
protected graphCode = '';
|
|
240
91
|
|
|
241
|
-
@Widget.Reactive()
|
|
242
|
-
protected error: LoginData = {};
|
|
243
|
-
|
|
244
|
-
@Widget.Reactive()
|
|
245
|
-
protected languages: RuntimeLanguage[] = [];
|
|
246
|
-
|
|
247
|
-
@Widget.Reactive()
|
|
248
|
-
protected currentLanguage: RuntimeLanguage = {} as RuntimeLanguage;
|
|
249
|
-
|
|
250
92
|
public initialize(config: Record<string, unknown> = {}) {
|
|
251
93
|
super.initialize(config);
|
|
252
94
|
|
|
@@ -255,69 +97,6 @@ export class LoginWidget extends BaseI18nRouterWidget {
|
|
|
255
97
|
return this;
|
|
256
98
|
}
|
|
257
99
|
|
|
258
|
-
protected async queryLanguageList() {
|
|
259
|
-
const body = gql`
|
|
260
|
-
{
|
|
261
|
-
resourceLangQuery {
|
|
262
|
-
queryLoginLanguage {
|
|
263
|
-
id
|
|
264
|
-
name
|
|
265
|
-
code
|
|
266
|
-
isoCode
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
|
-
try {
|
|
272
|
-
const res = await http.mutate<RuntimeLanguage[]>(SYSTEM_MODULE_NAME.RESOURCE, body, {
|
|
273
|
-
lang: await this.getCurrentLanguage()
|
|
274
|
-
});
|
|
275
|
-
return res.data.resourceLangQuery.queryLoginLanguage;
|
|
276
|
-
} catch (e) {
|
|
277
|
-
console.error('error query language list.', e);
|
|
278
|
-
return [];
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
protected async initLanguages(): Promise<void> {
|
|
283
|
-
if (!this.languages?.length) {
|
|
284
|
-
const languages = await this.queryLanguageList();
|
|
285
|
-
this.languages = languages.map((v) => {
|
|
286
|
-
if (!v.icon) {
|
|
287
|
-
if (v.code === EN_US_CODE) {
|
|
288
|
-
v.icon = 'oinone-yingguo';
|
|
289
|
-
} else {
|
|
290
|
-
v.icon = 'oinone-zhongguo';
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return v;
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
protected async getCurrentLanguage() {
|
|
299
|
-
return localStorage.getItem(LOGIN_LANGUAGE_STORAGE_KEY) ?? CurrentLanguage.DEFAULT_LANGUAGE;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
protected async getCurrentLanguageIsoCode() {
|
|
303
|
-
return localStorage.getItem(LOGIN_LANGUAGE_ISO_STORAGE_KEY);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
protected async setCurrentLanguage(language: RuntimeLanguage) {
|
|
307
|
-
localStorage.setItem(LOGIN_LANGUAGE_STORAGE_KEY, language.code);
|
|
308
|
-
localStorage.setItem(LOGIN_LANGUAGE_ISO_STORAGE_KEY, language.isoCode);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
protected initCurrentLanguage(code: string) {
|
|
312
|
-
Reflect.set(window, '__lang', code);
|
|
313
|
-
if (!this.currentLanguage || this.currentLanguage?.code !== code) {
|
|
314
|
-
const language = this.languages!.find((v) => v.code === code);
|
|
315
|
-
if (language) {
|
|
316
|
-
this.currentLanguage = language;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
100
|
@Widget.Reactive()
|
|
322
101
|
protected validation = {
|
|
323
102
|
status: '',
|
|
@@ -336,16 +115,6 @@ export class LoginWidget extends BaseI18nRouterWidget {
|
|
|
336
115
|
}
|
|
337
116
|
}
|
|
338
117
|
|
|
339
|
-
@Widget.Method()
|
|
340
|
-
protected onLanguageChange(value: RuntimeLanguage) {
|
|
341
|
-
if (!value || value.code === this.currentLanguage?.code) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
this.currentLanguage = value;
|
|
345
|
-
this.setCurrentLanguage(value);
|
|
346
|
-
window.location.reload();
|
|
347
|
-
}
|
|
348
|
-
|
|
349
118
|
@Widget.Method()
|
|
350
119
|
protected async getPicCode(message = this.errorMessages.verificationCodeEmpty) {
|
|
351
120
|
const result = await this.picCode();
|
|
@@ -662,41 +431,6 @@ export class LoginWidget extends BaseI18nRouterWidget {
|
|
|
662
431
|
protected gotoForget() {
|
|
663
432
|
this.router.push({ segments: [{ path: 'forget' }] });
|
|
664
433
|
}
|
|
665
|
-
|
|
666
|
-
@Widget.Method()
|
|
667
|
-
protected clearErrorMessage() {
|
|
668
|
-
this.error = {};
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
protected async beforeCreated() {
|
|
672
|
-
sessionStorage.removeItem(BASIC_CONFIG_KEY);
|
|
673
|
-
|
|
674
|
-
this.router = useRouter().router;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
protected async queryLanguageSetting(langCode) {
|
|
678
|
-
const mutation = `
|
|
679
|
-
{
|
|
680
|
-
appConfigQuery {
|
|
681
|
-
queryListByWrapper(queryWrapper: { rsql: "1==1 and scope==GLOBAL" }) {
|
|
682
|
-
extend
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
`;
|
|
687
|
-
const result = await http.mutate('base', mutation, { lang: langCode, translationOnlyGlobal: true });
|
|
688
|
-
return result.data['appConfigQuery']['queryListByWrapper'];
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
protected async beforeMount() {
|
|
692
|
-
this.isoStorageKey = LOGIN_LANGUAGE_ISO_STORAGE_KEY;
|
|
693
|
-
this.initLanguages().then(async () => {
|
|
694
|
-
const language = await this.getCurrentLanguage();
|
|
695
|
-
await this.queryLanguageSetting(language);
|
|
696
|
-
this.initCurrentLanguage(language);
|
|
697
|
-
super.beforeMount();
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
434
|
}
|
|
701
435
|
|
|
702
436
|
/**
|