mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-04-03 19:06:10 +00:00
优化页面显示效果
This commit is contained in:
@@ -24,11 +24,11 @@
|
|||||||
{{
|
{{
|
||||||
commandContentMap[chatElement.command!]
|
commandContentMap[chatElement.command!]
|
||||||
}}</button>
|
}}</button>
|
||||||
<InputButton
|
<InputButton size="md"
|
||||||
bgColor="bg-red-700 hover:bg-red-800 focus:ring-red-300 text-white focus:ring-4 focus:outline-none"
|
bgColor="bg-red-700 hover:bg-red-800 focus:ring-red-300 text-white focus:ring-4 focus:outline-none"
|
||||||
:content="commandContentMap[chatElement.command!]" :handleSubmit="handleDeleteUserClick"
|
:content="commandContentMap[chatElement.command!]" :handleSubmit="handleDeleteUserClick"
|
||||||
v-if="chatElement.command === 'DELETE_USER'" />
|
v-if="chatElement.command === 'DELETE_USER'" />
|
||||||
<InputButton
|
<InputButton size="md"
|
||||||
bgColor="bg-red-700 hover:bg-red-800 focus:ring-red-300 text-white focus:ring-4 focus:outline-none"
|
bgColor="bg-red-700 hover:bg-red-800 focus:ring-red-300 text-white focus:ring-4 focus:outline-none"
|
||||||
:content="commandContentMap[chatElement.command!]" :handleSubmit="handleDeleteDepartmentClick"
|
:content="commandContentMap[chatElement.command!]" :handleSubmit="handleDeleteDepartmentClick"
|
||||||
v-if="chatElement.command === 'DELETE_DEPARTMENT'" />
|
v-if="chatElement.command === 'DELETE_DEPARTMENT'" />
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<Headbar :changeAssistantVisible="changeAssistantVisible"></Headbar>
|
<Headbar :changeAssistantVisible="changeAssistantVisible" :onSidebarToggle="toggleSidebar"></Headbar>
|
||||||
<Sidebar>
|
<Sidebar ref="sidebarRef" @menu-click="handleMenuClick"></Sidebar>
|
||||||
</Sidebar>
|
|
||||||
<div class="flex flex-row h-[calc(100vh-3.5rem)] mt-14">
|
<div class="flex flex-row h-[calc(100vh-3.5rem)] mt-14">
|
||||||
<article class="flex-1 sm:ml-44 overflow-y-auto">
|
<article class="flex-1 sm:ml-44 overflow-y-auto">
|
||||||
<RouterView></RouterView>
|
<RouterView></RouterView>
|
||||||
@@ -12,15 +11,28 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
import { RouterView } from "vue-router";
|
import { RouterView } from "vue-router";
|
||||||
|
import Assistant from "./Assistant.vue";
|
||||||
import Headbar from "./Headbar.vue";
|
import Headbar from "./Headbar.vue";
|
||||||
import Sidebar from "./Sidebar.vue";
|
import Sidebar from "./Sidebar.vue";
|
||||||
import Assistant from "./Assistant.vue";
|
|
||||||
import { ref } from "vue";
|
|
||||||
|
|
||||||
const isAssistantVisible = ref(false);
|
const isAssistantVisible = ref(false);
|
||||||
|
const sidebarRef = ref();
|
||||||
|
|
||||||
const changeAssistantVisible = () => {
|
const changeAssistantVisible = () => {
|
||||||
isAssistantVisible.value = !isAssistantVisible.value;
|
isAssistantVisible.value = !isAssistantVisible.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleSidebar = () => {
|
||||||
|
if (sidebarRef.value) {
|
||||||
|
sidebarRef.value.toggleSidebar();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMenuClick = () => {
|
||||||
|
if (sidebarRef.value) {
|
||||||
|
sidebarRef.value.closeSidebar();
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<nav class="fixed top-0 z-1 w-full bg-white border-b border-gray-200">
|
<nav class="fixed top-0 w-full bg-white border-b border-gray-200 z-50">
|
||||||
<div class="px-3 py-3 lg:px-5 lg:pl-3">
|
<div class="px-3 py-3 lg:px-5 lg:pl-3">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center justify-start rtl:justify-end">
|
<div class="flex items-center justify-start rtl:justify-end">
|
||||||
<button id="sidebar-toggle-btn" data-drawer-target="logo-sidebar" data-drawer-toggle="logo-sidebar"
|
<button type="button" @click="handleSidebarToggle"
|
||||||
aria-controls="logo-sidebar" type="button"
|
|
||||||
class="inline-flex items-center p-2 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200">
|
class="inline-flex items-center p-2 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200">
|
||||||
<span class="sr-only">Open sidebar</span>
|
<span class="sr-only">Open sidebar</span>
|
||||||
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20"
|
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20"
|
||||||
@@ -101,28 +100,34 @@ import useUserAuth from "../composables/auth/useUserAuth";
|
|||||||
import { RouteName, RoutePath } from "../router/constants";
|
import { RouteName, RoutePath } from "../router/constants";
|
||||||
import AiChatIcon from "./icons/AiChatIcon.vue";
|
import AiChatIcon from "./icons/AiChatIcon.vue";
|
||||||
|
|
||||||
const userDropDownMenu = ref<DropdownInterface>();
|
const props = defineProps<{
|
||||||
|
changeAssistantVisible: () => void;
|
||||||
const { changeAssistantVisible } = defineProps<{
|
onSidebarToggle: () => void;
|
||||||
changeAssistantVisible: () => void;
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
onMounted(() => {
|
const handleSidebarToggle = () => {
|
||||||
initFlowbite();
|
props.onSidebarToggle();
|
||||||
const $dropdownUser = document.getElementById("dropdown-user");
|
};
|
||||||
const $dropdownButton = document.getElementById("dropdown-button");
|
|
||||||
userDropDownMenu.value = new Dropdown(
|
const userDropDownMenu = ref<DropdownInterface>();
|
||||||
$dropdownUser,
|
|
||||||
$dropdownButton,
|
|
||||||
{},
|
|
||||||
{ id: "dropdownMenu", override: true },
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const { user } = useUserStore();
|
const { user } = useUserStore();
|
||||||
const { signOut } = useUserAuth();
|
const { signOut } = useUserAuth();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const handleLogoutClick = () => {
|
const handleLogoutClick = () => {
|
||||||
signOut();
|
signOut();
|
||||||
router.push(RoutePath.LOGIN);
|
router.push(RoutePath.LOGIN);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initFlowbite();
|
||||||
|
const $dropdownUser = document.getElementById("dropdown-user");
|
||||||
|
const $dropdownButton = document.getElementById("dropdown-button");
|
||||||
|
userDropDownMenu.value = new Dropdown(
|
||||||
|
$dropdownUser,
|
||||||
|
$dropdownButton,
|
||||||
|
{},
|
||||||
|
{ id: "dropdownMenu", override: true },
|
||||||
|
);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<aside id="logo-sidebar"
|
<aside id="logo-sidebar"
|
||||||
class="fixed top-0 left-0 px-1 w-44 min-h-screen overflow-y-auto pt-20 transition-transform -translate-x-full bg-white border-r border-gray-200 sm:translate-x-0"
|
class="fixed top-0 left-0 px-1 w-44 min-h-screen overflow-y-auto pt-20 transform transition-transform duration-300 ease-in-out bg-white border-r border-gray-200"
|
||||||
aria-label="Sidebar" tabindex="-1">
|
:class="[
|
||||||
<div class="h-full px-3 pb-4 overflow-y-auto bg-white ">
|
isDrawerVisible ? 'translate-x-0' : '-translate-x-full sm:translate-x-0',
|
||||||
|
isDrawerVisible ? 'z-40' : ''
|
||||||
|
]" aria-label="Sidebar">
|
||||||
|
<div class="h-full px-3 pb-4 overflow-y-auto bg-white">
|
||||||
<ul class="space-y-2 font-medium">
|
<ul class="space-y-2 font-medium">
|
||||||
<li v-for="item in menuItems" :key="item.path">
|
<li v-for="item in menuItems" :key="item.path">
|
||||||
<RouterLink :to="item.path"
|
<RouterLink :to="item.path"
|
||||||
class="flex items-center p-2 gap-x-2 text-gray-900 rounded-lg hover:bg-gray-100 group"
|
class="flex items-center p-2 gap-x-2 text-gray-900 rounded-lg hover:bg-gray-100 group"
|
||||||
:class="{ 'bg-gray-100 ': isActive(item.path) }">
|
:class="{ 'bg-gray-100': isActive(item.path) }" @click="handleMenuClick">
|
||||||
<component :is="item.icon"
|
<component :is="item.icon"
|
||||||
class="shrink-0 text-gray-500 transition duration-75 group-hover:text-gray-900 " />
|
class="shrink-0 text-gray-500 transition duration-75 group-hover:text-gray-900" />
|
||||||
<span>{{ item.title }}</span>
|
<span>{{ item.title }}</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
<!-- 添加遮罩层 -->
|
|
||||||
<div id="drawer-backdrop" :class="isDrawerVisible ? 'block' : 'hidden'"
|
<!-- 遮罩层 -->
|
||||||
class="bg-gray-900 bg-opacity-50 fixed inset-0 z-50 sm:hidden" @click="closeSidebar">
|
<div class="fixed inset-0 bg-gray-900/50 transition-all duration-300 sm:hidden z-30" :class="[
|
||||||
|
isDrawerVisible ? 'opacity-100' : 'opacity-0 pointer-events-none'
|
||||||
|
]" @click="closeSidebar">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -38,6 +43,31 @@ import SettingsIcon from "./icons/SettingsIcon.vue";
|
|||||||
import UsersIcon from "./icons/UsersIcon.vue";
|
import UsersIcon from "./icons/UsersIcon.vue";
|
||||||
|
|
||||||
const isDrawerVisible = ref(false);
|
const isDrawerVisible = ref(false);
|
||||||
|
const emit = defineEmits(['menu-click']);
|
||||||
|
|
||||||
|
// 菜单点击处理
|
||||||
|
const handleMenuClick = () => {
|
||||||
|
emit('menu-click');
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleSidebar = () => {
|
||||||
|
isDrawerVisible.value = !isDrawerVisible.value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const openSidebar = () => {
|
||||||
|
isDrawerVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeSidebar = () => {
|
||||||
|
isDrawerVisible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
toggleSidebar,
|
||||||
|
openSidebar,
|
||||||
|
closeSidebar,
|
||||||
|
isDrawerVisible
|
||||||
|
});
|
||||||
|
|
||||||
// 菜单配置
|
// 菜单配置
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
@@ -89,11 +119,28 @@ const isActive = (path: string) => {
|
|||||||
return route.path === path;
|
return route.path === path;
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeSidebar = () => {
|
|
||||||
isDrawerVisible.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initFlowbite();
|
initFlowbite();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.invisible {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visible {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加移动端样式 */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.translate-x-0 {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.-translate-x-full {
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user