Browse Source

refactor: ♻️ 代码重构

pull/1/head
jiangx 3 years ago
parent
commit
fe008e6636
  1. 6
      src/composables/useHandleScreen.ts
  2. 7
      src/store/root/getters.ts

6
src/composables/useHandleScreen.ts

@ -54,8 +54,7 @@ export const useHandleScreen = (callback: () => void) => {
//跳转屏保挂载到全局 供app使用 //跳转屏保挂载到全局 供app使用
window.sleepToWallpaper = async () => { window.sleepToWallpaper = async () => {
await sleepToWallpaper()
nativeMethods.value?.goScreenSave()
await checkHandleScreen()
} }
async function checkHandleScreen() { async function checkHandleScreen() {
@ -93,8 +92,7 @@ export const useHandleScreen = (callback: () => void) => {
if (!nativeMethods.value?.hasProgram()) { if (!nativeMethods.value?.hasProgram()) {
return return
} }
await sleepToWallpaper()
nativeMethods.value?.goScreenSave()
await checkHandleScreen()
} }
}) })

7
src/store/root/getters.ts

@ -1,3 +1,4 @@
import { DEVICE } from '@/enums'
import type { State } from './state' import type { State } from './state'
import type { CreateGetters } from '../types' import type { CreateGetters } from '../types'
import type { PickRecommendShop } from '@/http/api/brand/types' import type { PickRecommendShop } from '@/http/api/brand/types'
@ -14,22 +15,26 @@ export type GenGetters = CreateGetters<State, GettersMap>
export const getters: GenGetters = { export const getters: GenGetters = {
nativeMethods() { nativeMethods() {
if (this.device.label === 'android') {
if (this.device.label === DEVICE.ANDROID) {
return window.android return window.android
} }
return window.chrome?.webview?.hostObjects?.sync?.csobj return window.chrome?.webview?.hostObjects?.sync?.csobj
}, },
//当前设备所处楼栋的楼层列表
currentBuildingFloorsList() { currentBuildingFloorsList() {
const currentBuilding = this.buildingList.find(building => building.buildingCode === this.device.buildingCode) const currentBuilding = this.buildingList.find(building => building.buildingCode === this.device.buildingCode)
return currentBuilding?.floorList ?? [] return currentBuilding?.floorList ?? []
}, },
//推荐店铺列表
recommendList() { recommendList() {
return this.BrandInfo.recommendList ?? [] return this.BrandInfo.recommendList ?? []
}, },
//品牌模块的楼层列表
brandFloorList() { brandFloorList() {
const currentBuilding = this.BrandInfo.buildingList?.find(item => item.buildingCode === this.device.buildingCode) const currentBuilding = this.BrandInfo.buildingList?.find(item => item.buildingCode === this.device.buildingCode)
return currentBuilding?.floorList ?? [] return currentBuilding?.floorList ?? []
}, },
//业态列表
industryList() { industryList() {
return this.BrandInfo.industryFatherList ?? [] return this.BrandInfo.industryFatherList ?? []
} }

Loading…
Cancel
Save