chat.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <cwg-page-wrapper class="webview-page" type="chat">
  3. <view class="page-container">
  4. <!-- WebView 内容区(自动占满剩余空间,不遮挡导航栏) -->
  5. <view class="web-view-container">
  6. <web-view :src="fileUrl" class="web-view" />
  7. </view>
  8. </view>
  9. </cwg-page-wrapper>
  10. </template>
  11. <script setup>
  12. import { ref, computed } from 'vue'
  13. import { onLoad } from '@dcloudio/uni-app'
  14. import Config from '@/config/index'
  15. const { Host80 } = Config
  16. import getWebBase from '@/utils/webBase'
  17. const webBase = getWebBase()
  18. const fileUrl = ref('')
  19. onLoad((options) => {
  20. fileUrl.value = `${Host80}${webBase}iframe/livechat.html`
  21. })
  22. </script>
  23. <style scoped lang="scss">
  24. @import "@/uni.scss";
  25. .webview-page {
  26. :deep(.content-wrapper) {
  27. padding: 0 !important;
  28. }
  29. :deep(.page-content) {
  30. height: calc(100vh - 56px);
  31. }
  32. :deep(.fixed) {
  33. height: 56px;
  34. }
  35. }
  36. /* 页面根容器:弹性布局,完美分配导航栏和web-view高度 */
  37. .page-container {
  38. display: flex;
  39. flex-direction: column;
  40. width: 100%;
  41. height: 100vh;
  42. }
  43. /* 顶部导航栏:正确适配安全区,高度计算正确 */
  44. .web-view-container {
  45. flex: 1;
  46. width: 100%;
  47. overflow: hidden;
  48. }
  49. .web-view {
  50. width: 100%;
  51. height: 100%;
  52. }
  53. </style>