<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文本处理工具 - 控制台</title>
<script src="javascript/tailwindcss.js"></script>
<script src="javascript/vue.global.js"></script>
<style>
[v-cloak] {
display: none;
}
.tab-item {
transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}
.tab-item.active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.iframe-container {
height: 100vh;
}
iframe {
border: none;
width: 100%;
height: 100%;
background: white;
}
body,
html {
margin: 0;
padding: 0;
height: 100vh;
overflow: hidden;
}
</style>
</head>
<body class="bg-gray-50 h-screen">
<div id="app" v-cloak class="flex gap-0 h-full">
<!-- Left Sidebar - Tab Navigation -->
<div class="w-80 bg-white shadow p-6 flex flex-col border-r border-gray-200">
<!-- Logo & Title -->
<div class="mb-8">
<h1 class="text-2xl font-bold text-gray-800 mb-2 flex items-center gap-3">
<svg class="w-8 h-8 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
文本处理工具
</h1>
<p class="text-sm text-gray-600">智能分割 · 批量改写 · 任务管理</p>
</div>
<!-- Tab Navigation -->
<nav class="flex-1 space-y-2">
<div v-for="tab in tabs" :key="tab.id" @click="switchTab(tab.id)" :class="[
'tab-item',
'flex items-center gap-3 px-4 py-4 rounded-lg cursor-pointer',
activeTab === tab.id
? 'active text-white shadow-lg transform scale-105'
: 'text-gray-700 hover:bg-purple-50 hover:text-purple-700'
]">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" :d="tab.icon" />
</svg>
<div class="flex-1">
<div class="font-semibold text-base">{{ tab.title }}</div>
<div class="text-xs opacity-80">{{ tab.description }}</div>
</div>
</div>
</nav>
<!-- Footer Info -->
<div class="mt-6 pt-6 border-t border-gray-200">
<div class="flex items-center gap-2 text-sm text-gray-600">
<svg class="w-5 h-5 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span>服务运行中</span>
</div>
<div class="text-xs text-gray-500 mt-2">
Version 1.0.0
</div>
</div>
</div>
<!-- Right Content - iframe -->
<div class="flex-1 bg-white overflow-hidden iframe-container">
<iframe :src="currentUrl" frameborder="0"></iframe>
</div>
</div>
<script>
const { createApp, ref, computed } = Vue;
createApp({
setup() {
const activeTab = ref('split');
const tabs = [
{
id: 'split',
title: '文本分割',
description: '上传和分割文本',
icon: 'M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z',
url: 'split.html'
},
{
id: 'tasks',
title: '任务管理',
description: '管理改写任务',
icon: 'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2',
url: 'tasks.html'
},
{
id: 'prompt',
title: '提示词设置',
description: '配置改写提示词',
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z',
url: 'prompt.html'
}
];
const currentUrl = computed(() => {
const tab = tabs.find(t => t.id === activeTab.value);
if (!tab) return tabs[0].url;
// 如果是任务管理页面,且 URL 中有 project 参数,传递给 iframe
if (tab.id === 'tasks') {
const urlParams = new URLSearchParams(window.location.search);
const projectParam = urlParams.get('project');
if (projectParam) {
return `${tab.url}?project=${encodeURIComponent(projectParam)}`;
}
}
return tab.url;
});
const switchTab = (tabId, params = {}) => {
activeTab.value = tabId;
// 更新 URL
const url = new URL(window.location);
url.searchParams.set('tab', tabId);
// 如果有 project 参数,也添加到 URL
if (params.project) {
url.searchParams.set('project', params.project);
} else {
url.searchParams.delete('project');
}
window.history.pushState({}, '', url);
};
// 监听来自 iframe 的消息
window.addEventListener('message', (event) => {
if (event.data.action === 'switchTab') {
switchTab(event.data.tab, { project: event.data.project });
}
});
// 从 URL 参数获取初始 tab
const urlParams = new URLSearchParams(window.location.search);
const tabParam = urlParams.get('tab');
if (tabParam && tabs.find(t => t.id === tabParam)) {
activeTab.value = tabParam;
}
return {
tabs,
activeTab,
currentUrl,
switchTab
};
}
}).mount('#app');
</script>
</body>
</html>