From 1c310b9d42086b41b8d8a970809eafc449522fa2 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Wed, 17 May 2023 13:41:58 +0800 Subject: [PATCH] loli position --- src/components/KUNGalgameTopBar.vue | 8 +---- .../setting-panel/KUNGalgameSettingPanel.vue | 33 +++++++++++------ .../setting-panel/components/Loli.vue | 3 +- src/hooks/useFixedLoli.ts | 35 +++++++++++++------ src/utils/cache/cache-key.ts | 6 ++-- src/utils/cache/local-storage.ts | 17 ++++++--- 6 files changed, 65 insertions(+), 37 deletions(-) diff --git a/src/components/KUNGalgameTopBar.vue b/src/components/KUNGalgameTopBar.vue index cf5ebb9e..417725f3 100644 --- a/src/components/KUNGalgameTopBar.vue +++ b/src/components/KUNGalgameTopBar.vue @@ -17,13 +17,7 @@ import { storeToRefs } from 'pinia' const settingsStore = useSettingsPanelStore() // 使数据变为响应式 -let { - showSettings, - showDarkMode, - showPageWidth, - showKUNGalgameBackground, - showFixedLoli, -} = storeToRefs(settingsStore) +let { showSettings } = storeToRefs(settingsStore) // 顶部导航栏单个项目的接口 interface topBar { diff --git a/src/components/setting-panel/KUNGalgameSettingPanel.vue b/src/components/setting-panel/KUNGalgameSettingPanel.vue index 4c955479..0f9890f9 100644 --- a/src/components/setting-panel/KUNGalgameSettingPanel.vue +++ b/src/components/setting-panel/KUNGalgameSettingPanel.vue @@ -18,7 +18,15 @@ import { useFixedLoli } from '@/hooks/useFixedLoli' const settingsStore = useSettingsPanelStore() // 使用全局固定看板娘的 hook -const { kungalgameLoliStatus, setLoli, setLoliBtn, initLoli } = useFixedLoli() +const { + kungalgameLoliStatus, + kungalgameLoliPositionX, + kungalgameLoliPositionY, + setLoli, + setLoliX, + setLoliY, + initLoli, +} = useFixedLoli() // 初始化看板娘 initLoli() @@ -30,20 +38,23 @@ const handleClose = () => { let checked = kungalgameLoliStatus.value === 'true' -let flag = false // 用户点击固定看板娘 const handleClick = () => { - let str = 'false' - if (flag) { - setLoli(str) - str = 'false' - flag = !flag + if (!checked) { + setLoli('true') } else { - setLoli(str) - str = 'true' - flag = !flag + setLoli('false') } } +// 看板娘的位置数据 +let loliPositionX = parseFloat(kungalgameLoliPositionX.value) +let loliPositionY = parseFloat(kungalgameLoliPositionY.value) + +// 看板娘的位置样式 +const loliPosition = { + left: `${loliPositionX}px`, + top: `${loliPositionY}px`, +}