-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,157 additions
and
116 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ipcMain, IpcMainInvokeEvent } from 'electron' | ||
import fs from 'fs-extra' | ||
import archiver from 'archiver' | ||
|
||
interface ArchiveOption { | ||
file: string | ||
name: string | ||
} | ||
|
||
function archive(srcFiles: ArchiveOption[], dist: string): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
const output = fs.createWriteStream(dist) | ||
const archive = archiver('zip', { | ||
zlib: { level: 9 } | ||
}) | ||
|
||
output.on('end', resolve) | ||
archive.on('error', reject) | ||
archive.pipe(output) | ||
|
||
srcFiles.forEach(({ file, name }) => { | ||
archive.file(file, { name }) | ||
}) | ||
|
||
archive.finalize() | ||
}) | ||
} | ||
|
||
export async function handler(srcFiles: ArchiveOption[], dist: string): Promise<Engine.FileSystem.ArchiveSuccess|Engine.FileSystem.ArchiveFail> { | ||
try { | ||
await archive(srcFiles, dist) | ||
} catch (reason) { | ||
const { message } = reason as Error | ||
return { | ||
success: false, | ||
name: '압축 실패', | ||
message | ||
} | ||
} | ||
|
||
return { | ||
success: true, | ||
name: '압축 성공', | ||
message: '압축을 성공했습니다', | ||
path: dist | ||
} | ||
} | ||
|
||
export function ipc(): void { | ||
ipcMain.handle('archive', async (e: IpcMainInvokeEvent, srcFiles: ArchiveOption[], dist: string): Promise<Engine.FileSystem.ArchiveSuccess|Engine.FileSystem.ArchiveFail> => { | ||
return await handler(srcFiles, dist) | ||
}) | ||
} |
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,52 @@ | ||
import { ipcMain, IpcMainInvokeEvent } from 'electron' | ||
import fs from 'fs-extra' | ||
import Zip from 'adm-zip' | ||
|
||
function unzip(src: string, dist: string, overwrite: boolean): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
if (!fs.existsSync(src)) { | ||
const err = new Error(`The '${src}' file not exists.`) | ||
reject(err) | ||
} | ||
// todo: adm-zip 패키지에 매개변수 3개를 사용할 경우, 비동기 사용에 오류가 있음. | ||
// 버그가 수정되기 전까지 비동기 사용 금지 | ||
// https://github.com/cthackers/adm-zip/issues/407 | ||
// new Zip(src).extractAllToAsync(dist, overwrite, (err) => { | ||
// if (err) reject(err) | ||
// else resolve(dist) | ||
// }) | ||
try { | ||
new Zip(src).extractAllTo(dist, overwrite) | ||
resolve(src) | ||
} catch (reason) { | ||
reject(reason) | ||
} | ||
}) | ||
} | ||
|
||
export async function handler(src: string, dist: string, overwrite: boolean): Promise<Engine.FileSystem.UnzipSuccess|Engine.FileSystem.UnzipFail> { | ||
try { | ||
await unzip(src, dist, overwrite) | ||
} catch (reason) { | ||
const { message } = reason as Error | ||
return { | ||
success: false, | ||
name: '압축 해제 실패', | ||
message | ||
} | ||
} | ||
|
||
return { | ||
success: true, | ||
name: '압축 해제', | ||
message: '압축을 해제했습니다', | ||
src, | ||
dist | ||
} | ||
} | ||
|
||
export function ipc(): void { | ||
ipcMain.handle('unzip', async (e: IpcMainInvokeEvent, src: string, dist: string, overwrite: boolean = false): Promise<Engine.FileSystem.UnzipSuccess|Engine.FileSystem.UnzipFail> => { | ||
return await handler(src, dist, overwrite) | ||
}) | ||
} |
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
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,68 @@ | ||
<template> | ||
<v-card | ||
flat | ||
tile | ||
> | ||
<v-card-title>무료 에셋 추가</v-card-title> | ||
<v-card-subtitle>인터넷에 공개된 무료 에셋을 자동으로 프로젝트에 추가하거나, 스토어로 이동할 수 있습니다.</v-card-subtitle> | ||
<v-card-text> | ||
<v-alert | ||
type="info" | ||
class="text-caption" | ||
> | ||
아래 공개된 에셋은 퍼블릭 도메인의 에셋으로써, 창작자가 권리를 포기하고 무료 배포한 에셋입니다. | ||
<br> | ||
하지만 이러한 권리는 변경되었을 수 있으므로, 상세 내용은 스토어에서 직접 확인하십시오. | ||
</v-alert> | ||
<v-container class="py-10"> | ||
<v-row> | ||
<asset-appender-card | ||
v-for="(card, i) in list" | ||
:key="`card-${i}`" | ||
:namespace="card.namespace" | ||
:subtitle="card.subtitle" | ||
:source="card.source" | ||
:title="card.title" | ||
:color="card.color" | ||
:logo="card.logo" | ||
:url="card.url" | ||
class="mx-5" | ||
/> | ||
</v-row> | ||
</v-container> | ||
</v-card-text> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import path from 'path' | ||
import { defineComponent, ref } from '@vue/composition-api' | ||
import AssetAppenderCard, { Card } from './AssetAppenderCard.vue' | ||
export default defineComponent({ | ||
components: { | ||
AssetAppenderCard | ||
}, | ||
setup() { | ||
const isProduction = process.env.NODE_ENV === 'production' | ||
const resourcesPath = isProduction ? process.resourcesPath : path.resolve(process.cwd(), 'build') | ||
console.log(resourcesPath) | ||
const list = ref<Card[]>([ | ||
{ | ||
logo: 'https://www.kenney.nl/data/img/logo.png', | ||
title: 'Kenny Isometric Tiles', | ||
subtitle: 'Kenny.nl에서 제공한 무료 에셋을 프로젝트에 추가합니다.', | ||
source: path.resolve(resourcesPath, 'additional', 'FreeAssets', 'Kenny.zip'), | ||
namespace: 'Kenny-isometric-tiles', | ||
url: 'https://www.kenney.nl/', | ||
color: '#2ECC92', | ||
} | ||
]) | ||
return { | ||
list | ||
} | ||
}, | ||
}) | ||
</script> |
Oops, something went wrong.