chat.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. import { useI18n } from 'vue-i18n'
  19. const { t } = useI18n()
  20. const fileUrl = ref('')
  21. const title = ref('')
  22. const pageTitle = computed(() => t(title.value))
  23. const fileType = ref('')
  24. // 获取文件后缀
  25. const getFileExt = (name) => {
  26. if (!name) return ''
  27. return name.split('.').pop()?.toUpperCase()
  28. }
  29. onLoad((options) => {
  30. title.value = options.title || '文件预览'
  31. fileUrl.value = `/iframe/livechat.html`
  32. console.log(fileUrl.value, 1212);
  33. })
  34. </script>
  35. <style scoped lang="scss">
  36. @import "@/uni.scss";
  37. .webview-page {
  38. :deep(.content-wrapper) {
  39. padding: 0 !important;
  40. }
  41. :deep(.page-content) {
  42. height: calc(100vh - 56px);
  43. }
  44. :deep(.fixed) {
  45. height: 56px;
  46. }
  47. }
  48. /* 页面根容器:弹性布局,完美分配导航栏和web-view高度 */
  49. .page-container {
  50. display: flex;
  51. flex-direction: column;
  52. width: 100%;
  53. height: 100vh;
  54. }
  55. /* 顶部导航栏:正确适配安全区,高度计算正确 */
  56. .web-view-container {
  57. flex: 1;
  58. width: 100%;
  59. overflow: hidden;
  60. }
  61. .web-view {
  62. width: 100%;
  63. height: 100%;
  64. }
  65. </style>