20 lines
443 B
TypeScript
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'
|
|
})
|
|
}
|
|
}
|