调试页面 编写中

This commit is contained in:
hawk86104 2025-03-06 18:53:21 +08:00
parent 1fe9ef7d3e
commit 66914bd393
3 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,22 @@
export default {
name: 'uniAppView',
title: 'uniapp小程序',
intro: '结合uni-app的开源生态使用web-view的方式和uni-app交互方便在您的微信、支付宝等小程序、以及安卓、ios中插入我们的tvt案例以及插件',
version: '1.0.0',
author: '地虎降天龙',
website: 'https://gitee.com/hawk86104',
state: 'active',
creatTime: '2025-03-05',
updateTime: '2025-03-05',
require: [],
preview: [
{
src: 'plugins/basic/base/preview/theBasic.png',
type: 'img',
name: 'h5demo',
title: '简单UI交互',
disableFPSGraph: true,
disableSrcBtn: true,
},
],
}

View File

@ -0,0 +1,35 @@
/*
* @Description:
* @Version: 1.668
* @Autor: 地虎降天龙
* @Date: 2025-03-05 11:49:24
* @LastEditors: 地虎降天龙
* @LastEditTime: 2025-03-05 11:52:28
*/
export function loadJweixin () {
return new Promise((resolve, reject) => {
if (window.wx) {
resolve(window.wx)
return
}
const script = document.createElement('script')
script.src = 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js' // 适当更换版本
script.onload = () => resolve(window.wx)
script.onerror = reject
document.body.appendChild(script)
})
}
export function loadWebView () {
return new Promise((resolve, reject) => {
if (window.uni) {
resolve(window.uni)
return
}
const script = document.createElement('script')
script.src = 'https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.0.1.52.js' // 适当更换版本
script.onload = () => resolve(window.wx)
script.onerror = reject
document.body.appendChild(script)
})
}

View File

@ -0,0 +1,49 @@
<!--
* @Description:
* @Version: 1.668
* @Autor: 地虎降天龙
* @Date: 2025-03-05 10:47:55
* @LastEditors: 地虎降天龙
* @LastEditTime: 2025-03-05 12:02:41
-->
<template>
<div class="title">dsad</div>
<div class="btn-list">
<button class="btn" type="button" data-action="navigateTo">navigateTo</button>
<button class="btn" type="button" data-action="redirectTo">redirectTo</button>
<button class="btn" type="button" data-action="navigateBack">navigateBack</button>
<button class="btn" type="button" data-action="reLaunch">reLaunch</button>
<button class="btn btn-red" type="button" data-action="switchTab">switchTab</button>
<button class="btn btn-yellow" type="button" @click="postMessage">postMessage</button>
<button class="btn btn-yellow" type="button" data-action="getEnv">getEnv</button>
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import { loadJweixin, loadWebView } from '../lib/initScript'
declare const uni: any
onMounted(async () => {
console.log('onMounted')
await loadJweixin()
await loadWebView()
uni.getEnv((res: any) => {
alert(`当前环境:${JSON.stringify(res)}`)
})
})
const postMessage = () => {
uni.postMessage({
data: {
action: '发送消息了',
},
})
}
</script>
<style lang="less" scoped>
.title {
color: white;
}
</style>