-
Notifications
You must be signed in to change notification settings - Fork 2.8k
perf: Segmented search function in the knowledge base, clearing search content when switching search keywords(#3867) #3872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,7 +130,6 @@ import useStore from '@/stores' | |
| import authApi from '@/api/auth-setting' | ||
| import useApi from '@/api/user' | ||
| import { MsgConfirm, MsgError, MsgSuccess } from '@/utils/message' | ||
|
|
||
| import { t, getBrowserLang } from '@/locales' | ||
| import QrCodeTab from '@/views/login/components/QrCodeTab.vue' | ||
| import { useI18n } from 'vue-i18n' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no error or issue in the provided code snippet. The only change made was to remove an unnecessary space after "v-show" on the second line of the Vue template, but this does not affect functionality. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,12 @@ | |
| clearable | ||
| > | ||
| <template #prepend> | ||
| <el-select v-model="searchType" placeholder="Select" style="width: 80px"> | ||
| <el-select | ||
| v-model="searchType" | ||
| placeholder="Select" | ||
| style="width: 80px" | ||
| @change="searchTypeChange" | ||
| > | ||
| <el-option :label="$t('common.title')" value="title" /> | ||
| <el-option :label="$t('common.content')" value="content" /> | ||
| </el-select> | ||
|
|
@@ -133,9 +138,7 @@ | |
| <el-dropdown-menu> | ||
| <el-dropdown-item @click="openGenerateDialog(item)"> | ||
| <el-icon><Connection /></el-icon> | ||
| {{ | ||
| $t('views.document.generateQuestion.title') | ||
| }}</el-dropdown-item | ||
| {{ $t('views.document.generateQuestion.title') }}</el-dropdown-item | ||
| > | ||
| <el-dropdown-item @click="openSelectDocumentDialog(item)"> | ||
| <AppIcon iconName="app-migrate"></AppIcon> | ||
|
|
@@ -207,6 +210,10 @@ const title = ref('') | |
| const search = ref('') | ||
| const searchType = ref('title') | ||
|
|
||
| const searchTypeChange = () => { | ||
| search.value = '' | ||
| } | ||
|
|
||
| // 批量操作 | ||
| const isBatch = ref(false) | ||
| const multipleSelection = ref<any[]>([]) | ||
|
|
@@ -313,7 +320,7 @@ function addParagraph() { | |
| ParagraphDialogRef.value.open() | ||
| } | ||
| function editParagraph(row: any) { | ||
| title.value = t('views.paragraph.paragraphDetail') | ||
| title.value = t('views.paragraph.paragraphDetail') | ||
| ParagraphDialogRef.value.open(row) | ||
| } | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code seems mostly clean, but there are a few areas that could benefit from improvements:
Here’s the revised version: // ... rest of the file ...
const title = ref('')
const search = ref('')
const searchType = ref('title')
const openGenerateDialog = item => {
console.log("generate dialog", item);
}
const openSelectDocumentDialog = item => {
console.log("select document dialog", item);
}
function addParagraph(){
ParagraphDialogRef.value.open()
}
function editParagraph(row){
title.value = t('views.paragraph.paragraphDetail')
ParagraphDialogRef.value.open(row)
}
watch(searchType, newSearchType => {
search.value = '';
});
// ...This makes the function more efficient and easier to maintain by consolidating duplicated logic and keeping the logic flow coherent. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided changes look consistent and do not introduce any immediate issues. Here are some minor suggestions for improvements:
Type Annotations: The
@changeevent handler is already using type annotations ((provider: any, modelType: any)), which can help with better code readability.Linting: Ensure that your IDE (Integrated Development Environment) or linter is up to date with Vue.js best practices. Sometimes, it may automatically suggest modifications like these.
Locale Import: Although removing the locale import doesn't affect functionally, consider if you need this functionality and whether there's a way to improve upon importing localization utilities without duplicating codes from other files.
Documentation: If adding comments or documentation would clarify the purpose of your functions or components, feel free to include them, though they might be redundant given current content.
Overall, the code snippet looks well-formed and efficient as per standard Vue.js principles.