web-view.uvue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 menu2Items = [
  6. { id: '1', name: '观察', icon: 'https://oss.xiaoxiongcode.com/static/home/kanke.png' },
  7. { id: '2', name: '提问', icon: 'https://oss.xiaoxiongcode.com/static/home/lianxi.png' },
  8. { id: '3', name: '假设', icon: 'https://oss.xiaoxiongcode.com/static/home/shiyan.png' },
  9. { id: '4', name: '实验', icon: 'https://oss.xiaoxiongcode.com/static/home/riji.png' },
  10. { id: '5', name: '总结', icon: 'https://oss.xiaoxiongcode.com/static/home/riji.png' },
  11. { id: '6', name: '拓展', icon: 'https://oss.xiaoxiongcode.com/static/home/riji.png' },
  12. ]
  13. const progress = ref(1)
  14. const webviewSrc = ref('')
  15. var isLoading = ref(true)
  16. onMounted(() => {
  17. webviewSrc.value = router.query().src
  18. progress.value = router.query().progress
  19. setTimeout(() => {
  20. isLoading.value = false
  21. }, 20000) // 6000毫秒 = 6秒
  22. })
  23. function handleMessage(e) {
  24. var pages = getCurrentPages();
  25. const prevPage = pages[pages.length - 2];
  26. (prevPage as any).status = "success"
  27. }
  28. function handleLoad() {
  29. console.log('handleLoad')
  30. }
  31. onShow(() => {
  32. var pages = getCurrentPages();
  33. const prevPage = pages[pages.length - 2];
  34. (prevPage as any).status = "test"
  35. })
  36. </script>
  37. <template>
  38. <!-- <Loading v-show="isLoading"/> -->
  39. <web-view :src="webviewSrc + '?' + Math.random()" class="w-full h-full" @message="handleMessage"
  40. @load="handleLoad"></web-view>
  41. </template>
  42. <style lang="less" scoped>
  43. </style>