Skip to content

Commit

Permalink
修改反馈逻辑
Browse files Browse the repository at this point in the history
升级electron到2.0.5
  • Loading branch information
while committed Jul 31, 2018
1 parent 30cc971 commit 1b54c09
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 42 deletions.
2 changes: 1 addition & 1 deletion ScorpioPackageTool/.electron-vue/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
ignore: /(^\/(src|test|tools|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/,
out: path.join(__dirname, '../../build'),
overwrite: true,
appVersion: "1.0.0", //版本号
// appVersion: "1.0.0", //版本号
executableName: "ScorpioPackageTool", //可执行文件名称
/* platform: process.env.BUILD_TARGET || 'all', */
platform: process.platform === 'darwin' ? "darwin" : "win32",
Expand Down
80 changes: 51 additions & 29 deletions ScorpioPackageTool/.electron-vue/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ process.env.NODE_ENV = 'production'
const { say } = require('cfonts')
const copydir = require('copy-dir')
const path = require('path')
const fs = require('fs')
const chalk = require('chalk')
const del = require('del')
const packager = require('electron-packager')
Expand Down Expand Up @@ -49,7 +50,7 @@ function build () {
console.log(`\n\n${results}`)
console.log(`${okayLog}take it away ${chalk.yellow('`electron-packager`')}\n`)
bundleApp().then(result => {
copyTool(result)
buildAppSuccess(result)
}).catch(err => {
process.exit(1)
})
Expand Down Expand Up @@ -102,34 +103,6 @@ function pack (config) {
})
})
}

function bundleApp () {
return new Promise((resolve, reject) => {
packager(buildConfig, (err, appPaths) => {
if (err) {
console.log(`\n${errorLog}${chalk.yellow('`electron-packager`')} says...\n`)
console.log(err + '\n')
reject(err)
} else {
console.log(`\n${doneLog}\n`)
resolve(appPaths)
}
})
})
}
function copyTool(appPaths) {
for (var appPath of appPaths) {
var dir = ""
if (buildConfig.platform == "win32") {
dir = path.resolve(appPath, "resources/tools")
} else {
dir = path.resolve(appPath, "ScorpioPackageTool.app/Contents/Resources/tools")
}
console.log("复制所有工具 : " + dir)
copydir.sync(path.resolve(process.cwd(), "tools"), dir)
}
}

