feat: Phase 2 交互与纠错工作台完成
- 新增实体编辑 API (名称、类型、定义、别名) - 新增实体删除和合并功能 - 新增关系管理 (创建、删除) - 新增转录文本编辑功能 - 新增划词创建实体功能 - 前端新增实体编辑器模态框 - 前端新增右键菜单和工具栏 - 文本与图谱双向联动优化
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>InsightFlow - 知识工作台</title>
|
||||
<title>InsightFlow - 知识工作台 (Phase 2)</title>
|
||||
<script src="https://d3js.org/d3.v7.min.js"></script>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
@@ -66,6 +66,23 @@
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.panel-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.btn-icon {
|
||||
background: transparent;
|
||||
border: 1px solid #333;
|
||||
color: #888;
|
||||
padding: 4px 10px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.btn-icon:hover {
|
||||
border-color: #00d4ff;
|
||||
color: #00d4ff;
|
||||
}
|
||||
.transcript-content {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
@@ -92,6 +109,13 @@
|
||||
}
|
||||
.segment-text {
|
||||
color: #e0e0e0;
|
||||
outline: none;
|
||||
}
|
||||
.segment-text[contenteditable="true"] {
|
||||
background: #1a1a1a;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #00d4ff;
|
||||
}
|
||||
.entity {
|
||||
background: rgba(123, 44, 191, 0.3);
|
||||
@@ -99,10 +123,16 @@
|
||||
padding: 0 4px;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
.entity:hover {
|
||||
background: rgba(123, 44, 191, 0.5);
|
||||
}
|
||||
.entity.selected {
|
||||
background: #ff6b6b;
|
||||
border-color: #ff6b6b;
|
||||
color: #fff;
|
||||
}
|
||||
.graph-panel {
|
||||
width: 50%;
|
||||
display: flex;
|
||||
@@ -127,10 +157,15 @@
|
||||
border-radius: 6px;
|
||||
margin-bottom: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.entity-item:hover {
|
||||
background: #222;
|
||||
}
|
||||
.entity-item.selected {
|
||||
background: #2a2a2a;
|
||||
border-left: 3px solid #ff6b6b;
|
||||
}
|
||||
.entity-type-badge {
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
@@ -139,11 +174,11 @@
|
||||
margin-right: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.type-project { background: #7b2cbf; }
|
||||
.type-tech { background: #00d4ff; color: #000; }
|
||||
.type-person { background: #ff6b6b; }
|
||||
.type-org { background: #4ecdc4; color: #000; }
|
||||
.type-other { background: #666; }
|
||||
.type-PROJECT { background: #7b2cbf; }
|
||||
.type-TECH { background: #00d4ff; color: #000; }
|
||||
.type-PERSON { background: #ff6b6b; }
|
||||
.type-ORG { background: #4ecdc4; color: #000; }
|
||||
.type-OTHER { background: #666; }
|
||||
.upload-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@@ -186,10 +221,158 @@
|
||||
font-size: 0.85rem;
|
||||
margin-top: 0;
|
||||
}
|
||||
.btn-danger {
|
||||
background: #ff6b6b;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #333;
|
||||
}
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
}
|
||||
/* Phase 2: Entity Editor Modal */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.8);
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 3000;
|
||||
}
|
||||
.modal-overlay.show {
|
||||
display: flex;
|
||||
}
|
||||
.modal {
|
||||
background: #1a1a1a;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.modal-header {
|
||||
font-size: 1.2rem;
|
||||
margin-bottom: 20px;
|
||||
color: #fff;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
color: #888;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
background: #0a0a0a;
|
||||
border: 1px solid #333;
|
||||
border-radius: 6px;
|
||||
color: #e0e0e0;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus,
|
||||
.form-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: #00d4ff;
|
||||
}
|
||||
.form-group textarea {
|
||||
min-height: 80px;
|
||||
resize: vertical;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
/* Phase 2: Context Menu */
|
||||
.context-menu {
|
||||
position: absolute;
|
||||
background: #1a1a1a;
|
||||
border: 1px solid #333;
|
||||
border-radius: 6px;
|
||||
padding: 6px 0;
|
||||
z-index: 4000;
|
||||
display: none;
|
||||
min-width: 160px;
|
||||
}
|
||||
.context-menu.show {
|
||||
display: block;
|
||||
}
|
||||
.context-menu-item {
|
||||
padding: 8px 16px;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
.context-menu-item:hover {
|
||||
background: #2a2a2a;
|
||||
}
|
||||
.context-menu-divider {
|
||||
height: 1px;
|
||||
background: #333;
|
||||
margin: 6px 0;
|
||||
}
|
||||
/* Phase 2: Relation Editor */
|
||||
.relation-editor {
|
||||
margin-top: 16px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #333;
|
||||
}
|
||||
.relation-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
background: #0a0a0a;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.relation-item button {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #ff6b6b;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
/* Phase 2: Selection toolbar */
|
||||
.selection-toolbar {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #1a1a1a;
|
||||
border: 1px solid #333;
|
||||
border-radius: 8px;
|
||||
padding: 10px 20px;
|
||||
display: none;
|
||||
gap: 10px;
|
||||
z-index: 3500;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.5);
|
||||
}
|
||||
.selection-toolbar.show {
|
||||
display: flex;
|
||||
}
|
||||
/* Graph node styles */
|
||||
.node-circle {
|
||||
cursor: pointer;
|
||||
}
|
||||
.node-label {
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -205,7 +388,10 @@
|
||||
<div class="editor-panel">
|
||||
<div class="panel-header">
|
||||
<span>📄 转录文本</span>
|
||||
<span style="font-size:0.8rem;color:#666;">点击实体高亮</span>
|
||||
<div class="panel-actions">
|
||||
<button class="btn-icon" onclick="toggleEditMode()" id="editBtn">✏️ 编辑</button>
|
||||
<button class="btn-icon" onclick="saveTranscript()" id="saveBtn" style="display:none;">💾 保存</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="transcript-content" id="transcriptContent">
|
||||
<div class="empty-state">
|
||||
@@ -218,7 +404,7 @@
|
||||
<div class="graph-panel">
|
||||
<div class="panel-header">
|
||||
<span>🔗 知识图谱</span>
|
||||
<span style="font-size:0.8rem;color:#666;">拖拽节点查看关系</span>
|
||||
<span style="font-size:0.8rem;color:#666;">右键节点编辑 | 拖拽建立关系</span>
|
||||
</div>
|
||||
<svg id="graph-svg"></svg>
|
||||
<div class="entity-list" id="entityList">
|
||||
@@ -228,6 +414,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Upload Modal -->
|
||||
<div class="upload-overlay" id="uploadOverlay">
|
||||
<div class="upload-box">
|
||||
<h2 style="margin-bottom:10px;">上传音频分析</h2>
|
||||
@@ -235,10 +422,113 @@
|
||||
<input type="file" id="fileInput" accept="audio/*" hidden>
|
||||
<button class="btn" onclick="document.getElementById('fileInput').click()">选择文件</button>
|
||||
<br><br>
|
||||
<button class="btn" style="background:#333;" onclick="hideUpload()">取消</button>
|
||||
<button class="btn btn-secondary" onclick="hideUpload()">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Entity Editor Modal -->
|
||||
<div class="modal-overlay" id="entityModal">
|
||||
<div class="modal">
|
||||
<h3 class="modal-header">编辑实体</h3>
|
||||
<div class="form-group">
|
||||
<label>实体名称</label>
|
||||
<input type="text" id="entityName" placeholder="实体名称">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>实体类型</label>
|
||||
<select id="entityType">
|
||||
<option value="PROJECT">项目 (PROJECT)</option>
|
||||
<option value="TECH">技术 (TECH)</option>
|
||||
<option value="PERSON">人物 (PERSON)</option>
|
||||
<option value="ORG">组织 (ORG)</option>
|
||||
<option value="OTHER">其他 (OTHER)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>定义描述</label>
|
||||
<textarea id="entityDefinition" placeholder="一句话描述这个实体..."></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>别名 (用逗号分隔)</label>
|
||||
<input type="text" id="entityAliases" placeholder="别名1, 别名2, 别名3">
|
||||
</div>
|
||||
<div class="relation-editor" id="relationEditor" style="display:none;">
|
||||
<h4 style="color:#888;font-size:0.9rem;margin-bottom:12px;">实体关系</h4>
|
||||
<div id="relationList"></div>
|
||||
<button class="btn-icon" onclick="showAddRelation()" style="margin-top:8px;">+ 添加关系</button>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-danger" onclick="deleteEntity()" id="deleteEntityBtn">删除</button>
|
||||
<button class="btn btn-secondary" onclick="hideEntityModal()">取消</button>
|
||||
<button class="btn" onclick="saveEntity()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Relation Modal -->
|
||||
<div class="modal-overlay" id="relationModal">
|
||||
<div class="modal">
|
||||
<h3 class="modal-header">添加关系</h3>
|
||||
<div class="form-group">
|
||||
<label>目标实体</label>
|
||||
<select id="relationTarget"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>关系类型</label>
|
||||
<select id="relationType">
|
||||
<option value="belongs_to">属于 (belongs_to)</option>
|
||||
<option value="works_with">合作 (works_with)</option>
|
||||
<option value="depends_on">依赖 (depends_on)</option>
|
||||
<option value="mentions">提及 (mentions)</option>
|
||||
<option value="related">相关 (related)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>关系证据/说明</label>
|
||||
<textarea id="relationEvidence" placeholder="描述这个关系的依据..."></textarea>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary" onclick="hideRelationModal()">取消</button>
|
||||
<button class="btn" onclick="saveRelation()">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Merge Entities Modal -->
|
||||
<div class="modal-overlay" id="mergeModal">
|
||||
<div class="modal">
|
||||
<h3 class="modal-header">合并实体</h3>
|
||||
<p style="color:#888;margin-bottom:16px;font-size:0.9rem;">将选中的实体合并到目标实体中</p>
|
||||
<div class="form-group">
|
||||
<label>源实体</label>
|
||||
<input type="text" id="mergeSource" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>目标实体 (保留)</label>
|
||||
<select id="mergeTarget"></select>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary" onclick="hideMergeModal()">取消</button>
|
||||
<button class="btn" onclick="confirmMerge()">合并</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Context Menu -->
|
||||
<div class="context-menu" id="contextMenu">
|
||||
<div class="context-menu-item" onclick="editEntity()">✏️ 编辑实体</div>
|
||||
<div class="context-menu-item" onclick="showMergeModal()">🔄 合并实体</div>
|
||||
<div class="context-menu-divider"></div>
|
||||
<div class="context-menu-item" onclick="createEntityFromSelection()">➕ 标记为实体</div>
|
||||
</div>
|
||||
|
||||
<!-- Selection Toolbar -->
|
||||
<div class="selection-toolbar" id="selectionToolbar">
|
||||
<span style="color:#888;font-size:0.85rem;">选中文本:</span>
|
||||
<button class="btn-icon" onclick="createEntityFromSelection()">标记为实体</button>
|
||||
<button class="btn-icon" onclick="hideSelectionToolbar()">取消</button>
|
||||
</div>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user