chore: 将全屏按钮置于顶部,使其显眼且易于操作 (#969)

* chore: 将全屏按钮置于顶部,使其显眼且易于操作
This commit is contained in:
xiaoming 2024-03-12 14:36:45 +08:00 committed by GitHub
parent 593fc1bb26
commit d1f0a3fd36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 90 additions and 50 deletions

View File

@ -3,6 +3,7 @@ import Search from "./search/index.vue";
import Notice from "./notice/index.vue";
import mixNav from "./sidebar/mixNav.vue";
import { useNav } from "@/layout/hooks/useNav";
import FullScreen from "./sidebar/fullScreen.vue";
import Breadcrumb from "./sidebar/breadCrumb.vue";
import topCollapse from "./sidebar/topCollapse.vue";
import { useTranslationLang } from "../hooks/useTranslationLang";
@ -10,7 +11,6 @@ import globalization from "@/assets/svg/globalization.svg?component";
import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
import Setting from "@iconify-icons/ri/settings-3-line";
import Check from "@iconify-icons/ep/check";
const {
layout,
device,
@ -47,8 +47,6 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
<div v-if="layout === 'vertical'" class="vertical-header-right">
<!-- 菜单搜索 -->
<Search id="header-search" />
<!-- 通知 -->
<Notice id="header-notice" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
@ -81,6 +79,10 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 全屏 -->
<FullScreen id="full-screen" />
<!-- 消息通知 -->
<Notice id="header-notice" />
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover select-none">

View File

@ -0,0 +1,30 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { useNav } from "@/layout/hooks/useNav";
const screenIcon = ref();
const { toggle, isFullscreen, Fullscreen, ExitFullscreen } = useNav();
isFullscreen.value = !!(
document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement
);
watch(
isFullscreen,
full => {
screenIcon.value = full ? ExitFullscreen : Fullscreen;
},
{
immediate: true
}
);
</script>
<template>
<span class="fullscreen-icon navbar-bg-hover" @click="toggle">
<IconifyIconOffline :icon="screenIcon" />
</span>
</template>

View File

@ -1,6 +1,7 @@
<script setup lang="ts">
import Search from "../search/index.vue";
import Notice from "../notice/index.vue";
import FullScreen from "./fullScreen.vue";
import SidebarItem from "./sidebarItem.vue";
import { isAllEmpty } from "@pureadmin/utils";
import { ref, nextTick, computed } from "vue";
@ -65,8 +66,6 @@ nextTick(() => {
<div class="horizontal-header-right">
<!-- 菜单搜索 -->
<Search id="header-search" />
<!-- 通知 -->
<Notice id="header-notice" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
@ -97,6 +96,10 @@ nextTick(() => {
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 全屏 -->
<FullScreen id="full-screen" />
<!-- 消息通知 -->
<Notice id="header-notice" />
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover">

View File

@ -2,6 +2,7 @@
import extraIcon from "./extraIcon.vue";
import Search from "../search/index.vue";
import Notice from "../notice/index.vue";
import FullScreen from "./fullScreen.vue";
import { isAllEmpty } from "@pureadmin/utils";
import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "@/plugins/i18n";
@ -98,8 +99,6 @@ watch(
<div class="horizontal-header-right">
<!-- 菜单搜索 -->
<Search id="header-search" />
<!-- 通知 -->
<Notice id="header-notice" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
@ -130,6 +129,10 @@ watch(
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 全屏 -->
<FullScreen id="full-screen" />
<!-- 消息通知 -->
<Notice id="header-notice" />
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover select-none">

View File

@ -4,7 +4,7 @@ import { emitter } from "@/utils/mitt";
import { RouteConfigs } from "../../types";
import { useTags } from "../../hooks/useTag";
import { routerArrays } from "@/layout/types";
import { useFullscreen, onClickOutside } from "@vueuse/core";
import { onClickOutside } from "@vueuse/core";
import { handleAliveRoute, getTopMenu } from "@/router/utils";
import { useSettingStoreHook } from "@/store/modules/settings";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
@ -59,7 +59,6 @@ const contextmenuRef = ref();
const isShowArrow = ref(false);
const topPath = getTopMenu()?.path;
const { VITE_HIDE_HOME } = import.meta.env;
const { isFullscreen, toggle } = useFullscreen();
const dynamicTagView = async () => {
await nextTick();
@ -329,28 +328,15 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
handleAliveRoute(route as ToRouteType);
break;
case 6:
//
toggle();
setTimeout(() => {
if (isFullscreen.value) {
tagsViews[6].icon = ExitFullscreen;
tagsViews[6].text = $t("buttons.hswholeExitFullScreen");
} else {
tagsViews[6].icon = Fullscreen;
tagsViews[6].text = $t("buttons.hswholeFullScreen");
}
}, 100);
break;
case 7:
//
onContentFullScreen();
setTimeout(() => {
if (pureSetting.hiddenSideBar) {
tagsViews[7].icon = ExitFullscreen;
tagsViews[7].text = $t("buttons.hscontentExitFullScreen");
tagsViews[6].icon = ExitFullscreen;
tagsViews[6].text = $t("buttons.hscontentExitFullScreen");
} else {
tagsViews[7].icon = Fullscreen;
tagsViews[7].text = $t("buttons.hscontentFullScreen");
tagsViews[6].icon = Fullscreen;
tagsViews[6].text = $t("buttons.hscontentFullScreen");
}
}, 100);
break;
@ -511,11 +497,6 @@ watch(route, () => {
dynamicTagView();
});
watch(isFullscreen, () => {
tagsViews[6].icon = Fullscreen;
tagsViews[6].text = $t("buttons.hswholeFullScreen");
});
onMounted(() => {
if (!instance) return;

View File

@ -4,6 +4,7 @@ import { useRouter } from "vue-router";
import { emitter } from "@/utils/mitt";
import userAvatar from "@/assets/user.jpg";
import { getTopMenu } from "@/router/utils";
import { useFullscreen } from "@vueuse/core";
import { useGlobal } from "@pureadmin/utils";
import type { routeMetaType } from "../types";
import { transformI18n } from "@/plugins/i18n";
@ -13,12 +14,15 @@ import { useAppStoreHook } from "@/store/modules/app";
import { useUserStoreHook } from "@/store/modules/user";
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { usePermissionStoreHook } from "@/store/modules/permission";
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
const errorInfo = "当前路由配置不正确,请检查配置";
export function useNav() {
const pureApp = useAppStoreHook();
const routers = useRouter().options.routes;
const { isFullscreen, toggle } = useFullscreen();
const { wholeMenus } = storeToRefs(usePermissionStoreHook());
/** 平台`layout`中所有`el-tooltip`的`effect`配置,默认`light` */
const tooltipEffect = getConfig()?.TooltipEffect ?? "light";
@ -136,6 +140,10 @@ export function useNav() {
logout,
routers,
$storage,
isFullscreen,
Fullscreen,
ExitFullscreen,
toggle,
backTopMenu,
onPanel,
getDivStyle,

View File

@ -104,17 +104,10 @@ export function useTags() {
disabled: multiTags.value.length > 1 ? false : true,
show: true
},
{
icon: Fullscreen,
text: $t("buttons.hswholeFullScreen"),
divided: true,
disabled: false,
show: true
},
{
icon: Fullscreen,
text: $t("buttons.hscontentFullScreen"),
divided: false,
divided: true,
disabled: false,
show: true
}

View File

@ -35,7 +35,8 @@
}
}
.set-icon {
.set-icon,
.fullscreen-icon {
display: flex;
align-items: center;
justify-content: center;
@ -460,10 +461,12 @@
/* 搜索 */
.search-container,
/* 告警 */
.dropdown-badge,
/* 国际化 */
.globalization,
/* 全屏 */
.fullscreen-icon,
/* 消息通知 */
.dropdown-badge,
/* 用户名 */
.el-dropdown-link,
/* 设置 */
@ -642,10 +645,12 @@ body[layout="vertical"] {
/* 搜索 */
.search-container,
/* 告警 */
.dropdown-badge,
/* 国际化 */
.globalization,
/* 全屏 */
.fullscreen-icon,
/* 消息通知 */
.dropdown-badge,
/* 用户名 */
.el-dropdown-link,
/* 设置 */

View File

@ -29,12 +29,6 @@ const GUIDE_STEPS = [
intro: "您可以在这里搜索想要查看的菜单",
position: "left"
},
{
element: document.querySelector("#header-notice") as string | HTMLElement,
title: "消息通知",
intro: "您可以在这里查看管理员发送的消息",
position: "left"
},
{
element: document.querySelector("#header-translation") as
| string
@ -43,6 +37,18 @@ const GUIDE_STEPS = [
intro: "您可以在这里进行语言切换",
position: "left"
},
{
element: document.querySelector("#full-screen") as string | HTMLElement,
title: "全屏",
intro: "您可以在这里进行全屏切换",
position: "left"
},
{
element: document.querySelector("#header-notice") as string | HTMLElement,
title: "消息通知",
intro: "您可以在这里查看管理员发送的消息",
position: "left"
},
{
element: document.querySelector(".set-icon") as string | HTMLElement,
title: "项目配置",

9
types/global.d.ts vendored
View File

@ -38,6 +38,15 @@ declare global {
msRequestAnimationFrame: (callback: FrameRequestCallback) => number;
}
/**
* Document
*/
interface Document {
webkitFullscreenElement?: Element;
mozFullScreenElement?: Element;
msFullscreenElement?: Element;
}
/**
*
*/