| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <script setup lang="ts">
- import { computed, ref, watch } from 'vue';
- import { SvgArrowRightIcon } from '@vben/icons';
- import { useAccessStore, useUserStore } from '@vben/stores';
- import useAvatar from '@/assets/image/user.png';
- import { $t } from '@/locales';
- import { Dropdown, message, Modal } from 'antdv-next';
- import Logo from '#/assets/image/logo.png';
- import { router } from '#/router';
- import SelectLang from '../select-lang.vue';
- const userStore = useUserStore();
- const accessStore = useAccessStore();
- const token = accessStore.accessToken;
- const isLogin = computed(() => !!userStore.userInfo);
- const menus = computed(() => [
- { title: $t('homeMenu.toolDownloads'), path: '/Views/Tools/Index.html' },
- {
- title: $t('homeMenu.aIGeneratedApps'),
- path: '/Views/Designer/AIGenerateApp.html',
- },
- {
- title: $t('homeMenu.aIAssistants'),
- path: '/Views/Designer/AIAssistant.html',
- },
- {
- title: $t('homeMenu.shaluAcademy'),
- path: `/Views/Account/SSOIndex.html?system=design&token=${token}`,
- },
- {
- title: $t('homeMenu.applicationMarket'),
- path: '/Views/Designer/systemAppStore.html?tab=application',
- },
- ]);
- const menuList = ref();
- function openLogin() {}
- function handleMenuClick({ key }: { key: string }) {
- if (key === 'Logout') {
- handleLogout();
- } else if (key === 'ChangeInformation') {
- window.open('/Views/Home/userSet.html', '_blank');
- }
- }
- function handleLogout() {
- Modal.confirm({
- title: $t('auth.logOut.title'),
- content: $t('auth.logOut.value'),
- okText: $t('btn.yes'),
- okType: 'danger',
- cancelText: $t('btn.no'),
- onOk() {
- userStore.setUserInfo(null);
- accessStore.setAccessToken(null);
- router.push('/');
- message.success($t('auth.logOutOK'));
- },
- onCancel() {},
- });
- }
- function handleClick(path: string) {
- window.open(path, '_blank');
- }
- watch(
- () => isLogin.value,
- (newValue) => {
- menuList.value = newValue
- ? [
- { key: 'Logout', label: $t('auth.logout') },
- { key: 'ChangeInformation', label: $t('auth.changeInformation') },
- ]
- : [];
- },
- { immediate: true },
- );
- </script>
- <template>
- <div class="mb-[32px] flex items-center justify-between">
- <img :src="Logo" alt="logo" class="logo" height="30px" width="138px" />
- <ul class="menu flex gap-[60px] text-xs">
- <li
- v-for="menuItem in menus"
- :key="menuItem.title"
- class="flex items-center gap-2"
- @click="handleClick(menuItem.path)"
- >
- <span>{{ menuItem.title }}</span>
- <SvgArrowRightIcon class="arrow size-2" />
- </li>
- </ul>
- <div class="flex gap-2">
- <SelectLang />
- <Dropdown
- :menu="{
- items: menuList,
- }"
- placement="bottom"
- @menu-click="(info: any) => handleMenuClick(info)"
- >
- <img
- v-if="userStore.userInfo?.avatar"
- :src="`/File/Download?fileId=${userStore.userInfo?.avatar}`"
- class="cursor-pointer"
- @click="openLogin"
- />
- <img
- v-else
- :avatar="useAvatar"
- class="cursor-pointer"
- @click="openLogin"
- />
- </Dropdown>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- .logo {
- cursor: pointer;
- }
- .menu li {
- color: #462424;
- cursor: pointer;
- &:hover {
- color: #7a003d;
- :deep(path) {
- fill: #7a003d;
- }
- }
- }
- .cursor-pointer {
- width: 24px;
- height: 24px;
- overflow: hidden;
- border: none;
- border-color: transparent;
- border-radius: 50%;
- }
- </style>
|