fix(context): share selected campus across layout
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
import { useAppStore } from '@/stores/app'
|
||||
@@ -7,9 +7,6 @@ import { useAppStore } from '@/stores/app'
|
||||
const route = useRoute()
|
||||
const appStore = useAppStore()
|
||||
|
||||
const campuses = ['本部院区', '东院区', '西院区']
|
||||
const selectedCampus = ref(campuses[0])
|
||||
|
||||
const pageTitle = computed(() => String(route.meta.title ?? '首页'))
|
||||
const pageGroup = computed(() => String(route.meta.group ?? '工作台'))
|
||||
</script>
|
||||
@@ -23,8 +20,10 @@ const pageGroup = computed(() => String(route.meta.group ?? '工作台'))
|
||||
<span class="header-spacer" />
|
||||
<label class="campus-selector">
|
||||
<span class="campus-label">院区</span>
|
||||
<select v-model="selectedCampus" aria-label="选择院区">
|
||||
<option v-for="campus in campuses" :key="campus" :value="campus">{{ campus }}</option>
|
||||
<select v-model="appStore.selectedCampus" aria-label="选择院区">
|
||||
<option v-for="campus in appStore.campuses" :key="campus" :value="campus">
|
||||
{{ campus }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<span class="environment-badge">{{ appStore.environment }}</span>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import type { WorkbenchCampus } from '@/api/workbench/types'
|
||||
|
||||
export const useAppStore = defineStore('app', {
|
||||
state: () => ({
|
||||
isLoggedIn: false,
|
||||
userName: '张文静',
|
||||
department: '医务管理 · 主任医师',
|
||||
environment: '原型演示环境',
|
||||
campuses: ['本部院区', '东院区', '西院区'] as WorkbenchCampus[],
|
||||
selectedCampus: '本部院区' as WorkbenchCampus,
|
||||
}),
|
||||
actions: {
|
||||
login(userName: string) {
|
||||
|
||||
Reference in New Issue
Block a user