-
示例:
+
+
+ generateSampleQuestions(false)"
+ >
+ 示例:
+
+
+
{{ generatingQuestions ? 'AI生成中...' : '加载中...' }}
-
+
-
+
-
添加文件后自动生成
+
暂无问题,请点击左侧按钮生成
@@ -136,6 +147,7 @@ import { message } from 'ant-design-vue';
import { queryApi } from '@/apis/knowledge_api';
import {
SearchOutlined,
+ ReloadOutlined,
} from '@ant-design/icons-vue';
const store = useDatabaseStore();
@@ -170,7 +182,7 @@ let exampleCarouselInterval = null;
// 加载示例问题
const loadSampleQuestions = async () => {
if (!store.database?.db_id) return;
-
+
try {
loadingQuestions.value = true;
const data = await queryApi.getSampleQuestions(store.database.db_id);
@@ -202,7 +214,7 @@ const clearQuestions = () => {
// 生成示例问题
const generateSampleQuestions = async (silent = false) => {
if (!store.database?.db_id) return;
-
+
try {
generatingQuestions.value = true;
const data = await queryApi.generateSampleQuestions(store.database.db_id, 10);
@@ -311,10 +323,10 @@ const onQuery = async () => {
onMounted(async () => {
// 加载查询参数
store.loadQueryParams();
-
+
// 加载示例问题
await loadSampleQuestions();
-
+
// 如果有示例问题,启动轮播
if (queryExamples.value.length > 0) {
startExampleCarousel();
@@ -583,10 +595,21 @@ defineExpose({
flex-wrap: wrap;
}
-.examples-label {
- font-size: 12px;
+.examples-label-btn {
color: var(--gray-500);
- white-space: nowrap;
+ font-size: 12px;
+ display: flex;
+ align-items: center;
+ margin-left: -8px;
+
+ &:hover {
+ color: var(--main-color);
+ background-color: var(--gray-100);
+ }
+
+ .anticon { /* Target Ant Design icons directly */
+ font-size: 10px; /* Make icon smaller */
+ }
}
.examples-container {
@@ -607,8 +630,13 @@ defineExpose({
text-align: left;
white-space: normal;
height: auto;
- padding: 4px 8px;
+ padding: 0;
font-size: 12px;
+ color: var(--gray-500);
+
+ &:hover {
+ color: var(--main-color);
+ }
}
.fade-enter-active,
diff --git a/web/src/views/DataBaseInfoView.vue b/web/src/views/DataBaseInfoView.vue
index 51fee778..00789d3d 100644
--- a/web/src/views/DataBaseInfoView.vue
+++ b/web/src/views/DataBaseInfoView.vue
@@ -214,15 +214,24 @@ watch(
setTimeout(async () => {
console.log('文件数量变化,检查是否需要生成问题,querySectionRef:', querySectionRef.value);
if (querySectionRef.value) {
- console.log('开始重新生成问题...');
- await querySectionRef.value.generateSampleQuestions(true);
+ // 检查是否开启了自动生成问题
+ if (database.value.additional_params?.auto_generate_questions) {
+ console.log('开始重新生成问题...');
+ await querySectionRef.value.generateSampleQuestions(true);
+ } else {
+ console.log('自动生成问题已关闭,跳过生成');
+ }
} else {
console.warn('querySectionRef 未准备好,稍后重试');
// 如果组件还没准备好,再等一会儿
setTimeout(async () => {
if (querySectionRef.value) {
- console.log('延迟后开始生成问题...');
- await querySectionRef.value.generateSampleQuestions(true);
+ if (database.value.additional_params?.auto_generate_questions) {
+ console.log('延迟后开始生成问题...');
+ await querySectionRef.value.generateSampleQuestions(true);
+ } else {
+ console.log('自动生成问题已关闭,跳过生成');
+ }
}
}, 2000);
}