Commit 532611d1 authored by liujiangnan's avatar liujiangnan

debug

parent 4e95eaab
......@@ -12,7 +12,7 @@ async function checkUrl(url) {
try {
const response = await fetch(url);
const text = await response.text();
// 检查返回内容是否包含错误 XML
if (text.includes('<Error>') && text.includes('<Code>NoSuchKey</Code>')) {
showErrorMsg.value = true;
......@@ -31,7 +31,7 @@ async function checkUrl(url) {
window.courseware.getData(async (dt) => {
url.value = dt?.url;
ppt_html.value = dt?.ppt_html;
if (ppt_html.value) {
// 如果是 PPT,先检查 URL 是否可访问
if (url.value.toLowerCase().includes('.ppt')) {
......@@ -42,28 +42,59 @@ window.courseware.getData(async (dt) => {
}
window.air.hideAirClassLoading('play_office', null);
}
},'play_office');
}, 'play_office');
function renderedHandler () {
function renderedHandler() {
window.air.hideAirClassLoading('play_office', null);
}
function errorHandler () {}
function errorHandler() { }
const ppt_iframe = ref(null);
function prevPage() {
if (ppt_iframe.value) {
ppt_iframe.value.contentWindow.ExecGoBack();
}
}
function nextPage() {
if (ppt_iframe.value) {
ppt_iframe.value.contentWindow.ExecNext();
}
}
const getProxiedUrl = (url) => {
try {
const urlObj = new URL(url);
return `/ppt${urlObj.pathname}${urlObj.search}${urlObj.hash}`;
} catch (e) {
return url;
}
}
</script>
<template>
<template v-if="url.indexOf(`.pdf`) > 0 || url.indexOf(`.PDF`) > 0">
<vue-office-pdf :src="url" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
<vue-office-pdf :src="url" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
</template>
<template v-if="url.indexOf(`.docx`) > 0 || url.indexOf(`.DOCX`) > 0">
<vue-office-docx :src="url" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
<vue-office-docx :src="url" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
</template>
<template v-if="url.indexOf(`.ppt`) > 0 || url.indexOf(`.PPT`) > 0 || url.indexOf(`.pptx`) > 0 || url.indexOf(`.PPTX`) > 0">
<div style="height: 100vh">
<template
v-if="url.indexOf(`.ppt`) > 0 || url.indexOf(`.PPT`) > 0 || url.indexOf(`.pptx`) > 0 || url.indexOf(`.PPTX`) > 0">
<div style="height: 100vh; position: relative;">
<div v-if="showErrorMsg" class="error-message">
课件正在生成中,请过一会儿再尝试
</div>
<iframe v-else frameborder="0" width="100%" height="100%" :src="ppt_html"></iframe>
<iframe v-else ref="ppt_iframe" frameborder="0" width="100%" height="100%" :src="getProxiedUrl(ppt_html)"></iframe>
<div class="page-buttons">
<button class="arrow-button prev" @click="prevPage">
<span class="arrow left"></span>
</button>
<button class="arrow-button next" @click="nextPage">
<span class="arrow right"></span>
</button>
</div>
</div>
</template>
</template>
......@@ -77,4 +108,53 @@ function errorHandler () {}
font-size: 16px;
color: #666;
}
.page-buttons {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 1000;
display: flex;
gap: 10px;
}
.arrow-button {
width: 40px;
height: 40px;
border-radius: 50%;
border: none;
background-color: #409EFF;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s;
}
.arrow-button:hover {
background-color: #66b1ff;
}
.arrow-button:disabled {
background-color: #c0c4cc;
cursor: not-allowed;
}
.arrow {
border: solid white;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 4px;
}
.left {
transform: rotate(135deg);
margin-left: 4px;
}
.right {
transform: rotate(-45deg);
margin-right: 4px;
}
</style>
......@@ -6,7 +6,14 @@ import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 3000
port: 3000,
proxy: {
'/ppt': {
target: 'https://teach.cdn.ireadabc.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/ppt/, '')
}
}
},
plugins: [
vue(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment