hookehuyr

refactor: 移除未使用的 NutUI 组件和 H5 小程序跳转逻辑

清理未使用的 NutTabbar 和 NutTabbarItem 组件类型定义。
删除 AppTabbar 中用于 H5 环境跳转小程序的复杂逻辑,简化页面导航。
移除已不再使用的 miniProgram.js 工具文件。
更新地图引导页面的 URL 参数。
......@@ -9,8 +9,6 @@ declare module 'vue' {
export interface GlobalComponents {
AppTabbar: typeof import('./src/components/AppTabbar.vue')['default']
IndexNav: typeof import('./src/components/indexNav.vue')['default']
NutTabbar: typeof import('@nutui/nutui-taro')['Tabbar']
NutTabbarItem: typeof import('@nutui/nutui-taro')['TabbarItem']
Picker: typeof import('./src/components/time-picker-data/picker.vue')['default']
PosterBuilder: typeof import('./src/components/PosterBuilder/index.vue')['default']
QrCode: typeof import('./src/components/qrCode.vue')['default']
......
......@@ -30,8 +30,6 @@
<script setup>
import Taro from '@tarojs/taro'
import { Home, Message, My } from '@nutui/icons-vue-taro'
// 迁移到独立 H5 项目时,别忘了把 miniProgram helper 一起带走。
import { isH5Env, navigateToMiniProgramPage } from '@/utils/miniProgram'
const props = defineProps({
current: {
......@@ -66,23 +64,11 @@ const tabItems = [
const isActive = (name) => name === props.current
const handleTabClick = async (item) => {
const handleTabClick = (item) => {
if (!item?.url || item.name === props.current) {
return
}
if (isH5Env()) {
try {
const has_navigated = await navigateToMiniProgramPage(item.url)
if (has_navigated) {
return
}
} catch (error) {
console.error('H5 跳转小程序页面失败:', error)
}
}
Taro.redirectTo({ url: item.url })
}
</script>
......
<!--
* @Date: 2026-04-22 13:14:52
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-04-22 13:20:49
* @LastEditTime: 2026-04-29 13:17:28
* @FilePath: /jls_weapp/src/pages/map-guide/index.vue
* @Description: 文件描述
-->
......@@ -10,5 +10,5 @@
</template>
<script setup>
const map_guide_url = 'https://oa-dev.onwall.cn/f/map/#/checkin/?id=835368&current_lng=121.52609&current_lat=31.25956&openid=oAHBN14FGjUihI-ayF22_rCe0APM&discount_title=便民服务&activityId=835370&_t=1776834254361'
const map_guide_url = 'https://oa-dev.onwall.cn/f/map/#/checkin/?id=835368&current_lng=121.52609&current_lat=31.25956&openid=oAHBN14FGjUihI-ayF22_rCe0APM&&activityId=8353701&_t=&navMode=jls'
</script>
......
const WECHAT_JS_SDK_URL = 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js'
let wechat_bridge_loading_promise = null
const isBrowserEnv = () => typeof window !== 'undefined' && typeof document !== 'undefined'
const getWechatBridge = () => {
if (typeof window === 'undefined') {
return null
}
return window.wx || window.jWeixin || null
}
const getMiniProgramBridge = () => getWechatBridge()?.miniProgram || null
export const isH5Env = () => isBrowserEnv()
const ensureWechatBridge = async () => {
if (!isH5Env()) {
return null
}
const current_bridge = getWechatBridge()
if (current_bridge) {
return current_bridge
}
if (!wechat_bridge_loading_promise) {
wechat_bridge_loading_promise = new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = WECHAT_JS_SDK_URL
script.async = true
script.onload = () => resolve(getWechatBridge())
script.onerror = () => reject(new Error('微信 JS SDK 加载失败'))
document.head.appendChild(script)
})
}
try {
return await wechat_bridge_loading_promise
} catch (error) {
wechat_bridge_loading_promise = null
throw error
}
}
export const isWechatMiniProgramWebview = () => new Promise((resolve) => {
const check_env = async () => {
if (!isH5Env()) {
resolve(false)
return
}
try {
await ensureWechatBridge()
} catch (error) {
console.error('微信 JS SDK 初始化失败:', error)
resolve(false)
return
}
const mini_program_bridge = getMiniProgramBridge()
if (!mini_program_bridge) {
resolve(false)
return
}
if (typeof mini_program_bridge.getEnv !== 'function') {
resolve(true)
return
}
mini_program_bridge.getEnv((result = {}) => {
resolve(!!result.miniprogram)
})
}
check_env().catch(() => {
resolve(false)
})
})
export const navigateToMiniProgramPage = async (url = '') => {
const normalized_url = String(url || '').trim()
if (!normalized_url) {
return false
}
const is_supported_webview = await isWechatMiniProgramWebview()
if (!is_supported_webview) {
return false
}
const mini_program_bridge = getMiniProgramBridge()
if (typeof mini_program_bridge?.navigateTo !== 'function') {
return false
}
return new Promise((resolve, reject) => {
mini_program_bridge.navigateTo({
url: normalized_url,
success: () => resolve(true),
fail: (error) => reject(error),
})
})
}