| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <template>
- <div class="navbar">
- <div class="left-side">
- <a-space>
- <img alt="logo"
- src="//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/dfdba5317c0c20ce20e64fac803d52bc.svg~tplv-49unhts6dw-image.image" />
- <a-typography-title :style="{ margin: 0, fontSize: '18px' }" :heading="5">
- 魔力链
- <a-tag v-if="false && currentPlatform == 'parse'" color="arcoblue"
- @click="clickChangePlatform">口令</a-tag>
- <a-tag v-if="false && currentPlatform == 'coupon'" color="red"
- @click="clickChangePlatform">优惠券</a-tag>
- </a-typography-title>
- <icon-menu-fold v-if="!topMenu && appStore.device === 'mobile'" style="font-size: 22px; cursor: pointer"
- @click="toggleDrawerMenu" />
- </a-space>
- </div>
- <a-modal v-model:visible="visibleChangePlatform" title="切换平台" @before-ok="changePlatform">
- <a-radio-group v-model="currentPlatform">
- <template v-for="item in platformList" :key="item">
- <a-radio :value="item.value">
- <template #radio="{ checked }">
- <a-space align="start" class="custom-radio-card"
- :class="{ 'custom-radio-card-checked': checked }">
- <div className="custom-radio-card-mask">
- <div className="custom-radio-card-mask-dot" />
- </div>
- <div>
- <div className="custom-radio-card-title">
- {{ item.name }}
- </div>
- <a-typography-text type="secondary"> {{ item.desc }}
- </a-typography-text>
- </div>
- </a-space>
- </template>
- </a-radio>
- </template>
- </a-radio-group>
- </a-modal>
- <div class="center-side">
- <Menu v-if="topMenu" />
- </div>
- <ul class="right-side">
- <li>
- <AccountWarning />
- </li>
- <li>
- <a-tooltip :content="$t('settings.search')">
- <a-button class="nav-btn" type="outline" :shape="'circle'">
- <template #icon>
- <icon-search />
- </template>
- </a-button>
- </a-tooltip>
- </li>
- <li>
- <a-tooltip :content="$t('settings.language')">
- <a-button class="nav-btn" type="outline" :shape="'circle'" @click="setDropDownVisible">
- <template #icon>
- <icon-language />
- </template>
- </a-button>
- </a-tooltip>
- <a-dropdown trigger="click" @select="changeLocale as any">
- <div ref="triggerBtn" class="trigger-btn"></div>
- <template #content>
- <a-doption v-for="item in locales" :key="item.value" :value="item.value">
- <template #icon>
- <icon-check v-show="item.value === currentLocale" />
- </template>
- {{ item.label }}
- </a-doption>
- </template>
- </a-dropdown>
- </li>
- <li>
- <a-tooltip :content="theme === 'light'
- ? $t('settings.navbar.theme.toDark')
- : $t('settings.navbar.theme.toLight')
- ">
- <a-button class="nav-btn" type="outline" :shape="'circle'" @click="handleToggleTheme">
- <template #icon>
- <icon-moon-fill v-if="theme === 'dark'" />
- <icon-sun-fill v-else />
- </template>
- </a-button>
- </a-tooltip>
- </li>
- <li>
- <a-tooltip :content="$t('settings.navbar.alerts')">
- <div class="message-box-trigger">
- <a-badge :count="9" dot>
- <a-button class="nav-btn" type="outline" :shape="'circle'" @click="setPopoverVisible">
- <icon-notification />
- </a-button>
- </a-badge>
- </div>
- </a-tooltip>
- <a-popover trigger="click" :arrow-style="{ display: 'none' }"
- :content-style="{ padding: 0, minWidth: '400px' }" content-class="message-popover">
- <div ref="refBtn" class="ref-btn"></div>
- <template #content>
- <message-box />
- </template>
- </a-popover>
- </li>
- <li>
- <a-tooltip :content="isFullscreen
- ? $t('settings.navbar.screen.toExit')
- : $t('settings.navbar.screen.toFull')
- ">
- <a-button class="nav-btn" type="outline" :shape="'circle'" @click="toggleFullScreen">
- <template #icon>
- <icon-fullscreen-exit v-if="isFullscreen" />
- <icon-fullscreen v-else />
- </template>
- </a-button>
- </a-tooltip>
- </li>
- <li>
- <a-tooltip :content="$t('settings.title')">
- <a-button class="nav-btn" type="outline" :shape="'circle'" @click="setVisible">
- <template #icon>
- <icon-settings />
- </template>
- </a-button>
- </a-tooltip>
- </li>
- <li>
- <a-dropdown trigger="click">
- <a-avatar :size="32" :style="{ marginRight: '8px', cursor: 'pointer' }">
- <img alt="avatar" :src="avatar" />
- </a-avatar>
- <template #content>
- <a-doption>
- <a-space @click="$router.push({ name: 'Info' })">
- <icon-user />
- <span>
- {{ $t('messageBox.userCenter') }}
- </span>
- </a-space>
- </a-doption>
- <a-doption>
- <a-space @click="$router.push({ name: 'Setting' })">
- <icon-settings />
- <span>
- {{ $t('messageBox.userSettings') }}
- </span>
- </a-space>
- </a-doption>
- <a-doption>
- <a-space @click="handleLogout">
- <icon-export />
- <span>
- {{ $t('messageBox.logout') }}
- </span>
- </a-space>
- </a-doption>
- </template>
- </a-dropdown>
- </li>
- </ul>
- </div>
- </template>
- <script lang="ts" setup>
- import { computed, ref, inject, onMounted } from 'vue';
- import { useDark, useToggle, useFullscreen, } from '@vueuse/core';
- import { useAppStore, useUserStore } from '@/store';
- import { LOCALE_OPTIONS } from '@/locale';
- import useLocale from '@/hooks/locale';
- import useUser from '@/hooks/user';
- import AccountWarning from '@/components/account-warning/index.vue';
- import Menu from '@/components/menu/index.vue';
- import MessageBox from '../message-box/index.vue';
- const appStore = useAppStore();
- const userStore = useUserStore();
- const { logout } = useUser();
- const { changeLocale, currentLocale } = useLocale();
- const { isFullscreen, toggle: toggleFullScreen } = useFullscreen();
- const locales = [...LOCALE_OPTIONS];
- const avatar = computed(() => {
- return userStore.avatar;
- });
- const theme = computed(() => {
- return appStore.theme;
- });
- const topMenu = computed(() => appStore.topMenu && appStore.menu);
- const isDark = useDark({
- selector: 'body',
- attribute: 'arco-theme',
- valueDark: 'dark',
- valueLight: 'light',
- storageKey: 'arco-theme',
- onChanged(dark: boolean) {
- // overridden default behavior
- appStore.toggleTheme(dark);
- },
- });
- const toggleTheme = useToggle(isDark);
- const visibleChangePlatform = ref(false);
- const handleToggleTheme = () => {
- toggleTheme();
- };
- const setVisible = () => {
- appStore.updateSettings({ globalSettings: true });
- };
- const refBtn = ref();
- const triggerBtn = ref();
- const setPopoverVisible = () => {
- const event = new MouseEvent('click', {
- view: window,
- bubbles: true,
- cancelable: true,
- });
- refBtn.value.dispatchEvent(event);
- };
- const currentPlatform = ref('parse')
- currentPlatform.value = appStore.currentPlatform
- const platformList = computed(() => [
- {
- value: 'parse',
- name: "口令",
- desc: "口令平台",
- },
- {
- value: 'coupon',
- name: "优惠券",
- desc: "优惠券平台",
- },
- ]);
- const clickChangePlatform = (val: string) => {
- visibleChangePlatform.value = true;
- };
- const changePlatform = () => {
- console.log(currentPlatform.value);
- appStore.togglePlatform(currentPlatform.value);
- return true;
- };
- const handleLogout = () => {
- logout();
- };
- const setDropDownVisible = () => {
- const event = new MouseEvent('click', {
- view: window,
- bubbles: true,
- cancelable: true,
- });
- triggerBtn.value.dispatchEvent(event);
- };
- const toggleDrawerMenu = inject('toggleDrawerMenu') as () => void;
- </script>
- <style scoped lang="less">
- .navbar {
- display: flex;
- justify-content: space-between;
- height: 100%;
- background-color: var(--color-bg-2);
- border-bottom: 1px solid var(--color-border);
- }
- .left-side {
- display: flex;
- align-items: center;
- padding-left: 20px;
- }
- .center-side {
- flex: 1;
- }
- .right-side {
- display: flex;
- padding-right: 20px;
- list-style: none;
- :deep(.locale-select) {
- border-radius: 20px;
- }
- li {
- display: flex;
- align-items: center;
- padding: 0 10px;
- }
- a {
- color: var(--color-text-1);
- text-decoration: none;
- }
- .nav-btn {
- border-color: rgb(var(--gray-2));
- color: rgb(var(--gray-8));
- font-size: 16px;
- }
- .trigger-btn,
- .ref-btn {
- position: absolute;
- bottom: 14px;
- }
- .trigger-btn {
- margin-left: 14px;
- }
- }
- </style>
- <style lang="less">
- .message-popover {
- .arco-popover-content {
- margin-top: 0;
- }
- }
- </style>
- <style scoped>
- .custom-radio-card {
- padding: 10px 16px;
- border: 1px solid var(--color-border-2);
- border-radius: 4px;
- width: 200px;
- box-sizing: border-box;
- }
- .custom-radio-card-mask {
- height: 14px;
- width: 14px;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- border-radius: 100%;
- border: 1px solid var(--color-border-2);
- box-sizing: border-box;
- }
- .custom-radio-card-mask-dot {
- width: 8px;
- height: 8px;
- border-radius: 100%;
- }
- .custom-radio-card-title {
- color: var(--color-text-1);
- font-size: 14px;
- font-weight: bold;
- margin-bottom: 8px;
- }
- .custom-radio-card:hover,
- .custom-radio-card-checked,
- .custom-radio-card:hover .custom-radio-card-mask,
- .custom-radio-card-checked .custom-radio-card-mask {
- border-color: rgb(var(--primary-6));
- }
- .custom-radio-card-checked {
- background-color: var(--color-primary-light-1);
- }
- .custom-radio-card:hover .custom-radio-card-title,
- .custom-radio-card-checked .custom-radio-card-title {
- color: rgb(var(--primary-6));
- }
- .custom-radio-card-checked .custom-radio-card-mask-dot {
- background-color: rgb(var(--primary-6));
- }
- </style>
|