Browse Source

[Fix][UI-Next][V1.0.0-Alpha] Fix ui and backend languages are not consistent bug (#8755)

3.0.0/version-upgrade
Devosend 3 years ago committed by GitHub
parent
commit
cbb756e1cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-ui-next/package.json
  2. 2
      dolphinscheduler-ui-next/src/layouts/content/components/locales/use-dropdown.ts
  3. 6
      dolphinscheduler-ui-next/src/service/service.ts

2
dolphinscheduler-ui-next/package.json

@ -15,6 +15,7 @@
"axios": "^0.24.0", "axios": "^0.24.0",
"date-fns": "^2.28.0", "date-fns": "^2.28.0",
"echarts": "^5.3.0", "echarts": "^5.3.0",
"js-cookie": "^3.0.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"monaco-editor": "^0.31.1", "monaco-editor": "^0.31.1",
"naive-ui": "^2.26.0", "naive-ui": "^2.26.0",
@ -28,6 +29,7 @@
"vue-router": "^4.0.12" "vue-router": "^4.0.12"
}, },
"devDependencies": { "devDependencies": {
"@types/js-cookie": "^3.0.1",
"@types/node": "^16.11.25", "@types/node": "^16.11.25",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",

2
dolphinscheduler-ui-next/src/layouts/content/components/locales/use-dropdown.ts

@ -17,6 +17,7 @@
import { DropdownOption } from 'naive-ui' import { DropdownOption } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import cookies from 'js-cookie'
import { useLocalesStore } from '@/store/locales/locales' import { useLocalesStore } from '@/store/locales/locales'
import type { Locales } from '@/store/locales/types' import type { Locales } from '@/store/locales/types'
@ -29,6 +30,7 @@ export function useDropDown(chooseVal: any) {
chooseVal.value = option.label chooseVal.value = option.label
locale.value = key as Locales locale.value = key as Locales
localesStore.setLocales(locale.value as Locales) localesStore.setLocales(locale.value as Locales)
cookies.set('language', locale.value, { path: '/' })
} }
return { return {
handleSelect handleSelect

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

@ -19,6 +19,7 @@ import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
import { useUserStore } from '@/store/user/user' import { useUserStore } from '@/store/user/user'
import qs from 'qs' import qs from 'qs'
import _ from 'lodash' import _ from 'lodash'
import cookies from 'js-cookie'
import router from '@/router' import router from '@/router'
const userStore = useUserStore() const userStore = useUserStore()
@ -56,6 +57,11 @@ const err = (err: AxiosError): Promise<AxiosError> => {
service.interceptors.request.use((config: AxiosRequestConfig<any>) => { service.interceptors.request.use((config: AxiosRequestConfig<any>) => {
config.headers && (config.headers.sessionId = userStore.getSessionId) config.headers && (config.headers.sessionId = userStore.getSessionId)
const sIdCookie = cookies.get('sessionId')
const language = cookies.get('language')
config.headers = config.headers || {}
if (language) config.headers.language = language
if (sIdCookie) config.headers.sessionId = sIdCookie
return config return config
}, err) }, err)

Loading…
Cancel
Save