optimize the vue component communication, replace event listening with share data

This commit is contained in:
RockYang
2024-09-30 14:20:59 +08:00
parent 1a1734abf0
commit 8923e938d2
23 changed files with 473 additions and 480 deletions

View File

@@ -17,11 +17,10 @@
</template>
<script setup>
import {ref} from "vue";
import {getMobileTheme, setMobileTheme} from "@/store/system";
import {ref, watch} from "vue";
import {useRouter} from "vue-router";
import {isMobile} from "@/utils/libs";
import bus from '@/store/eventbus'
import {useSharedStore} from "@/store/sharedata";
const router = useRouter()
if (!isMobile()) {
@@ -29,11 +28,11 @@ if (!isMobile()) {
}
const active = ref('home')
const theme = ref(getMobileTheme())
const store = useSharedStore()
const theme = ref(store.mobileTheme)
bus.on('changeTheme', (value) => {
theme.value = value
setMobileTheme(theme.value)
watch(() => store.mobileTheme, (val) => {
theme.value = val
})
</script>