refactor: convert getList and getUserList functions to async for improved handling of asynchronous operations
--bug=1054152 --user=刘瑞斌 【函数库】筛选“我的”函数后刷新页面,还是显示的全部函数 https://www.tapd.cn/57709429/s/1678876
This commit is contained in:
parent
ec6657177a
commit
26946d0afb
@ -509,7 +509,10 @@ function importFunctionLib(file: any) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getList() {
|
async function getList() {
|
||||||
|
if (userOptions.value?.length === 0) {
|
||||||
|
await getUserList()
|
||||||
|
}
|
||||||
const params = {
|
const params = {
|
||||||
...(searchValue.value && { name: searchValue.value }),
|
...(searchValue.value && { name: searchValue.value }),
|
||||||
...(functionType.value && { function_type: functionType.value }),
|
...(functionType.value && { function_type: functionType.value }),
|
||||||
@ -545,28 +548,26 @@ function refresh(data: any) {
|
|||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserList() {
|
async function getUserList() {
|
||||||
applicationApi.getUserList('FUNCTION', loading).then((res) => {
|
const res = await applicationApi.getUserList('FUNCTION', loading)
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
userOptions.value = res.data.map((item: any) => {
|
userOptions.value = res.data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
label: item.username,
|
label: item.username,
|
||||||
value: item.id
|
value: item.id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (user.userInfo) {
|
if (user.userInfo) {
|
||||||
const selectUserIdValue = localStorage.getItem(user.userInfo.id + 'function')
|
const selectUserIdValue = localStorage.getItem(user.userInfo.id + 'function')
|
||||||
if (selectUserIdValue && userOptions.value.find((v) => v.value === selectUserIdValue)) {
|
if (selectUserIdValue && userOptions.value.find((v) => v.value === selectUserIdValue)) {
|
||||||
selectUserId.value = selectUserIdValue
|
selectUserId.value = selectUserIdValue
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// getList()
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getUserList()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user