wyxd与聊天页面的切换,

This commit is contained in:
2026-07-31 10:24:55 +08:00
parent c5958812cf
commit 09f4d3ba52
16 changed files with 400 additions and 96 deletions

View File

@@ -105,11 +105,13 @@
font-size: 36rpx;
font-weight: 700;
color: #1a1a2e;
align-items: center;
}
.ncd-header uni-icons {
display: flex;
flex-shrink: 0;
align-items: center;
}
.ncd-options {
@@ -325,6 +327,62 @@
color: #ff4d4f;
}
/* ==========WYXD 文件入口横幅========== */
.wyxd-banner {
display: flex;
align-items: center;
padding: 14rpx 24rpx;
margin: 6rpx 20rpx;
background: linear-gradient(135deg, #e8f4fd, #f0e6ff);
border: 1.5rpx solid rgba(120, 120, 220, 0.25);
border-radius: 16rpx;
box-shadow: 0 2rpx 8rpx rgba(100, 100, 200, 0.08);
}
.wyxd-banner:active {
background: linear-gradient(135deg, #d8eafb, #e6d8ff);
transform: scale(0.98);
}
.wyxd-banner-icon {
font-size: 32rpx;
color: #6c6ce0;
margin-right: 12rpx;
}
.wyxd-banner-text {
flex: 1;
font-size: 26rpx;
font-weight: 600;
color: #4a4ab8;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wyxd-banner-arrow {
font-size: 24rpx;
color: #9999cc;
}
.wyxd-banner-close {
width: 36rpx;
height: 36rpx;
line-height: 36rpx;
text-align: center;
font-size: 28rpx;
color: #9999cc;
border-radius: 50%;
background: rgba(100, 100, 200, 0.08);
margin-left: 8rpx;
flex-shrink: 0;
}
.wyxd-banner-close:active {
background: rgba(100, 100, 200, 0.18);
color: #6c6ce0;
}
/* ==========聊天主体部分========== */
.main-chat {
display: flex;

View File

@@ -64,6 +64,15 @@
</view>
</view>
<!-- WYXD 文件入口从工作区 AI 修改进入时显示 -->
<view v-if="hasWyxdFile" class="wyxd-banner">
<view class="wyxd-banner-icon iconfont icon-wenjian"></view>
<view class="wyxd-banner-text" @click="goWyxdViewer">查看: {{ wyxdFileName }}</view>
<view class="wyxd-banner-arrow" @click="goWyxdViewer">&rsaquo;</view>
<view class="wyxd-banner-close" @click.stop="hasWyxdFile = false">&times;</view>
</view>
<view class="main-chat">
<scroll-view class="chat-messages" direction="vertical" scroll-y :scroll-into-view="scrollToView"
:upper-threshold="0" :scroll-with-animation="!isThinking" @scroll="onScroll">
@@ -293,6 +302,7 @@
watch
} from 'vue';
import {
onLoad,
onShow,
onUnload
} from '@dcloudio/uni-app';
@@ -356,6 +366,13 @@
// 聊天类型ai好友群聊
const ChatType = ref(0)
// WYXD 关联数据(从 WorkSpace 的「AI修改」进入时携带
const wyxdWorkspaceId = ref('')
const wyxdFilePath = ref('')
const wyxdFileName = ref('')
const wyxdUserToken = ref('')
const hasWyxdFile = ref(false)
// marked.setOptions({
// breaks: true, // 自动把换行符转成 <br> 换行
@@ -621,6 +638,17 @@
})
}
// 跳转到 WYXD 查看器(强制重新下载,不走缓存)
const goWyxdViewer = () => {
uni.navigateTo({
url: '/pages/WYXD/WYXD?workspaceId=' + encodeURIComponent(wyxdWorkspaceId.value)
+ '&filePath=' + encodeURIComponent(wyxdFilePath.value)
+ '&fileName=' + encodeURIComponent(wyxdFileName.value)
+ '&userToken=' + encodeURIComponent(wyxdUserToken.value)
+ '&forceDownload=1'
})
}
// 跳转到云端数据库
const goCloudDatabase = () => {
// 保存当前会话id确保从工作区返回时能恢复
@@ -1480,6 +1508,7 @@
if (oldId && oldId !== newId) {
isLoadingMessages.value = true
allmessages.value = []
hasWyxdFile.value = false
}
switch (ChatType.value) {
case 0:
@@ -1503,6 +1532,17 @@
immediate: true
})
// 接收 WYXD 参数从工作区「AI修改」进入时由 navigateTo 传入)
onLoad((options) => {
if (options.wyxdFilePath) {
wyxdWorkspaceId.value = options.wyxdWorkspaceId ? decodeURIComponent(options.wyxdWorkspaceId) : ''
wyxdFilePath.value = decodeURIComponent(options.wyxdFilePath)
wyxdFileName.value = options.wyxdFileName ? decodeURIComponent(options.wyxdFileName) : '未命名文档'
wyxdUserToken.value = options.wyxdUserToken ? decodeURIComponent(options.wyxdUserToken) : ''
hasWyxdFile.value = true
}
})
onMounted(() => {
// currentSessionId.value = getCurrentSessionId()
})

View File

@@ -188,7 +188,8 @@ onLoad((options) => {
userToken: userToken.value
})
if (isWyxdCached(workspaceId.value, filePath.value)) {
// forceDownload 强制重新下载不走缓存
if (options.forceDownload !== '1' && isWyxdCached(workspaceId.value, filePath.value)) {
loadFromCache()
} else {
startDownload()

View File

@@ -284,20 +284,35 @@
const handleLongPress = (folder) => {
if (isSelectFolder.value) return;
const isWyxd = folder.name && folder.name.toLowerCase().endsWith('.wyxd');
const itemList = isWyxd ? ['下载', '删除', 'WYXD查看器'] : ['下载', '删除'];
const itemList = isWyxd ? ['下载', '删除', 'WYXD查看器', 'AI修改'] : ['下载', '删除'];
uni.showActionSheet({
title: folder.name,
itemList: itemList,
success: (res) => {
switch (res.tapIndex) {
case 0:
handleDownload(folder);
break;
case 1:
handleDelete(folder);
break;
case 2:
if (isWyxd) openWyxdViewer(folder);
break;
if (isWyxd) {
switch (res.tapIndex) {
case 0:
handleDownload(folder);
break;
case 1:
handleDelete(folder);
break;
case 2:
openWyxdViewer(folder);
break;
case 3: // 'AI修改',
handleAiModify(folder);
break;
}
} else {
switch (res.tapIndex) {
case 0:
handleDownload(folder);
break;
case 1:
handleDelete(folder);
break;
}
}
}
})
@@ -472,6 +487,17 @@
});
};
// AI修改入口跳转对话页并传入 WYXD 信息
const handleAiModify = (folder) => {
const filePath = folder.path.startsWith('./') ? folder.path.slice(2) : folder.path;
uni.navigateTo({
url: '/pages/Chat/Chat?wyxdWorkspaceId=' + encodeURIComponent(workspaceId.value)
+ '&wyxdFilePath=' + encodeURIComponent(filePath)
+ '&wyxdFileName=' + encodeURIComponent(folder.name)
+ '&wyxdUserToken=' + encodeURIComponent(UserToken.value)
});
};
// 删除
const handleDelete = (folder) => {
uni.showModal({