refactor: 优化一些细节
(1)设置页面添加模型选择 (2)输入框添加自动Focus (3)优化模型选择器的样式
This commit is contained in:
parent
0b24bd36f4
commit
aeaeaad909
@ -17,7 +17,7 @@
|
||||
<PlusCircleOutlined />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<ModelSelectorComponent @select-model="handleModelSelect" />
|
||||
<ModelSelectorComponent class="nav-btn borderless" @select-model="handleModelSelect" />
|
||||
</div>
|
||||
<div class="header__right">
|
||||
<div class="nav-btn text" @click="opts.showPanel = !opts.showPanel">
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<div class="input-box" :class="customClasses">
|
||||
<div class="input-area">
|
||||
<a-textarea
|
||||
ref="inputRef"
|
||||
class="user-input"
|
||||
v-model:value="inputValue"
|
||||
@keydown="handleKeyPress"
|
||||
@ -32,7 +33,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, toRefs } from 'vue';
|
||||
import { ref, computed, toRefs, onMounted } from 'vue';
|
||||
import {
|
||||
SendOutlined,
|
||||
ArrowUpOutlined,
|
||||
@ -40,6 +41,8 @@ import {
|
||||
PauseOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
|
||||
|
||||
const inputRef = ref(null);
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
@ -107,6 +110,18 @@ const handleKeyPress = (e) => {
|
||||
const handleSendOrStop = () => {
|
||||
emit('send');
|
||||
};
|
||||
|
||||
|
||||
// Wait for component to mount before setting up onStartTyping
|
||||
onMounted(() => {
|
||||
// Use the template ref element for onStartTyping
|
||||
setTimeout(() => {
|
||||
if (inputRef.value) {
|
||||
inputRef.value.focus();
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<a-dropdown>
|
||||
<a class="model-select nav-btn" @click.prevent>
|
||||
<a class="model-select" @click.prevent>
|
||||
<BulbOutlined />
|
||||
<a-tooltip :title="configStore.config?.model_name" placement="right">
|
||||
<span class="model-text text"> {{ configStore.config?.model_name }} </span>
|
||||
@ -54,11 +54,25 @@ const handleSelectModel = (provider, name) => {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding: 0.25rem 0.5rem;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--gray-300);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
background-color: white;
|
||||
|
||||
&.borderless {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.model-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
|
||||
@ -17,25 +17,12 @@
|
||||
<a-button type="text" :class="{ activesec: state.section === 'user'}" @click="state.section='user'" :icon="h(UserOutlined)" v-if="userStore.isAdmin"> 用户管理 </a-button>
|
||||
</div>
|
||||
<div class="setting" v-if="state.windowWidth <= 520 || state.section === 'base'">
|
||||
<h3>功能配置</h3>
|
||||
<div class="section">
|
||||
<div class="card">
|
||||
<span class="label">{{ items?.enable_knowledge_base.des }}</span>
|
||||
<a-switch
|
||||
:checked="configStore.config.enable_knowledge_base"
|
||||
@change="handleChange('enable_knowledge_base', !configStore.config.enable_knowledge_base)"
|
||||
/>
|
||||
</div>
|
||||
<div class="card">
|
||||
<span class="label">{{ items?.enable_knowledge_graph.des }}</span>
|
||||
<a-switch
|
||||
:checked="configStore.config.enable_knowledge_graph"
|
||||
@change="handleChange('enable_knowledge_graph', !configStore.config.enable_knowledge_graph)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<h3>检索配置</h3>
|
||||
<div class="section">
|
||||
<div class="card card-select">
|
||||
<span class="label">对话模型</span>
|
||||
<ModelSelectorComponent @select-model="handleChatModelSelect" />
|
||||
</div>
|
||||
<div class="card card-select">
|
||||
<span class="label">{{ items?.embed_model.des }}</span>
|
||||
<a-select style="width: 300px"
|
||||
@ -81,6 +68,23 @@
|
||||
</a-select>
|
||||
</div>
|
||||
</div>
|
||||
<h3>功能配置</h3>
|
||||
<div class="section">
|
||||
<div class="card">
|
||||
<span class="label">{{ items?.enable_knowledge_base.des }}</span>
|
||||
<a-switch
|
||||
:checked="configStore.config.enable_knowledge_base"
|
||||
@change="handleChange('enable_knowledge_base', !configStore.config.enable_knowledge_base)"
|
||||
/>
|
||||
</div>
|
||||
<div class="card">
|
||||
<span class="label">{{ items?.enable_knowledge_graph.des }}</span>
|
||||
<a-switch
|
||||
:checked="configStore.config.enable_knowledge_graph"
|
||||
@change="handleChange('enable_knowledge_graph', !configStore.config.enable_knowledge_graph)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting" v-if="state.windowWidth <= 520 || state.section === 'model'">
|
||||
<h3>模型配置</h3>
|
||||
@ -121,6 +125,7 @@ import ModelProvidersComponent from '@/components/ModelProvidersComponent.vue';
|
||||
import UserManagementComponent from '@/components/UserManagementComponent.vue';
|
||||
import { notification, Button } from 'ant-design-vue';
|
||||
import { systemConfigApi } from '@/apis/admin_api'
|
||||
import ModelSelectorComponent from '@/components/ModelSelectorComponent.vue';
|
||||
|
||||
const configStore = useConfigStore()
|
||||
const userStore = useUserStore()
|
||||
@ -185,6 +190,13 @@ const updateWindowWidth = () => {
|
||||
state.windowWidth = window?.innerWidth || 0
|
||||
}
|
||||
|
||||
const handleChatModelSelect = ({ provider, name }) => {
|
||||
configStore.setConfigValues({
|
||||
model_provider: provider,
|
||||
model_name: name,
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateWindowWidth()
|
||||
window.addEventListener('resize', updateWindowWidth)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user