web-view.uvue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. const isLoading = ref(true)
  16. onMounted(() => {
  17. webviewSrc.value = router.query().src
  18. progress.value = router.query().progress
  19. })
  20. function handleMessage(e) {
  21. var pages = getCurrentPages();
  22. const prevPage = pages[pages.length - 2];
  23. (prevPage as any).status = "success"
  24. }
  25. function handleLoad() {
  26. console.log('handleLoad')
  27. isLoading.value = false
  28. }
  29. onShow(() => {
  30. var pages = getCurrentPages();
  31. const prevPage = pages[pages.length - 2];
  32. (prevPage as any).status = "test"
  33. })
  34. </script>
  35. <template>
  36. <Loading v-show="isLoading" />
  37. <web-view :src="webviewSrc + '?' + Math.random()" class="w-full h-full" @message="handleMessage"
  38. @load="handleLoad"></web-view>
  39. </template>
  40. <style lang="less" scoped></style>