-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gui): add assets explorer drag & list display
- Loading branch information
Showing
7 changed files
with
172 additions
and
80 deletions.
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
10 changes: 9 additions & 1 deletion
10
packages/gui/client/components/explorer/AGUIExplorerControls.vue
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 |
---|---|---|
@@ -1,15 +1,23 @@ | ||
<script lang="ts" setup> | ||
import { AGUIInput } from '..' | ||
</script> | ||
|
||
<template> | ||
<div class="agui-explorer-controls"> | ||
<div /> | ||
<div class="flex-grow" /> | ||
<slot /> | ||
<AGUIInput class="w-30" /> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
.agui-explorer-controls { | ||
display: flex; | ||
align-items: center; | ||
padding: 0 4px; | ||
height: var(--agui-explorer-controls-height, 32px); | ||
border-bottom: 1px solid var(--agui-c-border, #222); | ||
} | ||
</style> |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export interface FileItem { | ||
filename: string | ||
filename?: string | ||
name?: string | ||
kind?: 'file' | 'directory' | ||
icon?: string | ||
ext?: string | ||
handle?: FileSystemDirectoryHandle | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/gui/client/components/explorer/useAssetsExplorer.ts
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ref } from 'vue' | ||
import type { Trees } from '../..' | ||
import type { FileItem } from './types' | ||
|
||
export const vscodeFolderIcon = 'i-vscode-icons-default-folder' | ||
export const curFileList = ref<FileItem[]>([]) | ||
export const tree = ref() | ||
|
||
export async function listFilesInDirectory(dirHandle: FileSystemDirectoryHandle, options: { | ||
showFiles?: boolean | ||
}) { | ||
const files: Trees = [] | ||
for await (const entry of dirHandle.values()) { | ||
// exclude | ||
if (entry.name.startsWith('.')) | ||
continue | ||
|
||
if (entry.kind === 'directory') { | ||
files.push({ | ||
name: entry.name, | ||
kind: entry.kind, | ||
handle: entry, | ||
children: await listFilesInDirectory(entry, options), | ||
}) | ||
} | ||
|
||
// ignore file | ||
if (options.showFiles) { | ||
if (entry.kind === 'file') { | ||
files.push({ | ||
name: entry.name, | ||
kind: entry.kind, | ||
handle: entry, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
curFileList.value = files | ||
return files | ||
} | ||
|
||
export async function onOpenDir() { | ||
const fileList = [] | ||
try { | ||
const dirHandle = await window.showDirectoryPicker() | ||
|
||
// directory handle 转换为树结构 | ||
// console.log(dir.entries()) | ||
fileList.push(...await listFilesInDirectory(dirHandle, { | ||
showFiles: false, | ||
})) | ||
tree.value = { | ||
name: dirHandle.name, | ||
handle: dirHandle, | ||
children: fileList, | ||
expanded: true, | ||
} | ||
} | ||
catch (e) { | ||
// user abort | ||
console.error(e) | ||
} | ||
} |
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
1179615
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.
Successfully deployed to the following URLs:
advjs-parser – ./
advjs-parser-yunyoujun.vercel.app
advjs-parser.vercel.app
advjs-parser-git-main-yunyoujun.vercel.app
parser.advjs.org