mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
feat(overview): 店铺概览和公司概览Tab切换状态持久化到localStorage
This commit is contained in:
+9
-2
@@ -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' },
|
||||
|
||||
+9
-2
@@ -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' },
|
||||
|
||||
Reference in New Issue
Block a user