소스 검색

模拟加载数据

黄琪勇 3 달 전
부모
커밋
728720a12f
2개의 변경된 파일27개의 추가작업 그리고 1개의 파일을 삭제
  1. 0 0
      public/json.json
  2. 27 1
      src/views/pptScreen/pptScreen.vue

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/json.json


+ 27 - 1
src/views/pptScreen/pptScreen.vue

@@ -1,11 +1,37 @@
 <template>
   <div class="pptScreen">
-    <Screen />
+    <Screen v-if="!initLoading" />
   </div>
 </template>
 
 <script setup lang="ts">
 import Screen from "../Screen/index.vue"
+import Axios from "axios"
+import { ref } from "vue"
+import { useSlidesStore } from "@/store"
+
+const slidesStore = useSlidesStore()
+
+const initLoading = ref(true)
+
+Axios.get("json.json")
+  .then(res => {
+    if (res.status === 200 && typeof res.data === "object") {
+      const { title, width, height, theme, slides } = res.data
+      console.log(res.data)
+      slidesStore.setTitle(title)
+      slidesStore.setViewportSize(width)
+      slidesStore.setViewportRatio(height / width)
+      slidesStore.setTheme(theme)
+      slidesStore.setSlides(slides)
+      initLoading.value = false
+    } else {
+      console.log(res)
+    }
+  })
+  .catch(err => {
+    console.log(err)
+  })
 </script>
 
 <style lang="scss" scoped>

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.