feat: web通讯的处理

This commit is contained in:
2026-04-06 01:14:33 +08:00
parent c29330e03a
commit 1f75a7eab8
5 changed files with 108 additions and 16 deletions

View File

@@ -0,0 +1,27 @@
<template>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app'
import { chooseAndUploadImage } from '@/pages/webview/bridge.js'
onLoad(() => {
handleChoose()
})
const sendResult = (imageUrl) => {
// 触发全局事件
uni.$emit('UPLOAD_RESULT', imageUrl)
}
const handleChoose = async () => {
try {
const imageUrl = await chooseAndUploadImage()
sendResult(imageUrl)
} catch (e) {
sendResult('error')
}
uni.navigateBack()
}
</script>