feat(overview): 店铺概览和公司概览Tab切换状态持久化到localStorage

This commit is contained in:
小蟑螂
2026-04-25 17:41:53 +08:00
parent 90d0df6fc6
commit 4ec500081d
2 changed files with 18 additions and 4 deletions
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
import { ref } from 'vue';
import { ref, watch } from 'vue';
import { Segmented } from 'ant-design-vue';
@@ -40,7 +40,14 @@ interface Emits {
const props = defineProps<Props>();
const emit = defineEmits<Emits>();
const activeMode = ref<'platform' | 'shop' | 'category'>('platform');
const STORAGE_KEY = 'company-overview-tab';
const getDefaultMode = (): 'platform' | 'shop' | 'category' => {
const stored = localStorage.getItem(STORAGE_KEY);
if (stored === 'platform' || stored === 'shop' || stored === 'category') return stored;
return 'platform';
};
const activeMode = ref<'platform' | 'shop' | 'category'>(getDefaultMode());
watch(activeMode, (val) => localStorage.setItem(STORAGE_KEY, val));
const modeOptions = [
{ label: '平台汇总', value: 'platform' },
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { ShopVO } from '#/api/ecommerce/shop/types';
import { ref } from 'vue';
import { ref, watch } from 'vue';
import { Segmented } from 'ant-design-vue';
@@ -29,7 +29,14 @@ interface Emits {
const props = defineProps<Props>();
const emit = defineEmits<Emits>();
const activeMode = ref<'product' | 'category'>('product');
const STORAGE_KEY = 'shop-overview-tab';
const getDefaultMode = (): 'product' | 'category' => {
const stored = localStorage.getItem(STORAGE_KEY);
if (stored === 'product' || stored === 'category') return stored;
return 'product';
};
const activeMode = ref<'product' | 'category'>(getDefaultMode());
watch(activeMode, (val) => localStorage.setItem(STORAGE_KEY, val));
const modeOptions = [
{ label: '商品汇总', value: 'product' },