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