feat: 对话功能开发
This commit is contained in:
@@ -134,7 +134,16 @@ async function loadHistorySessions() {
|
||||
}
|
||||
|
||||
// 点击历史会话,跳转到对话页面并加载该会话
|
||||
function onHistoryClick(item) {
|
||||
async function onHistoryClick(item) {
|
||||
try {
|
||||
const baseUrl = window.__opencodeBaseUrl || 'http://127.0.0.1:4096';
|
||||
const detailUrl = `${baseUrl}/session/${item.id}/message`;
|
||||
const response = await axios.get(detailUrl);
|
||||
console.log('[onHistoryClick] 会话详情数据:', response.data);
|
||||
} catch (err) {
|
||||
console.error('[onHistoryClick] 获取会话详情失败:', err);
|
||||
}
|
||||
// 跳转到对话页面
|
||||
router.push({
|
||||
path: '/chat',
|
||||
query: { sessionId: item.id },
|
||||
@@ -167,9 +176,7 @@ async function stopService() {
|
||||
// 检查服务状态
|
||||
async function checkServiceStatus() {
|
||||
try {
|
||||
console.log('[checkServiceStatus] 检查服务状态...');
|
||||
const info = await window.opencode?.info();
|
||||
console.log('[checkServiceStatus] 服务信息:', info);
|
||||
const isRunning = info?.running || false;
|
||||
|
||||
// 更新服务状态
|
||||
@@ -179,20 +186,16 @@ async function checkServiceStatus() {
|
||||
// 服务运行中,更新 baseUrl 并加载历史记录
|
||||
if (info?.url) {
|
||||
window.__opencodeBaseUrl = info.url;
|
||||
console.log('[checkServiceStatus] 更新 baseUrl:', info.url);
|
||||
}
|
||||
// 如果历史记录为空,则加载
|
||||
if (historyItems.value.length === 0) {
|
||||
console.log('[checkServiceStatus] 服务运行中,加载历史记录');
|
||||
loadHistorySessions();
|
||||
}
|
||||
} else {
|
||||
// 服务未运行,清空历史记录
|
||||
console.log('[checkServiceStatus] 服务未运行,清空历史记录');
|
||||
historyItems.value = [];
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[checkServiceStatus] 获取服务状态失败:', err);
|
||||
// 获取状态失败,视为服务断开
|
||||
isServiceRunning.value = false;
|
||||
historyItems.value = [];
|
||||
|
||||
Reference in New Issue
Block a user