@@ -96,6 +96,7 @@ import { computed, ref, watchEffect, onMounted } from "vue";
9696import { useI18n } from " vue-i18n" ;
9797import { useRoute , useRouter } from " vue-router" ;
9898import { useGlobalStore } from " @/store/global" ;
99+ import { useSystemStore } from " @/store/system" ;
99100import { useSettingsStore } from ' @/store/settings' ;
100101import { storeToRefs } from " pinia" ;
101102import { Toast } from " @nutui/nutui" ;
@@ -111,49 +112,21 @@ const router = useRouter();
111112const route = useRoute ();
112113const methodStore = useMethodStore ()
113114const globalStore = useGlobalStore ();
115+ const systemStore = useSystemStore ();
114116const showLangSwitchPopup = ref (false );
115117const langList = [" zh" , " en" ];
116118const settingsStore = useSettingsStore ();
117119const { changeAppearanceSetting } = settingsStore ;
118120const { appearanceSetting } = storeToRefs (settingsStore );
119- // const { isSimpleMode, showFloatingRefreshButton } = storeToRefs(globalStore);
120- const isLandscape = ref (false );
121- const isSmall = ref (false );
122- const screenWidth = ref (window .innerWidth );
123- const screenHeight = ref (window .innerHeight );
124-
125- const handleResize = () => {
126- screenWidth .value = window .innerWidth ;
127- screenHeight .value = window .innerHeight ;
128- };
121+ // 从systemStore获取状态
122+ const { isPWA, isLandscape, isSmall } = storeToRefs (systemStore );
129123
130124onMounted (() => {
131- window .addEventListener (" resize" , handleResize );
132- });
133- const isPWA = ref (
134- (window .matchMedia (" (display-mode: standalone)" ).matches &&
135- ! / Android/ .test (navigator .userAgent )) ||
136- false
137- );
138-
139- // isPWA.value = true;
140- // isSmall.value = true;
141-
142- const navBarHeight = computed (() => {
143- return isPWA .value && ! isLandscape .value ? (isSmall .value ? " 78px" : " 95px" ) : " 56px" ;
125+ systemStore .initSystemState ();
144126});
145127
146- const navBartop = computed (() => {
147- return isPWA .value && ! isLandscape .value ? (isSmall .value ? " 38px" : " 55px" ) : " 0px" ;
148- });
149-
150- const navBartopRight = computed (() => {
151- return isPWA .value && ! isLandscape .value ? (isSmall .value ? " 52px" : " 65px" ) : " 15px" ;
152- });
153-
154- const Pwa_top = computed (() => {
155- return isPWA .value ? (isSmall .value ? " 20px" : " 45px" ) : " 45px" ;
156- });
128+ // 使用systemStore中的计算属性
129+ const { navBarHeight, navBartop, navBartopRight, pwaTopPadding : Pwa_top } = storeToRefs (systemStore );
157130
158131const isNeedBack = computed (() => {
159132 return route .meta .needNavBack ?? false ;
@@ -245,11 +218,6 @@ const refresh = async () => {
245218 }, 1000 );
246219 }
247220};
248- watchEffect (() => {
249- handleResize ();
250- isSmall .value = screenHeight .value < 750 || / iPad/ .test (navigator .userAgent );
251- isLandscape .value = screenWidth .value > screenHeight .value ;
252- });
253221 </script >
254222
255223<style lang="scss">
0 commit comments