新增工作空间面板,支持树形结构展示和文件预览功能;重构输入栏以集成常用工作流选择,优化用户交互体验;更新侧边栏以简化历史记录管理。

This commit is contained in:
2026-05-29 16:56:09 +08:00
parent 538e153473
commit 542895c61c
3 changed files with 490 additions and 278 deletions

View File

@@ -36,22 +36,49 @@
</el-button>
</div>
</div>
<!-- 常用工作流胶囊 -->
<div class="workflow-pills" v-if="commonWorkflows.length > 0">
<div
v-for="wf in commonWorkflows"
:key="wf.id"
class="workflow-pill"
:class="{ active: selectedWorkflowId === wf.id }"
@click="selectWorkflow(wf)"
>
<el-icon class="pill-icon">
<component :is="wf.icon" />
</el-icon>
<span class="pill-text">{{ wf.name }}</span>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
import { Top, Plus } from '@element-plus/icons-vue';
import { useRouter } from 'vue-router';
import { Top, Plus, MagicStick, Document, CircleCheck } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';
interface Emits {
(e: 'send', message: string): void;
}
interface Workflow {
id: number;
name: string;
icon: any;
prefix: string;
editPath: string;
}
const emit = defineEmits<Emits>();
const router = useRouter();
const message = ref('');
const selectedSkill = ref('default');
const selectedWorkflowId = ref<number | null>(null);
const skillLabels: Record<string, string> = {
default: '选择技能',
@@ -61,9 +88,7 @@ const skillLabels: Record<string, string> = {
};
const currentSkillDisplay = computed(() => {
return selectedSkill.value === 'default'
? '选择技能'
: skillLabels[selectedSkill.value];
return selectedSkill.value === 'default' ? '选择技能' : skillLabels[selectedSkill.value];
});
const skills: Record<string, string> = {
@@ -73,14 +98,49 @@ const skills: Record<string, string> = {
writing: '[技能:内容写作] 请根据下面的需求帮我创作内容:\n',
};
// 常用工作流列表
const commonWorkflows: Workflow[] = [
{
id: 1,
name: '审查+测试',
icon: Document,
prefix: '[工作流:审查+测试] 完成后请自动生成单元测试:\n',
editPath: '/settings/workflow',
},
{
id: 2,
name: '文档再编码',
icon: Document,
prefix: '[工作流:文档再编码] 请先编写接口文档,再实现代码:\n',
editPath: '/settings/workflow',
},
{
id: 3,
name: '代码重构',
icon: Document,
prefix: '[工作流:代码重构] 请帮我重构这段代码:\n',
editPath: '/settings/workflow',
},
{
id: 4,
name: '需求分析',
icon: Document,
prefix: '[工作流:需求分析] 请帮我分析这个需求并拆解任务:\n',
editPath: '/settings/workflow',
},
];
const handleSend = (event?: KeyboardEvent) => {
if (event) event.preventDefault();
const msg = message.value.trim();
if (!msg) return;
const skillPrefix = skills[selectedSkill.value] || '';
const finalMessage = (skillPrefix + msg).trim();
const workflowPrefix = selectedWorkflowId.value !== null ? commonWorkflows.find((w) => w.id === selectedWorkflowId.value)?.prefix || '' : '';
const finalMessage = (skillPrefix + workflowPrefix + msg).trim();
emit('send', finalMessage);
message.value = '';
// 发送后清空选择
selectedWorkflowId.value = null;
};
const handleAttachment = () => {
@@ -93,6 +153,16 @@ const handleSkillSelect = (key: string | number | object) => {
ElMessage.success(`已选择技能:${skillLabels[selectedSkill.value]}`);
}
};
const selectWorkflow = (wf: Workflow) => {
if (selectedWorkflowId.value === wf.id) {
selectedWorkflowId.value = null;
ElMessage.info('已取消工作流');
} else {
selectedWorkflowId.value = wf.id;
ElMessage.success(`已选择工作流:${wf.name}`);
}
};
</script>
<style scoped lang="scss">
@@ -117,7 +187,7 @@ const handleSkillSelect = (key: string | number | object) => {
0 24px 48px rgba(15, 23, 42, 0.12),
0 0 0 1px rgba(59, 130, 246, 0.08) inset,
0 8px 16px rgba(37, 99, 235, 0.1);
padding: 16px 18px 14px;
padding: 16px 18px 18px;
backdrop-filter: blur(16px);
}
@@ -213,4 +283,50 @@ const handleSkillSelect = (key: string | number | object) => {
background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
}
}
/* 工作流胶囊样式 */
.workflow-pills {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid rgba(59, 130, 246, 0.15);
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.workflow-pill {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border-radius: 999px;
border: 1px solid rgba(59, 130, 246, 0.3);
background: rgba(255, 255, 255, 0.6);
cursor: pointer;
transition: all 0.2s ease;
color: #475569;
&:hover {
border-color: #3b82f6;
background: rgba(59, 130, 246, 0.08);
transform: translateY(-1px);
}
&.active {
border-color: #3b82f6;
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
color: #ffffff;
box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}
.pill-icon {
font-size: 14px;
}
.pill-text {
font-size: 12px;
font-weight: 500;
line-height: 1.2;
}
}
</style>