Skip to content

Commit fc16282

Browse files
authored
[Feature][UI Next] Interface debugging(login)
1 parent b54482c commit fc16282

7 files changed

Lines changed: 56 additions & 33 deletions

File tree

dolphinscheduler-ui-next/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"naive-ui": "^2.21.5",
1717
"nprogress": "^0.2.0",
1818
"pinia": "^2.0.0-rc.10",
19+
"qs": "^6.10.2",
1920
"vfonts": "^0.1.0",
2021
"vue": "^3.2.23",
2122
"vue-i18n": "^9.2.0-beta.23",
@@ -24,6 +25,7 @@
2425
"devDependencies": {
2526
"@types/node": "^16.11.13",
2627
"@types/nprogress": "^0.2.0",
28+
"@types/qs": "^6.9.7",
2729
"@typescript-eslint/eslint-plugin": "^5.6.0",
2830
"@typescript-eslint/parser": "^5.6.0",
2931
"@vitejs/plugin-vue": "^1.10.2",

dolphinscheduler-ui-next/src/locales/modules/en_US.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
const login = {
1919
test: 'Test',
20-
username: 'Username',
21-
username_tips: 'Please enter your username',
22-
password: 'Password',
23-
password_tips: 'Please enter your password',
20+
userName: 'Username',
21+
userName_tips: 'Please enter your username',
22+
userPassword: 'Password',
23+
userPassword_tips: 'Please enter your password',
2424
signin: 'Sign In',
2525
}
2626

dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
const login = {
1919
test: '测试',
20-
username: '用户名',
21-
username_tips: '请输入用户名',
22-
password: '密码',
23-
password_tips: '请输入密码',
20+
userName: '用户名',
21+
userName_tips: '请输入用户名',
22+
userPassword: '密码',
23+
userPassword_tips: '请输入密码',
2424
signin: '登录',
2525
}
2626

dolphinscheduler-ui-next/src/router/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import {
1919
createRouter,
2020
createWebHistory,
21-
RouteRecordRaw,
2221
NavigationGuardNext,
2322
RouteLocationNormalized,
2423
} from 'vue-router'

dolphinscheduler-ui-next/src/service/service.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,42 @@
1616
*/
1717

1818
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
19+
import qs from 'qs'
1920

2021
const baseRequestConfig: AxiosRequestConfig = {
21-
baseURL: '/dolphinscheduler',
22+
baseURL: import.meta.env.VITE_APP_WEB_URL + '/dolphinscheduler',
2223
timeout: 10000,
24+
transformRequest: (params) => {
25+
return qs.stringify(params, { arrayFormat: 'repeat' })
26+
},
27+
paramsSerializer: (params) => {
28+
return qs.stringify(params, { arrayFormat: 'repeat'})
29+
}
2330
}
2431

2532
const service = axios.create(baseRequestConfig)
2633

27-
const err = (error: AxiosError): Promise<AxiosError> => {
28-
return Promise.reject(error)
34+
const err = (err: AxiosError): Promise<AxiosError> => {
35+
return Promise.reject(err)
2936
}
3037

3138
service.interceptors.request.use((config: AxiosRequestConfig<any>) => {
39+
console.log('config', config)
3240
return config
3341
}, err)
3442

43+
// The response to intercept
3544
service.interceptors.response.use((res: AxiosResponse) => {
36-
return res.data
45+
46+
// No code will be processed
47+
if (res.data.code === undefined) {
48+
return res.data
49+
}
50+
51+
switch (res.data.code) {
52+
case 0: return res.data.data
53+
default: throw new Error(`${res.data.msg}: ${res.config.url}`)
54+
}
3755
}, err)
3856

3957
export { service as axios }

dolphinscheduler-ui-next/src/store/theme/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import ThemeState from './types'
2121
export const useThemeStore = defineStore({
2222
id: 'theme',
2323
state: (): ThemeState => ({
24-
darkTheme: true,
24+
darkTheme: false,
2525
}),
2626
getters: {
2727
getTheme(): boolean {

dolphinscheduler-ui-next/src/views/login/index.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,32 @@ import { useI18n } from 'vue-i18n'
2121
import { NInput, NButton, NSwitch, NForm, NFormItem, FormRules } from 'naive-ui'
2222
import { useRouter } from 'vue-router'
2323
import type { Router } from 'vue-router'
24+
import { queryLog } from '@/service/modules/login'
2425

25-
const Login = defineComponent({
26+
const login = defineComponent({
2627
name: 'login',
2728
setup() {
2829
const { t, locale } = useI18n()
2930
const state = reactive({
3031
loginFormRef: ref(),
3132
loginForm: {
32-
username: '',
33-
password: '',
33+
userName: '',
34+
userPassword: '',
3435
},
3536
rules: {
36-
username: {
37+
userName: {
3738
trigger: ['input', 'blur'],
3839
validator() {
39-
if (state.loginForm.username === '') {
40-
return new Error(`${t('login.username_tips')}`)
40+
if (state.loginForm.userName === '') {
41+
return new Error(`${t('login.userName_tips')}`)
4142
}
4243
},
4344
},
44-
password: {
45+
userPassword: {
4546
trigger: ['input', 'blur'],
4647
validator() {
47-
if (state.loginForm.password === '') {
48-
return new Error(`${t('login.password_tips')}`)
48+
if (state.loginForm.userPassword === '') {
49+
return new Error(`${t('login.userPassword_tips')}`)
4950
}
5051
},
5152
},
@@ -60,7 +61,10 @@ const Login = defineComponent({
6061
const handleLogin = () => {
6162
state.loginFormRef.validate((valid: any) => {
6263
if (!valid) {
63-
router.push({ path: 'home' })
64+
queryLog({...state.loginForm}).then((res: Response) => {
65+
console.log('res', res)
66+
router.push({ path: 'home' })
67+
})
6468
} else {
6569
console.log('Invalid')
6670
}
@@ -91,29 +95,29 @@ const Login = defineComponent({
9195
<div class={styles['form-model']}>
9296
<NForm rules={this.rules} ref='loginFormRef'>
9397
<NFormItem
94-
label={this.t('login.username')}
98+
label={this.t('login.userName')}
9599
label-style={{ color: 'black' }}
96-
path='username'
100+
path='userName'
97101
>
98102
<NInput
99103
type='text'
100104
size='large'
101-
v-model={[this.loginForm.username, 'value']}
102-
placeholder={this.t('login.username_tips')}
105+
v-model={[this.loginForm.userName, 'value']}
106+
placeholder={this.t('login.userName_tips')}
103107
autofocus
104108
onKeydown={withKeys(this.handleLogin, ['enter'])}
105109
/>
106110
</NFormItem>
107111
<NFormItem
108-
label={this.t('login.password')}
112+
label={this.t('login.userPassword')}
109113
label-style={{ color: 'black' }}
110-
path='password'
114+
path='userPassword'
111115
>
112116
<NInput
113117
type='password'
114118
size='large'
115-
v-model={[this.loginForm.password, 'value']}
116-
placeholder={this.t('login.password_tips')}
119+
v-model={[this.loginForm.userPassword, 'value']}
120+
placeholder={this.t('login.userPassword_tips')}
117121
onKeydown={withKeys(this.handleLogin, ['enter'])}
118122
/>
119123
</NFormItem>
@@ -128,4 +132,4 @@ const Login = defineComponent({
128132
},
129133
})
130134

131-
export default Login
135+
export default login

0 commit comments

Comments
 (0)