-
Notifications
You must be signed in to change notification settings - Fork 13
feat(CharList): set unavailable tags as dimmed #264
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
Draft
BobLiu0518
wants to merge
1
commit into
MooncellWiki:main
Choose a base branch
from
BobLiu0518:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -109,6 +109,10 @@ const currDataTypes: Ref<Record<string, boolean>> = ref({ | |
| const displayModes = ref(["表格", "半身像", "头像"]); | ||
| const currDisplayMode = ref("表格"); | ||
|
|
||
| const dimmedMaps: Record<string, any>[][] = reactive( | ||
| props.filters.map((fg) => fg.filter.map(() => ({}))), | ||
| ); | ||
|
|
||
| const toggleCollapse = (index: number) => { | ||
| expanded.value[index] = !expanded.value[index]; | ||
| Cookies.set("opFilterExpandState", JSON.stringify(expanded.value), { | ||
|
|
@@ -246,6 +250,56 @@ const oridata = computed(() => { | |
| } | ||
| return result; | ||
| }); | ||
|
|
||
| function computeDimmedMaps() { | ||
| for (let fi = 0; fi < props.filters.length; fi++) { | ||
| const fg = props.filters[fi]; | ||
| for (let fj = 0; fj < fg.filter.length; fj++) { | ||
| const f = fg.filter[fj]; | ||
| const labels = flat(f.cbt); | ||
| const map: Record<string, boolean> = {}; | ||
|
|
||
| // 创建 states 副本 | ||
| const tempStates = states.map((group) => | ||
| group.map((s) => ({ | ||
| both: s.both, | ||
| selected: { ...s.selected }, | ||
| meta: s.meta, | ||
| })), | ||
| ); | ||
|
|
||
| const originalSelected = tempStates[fi][fj].selected; | ||
|
|
||
| for (const label of labels) { | ||
| // 临时替换选中项为仅包含当前 label | ||
| tempStates[fi][fj].selected = { [label]: true }; | ||
|
|
||
| const exists = props.source.some((char) => { | ||
| for (const g of tempStates) { | ||
| for (const sf of g) { | ||
| if (!predicate(sf as State, char)) return false; | ||
| } | ||
| } | ||
| return true; | ||
| }); | ||
| map[label] = !exists; | ||
| } | ||
|
|
||
| tempStates[fi][fj].selected = originalSelected; | ||
| dimmedMaps[fi][fj] = map; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| computeDimmedMaps(); | ||
| watch( | ||
| states, | ||
| () => { | ||
| computeDimmedMaps(); | ||
| }, | ||
| { deep: true }, | ||
| ); | ||
|
Comment on lines
+294
to
+301
|
||
|
|
||
| watch(oridata, () => { | ||
| page.value.index = 1; | ||
| }); | ||
|
|
@@ -395,6 +449,7 @@ watch(data, () => { | |
| :labels="flat(v2.cbt)" | ||
| :show-both="v2.both" | ||
| :no-width="i === 2" | ||
| :dimmed-labels="dimmedMaps[i][i2]" | ||
| /> | ||
| </NCollapseTransition> | ||
| </div> | ||
|
|
||
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.
The computeDimmedMaps function has O(n³) complexity with nested loops over filters, labels, and source data. This could cause performance issues with large datasets. Consider implementing memoization or debouncing to avoid unnecessary recalculations, especially since it runs on every state change.