Skip to content

Commit

Permalink
fix: Optimize the export dialog files display/selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Feb 4, 2025
1 parent b8eea40 commit abbb884
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
9 changes: 4 additions & 5 deletions xmcl-keystone-ui/src/components/InstanceManifestFileItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@
chevron_right
</v-icon>
</div>
<dir
<div
v-if="!item.children"
class="mr-4"
>
<v-avatar v-if="item.avatar">
<v-avatar size="24" v-if="item.avatar">
<v-img
:src="item.avatar"
style="width: 24px; height: 24px;"
/>
</v-avatar>
<v-icon v-else>
{{ getIcon(item) }}
</v-icon>
</dir>
</div>

<div class="flex-grow flex flex-col justify-center">
<div :style="{ fontSize: '16px', lineHeight: '100%', ...item.style }">
Expand All @@ -55,7 +54,7 @@
</div>
<div
v-if="item.size > 0"
class="inline-flex gap-2"
class="inline-flex gap-2 items-center"
>
<span :style="{ opacity: 0.6, fontStyle: 'italic', fontSize: '12px' }">
{{ getExpectedSize(item.size) }}
Expand Down
6 changes: 6 additions & 0 deletions xmcl-keystone-ui/src/composables/instanceFileNodeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { InjectionKey, Ref } from 'vue'
import { InstanceFile } from '@xmcl/runtime-api'
import { basename } from '@/util/basename'
import { CSSProperties } from 'vue/types/jsx'
import { injection } from '@/util/inject'
import { kInstanceModsContext } from './instanceMods'

export interface InstanceFileNode<T = never> {
name: string
Expand All @@ -28,6 +30,7 @@ export type InstanceFileExportData = {
}

export function useInstanceFileNodesFromLocal(local: Ref<InstanceFile[]>) {
const { modsIconsMap } = injection(kInstanceModsContext)
function getFileNode(f: InstanceFile): InstanceFileNode<InstanceFileExportData> {
return reactive({
name: basename(f.path),
Expand All @@ -42,6 +45,9 @@ export function useInstanceFileNodesFromLocal(local: Ref<InstanceFile[]>) {
modrinth: !!f.modrinth,
},
children: undefined,
curseforge: !!f.curseforge,
modrinth: !!f.modrinth,
avatar: modsIconsMap.value[basename(f.path, '/')],
})
}
const result = ref(local.value.map(getFileNode))
Expand Down
2 changes: 2 additions & 0 deletions xmcl-keystone-ui/src/composables/instanceMods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { InjectionKey, Ref } from 'vue'
import { useLocalStorageCache } from './cache'
import { useService } from './service'
import { useState } from './syncableState'
import { basename } from '@/util/basename'

export const kInstanceModsContext: InjectionKey<ReturnType<typeof useInstanceMods>> = Symbol('instance-mods')

Expand Down Expand Up @@ -106,6 +107,7 @@ export function useInstanceMods(instancePath: Ref<string>, instanceRuntime: Ref<
for (const item of newItems) {
// Update icon map
newIconMap[item.modId] = item.icon
newIconMap[basename(item.path)] = item.icon
if (item.enabled) {
for (const [key, val] of Object.entries(item.provideRuntime)) {
runtime[key] = val
Expand Down
18 changes: 9 additions & 9 deletions xmcl-keystone-ui/src/views/AppExportDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,15 @@ const { refresh, refreshing } = useRefreshable(async () => {
const files = manifest.files
let selected = [] as string[]
selected = files
.filter(file => !file.path.startsWith('.'))
.filter(file => !file.path.startsWith('logs'))
.filter(file => !file.path.startsWith('crash-reports'))
.filter(file => !file.path.startsWith('saves'))
.filter(file => !file.path.startsWith('resourcepacks'))
.filter(file => !file.path.startsWith('screenshots'))
.filter(file => !file.path.startsWith('data'))
.filter(file => !file.path.startsWith('server'))
.filter(file => !exclusions.includes(file.path))
.filter(file => file.path.startsWith('resourcepacks')
|| file.path.startsWith('mods')
|| file.path.startsWith('config')
|| file.path.startsWith('scripts')
|| file.path.startsWith('shaderpacks')
|| file.path.startsWith('options.txt')
|| file.path.startsWith('optionsof.txt')
|| file.path.startsWith('servers.dat'))
.filter(file => !file.path.endsWith('.disabled'))
.map(file => file.path)
nextTick().then(() => { data.selected = selected })
data.files = files
Expand Down
3 changes: 3 additions & 0 deletions xmcl-runtime/instanceIO/InstanceFileDiscover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export async function discover(instancePath: string, logger: Logger, filter?: (r
if (relativePath === 'instance.json') {
return
}
if (relativePath === 'server' && status.isDirectory()) {
return
}
// no lib or exe
if (relativePath.endsWith('.dll') || relativePath.endsWith('.so') || relativePath.endsWith('.exe')) {
return
Expand Down

0 comments on commit abbb884

Please sign in to comment.