处理聊天在webview打开时底部tabbar

This commit is contained in:
wangyifeng 2025-03-14 17:05:05 +08:00
parent 3fe60616a5
commit cba592b87d
10 changed files with 93 additions and 43 deletions

2
components.d.ts vendored
View File

@ -30,6 +30,8 @@ declare module 'vue' {
LoginMessage: typeof import('./src/components/talk/message/LoginMessage.vue')['default'] LoginMessage: typeof import('./src/components/talk/message/LoginMessage.vue')['default']
Message: typeof import('./src/components/x-message/message/index.vue')['default'] Message: typeof import('./src/components/x-message/message/index.vue')['default']
MixedMessage: typeof import('./src/components/talk/message/MixedMessage.vue')['default'] MixedMessage: typeof import('./src/components/talk/message/MixedMessage.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NIcon: typeof import('naive-ui')['NIcon']
PageAnimation: typeof import('./src/components/page-animation/index.vue')['default'] PageAnimation: typeof import('./src/components/page-animation/index.vue')['default']
RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default'] RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']

View File

@ -11,12 +11,12 @@ const userStore = useUserStore()
const root = document.documentElement const root = document.documentElement
root.style.setProperty('--statusBarHeight', `${statusBarHeight.value}px`) root.style.setProperty('--statusBarHeight', `${statusBarHeight.value}px`)
const handleWebview = () => { const handleWebview = () => {
let statusBarHeight = window?.plus?.navigator?.getStatusbarHeight() let statusBarHeight_ = window?.plus?.navigator?.getStatusbarHeight()
const webview = plus.webview.currentWebview() const webview = plus.webview.currentWebview()
webview.setStyle({ // webview.setStyle({
top: statusBarHeight, // top: statusBarHeight_,
bottom: 0, // bottom: 0,
}) // })
// console.log(webview) // console.log(webview)
token.value = webview.token token.value = webview.token
} }

View File

@ -2,8 +2,11 @@
<div class="choose-deps-page"> <div class="choose-deps-page">
<zPaging ref="zPaging" :show-scrollbar="false"> <zPaging ref="zPaging" :show-scrollbar="false">
<template #top> <template #top>
<div :class="state.chooseMode === 3 ? 'top_bg': ''"> <div :class="state.chooseMode === 3 ? 'top_bg' : ''">
<customNavbar :class="state.chooseMode === 3 ? 'index_top_navbar': ''" :title="pageTitle"></customNavbar> <customNavbar
:class="state.chooseMode === 3 ? 'index_top_navbar' : ''"
:title="pageTitle"
></customNavbar>
<div class="pl-[32rpx] pr-[32rpx] pt-[32rpx] pb-[32rpx]"> <div class="pl-[32rpx] pr-[32rpx] pt-[32rpx] pb-[32rpx]">
<customInput <customInput
:searchText="searchVal" :searchText="searchVal"
@ -460,6 +463,7 @@ import downDep from '@/static/image/chatList/downDep.png'
import downDepDis from '@/static/image/chatList/downDepDis.png' import downDepDis from '@/static/image/chatList/downDepDis.png'
import checkBox from '@/components/checkBox/index.vue' import checkBox from '@/components/checkBox/index.vue'
import lodash from 'lodash' import lodash from 'lodash'
import { handleSetWebviewStyle } from '@/utils/common'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
const { t } = useI18n() const { t } = useI18n()
@ -990,6 +994,7 @@ const checkCurrentItem = (item) => {
} }
onMounted(() => { onMounted(() => {
handleSetWebviewStyle()
init() init()
}) })
@ -1106,18 +1111,18 @@ const toUserDetail = (userItem) => {
height: 100%; height: 100%;
display: flex; display: flex;
} }
::v-deep .index_top_navbar .tmicon-angle-left{ ::v-deep .index_top_navbar .tmicon-angle-left {
color:#fff !important; color: #fff !important;
} }
::v-deep .index_top_navbar .text-weight-b{ ::v-deep .index_top_navbar .text-weight-b {
color:#fff !important; color: #fff !important;
} }
::v-deep .index_top_navbar .statusHeightTop > .noNvueBorder:first-child { ::v-deep .index_top_navbar .statusHeightTop > .noNvueBorder:first-child {
background: transparent !important; background: transparent !important;
border: none !important; border: none !important;
} }
.top_bg{ .top_bg {
background: url('@/static/image/mine/page_top.png') no-repeat; background: url('@/static/image/mine/page_top.png') no-repeat;
background-size: cover; background-size: cover;
background-position: bottom center; background-position: bottom center;

View File

@ -186,7 +186,7 @@ import customBtn from '@/components/custom-btn/custom-btn.vue'
import groupMemberList from '../chatSettings/components/groupMembersList.vue' import groupMemberList from '../chatSettings/components/groupMembersList.vue'
import avatarModule from '@/components/avatar-module/index.vue' import avatarModule from '@/components/avatar-module/index.vue'
import { ref, watch, computed } from 'vue' import { ref, watch, computed, onMounted } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app' import { onShow, onLoad } from '@dcloudio/uni-app'
import { useChatList } from '@/store/chatList/index.js' import { useChatList } from '@/store/chatList/index.js'
import { useAuth } from '@/store/auth' import { useAuth } from '@/store/auth'
@ -195,6 +195,7 @@ import addCircle from '@/static/image/chatList/addCircle.png'
import cahtPopover from '@/static/image/chatList/cahtPopover.png' import cahtPopover from '@/static/image/chatList/cahtPopover.png'
import { ServeCreateGroup } from '@/api/group/index' import { ServeCreateGroup } from '@/api/group/index'
import { useGroupTypeStore } from '@/store/groupType' import { useGroupTypeStore } from '@/store/groupType'
import { handleSetWebviewStyle } from '@/utils/common'
const { const {
groupName, groupName,
@ -217,6 +218,10 @@ onLoad(()=> {
groupStore.$reset() groupStore.$reset()
}) })
onMounted(() => {
handleSetWebviewStyle()
})
// //
const groupType = computed(() => { const groupType = computed(() => {
let group_type = '' let group_type = ''

View File

@ -1315,6 +1315,19 @@ const isLeader = computed(() => {
}) })
onMounted(async () => { onMounted(async () => {
if (typeof plus !== 'undefined') {
const webview = plus.webview.currentWebview()
webview.setStyle({
bottom: 0,
})
} else {
document.addEventListener('plusready', () => {
const webview = plus.webview.currentWebview()
webview.setStyle({
bottom: 0,
})
})
}
nextTick(() => { nextTick(() => {
state.value.mentionSelectHeight = pxTorPx( state.value.mentionSelectHeight = pxTorPx(
uni.getSystemInfoSync().windowHeight * 0.86, uni.getSystemInfoSync().windowHeight * 0.86,

View File

@ -131,6 +131,7 @@ import addCircle from '@/static/image/chatList/addCircle.png'
import cahtPopover from '@/static/image/chatList/cahtPopover.png' import cahtPopover from '@/static/image/chatList/cahtPopover.png'
import zu3289 from '@/static/image/chatList/zu3289@2x.png' import zu3289 from '@/static/image/chatList/zu3289@2x.png'
import ZPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue' import ZPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
import { handleSetWebviewStyle } from '@/utils/common'
const paging = ref() const paging = ref()
const isEmptyViewShow = ref(false) const isEmptyViewShow = ref(false)
const talkStore = useTalkStore() const talkStore = useTalkStore()
@ -214,6 +215,7 @@ const toAddressBookPage = () => {
); */ ); */
onShow(() => { onShow(() => {
handleSetWebviewStyle(true)
// //
talkStore talkStore
.loadTalkList() .loadTalkList()

View File

@ -14,6 +14,12 @@
<script setup> <script setup>
import searchList from './components/searchList.vue' import searchList from './components/searchList.vue'
import { ServeSeachQueryAll } from '@/api/search/index' import { ServeSeachQueryAll } from '@/api/search/index'
import { onMounted } from 'vue'
import { handleSetWebviewStyle } from '@/utils/common'
onMounted(() => {
handleSetWebviewStyle()
})
// //
const toMoreResultPage = (searchResultKey, searchText) => { const toMoreResultPage = (searchResultKey, searchText) => {

View File

@ -4,8 +4,8 @@ import { userInfoApi } from "@/api/user";
import {ref} from 'vue' import {ref} from 'vue'
export const useAuth = createGlobalState(() => { export const useAuth = createGlobalState(() => {
// const token = useStorage('token', '', uniStorage) const token = useStorage('token', '', uniStorage)
const token = ref("79b5c732d96d2b27a48a99dfd4a5566c43aaa5796242e854ebe3ffc198d6876b9628e7b764d9af65ab5dbb2d517ced88170491b74b048c0ba827c0d3741462cb89dc59ed46653a449af837a8262941caaef1334d640773710f8cd96473bacfb190cba595a5d6a9c87d70f0999a3ebb41147213b31b4bdccffca66a56acf3baab5af0154f0dce360079f37709f78e13711036899344bddb0fb4cf0f2890287cb62c3fcbe33368caa5e213624577be8b8420ab75b1f50775ee16142a4321c5d56995f37354a66a969da98d95ba6e65d142ed097e04b411c1ebad2f62866d0ec7e1838420530a9941dbbcd00490199f8b8942f76b6f248056e8ae1134eda922b6ba0e5d75a00b2e866b08fec48a0d1de7e6dff8d8a40ac1eb46bf79c6331a1a3cd43209d09865bc0ee5dc9c23d2413e0d85d2380202ce4de1e128063926efae4cb1") // const token = ref("79b5c732d96d2b27a48a99dfd4a5566c43aaa5796242e854ebe3ffc198d6876b9628e7b764d9af65ab5dbb2d517ced88170491b74b048c0ba827c0d3741462cb89dc59ed46653a449af837a8262941caaef1334d640773710f8cd96473bacfb190cba595a5d6a9c87d70f0999a3ebb41147213b31b4bdccffca66a56acf3baab5af0154f0dce360079f37709f78e13711036899344bddb0fb4cf0f2890287cb62c3fcbe33368caa5e213624577be8b8420ab75b1f50775ee16142a4321c5d56995f37354a66a969da98d95ba6e65d142ed097e04b411c1ebad2f62866d0ec7e1838420530a9941dbbcd00490199f8b8942f76b6f248056e8ae1134eda922b6ba0e5d75a00b2e866b08fec48a0d1de7e6dff8d8a40ac1eb46bf79c6331a1a3cd43209d09865bc0ee5dc9c23d2413e0d85d2380202ce4de1e128063926efae4cb1")
const refreshToken = useStorage('refreshToken', '', uniStorage) const refreshToken = useStorage('refreshToken', '', uniStorage)
const userInfo = useStorage('userInfo', {}, uniStorage) const userInfo = useStorage('userInfo', {}, uniStorage)
const leaderList = useStorage('leaderList', [], uniStorage) const leaderList = useStorage('leaderList', [], uniStorage)

View File

@ -64,7 +64,7 @@ export function clipboard(text, callback) {
export async function clipboardImage(src, callback) { export async function clipboardImage(src, callback) {
const { state } = await navigator.permissions.query({ const { state } = await navigator.permissions.query({
name: 'clipboard-write' name: 'clipboard-write',
}) })
if (state != 'granted') return if (state != 'granted') return
@ -77,8 +77,8 @@ export async function clipboardImage(src, callback) {
if (blob.type == 'image/png') { if (blob.type == 'image/png') {
await navigator.clipboard.write([ await navigator.clipboard.write([
new ClipboardItem({ new ClipboardItem({
[blob.type]: blob [blob.type]: blob,
}) }),
]) ])
return callback() return callback()
@ -112,7 +112,7 @@ export async function clipboardImage(src, callback) {
URL.revokeObjectURL(objectURL) URL.revokeObjectURL(objectURL)
}, },
'image/png', 'image/png',
1 1,
) )
} }
} catch (err) { } catch (err) {
@ -180,13 +180,13 @@ export function getVideoImage(file, time = 1) {
width: video.videoWidth, width: video.videoWidth,
height: video.videoHeight, height: video.videoHeight,
duration: video.duration, duration: video.duration,
file: null file: null,
} }
canvas.toBlob((blob) => { canvas.toBlob((blob) => {
data.file = new File([blob], 'image.jpeg', { data.file = new File([blob], 'image.jpeg', {
type: blob.type, type: blob.type,
lastModified: Date.now() lastModified: Date.now(),
}) })
URL.revokeObjectURL(objectURL) URL.revokeObjectURL(objectURL)
@ -196,3 +196,20 @@ export function getVideoImage(file, time = 1) {
} }
}) })
} }
//处理webview样式
export function handleSetWebviewStyle(hasTabBar) {
const setWebviewStyle = () => {
const webview = plus.webview.currentWebview()
webview.setStyle({
bottom: hasTabBar ? webview.tabBarHeight : 0,
})
}
if (typeof plus !== 'undefined') {
setWebviewStyle()
} else {
document.addEventListener('plusready', () => {
setWebviewStyle()
})
}
}

View File

@ -7,7 +7,7 @@ const request = axios.create({
baseURL: import.meta.env.VITE_BASEURL, baseURL: import.meta.env.VITE_BASEURL,
// 请求超时时间 // 请求超时时间
timeout: 10000 timeout: 60000
}) })
let once = false let once = false