Files
vueapp/api/navigation.ts
T
2026-06-05 15:27:29 +08:00

20 lines
443 B
TypeScript

import { getCurrentInstance } from 'vue'
type OpenProfileEmit = (event: 'open-profile') => void
export function createProfileOpener(emit: OpenProfileEmit) {
const instance = getCurrentInstance()
const hasOpenProfileListener = Boolean(instance?.vnode.props?.onOpenProfile)
return function openProfile() {
if (hasOpenProfileListener) {
emit('open-profile')
return
}
uni.navigateTo({
url: '/pages/profile/profile'
})
}
}