Browse Source

Fix the user module multi-language linkage problem (#7863)

3.0.0/version-upgrade
labbomb 3 years ago committed by GitHub
parent
commit
d014a11c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.tsx
  2. 4
      dolphinscheduler-ui-next/src/layouts/content/components/user/index.tsx
  3. 6
      dolphinscheduler-ui-next/src/layouts/content/index.tsx
  4. 41
      dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts

4
dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.tsx

@ -36,7 +36,7 @@ const Navbar = defineComponent({
type: Array as PropType<any>, type: Array as PropType<any>,
default: [], default: [],
}, },
profileOptions: { userDropdownOptions: {
type: Array as PropType<any>, type: Array as PropType<any>,
default: [], default: [],
}, },
@ -60,7 +60,7 @@ const Navbar = defineComponent({
<div class={styles.settings}> <div class={styles.settings}>
<Theme /> <Theme />
<Locales localesOptions={this.localesOptions} /> <Locales localesOptions={this.localesOptions} />
<User profileOptions={this.profileOptions} /> <User userDropdownOptions={this.userDropdownOptions} />
</div> </div>
</div> </div>
) )

4
dolphinscheduler-ui-next/src/layouts/content/components/user/index.tsx

@ -24,7 +24,7 @@ import { useDropDown } from './use-dropdown'
const User = defineComponent({ const User = defineComponent({
name: 'User', name: 'User',
props: { props: {
profileOptions: { userDropdownOptions: {
type: Array as PropType<any>, type: Array as PropType<any>,
default: [], default: [],
}, },
@ -38,7 +38,7 @@ const User = defineComponent({
<NDropdown <NDropdown
trigger='hover' trigger='hover'
show-arrow show-arrow
options={this.profileOptions} options={this.userDropdownOptions}
on-select={this.handleSelect} on-select={this.handleSelect}
> >
<NButton text> <NButton text>

6
dolphinscheduler-ui-next/src/layouts/content/index.tsx

@ -30,7 +30,7 @@ const Content = defineComponent({
const menuStore = useMenuStore() const menuStore = useMenuStore()
const { locale } = useI18n() const { locale } = useI18n()
const localesStore = useLocalesStore() const localesStore = useLocalesStore()
const { state, changeMenuOption, changeHeaderMenuOptions } = useDataList() const { state, changeMenuOption, changeHeaderMenuOptions, changeUserDropdown } = useDataList()
locale.value = localesStore.getLocales locale.value = localesStore.getLocales
@ -39,12 +39,14 @@ const Content = defineComponent({
changeMenuOption(state) changeMenuOption(state)
changeHeaderMenuOptions(state) changeHeaderMenuOptions(state)
genSideMenu(state) genSideMenu(state)
changeUserDropdown(state)
}) })
watch(useI18n().locale, () => { watch(useI18n().locale, () => {
changeMenuOption(state) changeMenuOption(state)
changeHeaderMenuOptions(state) changeHeaderMenuOptions(state)
genSideMenu(state) genSideMenu(state)
changeUserDropdown(state)
}) })
const genSideMenu = (state: any) => { const genSideMenu = (state: any) => {
@ -75,7 +77,7 @@ const Content = defineComponent({
onHandleMenuClick={this.getSideMenuOptions} onHandleMenuClick={this.getSideMenuOptions}
headerMenuOptions={this.headerMenuOptions} headerMenuOptions={this.headerMenuOptions}
localesOptions={this.localesOptions} localesOptions={this.localesOptions}
profileOptions={this.userDropdownOptions} userDropdownOptions={this.userDropdownOptions}
/> />
</NLayoutHeader> </NLayoutHeader>
<NLayout has-sider position='absolute' style='top: 65px'> <NLayout has-sider position='absolute' style='top: 65px'>

41
dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts

@ -62,28 +62,10 @@ export function useDataList() {
}, },
] ]
const userDropdownOptions = [
{
label: t('userDropdown.profile'),
key: 'profile',
icon: renderIcon(UserOutlined),
},
{
label: t('userDropdown.password'),
key: 'password',
icon: renderIcon(KeyOutlined),
},
{
label: t('userDropdown.logout'),
key: 'logout',
icon: renderIcon(LogoutOutlined),
},
]
const state = reactive({ const state = reactive({
isShowSide: false, isShowSide: false,
localesOptions, localesOptions,
userDropdownOptions, userDropdownOptions: [],
menuOptions: [], menuOptions: [],
headerMenuOptions: [], headerMenuOptions: [],
sideMenuOptions: [], sideMenuOptions: [],
@ -267,9 +249,30 @@ export function useDataList() {
) )
} }
const changeUserDropdown = (state: any) => {
state.userDropdownOptions = [
{
label: t('userDropdown.profile'),
key: 'profile',
icon: renderIcon(UserOutlined),
},
{
label: t('userDropdown.password'),
key: 'password',
icon: renderIcon(KeyOutlined),
},
{
label: t('userDropdown.logout'),
key: 'logout',
icon: renderIcon(LogoutOutlined),
},
]
}
return { return {
state, state,
changeHeaderMenuOptions, changeHeaderMenuOptions,
changeMenuOption, changeMenuOption,
changeUserDropdown
} }
} }

Loading…
Cancel
Save