Skip to content

Commit

Permalink
Merge pull request #323 from OpenWebGAL/dev
Browse files Browse the repository at this point in the history
4.5.8
  • Loading branch information
MakinoharaShoko authored Oct 28, 2024
2 parents d4ec761 + c5f7099 commit aee23cc
Show file tree
Hide file tree
Showing 26 changed files with 874 additions and 671 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webgal-terre",
"version": "4.5.7",
"version": "4.5.8",
"private": true,
"scripts": {
"dev": "concurrently \"yarn dev:terre\" \"yarn dev:origine\" \"yarn dev:start-dev-server\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/origine2/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webgal-origine-2",
"private": true,
"version": "4.5.7",
"version": "4.5.8",
"license": "MPL-2.0",
"scripts": {
"dev": "lingui extract && lingui compile --typescript && vite --host",
Expand Down
1 change: 1 addition & 0 deletions packages/origine2/src/components/Assets/Assets.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.controll {
display: flex;
flex-wrap: wrap;
padding: 8px;
gap: 4px;
align-items: center;
Expand Down
290 changes: 154 additions & 136 deletions packages/origine2/src/components/Assets/Assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function Assets({ basePath, isProtected = false, fileConfig, file
const isBasePath = (currentPathString === basePath.join('/'));
const folderType = fileConfig ? Array.from(fileConfig.entries()).find(([key]) => currentPathString.startsWith(key))?.[1].folderType : undefined;
const extName = folderType ? dirNameToExtNameMap.get(folderType) : [];
const filterText = useValue('');

const assetsFetcher = async () => {
const res = await api.assetsControllerReadAssets(currentPathString);
Expand All @@ -73,15 +74,19 @@ export default function Assets({ basePath, isProtected = false, fileConfig, file

const handleRefresh = () => mutate(currentPathString);
const handleOpenFolder = () => api.assetsControllerOpenDict(currentPathString);
const handleBack = () => !isBasePath && currentPath.set(currentPath.value.slice(0, currentPath.value.length - 1));
const handleBack = () => {
!isBasePath && currentPath.set(currentPath.value.slice(0, currentPath.value.length - 1));
filterText.set('');
};

const handleOpenFile = async (file: IFile) => {
if (file.isDir) {
currentPath.set([...currentPath.value, file.name]);
filterText.set('');
} else {
const pathFromBase = (currentPath.value.slice(basePath.length)).concat([file.name]).join('/');
const isScene = (folderType === 'scene') && file.name.endsWith('.txt');
fileFunction?.open && fileFunction.open({...file, pathFromBase}, isScene ? 'scene' : 'asset');
fileFunction?.open && fileFunction.open({ ...file, pathFromBase }, isScene ? 'scene' : 'asset');
}
};

Expand Down Expand Up @@ -147,128 +152,139 @@ export default function Assets({ basePath, isProtected = false, fileConfig, file
}}
>
<div className={styles.controll}>
{!isBasePath && <Button icon={<ArrowLeftIcon />} size='small' onClick={handleBack} />}
<div style={{ width: '100%', display: 'flex', gap: '0.25rem' }}>
{!isBasePath && <Button icon={<ArrowLeftIcon />} size='small' onClick={handleBack} />}
<Input
value={isBasePath ? '/' : currentPathString.replace(basePath.join('/'), '')}
size='small'
style={{ flexGrow: 1, minWidth: 0 }}
/>

{!isProtected && <>
<Popover
withArrow
open={createNewFilePopoverOpen.value}
onOpenChange={() => {
createNewFilePopoverOpen.set(!createNewFilePopoverOpen.value);
newFileName.set('');
}}
>
<PopoverTrigger>
<Button icon={<DocumentAddIcon />} size='small' />
</PopoverTrigger>
<PopoverSurface>
<div style={{ display: "flex", flexFlow: "column", gap: "16px" }}>
<Subtitle1>{t`新建文件`}</Subtitle1>
<Tooltip
content={{ children: t`已存在文件或文件夹 ${newFileName.value},请输入其他名称`, style: { color: 'var(--danger)' } }}
relationship="description"
visible={checkHasFile(newFileName.value.trim() + newFileExtensionName.value)}
positioning="below"

>
<Input
value={newFileName.value}
placeholder={t`新文件名`}
className={checkHasFile(newFileName.value.trim() + newFileExtensionName.value) ? styles.inputDanger : ''}
onChange={(_, data) => {
newFileName.set(data.value ?? "");
}} />
</Tooltip>
<Field label={t`扩展名`} size='small'>
<RadioGroup value={newFileExtensionName.value} onChange={(_, data) => newFileExtensionName.set(data.value)}>
<Radio value="" label={t`无`} />
<Radio value=".txt" label="txt" />
<Radio value=".json" label="json" />
</RadioGroup>
</Field>
<Button
appearance="primary"
disabled={disableCreateFile}
onClick={() => {
handleCreateNewFile(currentPathString, `${newFileName.value.trim()}${newFileExtensionName.value}`);
createNewFilePopoverOpen.set(false);
newFileName.set('');
}}
>{t`创建`}</Button>
</div>
</PopoverSurface>
</Popover>
<Popover
withArrow
open={createNewFolderPopoverOpen.value}
onOpenChange={() => {
createNewFolderPopoverOpen.set(!createNewFolderPopoverOpen.value);
newFileName.set('');
}}
>
<PopoverTrigger>
<Button icon={<FolderAddIcon />} size='small' />
</PopoverTrigger>
<PopoverSurface>
<div style={{ display: "flex", flexFlow: "column", gap: "16px" }}>
<Subtitle1>{t`新建文件夹`}</Subtitle1>
<Tooltip
content={{ children: t`已存在文件或文件夹 ${newFileName.value},请输入其他名称`, style: { color: 'var(--danger)' } }}
relationship="description"
visible={checkHasFile(newFileName.value.trim())}
positioning="below"
>
<Input
value={newFileName.value}
placeholder={t`新文件夹名`}
className={checkHasFile(newFileName.value.trim()) ? styles.inputDanger : ''}
onChange={(_, data) => {
newFileName.set(data.value ?? "");
}} />
</Tooltip>
<Button
appearance="primary"
disabled={disableCreateFile}
onClick={() => {
handleCreateNewFolder(currentPathString, newFileName.value.trim());
createNewFolderPopoverOpen.set(false);
newFileName.set('');
}}
>{t`创建`}</Button>
</div>
</PopoverSurface>
</Popover>
<Popover
withArrow
open={uploadAssetPopoverOpen.value}
onOpenChange={() => uploadAssetPopoverOpen.set(!uploadAssetPopoverOpen.value)}
>
<PopoverTrigger>
<Button icon={<ArrowExportUpIcon />} size='small' />
</PopoverTrigger>
<PopoverSurface>
<div style={{ display: "flex", flexFlow: "column", gap: "16px" }}>
<Subtitle1>{t`上传资源`}</Subtitle1>
<FileUploader onUpload={handleRefresh} targetDirectory={currentPathString} uploadUrl="/api/assets/upload" />
</div>
</PopoverSurface>
</Popover>
</>}

<Menu>
<MenuTrigger>
<Button icon={<MoreVerticalIcon />} size='small' />
</MenuTrigger>
<MenuPopover>
<MenuList>
<MenuItem icon={<ArrowSyncIcon />} onClick={handleRefresh} >{t`刷新`}</MenuItem>
<MenuItem icon={<FolderOpenIcon />} onClick={handleOpenFolder} >{t`打开文件夹`}</MenuItem>
</MenuList>
</MenuPopover>
</Menu>
</div>
<Input
value={isBasePath ? '/' : currentPathString.replace(basePath.join('/'), '')}
value={filterText.value}
onChange={(_, data) => filterText.set(data.value)}
placeholder={t`过滤文件`}
size='small'
style={{ flexGrow: 1, minWidth: 0 }}
style={{ width: '100%' }}
/>

{!isProtected && <>
<Popover
withArrow
open={createNewFilePopoverOpen.value}
onOpenChange={() => {
createNewFilePopoverOpen.set(!createNewFilePopoverOpen.value);
newFileName.set('');
}}
>
<PopoverTrigger>
<Button icon={<DocumentAddIcon />} size='small' />
</PopoverTrigger>
<PopoverSurface>
<div style={{ display: "flex", flexFlow: "column", gap: "16px" }}>
<Subtitle1>{t`新建文件`}</Subtitle1>
<Tooltip
content={{ children: t`已存在文件或文件夹 ${newFileName.value},请输入其他名称`, style: { color: 'var(--danger)' } }}
relationship="description"
visible={checkHasFile(newFileName.value.trim() + newFileExtensionName.value)}
positioning="below"

>
<Input
value={newFileName.value}
placeholder={t`新文件名`}
className={checkHasFile(newFileName.value.trim() + newFileExtensionName.value) ? styles.inputDanger : ''}
onChange={(_, data) => {
newFileName.set(data.value ?? "");
}} />
</Tooltip>
<Field label={t`扩展名`} size='small'>
<RadioGroup value={newFileExtensionName.value} onChange={(_, data) => newFileExtensionName.set(data.value)}>
<Radio value="" label={t`无`} />
<Radio value=".txt" label="txt" />
<Radio value=".json" label="json" />
</RadioGroup>
</Field>
<Button
appearance="primary"
disabled={disableCreateFile}
onClick={() => {
handleCreateNewFile(currentPathString, `${newFileName.value.trim()}${newFileExtensionName.value}`);
createNewFilePopoverOpen.set(false);
newFileName.set('');
}}
>{t`创建`}</Button>
</div>
</PopoverSurface>
</Popover><Popover
withArrow
open={createNewFolderPopoverOpen.value}
onOpenChange={() => {
createNewFolderPopoverOpen.set(!createNewFolderPopoverOpen.value);
newFileName.set('');
}}
>
<PopoverTrigger>
<Button icon={<FolderAddIcon />} size='small' />
</PopoverTrigger>
<PopoverSurface>
<div style={{ display: "flex", flexFlow: "column", gap: "16px" }}>
<Subtitle1>{t`新建文件夹`}</Subtitle1>
<Tooltip
content={{ children: t`已存在文件或文件夹 ${newFileName.value},请输入其他名称`, style: { color: 'var(--danger)' } }}
relationship="description"
visible={checkHasFile(newFileName.value.trim())}
positioning="below"
>
<Input
value={newFileName.value}
placeholder={t`新文件夹名`}
className={checkHasFile(newFileName.value.trim()) ? styles.inputDanger : ''}
onChange={(_, data) => {
newFileName.set(data.value ?? "");
}} />
</Tooltip>
<Button
appearance="primary"
disabled={disableCreateFile}
onClick={() => {
handleCreateNewFolder(currentPathString, newFileName.value.trim());
createNewFolderPopoverOpen.set(false);
newFileName.set('');
}}
>{t`创建`}</Button>
</div>
</PopoverSurface>
</Popover><Popover
withArrow
open={uploadAssetPopoverOpen.value}
onOpenChange={() => uploadAssetPopoverOpen.set(!uploadAssetPopoverOpen.value)}
>
<PopoverTrigger>
<Button icon={<ArrowExportUpIcon />} size='small' />
</PopoverTrigger>
<PopoverSurface>
<div style={{ display: "flex", flexFlow: "column", gap: "16px" }}>
<Subtitle1>{t`上传资源`}</Subtitle1>
<FileUploader onUpload={handleRefresh} targetDirectory={currentPathString} uploadUrl="/api/assets/upload" />
</div>
</PopoverSurface>
</Popover>
</>}

<Menu>
<MenuTrigger>
<Button icon={<MoreVerticalIcon />} size='small' />
</MenuTrigger>
<MenuPopover>
<MenuList>
<MenuItem icon={<ArrowSyncIcon />} onClick={handleRefresh} >{t`刷新`}</MenuItem>
<MenuItem icon={<FolderOpenIcon />} onClick={handleOpenFolder} >{t`打开文件夹`}</MenuItem>
</MenuList>
</MenuPopover>
</Menu>
</div>
{
extName && extName.length > 0 &&
Expand Down Expand Up @@ -296,21 +312,23 @@ export default function Assets({ basePath, isProtected = false, fileConfig, file
});
}}>
{
fileList?.map(file =>
(fileConfig?.get(`${currentPathString}/${file.name}`)?.isHidden) // 判断是否隐藏
? null
: <FileElement
key={file.name}
file={file}
desc={fileConfig?.get(`${currentPathString}/${file.name}`)?.desc ?? undefined}
currentPath={currentPath}
isProtected={fileConfig?.get(`${currentPathString}/${file.name}`)?.isProtected ?? isProtected}
handleOpenFile={handleOpenFile}
handleRenameFile={handleRenameFile}
handleDeleteFile={handleDeleteFile}
checkHasFile={checkHasFile}
/>
)
fileList
?.filter(file => file.name.toLocaleLowerCase().includes(filterText.value.toLocaleLowerCase()))
.map(file =>
(fileConfig?.get(`${currentPathString}/${file.name}`)?.isHidden) // 判断是否隐藏
? null
: <FileElement
key={file.name}
file={file}
desc={fileConfig?.get(`${currentPathString}/${file.name}`)?.desc ?? undefined}
currentPath={currentPath}
isProtected={fileConfig?.get(`${currentPathString}/${file.name}`)?.isProtected ?? isProtected}
handleOpenFile={handleOpenFile}
handleRenameFile={handleRenameFile}
handleDeleteFile={handleDeleteFile}
checkHasFile={checkHasFile}
/>
)
}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/origine2/src/config/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export interface Info {
}

export const __INFO: Info = {
version: '4.5.7',
version: '4.5.8',
buildTime: '2024-08-17T14:10:41.796Z', // 编译时会通过 version-sync.js 自动更新
};
Loading

0 comments on commit aee23cc

Please sign in to comment.