|
|
@@ -1,8 +1,44 @@
|
|
|
import {Logout, EditOne} from '@icon-park/vue-next';
|
|
|
import {h} from 'vue';
|
|
|
-import type {DropdownOption} from 'naive-ui';
|
|
|
+import {useDialog, type DropdownOption} from 'naive-ui';
|
|
|
+import {useUserStore} from '@stores';
|
|
|
+import {useI18n} from 'vue-i18n';
|
|
|
+import {lightVariable} from '@utils';
|
|
|
+import {useRouter} from 'vue-router';
|
|
|
+import {LOGIN_PATH} from '@routes';
|
|
|
|
|
|
export const dropdownOptions: DropdownOption[] = [
|
|
|
{label: '修改密码', key: 'editPassword', icon: () => h(EditOne)},
|
|
|
{label: '退出登录', key: 'logout', icon: () => h(Logout)},
|
|
|
];
|
|
|
+
|
|
|
+export function useDownSelect() {
|
|
|
+ const userStore = useUserStore();
|
|
|
+ const dialog = useDialog();
|
|
|
+ const {t} = useI18n();
|
|
|
+ const {push} = useRouter();
|
|
|
+
|
|
|
+ function logout() {
|
|
|
+ dialog.warning({
|
|
|
+ title: t('home.downMenu.logoutTitle'),
|
|
|
+ content: t('home.downMenu.logout'),
|
|
|
+ positiveText: t('home.downMenu.loginBtnOK'),
|
|
|
+ negativeText: t('home.downMenu.loginBtnCancel'),
|
|
|
+ positiveButtonProps: {
|
|
|
+ color: lightVariable.primaryColor,
|
|
|
+ },
|
|
|
+ onPositiveClick() {
|
|
|
+ userStore.logout();
|
|
|
+ push(LOGIN_PATH);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return function onSelect(key: string) {
|
|
|
+ switch (key) {
|
|
|
+ case 'logout':
|
|
|
+ logout();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|