-
Notifications
You must be signed in to change notification settings - Fork 2.8k
perf: Resource management filters optimization #3815
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 |
|---|---|---|
|
|
@@ -98,21 +98,28 @@ | |
| </el-button> | ||
| </template> | ||
| <div class="filter"> | ||
| <div class="form-item mb-16"> | ||
| <div class="form-item mb-16 ml-4"> | ||
| <div @click.stop> | ||
| <el-scrollbar height="300" style="margin: 0 0 0 10px"> | ||
| <el-input | ||
| v-model="filterText" | ||
| :placeholder="$t('common.search')" | ||
| prefix-icon="Search" | ||
| clearable | ||
| /> | ||
| <el-scrollbar height="300" v-if="filterData.length"> | ||
| <el-checkbox-group | ||
| v-model="workspaceArr" | ||
| style="display: flex; flex-direction: column" | ||
| > | ||
| <el-checkbox | ||
| v-for="item in workspaceOptions" | ||
| v-for="item in filterData" | ||
| :key="item.value" | ||
| :label="item.label" | ||
| :value="item.value" | ||
| /> | ||
| </el-checkbox-group> | ||
| </el-scrollbar> | ||
| <el-empty v-else :description="$t('common.noData')" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
@@ -245,7 +252,7 @@ | |
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { onMounted, ref, reactive, computed } from 'vue' | ||
| import { onMounted, ref, reactive, computed, watch } from 'vue' | ||
| import { useRouter, useRoute } from 'vue-router' | ||
| import KnowledgeResourceApi from '@/api/system-resource-management/knowledge' | ||
| import UserApi from '@/api/user/user' | ||
|
|
@@ -349,10 +356,28 @@ function reEmbeddingKnowledge(row: any) { | |
| const workspaceOptions = ref<any[]>([]) | ||
| const workspaceVisible = ref(false) | ||
| const workspaceArr = ref<any[]>([]) | ||
|
|
||
| const filterText = ref('') | ||
| const filterData = ref<any[]>([]) | ||
|
|
||
| watch( | ||
| [() => workspaceOptions.value, () => filterText.value], | ||
| () => { | ||
| if (!filterText.value.length) { | ||
| filterData.value = workspaceOptions.value | ||
| } | ||
| filterData.value = workspaceOptions.value.filter((v: any) => | ||
| v.label.toLowerCase().includes(filterText.value.toLowerCase()), | ||
| ) | ||
| }, | ||
| { immediate: true }, | ||
| ) | ||
|
|
||
| function filterWorkspaceChange(val: string) { | ||
| if (val === 'clear') { | ||
| workspaceArr.value = [] | ||
| } | ||
| filterText.value = '' | ||
| getList() | ||
| workspaceVisible.value = false | ||
| } | ||
|
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. Potential Improvements
Note that this example assumes that |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,21 +120,28 @@ | |
| </el-button> | ||
| </template> | ||
| <div class="filter"> | ||
| <div class="form-item mb-16"> | ||
| <div class="form-item mb-16 ml-4"> | ||
| <div @click.stop> | ||
| <el-scrollbar height="300" style="margin: 0 0 0 10px"> | ||
| <el-input | ||
| v-model="filterText" | ||
| :placeholder="$t('common.search')" | ||
| prefix-icon="Search" | ||
| clearable | ||
| /> | ||
| <el-scrollbar height="300" v-if="filterData.length"> | ||
| <el-checkbox-group | ||
| v-model="workspaceArr" | ||
| style="display: flex; flex-direction: column" | ||
| > | ||
| <el-checkbox | ||
| v-for="item in workspaceOptions" | ||
| v-for="item in filterData" | ||
| :key="item.value" | ||
| :label="item.label" | ||
| :value="item.value" | ||
| /> | ||
| </el-checkbox-group> | ||
| </el-scrollbar> | ||
| <el-empty v-else :description="$t('common.noData')" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
@@ -230,7 +237,7 @@ | |
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { onBeforeMount, onMounted, ref, reactive, nextTick, computed } from 'vue' | ||
| import { onBeforeMount, onMounted, ref, reactive, watch, computed } from 'vue' | ||
| import type { Provider, Model } from '@/api/type/model' | ||
| import EditModel from '@/views/model/component/EditModel.vue' | ||
| import ParamSettingDialog from '@/views/model/component/ParamSettingDialog.vue' | ||
|
|
@@ -314,6 +321,22 @@ const getRowProvider = computed(() => { | |
| } | ||
| }) | ||
|
|
||
| const filterText = ref('') | ||
| const filterData = ref<any[]>([]) | ||
|
|
||
| watch( | ||
| [() => workspaceOptions.value, () => filterText.value], | ||
| () => { | ||
| if (!filterText.value.length) { | ||
| filterData.value = workspaceOptions.value | ||
| } | ||
| filterData.value = workspaceOptions.value.filter((v: any) => | ||
| v.label.toLowerCase().includes(filterText.value.toLowerCase()), | ||
| ) | ||
| }, | ||
| { immediate: true }, | ||
| ) | ||
|
|
||
| function filterWorkspaceChange(val: string) { | ||
| if (val === 'clear') { | ||
| workspaceArr.value = [] | ||
|
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. Potential Issues and Optimization Suggestions:
By addressing these suggestions, you'll improve the overall efficiency and cleanliness of your Vue.js component while maintaining functional correctness. |
||
|
|
||
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.
Code Review and Optimizations
General Improvements:
Import Statements: The import statements seem to be correctly set up with
@/api/system-resource-management/applicationand@/locales.Vue Functionality:
onMounted,ref, etc.) are properly imported under their respective namespaces (e.g.,vue,vue-router).Conditional Rendering and Logic:
v-if,v-else-if, andv-elsefor better clarity in conditional rendering.Component Communication:
createEffect,setup) are used correctly.Potential Issues and Suggestions:
Performance Check:
Validation:
Security:
Code Readability:
Translation Support:
State Management:
reactive.Overall, the code looks well-structured and follows recommended Vue.js patterns. Minor adjustments could improve performance and maintainability based on additional context and usage details provided.