Skip to content

Commit 26946d0

Browse files
committed
refactor: convert getList and getUserList functions to async for improved handling of asynchronous operations
--bug=1054152 --user=刘瑞斌 【函数库】筛选“我的”函数后刷新页面,还是显示的全部函数 https://www.tapd.cn/57709429/s/1678876
1 parent ec66571 commit 26946d0

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

ui/src/views/function-lib/index.vue

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,10 @@ function importFunctionLib(file: any) {
509509
})
510510
}
511511
512-
function getList() {
512+
async function getList() {
513+
if (userOptions.value?.length === 0) {
514+
await getUserList()
515+
}
513516
const params = {
514517
...(searchValue.value && { name: searchValue.value }),
515518
...(functionType.value && { function_type: functionType.value }),
@@ -545,28 +548,26 @@ function refresh(data: any) {
545548
getList()
546549
}
547550
548-
function getUserList() {
549-
applicationApi.getUserList('FUNCTION', loading).then((res) => {
550-
if (res.data) {
551-
userOptions.value = res.data.map((item: any) => {
552-
return {
553-
label: item.username,
554-
value: item.id
555-
}
556-
})
557-
if (user.userInfo) {
558-
const selectUserIdValue = localStorage.getItem(user.userInfo.id + 'function')
559-
if (selectUserIdValue && userOptions.value.find((v) => v.value === selectUserIdValue)) {
560-
selectUserId.value = selectUserIdValue
561-
}
551+
async function getUserList() {
552+
const res = await applicationApi.getUserList('FUNCTION', loading)
553+
if (res.data) {
554+
userOptions.value = res.data.map((item: any) => {
555+
return {
556+
label: item.username,
557+
value: item.id
558+
}
559+
})
560+
if (user.userInfo) {
561+
const selectUserIdValue = localStorage.getItem(user.userInfo.id + 'function')
562+
if (selectUserIdValue && userOptions.value.find((v) => v.value === selectUserIdValue)) {
563+
selectUserId.value = selectUserIdValue
562564
}
563-
// getList()
564565
}
565-
})
566+
}
566567
}
567568
568569
onMounted(() => {
569-
getUserList()
570+
570571
})
571572
</script>
572573
<style lang="scss" scoped>

0 commit comments

Comments
 (0)