修复传参bug;解压显示bug

This commit is contained in:
2026-07-24 18:28:42 +08:00
parent cded249ab9
commit 48452cec2e
10 changed files with 3911 additions and 133 deletions

View File

@@ -42,7 +42,7 @@
<view class="wyxd-pager" v-if="slides.length > 1">
<view class="wyxd-pager-inner">
<view class="wyxd-nav-btn" :class="{ disabled: currentIndex <= 0 }" @click="prevSlide">
<view class="iconfont icon-fanhui" style="transform:rotate(180deg);font-size:24rpx;"></view>
<view class="iconfont icon-fanhui" style="font-size:24rpx;"></view>
</view>
<view class="wyxd-page-indicator">
<text class="wyxd-current">{{ pad(currentIndex + 1) }}</text>
@@ -50,7 +50,7 @@
<text class="wyxd-total">{{ pad(slides.length) }}</text>
</view>
<view class="wyxd-nav-btn" :class="{ disabled: currentIndex >= slides.length - 1 }" @click="nextSlide">
<view class="iconfont icon-fanhui" style="font-size:24rpx;"></view>
<view class="iconfont icon-fanhui" style="transform:rotate(180deg);font-size:24rpx;"></view>
</view>
</view>
</view>
@@ -131,12 +131,17 @@ const startDownload = async () => {
currentIndex.value = 0
status.value = 'downloading'
console.log("userToken.value",userToken.value);
console.log("workspaceId.value",workspaceId.value);
console.log("filePath.value",filePath.value);
const tempPath = await downloadWyxdAsZip(
userToken.value, workspaceId.value, filePath.value
)
console.log("获取到的下载地址:",tempPath);
status.value = 'extracting'
const extracted = await extractWyxd(tempPath)
console.log("extracted",extracted);
status.value = 'parsing'
const slideList = parseSlides(extracted.html, extracted.header, extracted.images)
@@ -165,9 +170,16 @@ const startDownload = async () => {
onLoad((options) => {
workspaceId.value = options.workspaceId || ''
filePath.value = options.filePath || ''
fileName.value = options.fileName || '未命名文档'
userToken.value = options.userToken || uni.getStorageSync('user_token') || ''
filePath.value = options?.filePath ? decodeURIComponent(options.filePath) : ''
fileName.value = options?.fileName ? decodeURIComponent(options.fileName) : '未命名文档'
userToken.value = options?.userToken ?? uni.getStorageSync('user_token') ?? ''
console.log('页面接收options原始参数', options)
console.log('最终赋值变量:', {
workspaceId: workspaceId.value,
filePath: filePath.value,
fileName: fileName.value,
userToken: userToken.value
})
if (isWyxdCached(workspaceId.value, filePath.value)) {
loadFromCache()

View File

@@ -460,6 +460,10 @@
// WYXD 查看器入口
const openWyxdViewer = (folder) => {
const filePath = folder.path.startsWith('./') ? folder.path.slice(2) : folder.path;
console.log("解析文件路径:",filePath);
console.log("folder",folder);
console.log("encode",encodeURIComponent(filePath));
console.log("encode",encodeURIComponent(folder.name));
uni.navigateTo({
url: '/pages/WYXD/WYXD?workspaceId=' + encodeURIComponent(workspaceId.value)
+ '&filePath=' + encodeURIComponent(filePath)

View File

@@ -1,20 +1,20 @@
{
"hash": "4dd2a69b",
"configHash": "d342a709",
"hash": "be335aef",
"configHash": "72122489",
"lockfileHash": "1e456fb2",
"browserHash": "4e27b22f",
"browserHash": "f2fb5697",
"optimized": {
"snarkdown": {
"src": "../../../../../node_modules/snarkdown/dist/snarkdown.es.js",
"file": "snarkdown.js",
"fileHash": "b76ccfaf",
"needsInterop": false
},
"jszip": {
"src": "../../../../../node_modules/jszip/dist/jszip.min.js",
"file": "jszip.js",
"fileHash": "0f2d87b8",
"fileHash": "db392aeb",
"needsInterop": true
},
"snarkdown": {
"src": "../../../../../node_modules/snarkdown/dist/snarkdown.es.js",
"file": "snarkdown.js",
"fileHash": "634089b0",
"needsInterop": false
}
},
"chunks": {

View File

@@ -3,9 +3,9 @@ import {
__require
} from "./chunk-TDUMLE5V.js";
// ../../../../../py/77/phone-app------test1-/node_modules/jszip/dist/jszip.min.js
// ../../../../Projects/uniapp/app-test/test1/node_modules/jszip/dist/jszip.min.js
var require_jszip_min = __commonJS({
"../../../../../py/77/phone-app------test1-/node_modules/jszip/dist/jszip.min.js"(exports, module) {
"../../../../Projects/uniapp/app-test/test1/node_modules/jszip/dist/jszip.min.js"(exports, module) {
!function(e) {
if ("object" == typeof exports && "undefined" != typeof module)
module.exports = e();

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
import "./chunk-TDUMLE5V.js";
// ../../../../../py/77/phone-app------test1-/node_modules/snarkdown/dist/snarkdown.es.js
// ../../../../Projects/uniapp/app-test/test1/node_modules/snarkdown/dist/snarkdown.es.js
var e = { "": ["<em>", "</em>"], _: ["<strong>", "</strong>"], "*": ["<strong>", "</strong>"], "~": ["<s>", "</s>"], "\n": ["<br />"], " ": ["<br />"], "-": ["<hr />"] };
function n(e2) {
return e2.replace(RegExp("^" + (e2.match(/^(\t| )+/) || "")[0], "gm"), "");

View File

@@ -2,7 +2,7 @@
;(function(){
let u=void 0,isReady=false,onReadyCallbacks=[],isServiceReady=false,onServiceReadyCallbacks=[];
const __uniConfig = {"pages":[],"globalStyle":{"backgroundColor":"#F8F8F8","navigationBar":{"backgroundColor":"#F8F8F8","titleText":"uni-app","type":"default","titleColor":"#000000"},"isNVue":false},"nvue":{"compiler":"uni-app","styleCompiler":"uni-app","flex-direction":"column"},"renderer":"auto","appname":"test1","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":true},"compilerVersion":"5.07","entryPagePath":"pages/Login/Login","entryPageQuery":"","realEntryPagePath":"","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000},"locales":{},"darkmode":false,"themeConfig":{}};
const __uniRoutes = [{"path":"pages/Login/Login","meta":{"isQuit":true,"isEntry":true,"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"登录页面","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/Chat/Chat","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"聊天页面(主页面)","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/WorkSpace/WorkSpace","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"工作区文件管理","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/UserProfileModal/UserProfileModal","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/ContactPages/ContactPages","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/WorkSpace/TemplateSpace/TemplateSpace","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/CloudDatabase/CloudDatabase","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"云端数据","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/CloudDbDetail/CloudDbDetail","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"数据库详情","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/text/text","meta":{"navigationBar":{"titleText":"","type":"default"},"isNVue":false}},{"path":"pages/text/IntuitiveAipptViewer","meta":{"navigationBar":{"titleText":"","type":"default"},"isNVue":false}}].map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
const __uniRoutes = [{"path":"pages/Login/Login","meta":{"isQuit":true,"isEntry":true,"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"登录页面","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/Chat/Chat","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"聊天页面(主页面)","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/WorkSpace/WorkSpace","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"工作区文件管理","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/UserProfileModal/UserProfileModal","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/ContactPages/ContactPages","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/WorkSpace/TemplateSpace/TemplateSpace","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/CloudDatabase/CloudDatabase","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"云端数据","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/CloudDbDetail/CloudDbDetail","meta":{"titleNView":false,"bounce":"none","softinputMode":"adjustResize","navigationBar":{"titleText":"数据库详情","style":"custom","type":"default"},"isNVue":false}},{"path":"pages/text/text","meta":{"navigationBar":{"titleText":"","type":"default"},"isNVue":false}},{"path":"pages/text/IntuitiveAipptViewer","meta":{"navigationBar":{"titleText":"","type":"default"},"isNVue":false}},{"path":"pages/WYXD/WYXD","meta":{"titleNView":false,"bounce":"none","navigationBar":{"titleText":"","style":"custom","type":"default"},"isNVue":false}}].map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
__uniConfig.styles=[];//styles
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,440 @@
/* 新建文件夹弹窗样式 */
.create-folder-name[data-v-507487c4] {
display: flex;
width: 100%;
padding: 0.3125rem 0.625rem;
box-sizing: border-box;
align-items: center;
background: rgba(108, 99, 255, 0.06);
border-radius: 0.4375rem;
border: 0.0625rem solid transparent;
transition: all 0.25s ease;
}
.create-folder-name uni-input[data-v-507487c4] {
box-sizing: border-box;
width: 100%;
font-size: 0.875rem;
color: #333;
}
.create-folder-name.has-value[data-v-507487c4] {
background-color: #ffffff;
border-color: #6c63ff;
box-shadow: 0 0 0 0.125rem rgba(108, 99, 255, 0.06);
}
/* 新建文件夹弹窗内部样式 */
.new-folder-name[data-v-507487c4] {
font-size: 0.875rem;
color: #555;
margin-bottom: 0.375rem;
}
.nf-path-label[data-v-507487c4] {
font-size: 0.75rem;
color: #999;
margin-top: 0.75rem;
margin-bottom: 0.25rem;
}
.nf-path-display[data-v-507487c4] {
font-size: 0.8125rem;
color: #333;
padding: 0.375rem 0.625rem;
background: #f5f5f8;
border-radius: 0.375rem;
word-break: break-all;
}
.nf-path-preview[data-v-507487c4] {
font-size: 0.8125rem;
color: #6c63ff;
padding: 0.375rem 0.625rem;
background: rgba(108, 99, 255, 0.05);
border: 0.0625rem dashed rgba(108, 99, 255, 0.25);
border-radius: 0.375rem;
word-break: break-all;
}
.option-wrapper[data-v-507487c4] {
display: flex;
justify-content: space-between;
gap: 0.625rem;
margin-top: 1.25rem;
}
.opt-btn[data-v-507487c4] {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 0.75rem 0;
border-radius: 0.5rem;
font-size: 0.9375rem;
font-weight: 500;
transition: all 0.2s ease;
}
.opt-btn[data-v-507487c4]:active {
transform: scale(0.97);
}
.opt-cancel[data-v-507487c4] {
background: #f0f1f5;
color: #666;
}
.opt-confirm[data-v-507487c4] {
background: linear-gradient(135deg, #6c63ff, #4a45d1);
color: #fff;
box-shadow: 0 0.125rem 0.375rem rgba(108, 99, 255, 0.25);
}
.workspace-container[data-v-507487c4] {
display: flex;
flex-direction: column;
background: linear-gradient(180deg, #f5f4f9 0%, #faf9fe 100%);
}
.workspace-text[data-v-507487c4] {
color: #6c63ff;
font-weight: bold;
}
.workspace-header[data-v-507487c4] {
width: 100%;
display: flex;
flex-shrink: 0;
flex-direction: column;
align-items: center;
padding: 0.375rem 0;
box-sizing: border-box;
position: relative;
z-index: 100;
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-bottom: 0.03125rem solid rgba(170, 170, 255, 0.1);
}
.custom-navbar[data-v-507487c4] {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.5rem 0.3125rem;
box-sizing: border-box;
position: relative;
}
.navbar-left[data-v-507487c4] {
display: flex;
justify-content: center;
align-items: center;
}
.navbar-before-title[data-v-507487c4] {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-size: 0.8125rem;
color: #6c63ff;
font-weight: 500;
}
.navbar-title[data-v-507487c4] {
display: flex;
flex: 1;
justify-content: center;
align-items: center;
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 1rem;
font-weight: 700;
color: #1a1a2e;
}
.navbar-right[data-v-507487c4] {
display: flex;
justify-content: center;
align-items: center;
margin-right: 0.625rem;
box-sizing: border-box;
}
.navbar-right .menu-open[data-v-507487c4] {
color: #6c63ff !important;
font-size: 1.25rem !important;
}
.custom-navbar-icon[data-v-507487c4] {
color: #6c63ff !important;
font-size: 1.25rem !important;
}
.search-file-warpper[data-v-507487c4] {
display: flex;
width: 90%;
align-items: center;
}
.search-file[data-v-507487c4] {
display: flex;
flex: 1;
align-items: center;
background: rgba(255, 255, 255, 0.9);
padding: 0.4375rem 0.75rem;
box-sizing: border-box;
border-radius: 0.875rem;
border: 0.0625rem solid #e8e7f5;
transition: all 0.25s ease;
}
.search-file[data-v-507487c4]:focus-within {
border-color: #6c63ff;
box-shadow: 0 0 0 0.125rem rgba(108, 99, 255, 0.06);
}
.icon-sousuo[data-v-507487c4] {
font-weight: bold;
color: #999;
}
.search-file-input[data-v-507487c4] {
margin-left: 0.5rem;
font-size: 0.8125rem;
color: #333;
}
.cancel-search[data-v-507487c4] {
display: flex;
flex-shrink: 0;
padding: 0 0 0 0.625rem;
box-sizing: border-box;
color: #6c63ff;
font-size: 0.875rem;
font-weight: 500;
}
.workspace-content[data-v-507487c4] {
width: 100%;
display: block;
flex: 1;
overflow: auto;
box-sizing: border-box;
position: relative;
}
/* 菜单卡片 */
.menu-card[data-v-507487c4] {
position: absolute;
top: 100%;
right: 0.625rem;
width: 8.75rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #fff;
border-radius: 0.75rem;
z-index: 999;
box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.08);
padding: 0.25rem 0;
overflow: hidden;
}
.menu-card-item[data-v-507487c4] {
width: 100%;
padding: 0.6875rem 0.875rem;
box-sizing: border-box;
font-size: 0.875rem;
color: #333;
transition: all 0.15s ease;
}
.menu-card-item[data-v-507487c4]:active {
background: rgba(108, 99, 255, 0.06);
}
.folder-null[data-v-507487c4] {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
position: absolute;
left: 50%;
top: 30%;
transform: translateX(-50%);
font-size: 0.9375rem;
color: #bbb;
}
.folder-null .iconfont[data-v-507487c4] {
font-size: 5.625rem;
color: #ddd;
}
.folder-grid[data-v-507487c4] {
width: 100%;
display: grid;
grid-template-columns: repeat(3, 1fr);
padding: 0.75rem;
box-sizing: border-box;
gap: 0.625rem;
align-items: start;
}
.folder-item[data-v-507487c4] {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
min-width: 0;
background: rgba(255, 255, 255, 0.7);
border-radius: 0.75rem;
padding: 0.75rem 0.25rem 0.5rem;
border: 0.0625rem solid transparent;
transition: all 0.2s ease;
}
.folder-item.select-folder[data-v-507487c4] {
border-color: rgba(108, 99, 255, 0.3);
background: rgba(108, 99, 255, 0.04);
}
.folder-item[data-v-507487c4]:active {
transform: scale(0.96);
background: rgba(255, 255, 255, 0.95);
}
.folder-item .folder-name[data-v-507487c4] {
max-width: 5rem;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
line-height: 1.375rem;
min-width: 0;
font-size: 0.8125rem;
color: #444;
}
.folder-item-style[data-v-507487c4] {
font-size: 3.4375rem !important;
color: #6c63ff !important;
}
.folder-checkbox[data-v-507487c4] {
width: 1.375rem;
height: 1.375rem;
border: 0.09375rem solid #fff;
border-radius: 50%;
box-shadow: 0 0.0625rem 0.25rem rgba(0, 0, 0, 0.12);
background: rgba(255, 255, 255, 0.9);
box-sizing: border-box;
position: absolute;
left: 50%;
top: 25%;
transform: translate(-50%);
display: flex;
justify-content: center;
align-items: center;
transition: all 0.2s ease;
}
.folder-checkbox.select-folder[data-v-507487c4] {
background: linear-gradient(135deg, #6c63ff, #4a45d1);
border-color: #6c63ff;
}
.workspace-footer[data-v-507487c4] {
width: 100%;
display: flex;
flex-shrink: 0;
justify-content: space-between;
padding: 0.75rem 0.9375rem;
box-sizing: border-box;
color: #888;
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-top: 0.03125rem solid rgba(170, 170, 255, 0.1);
font-size: 0.8125rem;
transition: all 0.2s ease;
}
.workspace-footer.folder-actions[data-v-507487c4] {
color: #6c63ff;
font-weight: 500;
}
.workspace-footer .iconfont[data-v-507487c4] {
font-size: 1.25rem !important;
}
.wyxd-container[data-v-507487c4] {
display: flex;
flex-direction: column;
background: #f5f5f5;
overflow: hidden;
}
.wyxd-header[data-v-507487c4] {
flex-shrink: 0;
background: #fff;
}
.wyxd-content[data-v-507487c4] {
flex: 1;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* ===== 状态占位 ===== */
.wyxd-state[data-v-507487c4] {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 1.25rem;
}
.wyxd-state-icon[data-v-507487c4] {
font-size: 2.5rem;
color: #ccc;
margin-bottom: 0.625rem;
}
.wyxd-state-title[data-v-507487c4] {
font-size: 0.875rem;
font-weight: 600;
color: #666;
margin-bottom: 0.25rem;
}
.wyxd-state-desc[data-v-507487c4] {
font-size: 0.75rem;
color: #999;
}
/* ===== 幻灯片区域 ===== */
.wyxd-slide-area[data-v-507487c4] {
flex: 1;
min-height: 0;
padding: 0.625rem;
}
.wyxd-slide-scroll[data-v-507487c4] {
height: 100%;
background: #fff;
border-radius: 0.375rem;
box-shadow: 0 0.0625rem 0.375rem rgba(0, 0, 0, 0.04);
}
.wyxd-slide-card[data-v-507487c4] {
padding: 1rem;
min-height: 100%;
box-sizing: border-box;
}
/* ===== 底部翻页 ===== */
.wyxd-pager[data-v-507487c4] {
flex-shrink: 0;
background: #fff;
border-top: 0.03125rem solid #eee;
padding: 0.5rem 0;
padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}
.wyxd-pager-inner[data-v-507487c4] {
display: flex;
align-items: center;
justify-content: center;
}
.wyxd-nav-btn[data-v-507487c4] {
width: 2rem;
height: 2rem;
display: flex;
align-items: center;
justify-content: center;
border-radius: 1rem;
background: #f5f5f5;
margin: 0 1rem;
}
.wyxd-nav-btn[data-v-507487c4]:active {
background: #e0e0e0;
}
.wyxd-nav-btn.disabled[data-v-507487c4] {
opacity: 0.3;
pointer-events: none;
}
.wyxd-page-indicator[data-v-507487c4] {
font-size: 0.8125rem;
color: #666;
display: flex;
align-items: center;
}
.wyxd-current[data-v-507487c4] {
color: #3b82f6;
font-weight: 700;
}
.wyxd-divider[data-v-507487c4] {
margin: 0 0.25rem;
color: #ccc;
}
.wyxd-total[data-v-507487c4] {
color: #999;
}

View File

@@ -40,6 +40,7 @@ export const clearCachedWyxd = (workspaceId, filePath) => {
// ===== 下载 =====
const getDownloadUrl = (token, workspaceId, filePath) => {
console.log("执行getDownloadUrl");
return new Promise((resolve, reject) => {
const cleanPath = filePath.startsWith('./') ? filePath.slice(2) : filePath
uni.request({
@@ -47,18 +48,21 @@ const getDownloadUrl = (token, workspaceId, filePath) => {
method: 'POST',
header: { 'Content-Type': 'application/json' },
data: {
access_token: token,
workspaces_id: workspaceId,
file_path: cleanPath
"access_token": token,
"workspaces_id": workspaceId,
"file_path": cleanPath
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data
const arr = respond.success ? (respond.message || respond.data) : respond
const fileInfo = Array.isArray(arr) ? arr[0] : arr
console.log("fileInfo",fileInfo);
if (fileInfo && fileInfo.url) {
console.log("fileInfo.url",fileInfo.url);
resolve(fileInfo.url)
} else {
console.log("获取下载地址失败");
reject(respond?.error || '获取下载地址失败')
}
} else {
@@ -73,11 +77,14 @@ const getDownloadUrl = (token, workspaceId, filePath) => {
export const downloadWyxdAsZip = (token, workspaceId, filePath, onProgress) => {
return new Promise(async (resolve, reject) => {
try {
console.log("执行downloadWyxdAsZip");
const downloadUrl = await getDownloadUrl(token, workspaceId, filePath)
console.log("downloadWyxdAsZip-downloadUrl",downloadUrl);
const downloadTask = uni.downloadFile({
url: downloadUrl,
success: (res) => {
if (res.statusCode === 200) {
console.log("downloadWyxdAsZip-tempFilePath",res.tempFilePath);
resolve(res.tempFilePath)
} else {
reject(`下载失败:${res.statusCode}`)
@@ -123,25 +130,87 @@ const utf8Decode = (uint8arr) => {
const readFileAsArrayBuffer = (filePath) => {
return new Promise((resolve, reject) => {
// App 环境uni.getFileSystemManager
const fs = uni.getFileSystemManager
if (typeof fs === 'function') {
fs().readFile({
// App 环境检测plus 对象仅在 App 运行时存在
if (typeof plus !== 'undefined') {
console.log('[readFileAsArrayBuffer] App环境filePath:', filePath)
console.log('[readFileAsArrayBuffer] typeof plus.io:', typeof plus.io)
console.log('[readFileAsArrayBuffer] typeof plus.io.resolveLocalFileSystemURL:', typeof plus.io?.resolveLocalFileSystemURL)
console.log('[readFileAsArrayBuffer] typeof plus.io.FileReader:', typeof plus.io?.FileReader)
// 方式1尝试 plus.io.resolveLocalFileSystemURL
if (plus.io && typeof plus.io.resolveLocalFileSystemURL === 'function') {
plus.io.resolveLocalFileSystemURL(filePath, (entry) => {
console.log('[readFileAsArrayBuffer] entry.isFile:', entry.isFile)
console.log('[readFileAsArrayBuffer] entry.isDirectory:', entry.isDirectory)
console.log('[readFileAsArrayBuffer] entry.fullPath:', entry.fullPath)
console.log('[readFileAsArrayBuffer] typeof entry.file:', typeof entry.file)
if (typeof entry.file !== 'function') {
reject(new Error('entry 没有 file 方法isFile=' + entry.isFile + ' isDirectory=' + entry.isDirectory))
return
}
try {
entry.file((file) => {
console.log('[readFileAsArrayBuffer] entry.file 成功file.size:', file.size)
const reader = new plus.io.FileReader()
reader.onloadend = (e) => {
const dataUrl = e.target.result
console.log('[readFileAsArrayBuffer] readAsDataURL 完成dataUrl 长度:', dataUrl?.length)
try {
// dataUrl 格式: "data:;base64,<base64data>"
const base64 = dataUrl.substring(dataUrl.indexOf(',') + 1)
const binary = atob(base64)
const bytes = new Uint8Array(binary.length)
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i)
console.log('[readFileAsArrayBuffer] 成功转为 Uint8Array长度:', bytes.length)
resolve(bytes)
} catch (err) {
console.error('[readFileAsArrayBuffer] base64 解码失败', err)
reject(new Error('文件解码失败:' + err.message))
}
}
reader.onerror = (e) => {
console.error('[readFileAsArrayBuffer] plus.io 读取失败', e)
reject(new Error('文件读取失败'))
}
reader.readAsDataURL(file)
}, (err) => {
console.error('[readFileAsArrayBuffer] 获取File对象失败', err)
reject(new Error('获取文件失败:' + (err.message || '')))
})
} catch (e) {
console.error('[readFileAsArrayBuffer] entry.file 调用同步异常:', e)
reject(new Error('entry.file 调用失败:' + (e.message || e)))
}
}, (err) => {
console.error('[readFileAsArrayBuffer] 解析文件路径失败', err)
reject(new Error('解析文件路径失败:' + (err.message || '')))
})
return
}
// 方式2降级 - 尝试 uni.getFileSystemManager
if (typeof uni !== 'undefined' && typeof uni.getFileSystemManager === 'function') {
console.log('[readFileAsArrayBuffer] 降级使用 uni.getFileSystemManager')
const fs = uni.getFileSystemManager()
fs.readFile({
filePath: filePath,
encoding: 'base64',
success: (res) => {
const base64 = res.data || ''
const binary = atob(base64)
const bytes = new Uint8Array(binary.length)
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i)
}
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i)
resolve(bytes)
},
fail: (err) => reject(new Error('无法读取文件:' + (err.errMsg || err.message || '')))
fail: (err) => reject(new Error('无法读取文件:' + (err.errMsg || '')))
})
return
}
reject(new Error('App 环境下无可用的文件读取 API'))
return
}
// H5 环境fetch blob URL
fetch(filePath)
.then(res => {
@@ -155,6 +224,7 @@ const readFileAsArrayBuffer = (filePath) => {
export const extractWyxd = async (zipFilePath) => {
const data = await readFileAsArrayBuffer(zipFilePath)
console.log("data",data);
const zip = await JSZip.loadAsync(data)
const result = { header: '', html: '', images: {} }