From 628b4889084d83a1b3618e13fde43627e1399f6b Mon Sep 17 00:00:00 2001 From: toyobayashi Date: Wed, 15 Aug 2018 22:47:54 +0800 Subject: [PATCH] [renderer] fix path problem --- README.md | 2 +- README_CN.md | 2 +- app/script/webpack.config.ts | 8 ++++- app/src/ts/renderer-back.ts | 15 +++++++++ app/src/ts/renderer/win.ts | 49 ++++------------------------ app/src/ts/template/back.template.ts | 2 ++ 6 files changed, 33 insertions(+), 45 deletions(-) create mode 100644 app/src/ts/renderer-back.ts create mode 100644 app/src/ts/template/back.template.ts diff --git a/README.md b/README.md index 8d31a5f..f632fc9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Webpack](https://img.shields.io/badge/dynamic/json.svg?label=webpack&url=https%3A%2F%2Fraw.githubusercontent.com%2Ftoyobayashi%2Fmishiro%2Fmaster%2Fapp%2Fpackage.json&query=%24.devDependencies.webpack&colorB=55a7dd)](https://webpack.js.org/) --> -[Release Download](https://github.com/toyobayashi/mishiro/releases) __(Windows Release Only)__ +[Release Download](https://github.com/toyobayashi/mishiro/releases) __(Windows Release Only. Do not install mishiro in a path which includes Chinese or Japanese characters)__ [中文](https://github.com/toyobayashi/mishiro/blob/master/README_CN.md) diff --git a/README_CN.md b/README_CN.md index e760810..67b0796 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,5 +1,5 @@ # mishiro -[戳这里下载](https://github.com/toyobayashi/mishiro/releases) __(只提供Windwos的发布版,MacOS请按照下面的步骤和[Electron分发应用](http://electronjs.org/docs/tutorial/application-distribution)自行编译打包)__ +[戳这里下载](https://github.com/toyobayashi/mishiro/releases) __(只提供Windwos的发布版,MacOS请按照下面的步骤和[Electron分发应用](http://electronjs.org/docs/tutorial/application-distribution)自行编译打包。请不要安装在有汉字的目录下)__ ## 用法 diff --git a/app/script/webpack.config.ts b/app/script/webpack.config.ts index 972714b..f15ae68 100644 --- a/app/script/webpack.config.ts +++ b/app/script/webpack.config.ts @@ -89,7 +89,8 @@ export const renderer: webpack.Configuration = { target: 'electron-renderer', entry: { 'mishiro.renderer': path.join(__dirname, '../src/ts/renderer.ts'), - 'mishiro.live': path.join(__dirname, '../src/ts/renderer-game.ts') + 'mishiro.live': path.join(__dirname, '../src/ts/renderer-game.ts'), + 'mishiro.back': path.join(__dirname, '../src/ts/renderer-back.ts') }, output: { path: path.join(__dirname, '../public'), @@ -145,6 +146,11 @@ export const renderer: webpack.Configuration = { inject: false, template: path.join(__dirname, '../src/ts/template/game.template.ts'), filename: 'game.html' + }), + new HtmlWebpackPlugin({ + inject: false, + template: path.join(__dirname, '../src/ts/template/back.template.ts'), + filename: 'back.html' }) ], optimization: { diff --git a/app/src/ts/renderer-back.ts b/app/src/ts/renderer-back.ts new file mode 100644 index 0000000..f2ac206 --- /dev/null +++ b/app/src/ts/renderer-back.ts @@ -0,0 +1,15 @@ +import './asar' +import { ipcRenderer, remote, Event } from 'electron' +import { util } from 'mishiro-core' +import { removeSync } from 'fs-extra' + +const BrowserWindow = remote.BrowserWindow +ipcRenderer.on('texture2d', (_event: Event, assetbundle: string, randomId: string, fromWindowId: number) => { + const fromWindow = BrowserWindow.fromId(fromWindowId) + util.unpackTexture2D(assetbundle).then(result => { + removeSync(assetbundle) + fromWindow.webContents.send(randomId, null, result) + }).catch(e => { + fromWindow.webContents.send(randomId, e, []) + }) +}) diff --git a/app/src/ts/renderer/win.ts b/app/src/ts/renderer/win.ts index 356ef2a..d170f4e 100644 --- a/app/src/ts/renderer/win.ts +++ b/app/src/ts/renderer/win.ts @@ -1,51 +1,16 @@ import { remote, BrowserWindow, ipcRenderer } from 'electron' -import { join } from 'path' +import getPath from '../common/get-path' +import { format } from 'url' let id = ipcRenderer.sendSync('mainWindowId') let win: BrowserWindow | null = new remote.BrowserWindow({ width: 346, height: 346, show: false, parent: remote.BrowserWindow.fromId(id) }) -win.loadURL(`data:text/html, - -`) +win.loadURL(format({ + pathname: getPath('./public/back.html'), + protocol: 'file:', + slashes: true +})) window.addEventListener('beforeunload', () => { if (win) win.close() diff --git a/app/src/ts/template/back.template.ts b/app/src/ts/template/back.template.ts new file mode 100644 index 0000000..e899269 --- /dev/null +++ b/app/src/ts/template/back.template.ts @@ -0,0 +1,2 @@ +export default ` +`