Skip to content

fix: Application history log interface loading status display error #2151

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

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions ui/src/views/log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
</LayoutContainer>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, computed } from 'vue'
import { ref, type Ref, onMounted, reactive, computed } from 'vue'
import { useRoute } from 'vue-router'
import { cloneDeep } from 'lodash'
import ChatRecordDrawer from './component/ChatRecordDrawer.vue'
Expand Down Expand Up @@ -507,11 +507,13 @@ function getList() {
})
}
function getDetail() {
application.asyncGetApplicationDetail(id as string, loading).then((res: any) => {
detail.value = res.data
days.value = res.data.clean_time
})
function getDetail(isLoading = false) {
application
.asyncGetApplicationDetail(id as string, isLoading ? loading : undefined)
.then((res: any) => {
detail.value = res.data
days.value = res.data.clean_time
})
}
const exportLog = () => {
Expand Down Expand Up @@ -562,7 +564,7 @@ function saveCleanTime() {
.then(() => {
MsgSuccess(t('common.saveSuccess'))
dialogVisible.value = false
getDetail()
getDetail(true)
})
.catch(() => {
dialogVisible.value = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this code snippet, there are several minor improvements and optimizations:

  1. Type Annotations: Replace any with Ref<any> to improve type safety while utilizing Vue's reactivity system.

  2. Use of Parameters: The parameter definition for the getDetail function allows passing an optional boolean (isLoading) which sets the loading status dynamically. This is beneficial when you want to control whether the loading should occur or not based on certain conditions.

  3. Function Parameter Naming: Changed id as string to just id since it can be reliably converted to a string during the function call without needing explicit casting.

These changes enhance the readability, maintainability, and performance of the code by improving typesafety and reducing unnecessary conversions.

Expand Down