|
@@ -156,11 +156,25 @@ export const unlockProjectFolder = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const copyTemplate = async (_e: Event, targetPath: string) => {
|
|
export const copyTemplate = async (_e: Event, targetPath: string) => {
|
|
|
- const templatePath = app.isPackaged
|
|
|
|
|
- ? path.join(process.resourcesPath, 'template/src')
|
|
|
|
|
- : path.join(process.cwd(), 'resources/template/src')
|
|
|
|
|
|
|
+ const templatePaths = app.isPackaged
|
|
|
|
|
+ ? [
|
|
|
|
|
+ path.join(process.resourcesPath, 'template/src'),
|
|
|
|
|
+ path.join(process.resourcesPath, 'app.asar.unpacked/resources/template/src')
|
|
|
|
|
+ ]
|
|
|
|
|
+ : [path.join(process.cwd(), 'resources/template/src')]
|
|
|
|
|
+ const templatePath = templatePaths.find((item) => fs.existsSync(item))
|
|
|
|
|
+
|
|
|
|
|
+ await fs.ensureDir(targetPath)
|
|
|
|
|
+ if (templatePath) {
|
|
|
|
|
+ await fs.copy(templatePath, targetPath)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- await fs.cpSync(templatePath, targetPath, { recursive: true })
|
|
|
|
|
|
|
+ await fs.ensureDir(path.join(targetPath, 'assets/images'))
|
|
|
|
|
+ await fs.ensureDir(path.join(targetPath, 'assets/fonts'))
|
|
|
|
|
+ await fs.ensureDir(path.join(targetPath, 'assets/others'))
|
|
|
|
|
+ // .gitkeep占位文件 创建后移除
|
|
|
|
|
+ await fs.remove(path.join(targetPath, 'assets/images/.gitkeep'))
|
|
|
|
|
+ await fs.remove(path.join(targetPath, 'assets/others/.gitkeep'))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function handleFile() {
|
|
export function handleFile() {
|