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 e28a12a1ee
commit 77948b1e16
23 changed files with 473 additions and 480 deletions

View File

@@ -52,11 +52,12 @@
</template>
<script setup>
import {computed, ref} from 'vue';
import {computed, ref, watch} from 'vue';
import {setMenuItems, useSidebarStore} from '@/store/sidebar';
import {httpGet} from "@/utils/http";
import {ElMessage} from "element-plus";
import {useRoute} from "vue-router";
import {useSharedStore} from "@/store/sharedata";
const title = ref('')
const logo = ref('')
@@ -68,16 +69,11 @@ httpGet('/api/admin/config/get?key=system').then(res => {
}).catch(e => {
ElMessage.error("加载系统配置失败: " + e.message)
})
// eslint-disable-next-line no-undef
const props = defineProps({
theme: String,
});
const theme = computed(() => {
return props.theme
const store = useSharedStore()
const theme = ref(store.adminTheme)
watch(() => store.adminTheme, (val) => {
theme.value = val
})
const items = [
{
icon: 'home',