Skip to content
Merged
Show file tree
Hide file tree
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/components/dynamics-form/items/upload/UploadInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
>
<el-button type="primary">{{ $t('chat.uploadFile.label') }}</el-button>
<template #file="{ file }">
<el-card style="--el-card-padding: 0" shadow="never">
<el-card style="--el-card-padding: 0" shadow="never" class="upload_content">
<div
class="flex-between"
:class="[inputDisabled ? 'is-disabled' : '']"
Expand Down Expand Up @@ -112,13 +112,15 @@ const uploadFile = async (file: any, fileList: Array<any>) => {
})
}
</script>
<style lang="scss">
.is-disabled {
background-color: var(--el-fill-color-light);
color: var(--el-text-color-placeholder);
cursor: not-allowed;
&:hover {
<style lang="scss" scoped>
.upload_content {
.is-disabled {
background-color: var(--el-fill-color-light);
color: var(--el-text-color-placeholder);
cursor: not-allowed;
&:hover {
cursor: not-allowed;
}
}
}
</style>
19 changes: 17 additions & 2 deletions ui/src/layout/components/breadcrumb/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="breadcrumb ml-4 mt-4 mb-12 flex">
<back-button :to="toBackPath" class="mt-4"></back-button>
<back-button @click="toBack"></back-button>
<div class="flex align-center">
<el-avatar
v-if="isApplication"
Expand Down Expand Up @@ -30,8 +30,9 @@ import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router'
import { resetUrl } from '@/utils/common'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import useStore from '@/stores'
const { common, application } = useStore()
const { common, folder } = useStore()
const route = useRoute()
const router = useRouter()

const {
meta: { activeMenu },
Expand Down Expand Up @@ -104,6 +105,20 @@ function getApplicationDetail() {
})
}

function toBack() {
if (isKnowledge.value) {
folder.setCurrentFolder({
id: folderId,
})
} else if (isApplication.value) {
folder.setCurrentFolder({
id: current.value.folder,
})
}

router.push({ path: toBackPath.value })
}

onMounted(() => {
if (isKnowledge.value) {
getKnowledgeDetail()
Copy link
Contributor

Choose a reason for hiding this comment

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

The provided code appears to have several optimizations and bug fixes:

Optimizations:

  1. Removed Redundant Import Statements: The loadSharedApi import statement is not used anywhere in the snippet, so it can be removed.
  2. Refactored Back Navigation Logic: Moved the logic for handling different scenarios (knowledge and application folders) into its own function toBack(). This simplifies the routing process and enhances readability.

Potential Issues:

  1. Routing Guard Missing: No check is done before pushing a new URL, which might lead to unexpected behavior if multiple routes are handled.
  2. Error Handling: There's no error handling mechanism in place for fetching data via APIs. Ensure that each API call includes proper error checking.

Additional Suggestion:
Consider adding type annotations to make the code more maintainable. For example, you could annotate variables with their expected types:

let folderId:number | null = null;

Here’s an improved version of the code incorporating these changes:

// Improved Code Snippet

import { ref } from 'vue';
import BackButton from './components/BackButton.vue';
import { useStore } from '@/stores';

// ... rest of imports omitted ...

const { common, folder } = useStore();
const route = useRoute();
const router = useRouter();

let folderId: number | null = null; // Type annotation added

// ... rest of template and methods unchanged ...
  
onMounted(() => {
  if (isKnowledge.value) {
    getKnowledgeDetail();
    fetchFolderDetails(); // Function name should match actual implementation
  } else if (isApplication.value) {
    setCurrentApplicationFolder();
    fetchDataFromApplicationFolder();
  }

  // Add this line to check before navigation or handle errors appropriately
  if (!folderId || !router.isReady()) return;
});

async function getCurrentApplicationFolder(): Promise<void> {
  folderId = await fetchCurrentApplicationFolderAPI(route);
}

function setCurrentApplicationFolder(): void {
  folder.setCurrentFolder({ id: current.value.folder });
}

function toBack(): void {
  router.push({ path: toBackPath.value }).catch(err => console.error('Failed to push:', err));
}

Ensure to replace placeholder functions (fetchCurrentApplicationFolderAPI, etc.) with actual implementations according to your application architecture.

Expand Down
Loading
Loading