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