Browse Source

Merge branch 'dev' of https://git.1000my.com/common/base_daoshi_vue_ts into dev

pull/1/head
高志龙 3 years ago
parent
commit
1f521f15f8
  1. 5
      src/composables/useHandleScreen.ts
  2. 30
      src/composables/useSearchShop.ts
  3. 2
      src/types/native.d.ts

5
src/composables/useHandleScreen.ts

@ -53,7 +53,10 @@ export const useHandleScreen = (callback: () => void) => {
}
//跳转屏保挂载到全局 供app使用
window.sleepToWallpaper = sleepToWallpaper
window.sleepToWallpaper = async () => {
await sleepToWallpaper()
nativeMethods.value?.goScreenSave()
}
async function checkHandleScreen() {
toIndexTime.value = totalTime.value[0]

30
src/composables/useSearchShop.ts

@ -4,13 +4,13 @@ import type { Ref, ShallowRef } from 'vue'
/**
* @param {*} watchName
* @param {Ref<UnwrapRef<number>>} [searchType=0] 0:键盘搜索 1:手写搜索
* @return {*} [searchShopListRef]
* @return {*} [searchShopList]
*/
export const useSearchShop = (watchName: Ref<string>, searchType: Ref<0 | 1>): { searchShopListRef: ShallowRef<Shop[]> } => {
export const useSearchShop = (watchName: Ref<string>, searchType: Ref<0 | 1>): { searchShopList: ShallowRef<Shop[]> } => {
const store = useRootStore()
const searchShopListRef = shallowRef<Shop[]>([])
const cacheFirstSearchListRef = shallowRef<Shop[]>([]) //缓存第一次检索首字母后的列表结果
const shopListRef = computed(() => store.shopList)
const searchShopList = shallowRef<Shop[]>([])
const cacheFirstSearchList = shallowRef<Shop[]>([]) //缓存第一次检索首字母后的列表结果
const shopList = computed(() => store.shopList)
watch(watchName, val => {
if (val.length) {
@ -18,29 +18,31 @@ export const useSearchShop = (watchName: Ref<string>, searchType: Ref<0 | 1>): {
let _shopList: Shop[] = []
if (val.length === 1) {
//缓存第一次搜索结果
cacheFirstSearchListRef.value = shopListRef.value.filter(
cacheFirstSearchList.value = shopList.value.filter(
item =>
item.initials?.toUpperCase()?.startsWith(val) ||
item.shopNameEn?.toUpperCase()?.startsWith(val) ||
item.shopName?.toUpperCase()?.startsWith(val)
item.shopName?.toUpperCase()?.startsWith(val) ||
item.spelling?.toUpperCase()?.startsWith(val)
)
} else {
const searchName = val.slice(1)
_shopList = cacheFirstSearchListRef.value.filter(
_shopList = cacheFirstSearchList.value.filter(
item =>
item.initials?.toUpperCase()?.includes(searchName) ||
item.shopNameEn?.toUpperCase()?.includes(searchName) ||
item.shopName?.toUpperCase()?.includes(searchName)
item.shopName?.toUpperCase()?.includes(searchName) ||
item.spelling?.toUpperCase()?.includes(searchName)
)
}
searchShopListRef.value = val.length === 1 ? cacheFirstSearchListRef.value : _shopList
searchShopList.value = val.length === 1 ? cacheFirstSearchList.value : _shopList
} else {
searchShopListRef.value = val.length ? shopListRef.value.filter(item => item.shopName.includes(val)) : []
searchShopList.value = val.length ? shopList.value.filter(item => item.shopName.includes(val)) : []
}
} else {
searchShopListRef.value = []
cacheFirstSearchListRef.value = []
searchShopList.value = []
cacheFirstSearchList.value = []
}
})
return { searchShopListRef }
return { searchShopList }
}

2
src/types/native.d.ts

@ -42,7 +42,7 @@ export declare global {
hasProgram(): boolean //是否有节目列表 用于前端导视是否弹起屏保弹框
}
interface Window {
sleepToWallpaper(): Promise<void>
sleepToWallpaper(): void
android: NativeMethods
chrome: {
webview: {

Loading…
Cancel
Save