hookehuyr

feat(OfficeViewer): 添加加载状态指示器

在 OfficeViewer 组件中添加加载状态指示器,提升用户体验
移除 StudyDetailPage 中多余的文档加载完成提示
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
49 <span class="unsupported-text">不支持的文件类型: {{ fileType }}</span> 49 <span class="unsupported-text">不支持的文件类型: {{ fileType }}</span>
50 </div> 50 </div>
51 </div> 51 </div>
52 +
53 + <van-loading vertical v-if="loading" class="loading-overlay">
54 + 加载中...
55 + </van-loading>
52 </div> 56 </div>
53 </template> 57 </template>
54 58
...@@ -94,6 +98,7 @@ const containerHeight = computed(() => props.height) ...@@ -94,6 +98,7 @@ const containerHeight = computed(() => props.height)
94 */ 98 */
95 const onRendered = () => { 99 const onRendered = () => {
96 console.log('Office document rendered successfully') 100 console.log('Office document rendered successfully')
101 + loading.value = false
97 error.value = '' 102 error.value = ''
98 emit('rendered') 103 emit('rendered')
99 } 104 }
...@@ -104,6 +109,7 @@ const onRendered = () => { ...@@ -104,6 +109,7 @@ const onRendered = () => {
104 */ 109 */
105 const onError = (err) => { 110 const onError = (err) => {
106 console.error('Office document render error:', err) 111 console.error('Office document render error:', err)
112 + loading.value = false
107 error.value = '文档加载失败,请检查文件格式或网络连接' 113 error.value = '文档加载失败,请检查文件格式或网络连接'
108 emit('error', err) 114 emit('error', err)
109 } 115 }
...@@ -113,6 +119,7 @@ const onError = (err) => { ...@@ -113,6 +119,7 @@ const onError = (err) => {
113 */ 119 */
114 const retry = () => { 120 const retry = () => {
115 console.log('Retrying to load office document') 121 console.log('Retrying to load office document')
122 + loading.value = true
116 error.value = '' 123 error.value = ''
117 emit('retry') 124 emit('retry')
118 } 125 }
...@@ -150,14 +157,20 @@ watch(() => props.fileType, (newType) => { ...@@ -150,14 +157,20 @@ watch(() => props.fileType, (newType) => {
150 console.log('Office document fileType changed:', newType) 157 console.log('Office document fileType changed:', newType)
151 }) 158 })
152 159
160 +// 响应式数据
161 +const loading = ref(false)
162 +
153 // 组件挂载时的初始化 163 // 组件挂载时的初始化
154 onMounted(() => { 164 onMounted(() => {
155 console.log('OfficeViewer 组件已挂载') 165 console.log('OfficeViewer 组件已挂载')
166 + // 生成一个loading 效果
167 + loading.value = true
156 }) 168 })
157 </script> 169 </script>
158 170
159 <style lang="less" scoped> 171 <style lang="less" scoped>
160 .office-viewer { 172 .office-viewer {
173 + position: relative;
161 width: 100%; 174 width: 100%;
162 height: 100%; 175 height: 100%;
163 background: #fff; 176 background: #fff;
...@@ -241,6 +254,19 @@ onMounted(() => { ...@@ -241,6 +254,19 @@ onMounted(() => {
241 } 254 }
242 } 255 }
243 } 256 }
257 +
258 + // Loading 覆盖层样式
259 + .loading-overlay {
260 + position: absolute;
261 + top: 50%;
262 + left: 50%;
263 + transform: translate(-50%, -50%);
264 + z-index: 1000;
265 + background: rgba(255, 255, 255, 0.9);
266 + border-radius: 8px;
267 + padding: 20px;
268 + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
269 + }
244 } 270 }
245 271
246 // 移动端适配 272 // 移动端适配
......
...@@ -988,7 +988,7 @@ const onPdfLoad = (load) => { ...@@ -988,7 +988,7 @@ const onPdfLoad = (load) => {
988 */ 988 */
989 const onOfficeRendered = () => { 989 const onOfficeRendered = () => {
990 console.log('Office 文档渲染完成'); 990 console.log('Office 文档渲染完成');
991 - showToast('文档加载完成'); 991 + // showToast('文档加载完成');
992 }; 992 };
993 993
994 /** 994 /**
......