chore: freeze guide and explain update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export type GuideTopTab = 'guide' | 'explain'
|
||||
export const GUIDE_LOCATION_PREVIEW_STORAGE_KEY = 'museum-guide:last-location-preview-url'
|
||||
|
||||
export const GUIDE_TOP_TABS: Array<{ id: GuideTopTab; label: string }> = [
|
||||
{ id: 'guide', label: '导览' },
|
||||
@@ -11,7 +12,29 @@ export const isGuideTopTab = (value: unknown): value is GuideTopTab => {
|
||||
|
||||
export const guideTopTabUrl = (tab: GuideTopTab) => `/pages/index/index?tab=${tab}`
|
||||
|
||||
export const saveLastGuideLocationPreviewUrl = (url: string) => {
|
||||
if (typeof window === 'undefined' || !url) return
|
||||
|
||||
window.sessionStorage.setItem(GUIDE_LOCATION_PREVIEW_STORAGE_KEY, url)
|
||||
}
|
||||
|
||||
export const getLastGuideLocationPreviewUrl = () => {
|
||||
if (typeof window === 'undefined') return ''
|
||||
|
||||
return window.sessionStorage.getItem(GUIDE_LOCATION_PREVIEW_STORAGE_KEY) || ''
|
||||
}
|
||||
|
||||
export const navigateToGuideTopTab = (tab: GuideTopTab) => {
|
||||
if (tab === 'guide') {
|
||||
const lastLocationPreviewUrl = getLastGuideLocationPreviewUrl()
|
||||
if (lastLocationPreviewUrl) {
|
||||
uni.reLaunch({
|
||||
url: lastLocationPreviewUrl
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
uni.reLaunch({
|
||||
url: guideTopTabUrl(tab)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user