feat(custom): 新增webview
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-04-21 05:40:07 +08:00
parent ee446dd4a9
commit ddd7789817
4 changed files with 43 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
export default defineAppConfig({
pages: [
'pages/index/index',
'pages/webview/index',
'pages/yaotouzi/index/index',
'pages/game_detail/index',
'pages/yaotouzi/records/index',

View File

@@ -1,17 +1,17 @@
<template>
<view class="index">
<swiper class="swiper" :circular="true" :autoplay="true">
<swiper-item v-for="(item, index) in list" :key="index">
<image :src="item" />
</swiper-item>
</swiper>
<view class="container">
<!-- <view>摇骰子</view> -->
<view class="index">
<swiper class="swiper" :circular="true" :autoplay="true">
<swiper-item v-for="(item, index) in list" :key="index">
<image :src="item" />
</swiper-item>
</swiper>
<view class="container">
<!-- <view>摇骰子</view> -->
<rich-text :nodes="info.introduction"></rich-text>
<view class="btn" @click="startGame()">开始游戏</view>
</view>
<rich-text :nodes="info.introduction"></rich-text>
<view class="btn" @click="startGame()">开始游戏</view>
</view>
</view>
</template>
<script lang="ts" setup>
@@ -23,13 +23,20 @@ const info = ref<any>({})
const list = ref<string[]>([])
Taro.useLoad(() => {
info.value = Taro.getStorageSync('gameItem')
list.value.push(info.value.cover)
info.value = Taro.getStorageSync('gameItem')
list.value.push(info.value.cover)
})
const startGame = () => {
// 判断url中是否含有http
if (info.value.url.indexOf('http') === -1) {
Taro.navigateTo({
url: info.value.url,
url: info.value.url,
})
} else {
Taro.navigateTo({
url: `/pages/webview/index?url=${info.value.url}`,
})
}
}
</script>

View File

@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: 'webview',
})

View File

@@ -0,0 +1,18 @@
<template>
<view>
<web-view :src="src" />
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import Taro from '@tarojs/taro'
const src = ref('')
Taro.useLoad((e) => {
src.value = `${e.url}?uid=${Taro.getStorageSync('uid')}`
})
</script>
<style lang="scss"></style>