-
Notifications
You must be signed in to change notification settings - Fork 208
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
perf: Optimized interaction logic #1601
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,7 +200,6 @@ const props = withDefaults( | |
); | ||
|
||
const { t } = useI18n(); | ||
const message = useMessage(); | ||
const fileManageStore = useFileManageStore(); | ||
|
||
const isLoaded = ref(false); | ||
|
@@ -210,25 +209,6 @@ const settingDrawer = ref(false); | |
const tabDefaultValue = ref('fileManage'); | ||
const tableData = ref<RowData[]>([]); | ||
|
||
const actionItem = [ | ||
{ | ||
iconName: Delete, | ||
label: t('Delete'), | ||
type: 'error', | ||
onClick: (row: RowData) => { | ||
message.success(row.name); | ||
} | ||
}, | ||
{ | ||
iconName: CloudDownload, | ||
label: t('Download'), | ||
type: 'info', | ||
onClick: (row: RowData) => { | ||
message.success(row.name); | ||
} | ||
} | ||
]; | ||
|
||
watch( | ||
() => fileManageStore.fileList, | ||
fileList => { | ||
|
@@ -305,27 +285,61 @@ const createColumns = (): DataTableColumns<RowData> => { | |
{ | ||
default: () => [ | ||
h(NIcon, { | ||
size: '16', | ||
size: '18', | ||
component: Folder | ||
}), | ||
h( | ||
NEllipsis, | ||
NFlex, | ||
{ | ||
justify: 'center', | ||
align: 'flex-start', | ||
style: { | ||
maxWidth: '260px', | ||
cursor: 'pointer' | ||
flexDirection: 'column', | ||
rowGap: '0px' | ||
} | ||
}, | ||
{ | ||
default: () => | ||
default: () => [ | ||
h( | ||
NEllipsis, | ||
{ | ||
style: { | ||
maxWidth: '210px', | ||
cursor: 'pointer' | ||
} | ||
}, | ||
{ | ||
default: () => | ||
h( | ||
NText, | ||
{ | ||
depth: 1, | ||
strong: true | ||
}, | ||
{ | ||
default: () => row.name | ||
} | ||
) | ||
} | ||
), | ||
h( | ||
NText, | ||
{ | ||
depth: 1, | ||
strong: true | ||
depth: 3, | ||
strong: true, | ||
style: { | ||
fontSize: '10px' | ||
} | ||
}, | ||
{ default: () => row.name } | ||
{ | ||
default: () => { | ||
if (row.name === '..') return; | ||
|
||
return row.perm ? row.perm : '-'; | ||
} | ||
} | ||
) | ||
] | ||
} | ||
) | ||
] | ||
|
@@ -343,14 +357,9 @@ const createColumns = (): DataTableColumns<RowData> => { | |
}, | ||
render(row: RowData) { | ||
return h( | ||
NTag, | ||
NText, | ||
{ | ||
size: 'small', | ||
style: { | ||
marginRight: '6px' | ||
}, | ||
type: 'info', | ||
bordered: false | ||
depth: 1 | ||
}, | ||
{ | ||
default: () => { | ||
|
@@ -388,14 +397,10 @@ const createColumns = (): DataTableColumns<RowData> => { | |
align: 'center', | ||
render(row: RowData) { | ||
return h( | ||
NTag, | ||
NText, | ||
{ | ||
size: 'small', | ||
style: { | ||
marginRight: '6px' | ||
}, | ||
type: 'success', | ||
bordered: false | ||
depth: 1, | ||
strong: true | ||
}, | ||
{ | ||
default: () => getFileName(row) | ||
|
@@ -451,8 +456,4 @@ onBeforeUnmount(() => { | |
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
::v-deep(.n-data-table-td--last-col) { | ||
line-height: 100% !important; | ||
} | ||
</style> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet contains HTML, CSS, and TypeScript components. The main issue I noticed was some inconsistencies between JavaScript variables used within different blocks of code and the corresponding properties set at |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific example of the code provided, there appear to be no major problems at the moment since it seems well organized and follows proper coding practices. However, here are some potential optimizations that could potentially improve its performance or readability:
Use
computed
properties instead of local variables: The use of local variables such as_filePathList
,_showInner_
, etc., can sometimes cause memory leaks and make debugging harder. Local variables should be replaced with computed properties for reusability.Avoid unnecessary array creation: If creating an array only to then remove all elements immediately afterward will result in memory being freed unnecessarily, it might be more efficient to copy values into another data structure if necessary.
Optimize component name changes: Inlining
<n-flex>
and other layout components within<template #body></template>
blocks (#table-part
) can speed up rendering when they need access to their parent container's children.Avoid inline references when possible: Where possible, consider moving these parts outside a template section so they're loaded earlier than most HTML elements.
Ensure state updates are atomic: If updating paths during a file management operation would lead directly to unexpected results across multiple operations, consider synchronizing the path updates through a method like
useEffect
.Note that although these modifications may enhance the current implementation's efficiency, thorough tests should also be performed before implementing any significant optimization strategies to ensure they do not introduce regressions elsewhere in the system.