2026-05-26 16:01:13 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="input-shell">
|
|
|
|
|
<div class="input-card">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="message"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="1"
|
|
|
|
|
:autosize="{ minRows: 2, maxRows: 5 }"
|
|
|
|
|
placeholder="多说说你的偏好和要求,我会越用越懂你"
|
|
|
|
|
class="message-input"
|
|
|
|
|
@keydown.enter.exact="handleSend"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div class="input-toolbar">
|
|
|
|
|
<div class="toolbar-left">
|
|
|
|
|
<el-button circle class="tool-btn" @click="handleAttachment">
|
|
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
|
|
</el-button>
|
2026-05-26 17:58:23 +08:00
|
|
|
<el-dropdown trigger="click" @command="handleSkillSelect">
|
|
|
|
|
<el-button class="pill-btn">
|
|
|
|
|
{{ currentSkillDisplay }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<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="refactor">代码重构</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="writing">内容写作</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dropdown>
|
2026-05-26 16:01:13 +08:00
|
|
|
</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>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-05-26 17:58:23 +08:00
|
|
|
import { ref, computed } from 'vue';
|
2026-05-26 16:01:13 +08:00
|
|
|
import { Top, Plus } from '@element-plus/icons-vue';
|
|
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
|
|
|
|
|
interface Emits {
|
|
|
|
|
(e: 'send', message: string): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<Emits>();
|
|
|
|
|
const message = ref('');
|
2026-05-26 17:58:23 +08:00
|
|
|
const selectedSkill = ref('default');
|
|
|
|
|
|
|
|
|
|
const skillLabels: Record<string, string> = {
|
|
|
|
|
default: '选择技能',
|
|
|
|
|
'code-review': '代码审查',
|
|
|
|
|
refactor: '代码重构',
|
|
|
|
|
writing: '内容写作',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const currentSkillDisplay = computed(() => {
|
|
|
|
|
return selectedSkill.value === 'default'
|
|
|
|
|
? '选择技能'
|
|
|
|
|
: skillLabels[selectedSkill.value];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const skills: Record<string, string> = {
|
|
|
|
|
default: '',
|
|
|
|
|
'code-review': '[技能:代码审查] 请帮我审查下面这段代码,找出潜在问题并给出改进建议:\n',
|
|
|
|
|
refactor: '[技能:代码重构] 请帮我重构下面这段代码,提升可读性和可维护性:\n',
|
|
|
|
|
writing: '[技能:内容写作] 请根据下面的需求帮我创作内容:\n',
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-26 16:01:13 +08:00
|
|
|
const handleSend = (event?: KeyboardEvent) => {
|
|
|
|
|
if (event) event.preventDefault();
|
|
|
|
|
const msg = message.value.trim();
|
|
|
|
|
if (!msg) return;
|
2026-05-26 17:58:23 +08:00
|
|
|
const skillPrefix = skills[selectedSkill.value] || '';
|
2026-05-29 14:20:27 +08:00
|
|
|
const finalMessage = (skillPrefix + msg).trim();
|
2026-05-26 17:58:23 +08:00
|
|
|
emit('send', finalMessage);
|
2026-05-26 16:01:13 +08:00
|
|
|
message.value = '';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleAttachment = () => {
|
|
|
|
|
ElMessage.info('附件上传功能开发中...');
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-26 17:58:23 +08:00
|
|
|
const handleSkillSelect = (key: string | number | object) => {
|
|
|
|
|
selectedSkill.value = String(key);
|
|
|
|
|
if (selectedSkill.value !== 'default') {
|
|
|
|
|
ElMessage.success(`已选择技能:${skillLabels[selectedSkill.value]}`);
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-05-26 16:01:13 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.input-shell {
|
|
|
|
|
position: relative;
|
|
|
|
|
z-index: 12;
|
|
|
|
|
margin-top: -20px;
|
|
|
|
|
padding: 0 0 50px;
|
|
|
|
|
background: transparent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-card {
|
|
|
|
|
width: min(1060px, 82%);
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
background:
|
2026-05-26 17:58:23 +08:00
|
|
|
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;
|
2026-05-26 16:01:13 +08:00
|
|
|
box-shadow:
|
2026-05-26 17:58:23 +08:00
|
|
|
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;
|
|
|
|
|
backdrop-filter: blur(16px);
|
2026-05-26 16:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.message-input {
|
|
|
|
|
:deep(.el-textarea__inner) {
|
|
|
|
|
border: none;
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
resize: none;
|
|
|
|
|
padding: 8px 6px 14px;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
line-height: 1.65;
|
|
|
|
|
color: #0f172a;
|
|
|
|
|
background: transparent;
|
|
|
|
|
min-height: 50px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
|
color: #90a1b7;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-toolbar {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
padding-top: 2px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.toolbar-left,
|
|
|
|
|
.toolbar-right {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tool-btn {
|
2026-05-26 17:58:23 +08:00
|
|
|
width: 32px;
|
|
|
|
|
height: 32px;
|
2026-05-26 16:01:13 +08:00
|
|
|
border: 1px solid #d9e4f5;
|
|
|
|
|
color: #5b6b84;
|
|
|
|
|
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
|
2026-05-26 17:58:23 +08:00
|
|
|
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
|
|
|
|
|
transition: all 0.2s ease;
|
2026-05-26 16:01:13 +08:00
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
color: #2b4d8f;
|
2026-05-26 17:58:23 +08:00
|
|
|
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);
|
2026-05-26 16:01:13 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pill-btn {
|
2026-05-26 17:58:23 +08:00
|
|
|
height: 32px;
|
|
|
|
|
padding: 0 14px;
|
2026-05-26 16:01:13 +08:00
|
|
|
border-radius: 999px;
|
|
|
|
|
border: 1px solid #dbe7f7;
|
|
|
|
|
color: #30435f;
|
|
|
|
|
background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: 600;
|
2026-05-26 17:58:23 +08:00
|
|
|
transition: all 0.2s ease;
|
2026-05-26 16:01:13 +08:00
|
|
|
|
2026-05-26 17:58:23 +08:00
|
|
|
&:hover {
|
|
|
|
|
background: linear-gradient(135deg, #f0f7ff 0%, #e0edff 100%);
|
|
|
|
|
border-color: #bfdbfe;
|
|
|
|
|
color: #1d4ed8;
|
|
|
|
|
}
|
2026-05-26 16:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.send-btn {
|
2026-05-26 17:58:23 +08:00
|
|
|
width: 32px;
|
|
|
|
|
height: 32px;
|
2026-05-26 16:01:13 +08:00
|
|
|
border: none;
|
2026-05-26 17:58:23 +08:00
|
|
|
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
|
2026-05-26 16:01:13 +08:00
|
|
|
color: #fff;
|
2026-05-26 17:58:23 +08:00
|
|
|
box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
|
|
|
|
|
transition: all 0.2s ease;
|
2026-05-26 16:01:13 +08:00
|
|
|
|
|
|
|
|
&:hover:not(:disabled) {
|
2026-05-26 17:58:23 +08:00
|
|
|
filter: brightness(1.08);
|
2026-05-26 16:01:13 +08:00
|
|
|
transform: translateY(-1px);
|
2026-05-26 17:58:23 +08:00
|
|
|
box-shadow: 0 8px 20px rgba(59, 130, 246, 0.5);
|
2026-05-26 16:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:disabled {
|
2026-05-26 17:58:23 +08:00
|
|
|
opacity: 0.5;
|
2026-05-26 16:01:13 +08:00
|
|
|
box-shadow: none;
|
2026-05-26 17:58:23 +08:00
|
|
|
background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
|
2026-05-26 16:01:13 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|