feat: 联调对话功能
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { getCurrentInstance } from 'vue'
|
||||
|
||||
type OpenProfileEmit = (event: 'open-profile') => void
|
||||
type OpenSettingsEmit = (event: 'open-settings') => void
|
||||
type GoHomeEmit = (event: 'go-home') => void
|
||||
|
||||
export function createProfileOpener(emit: OpenProfileEmit) {
|
||||
const instance = getCurrentInstance()
|
||||
@@ -17,3 +19,35 @@ export function createProfileOpener(emit: OpenProfileEmit) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function createSettingsOpener(emit: OpenSettingsEmit) {
|
||||
const instance = getCurrentInstance()
|
||||
const hasOpenSettingsListener = Boolean(instance?.vnode.props?.onOpenSettings)
|
||||
|
||||
return function openSettings() {
|
||||
if (hasOpenSettingsListener) {
|
||||
emit('open-settings')
|
||||
return
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/config/config'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function createHomeNavigator(emit: GoHomeEmit) {
|
||||
const instance = getCurrentInstance()
|
||||
const hasGoHomeListener = Boolean(instance?.vnode.props?.onGoHome)
|
||||
|
||||
return function goHome() {
|
||||
if (hasGoHomeListener) {
|
||||
emit('go-home')
|
||||
return
|
||||
}
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user