From a90997d12d4849ccd0590143121519a64c162931 Mon Sep 17 00:00:00 2001 From: Twilight Date: Sun, 6 Oct 2024 00:50:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E9=85=8D=E8=89=B2?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/App.vue | 91 +++++++++++++++++++++++++++++++------- src/layouts/Header.vue | 50 ++++++++++++++++++--- src/main.ts | 3 +- src/stores/app.ts | 4 ++ src/styles/color.less | 82 ++++++++++++++++++++++++++++++++++ src/{ => styles}/style.css | 2 +- 7 files changed, 209 insertions(+), 24 deletions(-) create mode 100644 src/styles/color.less rename src/{ => styles}/style.css (97%) diff --git a/package.json b/package.json index 85d3ff7..42db299 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.4.0", "eslint-plugin-vue": "^9.27.0", + "less": "^4.2.0", "naive-ui": "^2.39.0", "postcss": "^8.4.45", "prettier": "^3.3.3", diff --git a/src/App.vue b/src/App.vue index ce1457e..d6b21d0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -49,9 +49,9 @@ diff --git a/src/layouts/Header.vue b/src/layouts/Header.vue index a00562a..2f60772 100644 --- a/src/layouts/Header.vue +++ b/src/layouts/Header.vue @@ -37,6 +37,7 @@
@@ -61,6 +62,7 @@
@@ -76,18 +78,14 @@ - + -
+
@@ -216,8 +214,10 @@ import leaflowpng from "@/assets/images/leaflow.png"; import { useChatStore } from "@/stores/chat"; import groupPng from "@/assets/images/group.png"; import config from "@/config/config"; +import { useAppStore } from "@/stores/app"; const userStore = useUserStore(); +const appStore = useAppStore(); const chatStore = useChatStore(); const isMobile = useIsMobile(); const showDrawer = ref(false); @@ -253,4 +253,40 @@ const newChat = () => { const gotoLogin = () => { router.push("/auth/login"); }; + +const leftMenu = ref(); +const centerLogo = ref(); + +const setCirclePosition = () => { + if (isMobile.value) { + // 获取 leftMenu 的位置 + const leftMenuRect = leftMenu.value.getBoundingClientRect(); + + // 计算元素的正中心 + const centerX = leftMenuRect.x + leftMenuRect.width / 2; + const centerY = leftMenuRect.y + leftMenuRect.height / 2; + + appStore.headerCenterLogoPosition.x = centerX; + appStore.headerCenterLogoPosition.y = centerY; + } else { + // 获取 centerLogo 的位置 + const centerLogoRect = centerLogo.value.getBoundingClientRect(); + + // 计算元素的正中心 + const centerX = centerLogoRect.x + centerLogoRect.width / 2; + const centerY = centerLogoRect.y + centerLogoRect.height / 2; + appStore.headerCenterLogoPosition.x = centerX; + appStore.headerCenterLogoPosition.y = centerY; + } +}; + +onMounted(() => { + setCirclePosition(); +}); + +window.addEventListener("resize", setCirclePosition); + +onUnmounted(() => { + window.removeEventListener("resize", setCirclePosition); +}); diff --git a/src/main.ts b/src/main.ts index e0a3b8f..e0c3d26 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,8 @@ const meta = document.createElement("meta"); meta.name = "naive-ui-style"; document.head.appendChild(meta); -import "./style.css"; +import "./styles/style.css"; +import "./styles/color.less"; import "animate.css"; import { registerPlugins } from "./plugins"; import router from "./router"; diff --git a/src/stores/app.ts b/src/stores/app.ts index 0f3e936..78e493f 100644 --- a/src/stores/app.ts +++ b/src/stores/app.ts @@ -9,5 +9,9 @@ export const useAppStore = defineStore("app", { contentScrollPosition: 0, contentScrollOnBottom: false, contentScrollable: false, + headerCenterLogoPosition: { + x: 0, + y: 0, + } }), }); diff --git a/src/styles/color.less b/src/styles/color.less new file mode 100644 index 0000000..ad305a4 --- /dev/null +++ b/src/styles/color.less @@ -0,0 +1,82 @@ +// // light-dark-8deg-animation +// @keyframes light-to-dark { +// from { +// clip-path: polygon( +// 0 0, +// 0 0, +// calc(tan(8deg) * -100vh) 100%, +// calc(tan(8deg) * -100vh) 100% +// ); +// } + +// to { +// clip-path: polygon( +// 0 0, +// calc((tan(8deg) * 100vh) + 100%) 0, +// 100% 100%, +// calc(tan(8deg) * -100vh) 100% +// ); +// } +// } + +// @keyframes dark-to-light { +// from { +// clip-path: polygon( +// calc((tan(8deg) * 100vh) + 100%) 0, +// calc((tan(8deg) * 100vh) + 100%) 0, +// 100% 100%, +// 100% 100% +// ); +// } + +// to { +// clip-path: polygon( +// 0 0, +// calc((tan(8deg) * 100vh) + 100%) 0, +// 100% 100%, +// calc(tan(8deg) * -100vh) 100% +// ); +// } +// } + +// :root::view-transition-group(root) { +// animation-duration: 1s; +// } + +// :root::view-transition-new(root), +// :root::view-transition-old(root) { +// mix-blend-mode: normal; +// } + +// :root::view-transition-old(root), +// :root[theme="dark"]::view-transition-old(root) { +// animation: none; +// } + +// :root::view-transition-new(root) { +// animation-name: dark-to-light; +// } + +// :root[theme="dark"]::view-transition-new(root) { +// animation-name: light-to-dark; +// } + +::view-transition-old(root), +::view-transition-new(root) { + animation: none; + mix-blend-mode: normal; +} + +:root[theme="dark"]::view-transition-old(root) { + z-index: 1; +} +:root[theme="light"]::view-transition-new(root) { + z-index: 999; +} + +::view-transition-old(root) { + z-index: 999; +} +::view-transition-new(root) { + z-index: 1; +} diff --git a/src/style.css b/src/styles/style.css similarity index 97% rename from src/style.css rename to src/styles/style.css index 57cce0c..b68af2f 100644 --- a/src/style.css +++ b/src/styles/style.css @@ -1,5 +1,5 @@ @import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@100..900&display=swap"); -@import "styles/github-markdown.css"; +@import "github-markdown.css"; @tailwind base; @tailwind components; @tailwind utilities;