web-view.uvue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <script setup lang='ts'>
  2. import { ref, onMounted, watchEffect } from 'vue'
  3. import Loading from '@/components/loading.uvue'
  4. import { router } from '@/.cool'
  5. const progress = ref(1)
  6. const webviewSrc = ref('')
  7. var isLoading = ref(true)
  8. onMounted(() => {
  9. webviewSrc.value = router.query().src
  10. progress.value = router.query().progress
  11. })
  12. function handleMessage(e) {
  13. var pages = getCurrentPages();
  14. const prevPage = pages[pages.length - 2];
  15. (prevPage as any).status = "success"
  16. }
  17. function handleLoad() {
  18. isLoading.value = false
  19. }
  20. function onWebError() {
  21. const t = Date.now()
  22. webviewSrc.value = router.query().src + '?t=' + t
  23. console.log('onWebError')
  24. }
  25. onShow(() => {
  26. var pages = getCurrentPages();
  27. const prevPage = pages[pages.length - 2];
  28. (prevPage as any).status = "test"
  29. })
  30. </script>
  31. <template>
  32. <Loading v-show="isLoading" />
  33. <web-view :src="webviewSrc" id="web-view" class="w-full h-full" @message="handleMessage" @load="handleLoad"
  34. @error="onWebError"></web-view>
  35. </template>
  36. <style lang="less" scoped></style>