feat: 小鑫 AI 助手 - 前端构建打包、DuckDB 处理 Excel、设置与审批级别
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div class="input-bar">
|
||||
<textarea
|
||||
ref="ta"
|
||||
v-model="text"
|
||||
class="ta"
|
||||
:disabled="disabled"
|
||||
rows="1"
|
||||
placeholder="输入消息,Enter 发送,Shift+Enter 换行"
|
||||
@input="autoGrow"
|
||||
@keydown.enter.exact.prevent="submit"
|
||||
></textarea>
|
||||
<button class="send" :disabled="disabled || !text.trim()" @click="submit">
|
||||
<span v-if="!disabled">➤</span>
|
||||
<span v-else class="spinner"></span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick } from "vue";
|
||||
|
||||
defineProps<{ disabled?: boolean }>();
|
||||
const emit = defineEmits<{ send: [text: string] }>();
|
||||
|
||||
const text = ref("");
|
||||
const ta = ref<HTMLTextAreaElement | null>(null);
|
||||
|
||||
function autoGrow() {
|
||||
const el = ta.value;
|
||||
if (!el) return;
|
||||
el.style.height = "auto";
|
||||
el.style.height = Math.min(el.scrollHeight, 160) + "px";
|
||||
}
|
||||
|
||||
function submit() {
|
||||
const v = text.value.trim();
|
||||
if (!v) return;
|
||||
emit("send", v);
|
||||
text.value = "";
|
||||
nextTick(autoGrow);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.input-bar {
|
||||
display: flex; align-items: flex-end; gap: 10px;
|
||||
padding: 14px 20px;
|
||||
background: var(--surface);
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.ta {
|
||||
flex: 1; resize: none; border: 1px solid var(--border);
|
||||
background: var(--surface-2); color: var(--text);
|
||||
border-radius: 14px; padding: 12px 16px; font: inherit; font-size: 14.5px;
|
||||
line-height: 1.5; max-height: 160px; outline: none; transition: border-color 0.15s;
|
||||
}
|
||||
.ta:focus { border-color: var(--primary); }
|
||||
.ta:disabled { opacity: 0.6; }
|
||||
.send {
|
||||
width: 44px; height: 44px; flex-shrink: 0; border: none; border-radius: 12px;
|
||||
background: var(--primary); color: #fff; cursor: pointer; font-size: 16px;
|
||||
display: grid; place-items: center; transition: 0.15s;
|
||||
}
|
||||
.send:hover:not(:disabled) { background: var(--primary-hover); }
|
||||
.send:disabled { background: var(--text-dim); cursor: not-allowed; }
|
||||
.spinner {
|
||||
width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4);
|
||||
border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
</style>
|
||||
Reference in New Issue
Block a user