feat: multi-branch template scanning from git repo + manual template selection
- Rewrite template.rs to scan all remote branches via git commands (git fetch/branch -r/ls-tree/git show/git archive) - Add manual template picker dropdown in CreateForm UI - Remove sentence-transformers/embed.py from Dockerfile (separate container) - Clean up Gitea API approach, use local git repo instead - Add chat panel and sidebar layout improvements
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Project, Workflow, ExecutionLogEntry, Comment, Timer, KbArticle, KbArticleSummary, PlanStepInfo, LlmCallLogEntry } from './types'
|
||||
import type { Project, Workflow, ExecutionLogEntry, Comment, Timer, KbArticle, KbArticleSummary, PlanStepInfo, LlmCallLogEntry, ChatMessage } from './types'
|
||||
|
||||
const BASE = `${import.meta.env.BASE_URL.replace(/\/$/, '')}/api`
|
||||
|
||||
@@ -37,12 +37,15 @@ export const api = {
|
||||
listWorkflows: (projectId: string) =>
|
||||
request<Workflow[]>(`/projects/${projectId}/workflows`),
|
||||
|
||||
createWorkflow: (projectId: string, requirement: string) =>
|
||||
createWorkflow: (projectId: string, requirement: string, templateId?: string) =>
|
||||
request<Workflow>(`/projects/${projectId}/workflows`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ requirement }),
|
||||
body: JSON.stringify({ requirement, template_id: templateId || undefined }),
|
||||
}),
|
||||
|
||||
listTemplates: () =>
|
||||
request<{ id: string; name: string; description: string }[]>('/templates'),
|
||||
|
||||
listSteps: (workflowId: string) =>
|
||||
request<ExecutionLogEntry[]>(`/workflows/${workflowId}/steps`),
|
||||
|
||||
@@ -103,6 +106,12 @@ export const api = {
|
||||
deleteArticle: (id: string) =>
|
||||
request<boolean>(`/kb/articles/${id}`, { method: 'DELETE' }),
|
||||
|
||||
chat: (messages: ChatMessage[]) =>
|
||||
request<{ reply: string }>('/chat', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ messages }),
|
||||
}),
|
||||
|
||||
getSettings: () => request<Record<string, string>>('/settings'),
|
||||
|
||||
putSetting: (key: string, value: string) =>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, computed } from 'vue'
|
||||
import Sidebar from './Sidebar.vue'
|
||||
import ChatPanel from './ChatPanel.vue'
|
||||
import WorkflowView from './WorkflowView.vue'
|
||||
import ReportView from './ReportView.vue'
|
||||
import CreateForm from './CreateForm.vue'
|
||||
@@ -19,11 +20,38 @@ const showObj = ref(false)
|
||||
const kbArticles = ref<KbArticleSummary[]>([])
|
||||
const selectedArticleId = ref('')
|
||||
const appTitle = ref('')
|
||||
const chatOpen = ref(false)
|
||||
const showSettings = ref(false)
|
||||
const editingTitle = ref(false)
|
||||
const titleInput = ref('')
|
||||
|
||||
const basePath = import.meta.env.BASE_URL.replace(/\/$/, '')
|
||||
|
||||
const isReportPage = computed(() => !!reportWorkflowId.value)
|
||||
|
||||
const currentPageTitle = computed(() => {
|
||||
if (showKb.value) return 'Knowledge Base'
|
||||
if (showObj.value) return 'Object Storage'
|
||||
if (selectedProjectId.value) {
|
||||
const p = projects.value.find(p => p.id === selectedProjectId.value)
|
||||
return p?.name || ''
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
function onEditTitle() {
|
||||
titleInput.value = appTitle.value || 'Tori'
|
||||
editingTitle.value = true
|
||||
}
|
||||
|
||||
function onSaveTitle() {
|
||||
const val = titleInput.value.trim()
|
||||
if (val && val !== appTitle.value) {
|
||||
onUpdateAppTitle(val)
|
||||
}
|
||||
editingTitle.value = false
|
||||
}
|
||||
|
||||
function parseUrl(): { projectId: string; reportId: string; kb: boolean; obj: boolean } {
|
||||
let path = location.pathname
|
||||
if (basePath && path.startsWith(basePath)) {
|
||||
@@ -96,11 +124,11 @@ function onStartCreate() {
|
||||
history.pushState(null, '', `${basePath}/`)
|
||||
}
|
||||
|
||||
async function onConfirmCreate(req: string) {
|
||||
async function onConfirmCreate(req: string, templateId?: string) {
|
||||
try {
|
||||
const project = await api.createProject('新项目')
|
||||
projects.value.unshift(project)
|
||||
await api.createWorkflow(project.id, req)
|
||||
await api.createWorkflow(project.id, req, templateId)
|
||||
creating.value = false
|
||||
selectedProjectId.value = project.id
|
||||
history.pushState(null, '', `${basePath}/projects/${project.id}`)
|
||||
@@ -213,9 +241,22 @@ function onArticleSaved(id: string, title: string, updatedAt: string) {
|
||||
a.title = title
|
||||
a.updated_at = updatedAt
|
||||
}
|
||||
// Re-sort by updated_at descending
|
||||
kbArticles.value.sort((a, b) => b.updated_at.localeCompare(a.updated_at))
|
||||
}
|
||||
|
||||
function goHome() {
|
||||
showKb.value = false
|
||||
showObj.value = false
|
||||
selectedArticleId.value = ''
|
||||
creating.value = false
|
||||
if (projects.value[0]) {
|
||||
selectedProjectId.value = projects.value[0].id
|
||||
history.pushState(null, '', `${basePath}/projects/${projects.value[0].id}`)
|
||||
} else {
|
||||
selectedProjectId.value = ''
|
||||
history.pushState(null, '', `${basePath}/`)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -223,54 +264,92 @@ function onArticleSaved(id: string, title: string, updatedAt: string) {
|
||||
<ReportView :workflowId="reportWorkflowId" :key="reportWorkflowId" />
|
||||
</div>
|
||||
<div v-else class="app-layout">
|
||||
<Sidebar
|
||||
:projects="projects"
|
||||
:selectedId="selectedProjectId"
|
||||
:kbMode="showKb"
|
||||
:objMode="showObj"
|
||||
:kbArticles="kbArticles"
|
||||
:selectedArticleId="selectedArticleId"
|
||||
:appTitle="appTitle"
|
||||
@select="onSelectProject"
|
||||
@create="onStartCreate"
|
||||
@delete="onDeleteProject"
|
||||
@openKb="onOpenKb"
|
||||
@closeKb="onCloseKb"
|
||||
@openObj="onOpenObj"
|
||||
@closeObj="onCloseObj"
|
||||
@selectArticle="selectedArticleId = $event"
|
||||
@createArticle="onCreateArticle"
|
||||
@deleteArticle="onDeleteArticle"
|
||||
@updateAppTitle="onUpdateAppTitle"
|
||||
/>
|
||||
<main class="main-content">
|
||||
<div v-if="error" class="error-banner" @click="error = ''">{{ error }}</div>
|
||||
<ObjBrowser
|
||||
v-if="showObj"
|
||||
@close="onCloseObj"
|
||||
/>
|
||||
<KbEditor
|
||||
v-else-if="showKb && selectedArticleId"
|
||||
:articleId="selectedArticleId"
|
||||
:key="selectedArticleId"
|
||||
@saved="onArticleSaved"
|
||||
/>
|
||||
<div v-else-if="showKb" class="empty-state">
|
||||
选择或创建一篇文章
|
||||
<header class="app-header">
|
||||
<div class="header-left">
|
||||
<span class="header-title" @click="goHome">{{ appTitle || 'Tori' }}</span>
|
||||
<template v-if="currentPageTitle">
|
||||
<span class="header-sep">/</span>
|
||||
<span class="header-page">{{ currentPageTitle }}</span>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else-if="creating" class="empty-state">
|
||||
<CreateForm @submit="onConfirmCreate" @cancel="creating = false" />
|
||||
<div class="header-right">
|
||||
<div class="header-settings-wrapper">
|
||||
<button class="header-btn" @click="showSettings = !showSettings" title="Settings">⚙</button>
|
||||
<div v-if="showSettings" class="header-settings-menu">
|
||||
<div class="settings-item-row" v-if="!editingTitle">
|
||||
<span class="settings-label">App Title</span>
|
||||
<button class="settings-value" @click="onEditTitle">{{ appTitle || 'Tori' }}</button>
|
||||
</div>
|
||||
<div class="settings-item-row" v-else>
|
||||
<input
|
||||
class="settings-input"
|
||||
v-model="titleInput"
|
||||
@keyup.enter="onSaveTitle"
|
||||
@keyup.escape="editingTitle = false"
|
||||
@vue:mounted="($event: any) => $event.el.focus()"
|
||||
/>
|
||||
<button class="settings-save" @click="onSaveTitle">OK</button>
|
||||
</div>
|
||||
<button class="settings-item" @click="showSettings = false; onOpenKb()">Knowledge Base</button>
|
||||
<button class="settings-item" @click="showSettings = false; onOpenObj()">Object Storage</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="header-btn" @click="chatOpen = !chatOpen" :title="chatOpen ? 'Close chat' : 'Open chat'">
|
||||
💬
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="!selectedProjectId" class="empty-state">
|
||||
选择或创建一个项目开始
|
||||
</div>
|
||||
<WorkflowView
|
||||
v-else
|
||||
:projectId="selectedProjectId"
|
||||
:key="selectedProjectId"
|
||||
@projectUpdate="onProjectUpdate"
|
||||
</header>
|
||||
<div class="app-body">
|
||||
<Sidebar
|
||||
:projects="projects"
|
||||
:selectedId="selectedProjectId"
|
||||
:kbMode="showKb"
|
||||
:objMode="showObj"
|
||||
:kbArticles="kbArticles"
|
||||
:selectedArticleId="selectedArticleId"
|
||||
@select="onSelectProject"
|
||||
@create="onStartCreate"
|
||||
@delete="onDeleteProject"
|
||||
@openKb="onOpenKb"
|
||||
@closeKb="onCloseKb"
|
||||
@openObj="onOpenObj"
|
||||
@closeObj="onCloseObj"
|
||||
@selectArticle="selectedArticleId = $event"
|
||||
@createArticle="onCreateArticle"
|
||||
@deleteArticle="onDeleteArticle"
|
||||
/>
|
||||
</main>
|
||||
<main class="main-content">
|
||||
<div v-if="error" class="error-banner" @click="error = ''">{{ error }}</div>
|
||||
<ObjBrowser
|
||||
v-if="showObj"
|
||||
@close="onCloseObj"
|
||||
/>
|
||||
<KbEditor
|
||||
v-else-if="showKb && selectedArticleId"
|
||||
:articleId="selectedArticleId"
|
||||
:key="selectedArticleId"
|
||||
@saved="onArticleSaved"
|
||||
/>
|
||||
<div v-else-if="showKb" class="empty-state">
|
||||
选择或创建一篇文章
|
||||
</div>
|
||||
<div v-else-if="creating" class="empty-state">
|
||||
<CreateForm @submit="onConfirmCreate" @cancel="creating = false" />
|
||||
</div>
|
||||
<div v-else-if="!selectedProjectId" class="empty-state">
|
||||
选择或创建一个项目开始
|
||||
</div>
|
||||
<WorkflowView
|
||||
v-else
|
||||
:projectId="selectedProjectId"
|
||||
:key="selectedProjectId"
|
||||
@projectUpdate="onProjectUpdate"
|
||||
/>
|
||||
</main>
|
||||
<aside v-if="chatOpen" class="chat-sidebar">
|
||||
<ChatPanel />
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -282,10 +361,175 @@ function onArticleSaved(id: string, title: string, updatedAt: string) {
|
||||
|
||||
.app-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-header {
|
||||
height: var(--header-height);
|
||||
min-height: var(--header-height);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 16px;
|
||||
background: var(--bg-primary);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: var(--accent);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.header-title:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.header-sep {
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.header-page {
|
||||
font-size: 14px;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.header-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.header-btn:hover {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.header-settings-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header-settings-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 4px;
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
min-width: 200px;
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
.settings-item-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
|
||||
.settings-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.settings-value {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.settings-value:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.settings-input {
|
||||
flex: 1;
|
||||
padding: 4px 8px;
|
||||
font-size: 13px;
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: var(--text-primary);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.settings-input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.settings-save {
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.settings-item {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.settings-item:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.app-body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
@@ -309,4 +553,12 @@ function onArticleSaved(id: string, title: string, updatedAt: string) {
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.chat-sidebar {
|
||||
width: var(--chat-sidebar-width, 360px);
|
||||
flex-shrink: 0;
|
||||
border-left: 1px solid var(--border);
|
||||
background: var(--bg-secondary);
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
216
web/src/components/ChatPanel.vue
Normal file
216
web/src/components/ChatPanel.vue
Normal file
@@ -0,0 +1,216 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick } from 'vue'
|
||||
import { api } from '../api'
|
||||
import type { ChatMessage } from '../types'
|
||||
|
||||
const messages = ref<ChatMessage[]>([])
|
||||
const input = ref('')
|
||||
const loading = ref(false)
|
||||
const listEl = ref<HTMLElement | null>(null)
|
||||
|
||||
async function scrollToBottom() {
|
||||
await nextTick()
|
||||
if (listEl.value) {
|
||||
listEl.value.scrollTop = listEl.value.scrollHeight
|
||||
}
|
||||
}
|
||||
|
||||
async function send() {
|
||||
const text = input.value.trim()
|
||||
if (!text || loading.value) return
|
||||
|
||||
messages.value.push({ role: 'user', content: text })
|
||||
input.value = ''
|
||||
loading.value = true
|
||||
await scrollToBottom()
|
||||
|
||||
try {
|
||||
const resp = await api.chat(messages.value)
|
||||
messages.value.push({ role: 'assistant', content: resp.reply })
|
||||
} catch (e: any) {
|
||||
messages.value.push({ role: 'assistant', content: `Error: ${e.message}` })
|
||||
} finally {
|
||||
loading.value = false
|
||||
await scrollToBottom()
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
messages.value = []
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
function onKeydown(e: KeyboardEvent) {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault()
|
||||
send()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="chat-panel">
|
||||
<div class="chat-header">
|
||||
<span class="chat-title">Chat</span>
|
||||
<button class="chat-clear" @click="clear" :disabled="messages.length === 0 && !loading">Clear</button>
|
||||
</div>
|
||||
|
||||
<div class="chat-messages" ref="listEl">
|
||||
<div v-if="messages.length === 0 && !loading" class="chat-empty">
|
||||
Ask anything...
|
||||
</div>
|
||||
<div
|
||||
v-for="(msg, i) in messages"
|
||||
:key="i"
|
||||
class="chat-msg"
|
||||
:class="msg.role"
|
||||
>
|
||||
<div class="chat-bubble">{{ msg.content }}</div>
|
||||
</div>
|
||||
<div v-if="loading" class="chat-msg assistant">
|
||||
<div class="chat-bubble thinking">Thinking...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-input-area">
|
||||
<textarea
|
||||
v-model="input"
|
||||
@keydown="onKeydown"
|
||||
placeholder="Type a message... (Shift+Enter for newline)"
|
||||
rows="2"
|
||||
:disabled="loading"
|
||||
/>
|
||||
<button class="chat-send" @click="send" :disabled="!input.trim() || loading">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.chat-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chat-title {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.chat-clear {
|
||||
background: none;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.chat-clear:hover:not(:disabled) {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 12px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.chat-empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.chat-msg {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.chat-msg.user {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.chat-msg.assistant {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.chat-bubble {
|
||||
max-width: 85%;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.chat-msg.user .chat-bubble {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chat-msg.assistant .chat-bubble {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chat-bubble.thinking {
|
||||
color: var(--text-secondary);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.chat-input-area {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chat-input-area textarea {
|
||||
flex: 1;
|
||||
resize: none;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
padding: 8px 10px;
|
||||
font-size: 13px;
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.chat-input-area textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.chat-send {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
padding: 8px 14px;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.chat-send:hover:not(:disabled) {
|
||||
background: var(--accent-hover);
|
||||
}
|
||||
|
||||
.chat-send:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
@@ -1,20 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { api } from '../api'
|
||||
import examples from '../examples.json'
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [requirement: string]
|
||||
submit: [requirement: string, templateId?: string]
|
||||
cancel: []
|
||||
}>()
|
||||
|
||||
const requirement = ref('')
|
||||
const inputEl = ref<HTMLTextAreaElement>()
|
||||
const templates = ref<{ id: string; name: string; description: string }[]>([])
|
||||
const selectedTemplate = ref('')
|
||||
|
||||
onMounted(() => inputEl.value?.focus())
|
||||
onMounted(async () => {
|
||||
inputEl.value?.focus()
|
||||
try {
|
||||
templates.value = await api.listTemplates()
|
||||
} catch {
|
||||
// ignore — templates dropdown just won't show
|
||||
}
|
||||
})
|
||||
|
||||
function onSubmit() {
|
||||
const text = requirement.value.trim()
|
||||
if (text) emit('submit', text)
|
||||
if (text) emit('submit', text, selectedTemplate.value || undefined)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -38,6 +48,13 @@ function onSubmit() {
|
||||
@keydown.ctrl.enter="onSubmit"
|
||||
@keydown.meta.enter="onSubmit"
|
||||
/>
|
||||
<div v-if="templates.length" class="template-select">
|
||||
<label>模板</label>
|
||||
<select v-model="selectedTemplate">
|
||||
<option value="">自动选择</option>
|
||||
<option v-for="t in templates" :key="t.id" :value="t.id">{{ t.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="create-hint">Ctrl+Enter 提交</div>
|
||||
<div class="create-actions">
|
||||
<button class="btn-cancel" @click="emit('cancel')">取消</button>
|
||||
@@ -100,6 +117,34 @@ function onSubmit() {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.template-select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.template-select label {
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.template-select select {
|
||||
flex: 1;
|
||||
padding: 6px 8px;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.template-select select:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.create-hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import type { Project, KbArticleSummary } from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -9,7 +8,6 @@ const props = defineProps<{
|
||||
objMode: boolean
|
||||
kbArticles: KbArticleSummary[]
|
||||
selectedArticleId: string
|
||||
appTitle?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -23,26 +21,8 @@ const emit = defineEmits<{
|
||||
selectArticle: [id: string]
|
||||
createArticle: []
|
||||
deleteArticle: [id: string]
|
||||
updateAppTitle: [title: string]
|
||||
}>()
|
||||
|
||||
const showSettings = ref(false)
|
||||
const editingTitle = ref(false)
|
||||
const titleInput = ref('')
|
||||
|
||||
function onEditTitle() {
|
||||
titleInput.value = props.appTitle || 'Tori'
|
||||
editingTitle.value = true
|
||||
}
|
||||
|
||||
function onSaveTitle() {
|
||||
const val = titleInput.value.trim()
|
||||
if (val && val !== props.appTitle) {
|
||||
emit('updateAppTitle', val)
|
||||
}
|
||||
editingTitle.value = false
|
||||
}
|
||||
|
||||
function onDelete(e: Event, id: string) {
|
||||
e.stopPropagation()
|
||||
if (confirm('确定删除这个项目?')) {
|
||||
@@ -56,16 +36,6 @@ function onDeleteArticle(e: Event, id: string) {
|
||||
emit('deleteArticle', id)
|
||||
}
|
||||
}
|
||||
|
||||
function onOpenKb() {
|
||||
showSettings.value = false
|
||||
emit('openKb')
|
||||
}
|
||||
|
||||
function onOpenObj() {
|
||||
showSettings.value = false
|
||||
emit('openObj')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -74,7 +44,6 @@ function onOpenObj() {
|
||||
<template v-if="objMode">
|
||||
<div class="sidebar-header">
|
||||
<button class="btn-back" @click="emit('closeObj')">← Back</button>
|
||||
<h1 class="logo">Object Storage</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -82,7 +51,6 @@ function onOpenObj() {
|
||||
<template v-else-if="kbMode">
|
||||
<div class="sidebar-header">
|
||||
<button class="btn-back" @click="emit('closeKb')">← Back</button>
|
||||
<h1 class="logo">Knowledge Base</h1>
|
||||
<button class="btn-new" @click="emit('createArticle')">+ 新文章</button>
|
||||
</div>
|
||||
<nav class="project-list">
|
||||
@@ -106,7 +74,6 @@ function onOpenObj() {
|
||||
<!-- Normal Mode -->
|
||||
<template v-else>
|
||||
<div class="sidebar-header">
|
||||
<h1 class="logo">{{ props.appTitle || 'Tori' }}</h1>
|
||||
<button class="btn-new" @click="emit('create')">+ 新项目</button>
|
||||
</div>
|
||||
<nav class="project-list">
|
||||
@@ -124,29 +91,6 @@ function onOpenObj() {
|
||||
<span class="project-time">{{ new Date(project.updated_at).toLocaleDateString() }}</span>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="settings-wrapper">
|
||||
<button class="btn-settings" @click="showSettings = !showSettings">Settings</button>
|
||||
<div v-if="showSettings" class="settings-menu">
|
||||
<div class="settings-item-row" v-if="!editingTitle">
|
||||
<span class="settings-label">App Title</span>
|
||||
<button class="settings-value" @click="onEditTitle">{{ props.appTitle || 'Tori' }}</button>
|
||||
</div>
|
||||
<div class="settings-item-row" v-else>
|
||||
<input
|
||||
class="settings-input"
|
||||
v-model="titleInput"
|
||||
@keyup.enter="onSaveTitle"
|
||||
@keyup.escape="editingTitle = false"
|
||||
@vue:mounted="($event: any) => $event.el.focus()"
|
||||
/>
|
||||
<button class="settings-save" @click="onSaveTitle">OK</button>
|
||||
</div>
|
||||
<button class="settings-item" @click="onOpenKb">Knowledge Base</button>
|
||||
<button class="settings-item" @click="onOpenObj">Object Storage</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -167,13 +111,6 @@ function onOpenObj() {
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--accent);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
@@ -285,113 +222,4 @@ function onOpenObj() {
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.settings-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btn-settings {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border: none;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.btn-settings:hover {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.settings-menu {
|
||||
position: absolute;
|
||||
bottom: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin-bottom: 4px;
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.settings-item {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.settings-item:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.settings-item-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
|
||||
.settings-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.settings-value {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.settings-value:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.settings-input {
|
||||
flex: 1;
|
||||
padding: 4px 8px;
|
||||
font-size: 13px;
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: var(--text-primary);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.settings-input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.settings-save {
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
}
|
||||
|
||||
:root {
|
||||
--header-height: 44px;
|
||||
--sidebar-width: 240px;
|
||||
--chat-sidebar-width: 360px;
|
||||
--bg-primary: #ffffff;
|
||||
--bg-secondary: #f7f8fa;
|
||||
--bg-tertiary: #eef0f4;
|
||||
|
||||
@@ -64,6 +64,11 @@ export interface Timer {
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant'
|
||||
content: string
|
||||
}
|
||||
|
||||
export interface LlmCallLogEntry {
|
||||
id: string
|
||||
workflow_id: string
|
||||
|
||||
Reference in New Issue
Block a user