function web () {
del.sync(['dist/web/*', '!.gitkeep'])
webpack(webConfig, (err, stats) => {
Expand Down Expand Up @@ -161,3 +134,52 @@ function greeting () {
} else console.log(chalk.yellow.bold('\n lets-build'))
console.log()
}

function bundleApp () {
return new Promise((resolve, reject) => {
packager(buildConfig, (err, appPaths) => {
if (err) {
console.log(`\n${errorLog}${chalk.yellow('`electron-packager`')} says...\n`)
console.log(err + '\n')
reject(err)
} else {
console.log(`\n${doneLog}\n`)
resolve(appPaths)
}
})
})
}
function getResourcePath(appPath) {
if (buildConfig.platform == "win32") {
return path.resolve(appPath, "resources/")
} else {
return path.resolve(appPath, "ScorpioPackageTool.app/Contents/Resources/")
}
}
function buildAppSuccess(appPaths) {
copyTool(appPaths)
createInfos(appPaths)
}
function copyTool(appPaths) {
for (var appPath of appPaths) {
var dir = getResourcePath(appPath)
console.log("复制所有工具 : " + dir)
copydir.sync(path.resolve(process.cwd(), "tools"), path.resolve(dir, "tools"))
}
}
function createInfos(appPaths) {
var info = {
"date" : new Date().getTime()
}
var strInfo = JSON.stringify(info)
console.log("写入信息 : " + strInfo)
for (var appPath of appPaths) {
var dir = getResourcePath(appPath)
try {
fs.writeFileSync(path.resolve(dir, "info.json"), strInfo)
} catch (e) {
console.log(e)
}
}
}

2 changes: 1 addition & 1 deletion ScorpioPackageTool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"css-loader": "^0.28.4",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^2.0.2",
"electron": "^2.0.5",
"electron-debug": "^1.4.0",
"electron-devtools-installer": "^2.2.4",
"electron-packager": "^8.5.0",
Expand Down
2 changes: 1 addition & 1 deletion ScorpioPackageTool/src/main/application-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Electron: ${ele}
}
dialog.showMessageBox(options, function (index) {
if (index === 1) {
shell.openExternal(`mailto:bug@fengyuezhu.com?subject=ScorpioAndroidTool反馈&body=${options.detail}`)
shell.openExternal("https://github.com/qingfeng346/ScorpioPackageTool/issues/new")
}
})
}
Expand Down
28 changes: 20 additions & 8 deletions ScorpioPackageTool/src/renderer/common/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ var Util = (function() {
} else {
this.toolsPath = path.resolve(appInfo.path.appPath, "../tools")
}
this.buildInfo = this.getBuildInfo()
console.log("toolsPath : " + this.toolsPath)
console.log("dataPath : " + this.dataPath)
this.activeMenu = ""
console.log("buildInfo : " + JSON.stringify(this.buildInfo))
this.mkdir(this.dataPath)
this.mkdir(this.apkPath)
this.activeMenu = ""
this.event = new events()
ipcRenderer.on('showOpenDialogResult', this.showOpenDialogResult)
ipcRenderer.on("showMessageBoxResult", this.showMessageBoxResult)
Expand Down Expand Up @@ -321,6 +323,16 @@ var Util = (function() {
Util.getAppInfo = function() {
return ipcRenderer.sendSync('getAppInfo')
}
Util.getBuildInfo = function() {
var file = path.resolve(this.toolsPath, "../info.json")
if (fs.existsSync(file)) {
return JSON.parse(fs.readFileSync(file))
} else {
return {
"date" : new Date().getTime()
}
}
}
Util.showOpenDialog = function(options, args, callback) {
ShowOpenDialogCallback = callback
ipcRenderer.send('showOpenDialog', options, args)
Expand Down Expand Up @@ -379,12 +391,12 @@ var Util = (function() {
return await this.executeAsync(`${bat} -s ${id} ${command}`, "adb")
}
Util.getAndroidProp = async function(id, key) {
var bat = Util.IsWindows() ? "adb.exe" : "./adb";
var str = await this.shellAndroid(id, `getprop | grep ${key}`)
// console.log(str)
var start = str.lastIndexOf("[")
var end = str.lastIndexOf("]")
return str.substring(start + 1, end)
var str = await this.shellAndroid(id, `getprop ${key}`)
// // console.log(str)
// var start = str.lastIndexOf("[")
// var end = str.lastIndexOf("]")
// return str.substring(start + 1, end)
return str
}
Util.getAndroidDevices = async function() {
var bat = Util.IsWindows() ? "adb.exe" : "./adb";
Expand All @@ -398,7 +410,7 @@ var Util = (function() {
if (id == "") { continue; }
var model = await this.getAndroidProp(id, "ro.product.model")
var androidVersion = await this.getAndroidProp(id, "ro.build.version.sdk")
devices.push({id : id, model: model, androidVersion: androidVersion})
devices.push({id : id, model: model, androidVersion: androidVersion.trim()})
}
// console.log(JSON.stringify(devices))
return devices;
Expand Down
4 changes: 2 additions & 2 deletions ScorpioPackageTool/src/renderer/components/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<i class="el-icon-tickets"></i>
<span slot="title">文件</span>
</el-menu-item>
<el-menu-item index="operate">
<!-- <el-menu-item index="operate">
<i class="el-icon-menu"></i>
<span slot="title">操作</span>
</el-menu-item>
</el-menu-item> -->
</el-menu>
</el-aside>
<el-container>
Expand Down

0 comments on commit 1b54c09

Please sign in to comment.