Skip to content

Commit cf4ce7e

Browse files
Merge pull request #405 from 1Panel-dev/pr@main@perf-cross_domain
跨域地址过滤空行
2 parents 7f30d03 + 8038385 commit cf4ce7e

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

ui/src/views/application-overview/component/SettingAPIKeyDialog.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ const submit = async (formEl: FormInstance | undefined) => {
7575
const obj = {
7676
allow_cross_domain: form.value.allow_cross_domain,
7777
cross_domain_list: form.value.cross_domain_list
78-
? form.value.cross_domain_list.split('\n')
78+
? form.value.cross_domain_list.split('\n').filter(function (item: string) {
79+
return item !== ''
80+
})
7981
: []
8082
}
8183
overviewApi.putAPIKey(id as string, APIKeyId.value, obj, loading).then((res) => {

ui/src/views/dataset/component/ParagraphPreview.vue

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
<span class="ml-4">{{ item?.name }}</span>
99
</div>
1010
</template>
11-
<el-scrollbar>
11+
<el-scrollbar ref="scrollRef" :key="index">
1212
<div class="mb-16">
1313
<el-text type="info">{{ item.content.length }} 段落</el-text>
1414
</div>
15-
16-
<div class="paragraph-list">
15+
<div class="paragraph-list" v-infinite-scroll="loadScroll">
1716
<el-card
18-
v-for="(child, cIndex) in item.content"
17+
v-for="(child, cIndex) in scrollData"
1918
:key="cIndex"
2019
shadow="never"
2120
class="card-never mb-16"
@@ -52,7 +51,7 @@
5251
/>
5352
</template>
5453
<script setup lang="ts">
55-
import { ref, reactive, onMounted, watch } from 'vue'
54+
import { ref, reactive, onMounted, watch, nextTick } from 'vue'
5655
import { cloneDeep } from 'lodash'
5756
import type { TabsPaneContext } from 'element-plus'
5857
import EditParagraphDialog from './EditParagraphDialog.vue'
@@ -70,23 +69,49 @@ const props = defineProps({
7069
const emit = defineEmits(['update:data'])
7170
7271
const EditParagraphDialogRef = ref()
72+
const scrollRef = ref()
7373
7474
const activeName = ref(0)
7575
const currentPIndex = ref(null) as any
7676
const currentCIndex = ref(null) as any
7777
7878
const newData = ref<any[]>([])
7979
80+
// 滚动加载数据
81+
const paginationConfig = reactive({
82+
current_page: 1,
83+
page_size: 20
84+
})
85+
86+
const scrollData = ref<any[]>([])
87+
8088
watch(
8189
() => props.data,
8290
(value) => {
8391
newData.value = value
92+
paginationConfig.current_page = 1
93+
nextTick(() => {
94+
scrollRef.value?.[activeName.value]?.scrollTo(0, 0)
95+
})
96+
scrollData.value = newData.value[activeName.value]?.content.slice(0, paginationConfig.page_size)
8497
},
8598
{
8699
immediate: true
87100
}
88101
)
89102
103+
function loadScroll() {
104+
if (newData.value[activeName.value]?.content.length > scrollData.value.length) {
105+
paginationConfig.current_page += 1
106+
scrollData.value.push(
107+
...newData.value[activeName.value].content.slice(
108+
(paginationConfig.current_page - 1) * paginationConfig.page_size,
109+
paginationConfig.current_page * paginationConfig.page_size
110+
)
111+
)
112+
}
113+
}
114+
90115
function editHandle(item: any, index: number, cIndex: number) {
91116
currentPIndex.value = index
92117
currentCIndex.value = cIndex
@@ -100,17 +125,22 @@ function deleteHandle(item: any, index: number, cIndex: number) {
100125
})
101126
.then(() => {
102127
newData.value[index].content.splice(cIndex, 1)
128+
scrollData.value.splice(cIndex, 1)
103129
emit('update:data', newData.value)
104130
})
105131
.catch(() => {})
106132
}
107133
108134
function updateContent(data: any) {
109135
newData.value[currentPIndex.value].content[currentCIndex.value] = cloneDeep(data)
136+
scrollData.value[currentCIndex.value] = cloneDeep(data)
110137
emit('update:data', newData.value)
111138
}
112139
113-
const handleClick = (tab: TabsPaneContext, event: Event) => {}
140+
const handleClick = (tab: TabsPaneContext, event: Event) => {
141+
paginationConfig.current_page = 1
142+
scrollData.value = newData.value[Number(tab.index)]?.content.slice(0, paginationConfig.page_size)
143+
}
114144
115145
onMounted(() => {})
116146
</script>

ui/src/views/dataset/step/StepSecond.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
<el-col :span="14" class="p-24 border-l">
9696
<div v-loading="loading">
9797
<h4 class="title-decoration-1 mb-8">分段预览</h4>
98+
9899
<ParagraphPreview v-model:data="paragraphList" :isConnect="checkedConnect" />
99100
</div>
100101
</el-col>

0 commit comments

Comments
 (0)