diff --git a/dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx b/dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx index 77f1660e6d..39c9cfa5cc 100644 --- a/dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx +++ b/dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx @@ -15,53 +15,51 @@ * limitations under the License. */ -import { defineComponent, PropType, ref } from 'vue' +import { defineComponent, PropType, ref, watch, onMounted } from 'vue' import styles from './index.module.scss' import { NLayoutSider, NMenu } from 'naive-ui' +import { useI18n } from 'vue-i18n' +import { useLanguageStore } from '@/store/language/language' -const Sidebar = defineComponent({ - name: 'Sidebar', - props: { - sideMenuOptions: { - type: Array as PropType, - default: [], - }, - isShowSide: { - type: Boolean as PropType, - default: false, - }, - }, - setup() { - const collapsedRef = ref(false) - const defaultExpandedKeys = [ - 'workflow', - 'udf-manage', - 'service-manage', - 'statistical-manage', - ] +interface Props { + sideMenuOptions: Array, + isShowSide: boolean +} - return { collapsedRef, defaultExpandedKeys } - }, - render() { - return ( - this.isShowSide && ( - (this.collapsedRef = true)} - onExpand={() => (this.collapsedRef = false)} - > - - - ) - ) - }, -}) +const Sidebar = (props: Props) => { + // console.log('props', JSON.stringify(props)) + const collapsedRef = ref(false) + const defaultExpandedKeys = [ + 'workflow', + 'udf-manage', + 'service-manage', + 'statistical-manage', + ] + + watch(useI18n().locale, () => { + const languageStore = useLanguageStore() + refreshOptionsRef.value = props.sideMenuOptions + // console.log(123, JSON.stringify(props)) + }) + + const refreshOptionsRef = ref() + + return ( + (collapsedRef.value = true)} + onExpand={() => (collapsedRef.value = false)} + > + + + ) +} export default Sidebar diff --git a/dolphinscheduler-ui-next/src/layouts/content/index.tsx b/dolphinscheduler-ui-next/src/layouts/content/index.tsx index 92b387ea7c..fddf0ac0e9 100644 --- a/dolphinscheduler-ui-next/src/layouts/content/index.tsx +++ b/dolphinscheduler-ui-next/src/layouts/content/index.tsx @@ -15,58 +15,54 @@ * limitations under the License. */ -import { defineComponent, ref, toRefs } from 'vue' +import { ref } from 'vue' import { NLayout, NLayoutContent, NLayoutHeader } from 'naive-ui' import NavBar from './components/navbar' import SideBar from './components/sidebar' import { useDataList } from './use-dataList' +import { useLanguageStore } from '@/store/language/language' -const Content = defineComponent({ - name: 'Content', - setup() { - const { state, getHeaderMenuOptions } = useDataList() +const Content = () => { - const headerMenuOptions = getHeaderMenuOptions(state.menuOptions) + const { state, getHeaderMenuOptions } = useDataList() - const sideMenuOptions = ref() + const headerMenuOptions = getHeaderMenuOptions(state.menuOptions) - const getSideMenuOptions = (item: any) => { - sideMenuOptions.value = - state.menuOptions.filter((menu) => menu.key === item.key)[0].children || - [] - state.isShowSide = sideMenuOptions.value.length !== 0 - } + const sideMenuOptions = ref() + const languageStore = useLanguageStore() - return { - ...toRefs(state), - headerMenuOptions, - getSideMenuOptions, - sideMenuOptions, - } - }, - render() { - return ( - - - - - - - - - - + const getSideMenuOptions = (item: any) => { + // console.log('item', item) + languageStore.setMenuKey(item.key) + sideMenuOptions.value = + state.menuOptions.filter((menu) => menu.key === item.key)[0].children || + [] + state.isShowSide = sideMenuOptions.value.length !== 0 + // console.log('sideMenuOptions.value', sideMenuOptions.value) + // console.log('state.isShowSide', state.isShowSide) + } + + return ( + + + + + + + + + - ) - }, -}) + + ) +} export default Content diff --git a/dolphinscheduler-ui-next/src/store/language/language.ts b/dolphinscheduler-ui-next/src/store/language/language.ts new file mode 100644 index 0000000000..abf5f51467 --- /dev/null +++ b/dolphinscheduler-ui-next/src/store/language/language.ts @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { defineStore } from 'pinia' +import LanguageState from './types' + +export const useLanguageStore = defineStore({ + id: 'language', + state: (): LanguageState => ({ + menuKey: '', + }), + getters: { + getMenuKey(): string { + return this.menuKey + }, + }, + actions: { + setMenuKey(menuKey: string): void { + this.menuKey = menuKey + }, + }, +}) diff --git a/dolphinscheduler-ui-next/src/store/language/types.ts b/dolphinscheduler-ui-next/src/store/language/types.ts new file mode 100644 index 0000000000..5bccca4f9b --- /dev/null +++ b/dolphinscheduler-ui-next/src/store/language/types.ts @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface LanguageState { + menuKey: string +} + +export default LanguageState diff --git a/dolphinscheduler-ui-next/src/views/login/index.tsx b/dolphinscheduler-ui-next/src/views/login/index.tsx index db88412ee3..31fc87ea0f 100644 --- a/dolphinscheduler-ui-next/src/views/login/index.tsx +++ b/dolphinscheduler-ui-next/src/views/login/index.tsx @@ -15,86 +15,80 @@ * limitations under the License. */ -import { defineComponent, toRefs, withKeys } from 'vue' +import { withKeys } from 'vue' import styles from './index.module.scss' import { NInput, NButton, NSwitch, NForm, NFormItem } from 'naive-ui' import { useValidate } from './use-validate' import { useTranslate } from './use-translate' import { useLogin } from './use-login' -const login = defineComponent({ - name: 'login', - setup() { - const { state, t, locale } = useValidate() +const login = () => { + const { state, t, locale } = useValidate() - const { handleChange } = useTranslate(locale) + const { handleChange } = useTranslate(locale) - const { handleLogin } = useLogin(state) + const { handleLogin } = useLogin(state) - return { t, handleChange, handleLogin, ...toRefs(state) } - }, - render() { - return ( -
-
- - {{ - checked: () => 'en_US', - unchecked: () => 'zh_CN', - }} - + return ( +
+
+ + {{ + checked: () => 'en_US', + unchecked: () => 'zh_CN', + }} + +
+
+
+
-
-
-
-
-
- - - - - - - - - + + - {this.t('login.login')} - -
+ + + + + + + + {t('login.login')} +
- ) - }, -}) +
+ ) +} export default login