输入框工作流调整
This commit is contained in:
@@ -1,65 +1,92 @@
|
||||
<template>
|
||||
<div class="input-shell">
|
||||
<div class="input-card">
|
||||
<div class="input-card" :class="{ 'is-focused': isFocused }">
|
||||
<!-- 已选中状态标签栏 -->
|
||||
<div v-if="selectedWorkflowId !== null || selectedSkill !== 'default'" class="selected-tags">
|
||||
<div v-if="selectedWorkflowId !== null" class="selected-tag workflow-tag">
|
||||
<el-icon><Promotion /></el-icon>
|
||||
<span>{{ commonWorkflows.find((w) => w.id === selectedWorkflowId)?.name }}</span>
|
||||
<el-icon class="tag-close" @click="selectedWorkflowId = null"><Close /></el-icon>
|
||||
</div>
|
||||
<div v-if="selectedSkill !== 'default'" class="selected-tag skill-tag">
|
||||
<el-icon><MagicStick /></el-icon>
|
||||
<span>{{ skillLabels[selectedSkill] }}</span>
|
||||
<el-icon class="tag-close" @click="selectedSkill = 'default'"><Close /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 文本输入区 -->
|
||||
<el-input
|
||||
v-model="message"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
:autosize="{ minRows: 2, maxRows: 5 }"
|
||||
placeholder="多说说你的偏好和要求,我会越用越懂你"
|
||||
:autosize="{ minRows: 1, maxRows: 6 }"
|
||||
placeholder="有什么想聊的?按 Enter 发送,Shift+Enter 换行"
|
||||
class="message-input"
|
||||
@keydown.enter.exact="handleSend"
|
||||
@focus="isFocused = true"
|
||||
@blur="isFocused = false"
|
||||
@keydown.enter.exact.prevent="handleSend"
|
||||
@keydown.enter.shift.exact="() => {}"
|
||||
/>
|
||||
|
||||
<!-- 底部工具栏 -->
|
||||
<div class="input-toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-button circle class="tool-btn" @click="handleAttachment">
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-button>
|
||||
<el-dropdown trigger="click" @command="handleSkillSelect">
|
||||
<el-button class="pill-btn">
|
||||
{{ currentSkillDisplay }}
|
||||
</el-button>
|
||||
<!-- 上传附件 -->
|
||||
<el-tooltip content="上传文件" placement="top">
|
||||
<button class="tool-icon-btn" @click="handleAttachment">
|
||||
<el-icon><Paperclip /></el-icon>
|
||||
</button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 选择技能 -->
|
||||
<el-dropdown trigger="click" placement="top-start" @command="handleSkillSelect">
|
||||
<el-tooltip content="选择技能" placement="top">
|
||||
<button class="tool-icon-btn" :class="{ active: selectedSkill !== 'default' }">
|
||||
<el-icon><MagicStick /></el-icon>
|
||||
<span class="tool-label">技能</span>
|
||||
</button>
|
||||
</el-tooltip>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="default">默认对话</el-dropdown-item>
|
||||
<el-dropdown-item command="code-review">代码审查</el-dropdown-item>
|
||||
<el-dropdown-item command="default">
|
||||
<el-icon><CircleClose /></el-icon>不使用技能
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided command="code-review">代码审查</el-dropdown-item>
|
||||
<el-dropdown-item command="refactor">代码重构</el-dropdown-item>
|
||||
<el-dropdown-item command="writing">内容写作</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<el-button circle class="send-btn" :disabled="!message.trim()" @click="handleSend">
|
||||
<el-icon><Top /></el-icon>
|
||||
</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 class="toolbar-right">
|
||||
<span class="hint-text">Shift+Enter 换行</span>
|
||||
<button class="send-btn" :disabled="!message.trim()" @click="handleSend">
|
||||
<el-icon><Top /></el-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 快捷工作流胶囊(输入框下方) -->
|
||||
<div v-if="commonWorkflows.length > 0" class="workflow-shortcuts">
|
||||
<button
|
||||
v-for="wf in commonWorkflows"
|
||||
:key="wf.id"
|
||||
class="shortcut-pill"
|
||||
:class="{ active: selectedWorkflowId === wf.id }"
|
||||
@click="toggleWorkflow(wf.id)"
|
||||
>
|
||||
<el-icon><Promotion /></el-icon>
|
||||
{{ wf.name }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { Top, Plus, MagicStick, Document, CircleCheck } from '@element-plus/icons-vue';
|
||||
import { ref } from 'vue';
|
||||
import { Top, MagicStick, Promotion, Close, CircleClose, Paperclip } from '@element-plus/icons-vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
interface Emits {
|
||||
@@ -69,14 +96,12 @@ interface Emits {
|
||||
interface Workflow {
|
||||
id: number;
|
||||
name: string;
|
||||
icon: any;
|
||||
prefix: string;
|
||||
editPath: string;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
const router = useRouter();
|
||||
const message = ref('');
|
||||
const isFocused = ref(false);
|
||||
const selectedSkill = ref('default');
|
||||
const selectedWorkflowId = ref<number | null>(null);
|
||||
|
||||
@@ -87,59 +112,28 @@ const skillLabels: Record<string, string> = {
|
||||
writing: '内容写作',
|
||||
};
|
||||
|
||||
const currentSkillDisplay = computed(() => {
|
||||
return selectedSkill.value === 'default' ? '选择技能' : skillLabels[selectedSkill.value];
|
||||
});
|
||||
|
||||
const skills: Record<string, string> = {
|
||||
const skillPrefixes: Record<string, string> = {
|
||||
default: '',
|
||||
'code-review': '[技能:代码审查] 请帮我审查下面这段代码,找出潜在问题并给出改进建议:\n',
|
||||
refactor: '[技能:代码重构] 请帮我重构下面这段代码,提升可读性和可维护性:\n',
|
||||
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',
|
||||
},
|
||||
{ id: 1, name: '审查', prefix: '[工作流:审查] 完成后请自动生成单元测试:\n' },
|
||||
{ id: 2, name: '文档再编码', prefix: '[工作流:文档再编码] 请先编写接口文档,再实现代码:\n' },
|
||||
{ id: 3, name: '代码重构', prefix: '[工作流:代码重构] 请帮我重构这段代码:\n' },
|
||||
{ id: 4, name: '需求分析', prefix: '[工作流:需求分析] 请帮我分析这个需求并拆解任务:\n' },
|
||||
];
|
||||
|
||||
const handleSend = (event?: KeyboardEvent) => {
|
||||
if (event) event.preventDefault();
|
||||
const handleSend = () => {
|
||||
const msg = message.value.trim();
|
||||
if (!msg) return;
|
||||
const skillPrefix = skills[selectedSkill.value] || '';
|
||||
const skillPrefix = skillPrefixes[selectedSkill.value] || '';
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -147,186 +141,241 @@ const handleAttachment = () => {
|
||||
ElMessage.info('附件上传功能开发中...');
|
||||
};
|
||||
|
||||
const handleSkillSelect = (key: string | number | object) => {
|
||||
selectedSkill.value = String(key);
|
||||
if (selectedSkill.value !== 'default') {
|
||||
ElMessage.success(`已选择技能:${skillLabels[selectedSkill.value]}`);
|
||||
}
|
||||
const handleSkillSelect = (key: string | number | object | null) => {
|
||||
selectedSkill.value = String(key ?? 'default');
|
||||
};
|
||||
|
||||
const selectWorkflow = (wf: Workflow) => {
|
||||
if (selectedWorkflowId.value === wf.id) {
|
||||
selectedWorkflowId.value = null;
|
||||
ElMessage.info('已取消工作流');
|
||||
} else {
|
||||
selectedWorkflowId.value = wf.id;
|
||||
ElMessage.success(`已选择工作流:${wf.name}`);
|
||||
}
|
||||
const handleWorkflowSelect = (id: number | null) => {
|
||||
selectedWorkflowId.value = id;
|
||||
};
|
||||
|
||||
const toggleWorkflow = (id: number) => {
|
||||
selectedWorkflowId.value = selectedWorkflowId.value === id ? null : id;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.input-shell {
|
||||
position: relative;
|
||||
z-index: 12;
|
||||
margin-top: -20px;
|
||||
padding: 0 0 50px;
|
||||
padding: 0 24px 24px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.input-card {
|
||||
width: min(1060px, 82%);
|
||||
max-width: 860px;
|
||||
margin: 0 auto;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.94) 100%),
|
||||
radial-gradient(120% 180% at 0% 0%, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0) 38%),
|
||||
radial-gradient(80% 120% at 100% 100%, rgba(168, 85, 247, 0.08) 0%, rgba(168, 85, 247, 0) 38%);
|
||||
border: 1px solid rgba(59, 130, 246, 0.28);
|
||||
border-radius: 20px;
|
||||
box-shadow:
|
||||
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 18px;
|
||||
backdrop-filter: blur(16px);
|
||||
background: #fff;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
|
||||
transition:
|
||||
border-color 0.2s,
|
||||
box-shadow 0.2s;
|
||||
overflow: hidden;
|
||||
|
||||
&.is-focused {
|
||||
border-color: #93c5fd;
|
||||
box-shadow:
|
||||
0 0 0 3px rgba(59, 130, 246, 0.12),
|
||||
0 2px 12px rgba(15, 23, 42, 0.07);
|
||||
}
|
||||
}
|
||||
|
||||
/* 已选标签栏 */
|
||||
.selected-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding: 10px 14px 0;
|
||||
}
|
||||
|
||||
.selected-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 8px 3px 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
|
||||
&.workflow-tag {
|
||||
background: #eff6ff;
|
||||
color: #2563eb;
|
||||
border: 1px solid #bfdbfe;
|
||||
}
|
||||
|
||||
&.skill-tag {
|
||||
background: #f5f3ff;
|
||||
color: #7c3aed;
|
||||
border: 1px solid #ddd6fe;
|
||||
}
|
||||
|
||||
.tag-close {
|
||||
margin-left: 2px;
|
||||
cursor: pointer;
|
||||
opacity: 0.6;
|
||||
transition: opacity 0.15s;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 文本域 */
|
||||
.message-input {
|
||||
:deep(.el-textarea__inner) {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
resize: none;
|
||||
padding: 8px 6px 14px;
|
||||
padding: 14px 16px 8px;
|
||||
font-size: 15px;
|
||||
line-height: 1.65;
|
||||
line-height: 1.6;
|
||||
color: #0f172a;
|
||||
background: transparent;
|
||||
min-height: 50px;
|
||||
font-weight: 500;
|
||||
min-height: 28px !important;
|
||||
|
||||
&::placeholder {
|
||||
color: #90a1b7;
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部工具栏 */
|
||||
.input-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-top: 2px;
|
||||
padding: 6px 10px 10px 12px;
|
||||
}
|
||||
|
||||
.toolbar-left,
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.tool-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #d9e4f5;
|
||||
color: #5b6b84;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
|
||||
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
|
||||
transition: all 0.2s ease;
|
||||
.tool-icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 0.15s,
|
||||
color 0.15s;
|
||||
outline: none;
|
||||
|
||||
.el-icon {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #2b4d8f;
|
||||
background: linear-gradient(135deg, #f0f7ff 0%, #e0edff 100%);
|
||||
border-color: #bfdbfe;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
|
||||
background: #f1f5f9;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #eff6ff;
|
||||
color: #2563eb;
|
||||
}
|
||||
}
|
||||
|
||||
.pill-btn {
|
||||
height: 32px;
|
||||
padding: 0 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #dbe7f7;
|
||||
color: #30435f;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
|
||||
.tool-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #f0f7ff 0%, #e0edff 100%);
|
||||
border-color: #bfdbfe;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
.hint-text {
|
||||
font-size: 11px;
|
||||
color: #cbd5e1;
|
||||
margin-right: 6px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
|
||||
border-radius: 8px;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
|
||||
transition: all 0.2s ease;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 0.15s,
|
||||
transform 0.1s,
|
||||
opacity 0.15s;
|
||||
outline: none;
|
||||
|
||||
.el-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
filter: brightness(1.08);
|
||||
background: #1d4ed8;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 20px rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
box-shadow: none;
|
||||
background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
|
||||
background: #e2e8f0;
|
||||
color: #94a3b8;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* 工作流胶囊样式 */
|
||||
.workflow-pills {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid rgba(59, 130, 246, 0.15);
|
||||
/* 快捷工作流胶囊 */
|
||||
.workflow-shortcuts {
|
||||
max-width: 860px;
|
||||
margin: 10px auto 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.workflow-pill {
|
||||
.shortcut-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 10px;
|
||||
gap: 5px;
|
||||
height: 28px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
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;
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
color: #475569;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(4px);
|
||||
transition: all 0.15s;
|
||||
outline: none;
|
||||
|
||||
.el-icon {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #3b82f6;
|
||||
background: rgba(59, 130, 246, 0.08);
|
||||
transform: translateY(-1px);
|
||||
border-color: #93c5fd;
|
||||
color: #2563eb;
|
||||
background: rgba(239, 246, 255, 0.9);
|
||||
}
|
||||
|
||||
&.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;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user