mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 06:55:36 +08:00
打包常用函数
This commit is contained in:
parent
3338b8ba14
commit
4c264bafc5
52
src/common.js
Normal file
52
src/common.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
exports.fofo = {
|
||||||
|
pluginInfo: function () {
|
||||||
|
return JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')))
|
||||||
|
},
|
||||||
|
|
||||||
|
isDev: function () {
|
||||||
|
return /[a-zA-Z0-9\-]+\.asar/.test(__dirname) ? false : true
|
||||||
|
},
|
||||||
|
|
||||||
|
pushData: function (databases, data) {
|
||||||
|
var db = utools.db.get(databases);
|
||||||
|
if (db) {
|
||||||
|
utools.db.put({ _id: databases, data: data, _rev: db._rev });
|
||||||
|
} else {
|
||||||
|
utools.db.put({ _id: databases, data: data });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
showChangeLog: function () {
|
||||||
|
this.pushData('plugin', { version: this.pluginInfo().version })
|
||||||
|
fs.readFile(path.join(__dirname, 'CHANGELOG.md'), { encoding: 'utf8' }, (err, data) => {
|
||||||
|
if (data) utools.ubrowser.goto(data, '更新日志').run({
|
||||||
|
width: 1080,
|
||||||
|
height: 860
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
isRunningAtFirstTime: function () {
|
||||||
|
try {
|
||||||
|
var historyVersion = utools.db.get('plugin').data.version
|
||||||
|
if (historyVersion != this.pluginInfo().version) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
GetFilePath: function (Path, File) {
|
||||||
|
if (isDev) {
|
||||||
|
return path.join(__dirname, Path, File)
|
||||||
|
} else {
|
||||||
|
return path.join(__dirname.replace(/([a-zA-Z0-9\-]+\.asar)/,'$1.unpacked'), Path, File)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,13 @@
|
|||||||
const { clipboard } = require('electron');
|
const { clipboard } = require('electron');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
|
||||||
//-------checkUpdate------
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require("path")
|
|
||||||
|
|
||||||
pluginInfo = JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')));
|
fofoCommon = require('./common').fofo
|
||||||
|
|
||||||
open = url => {
|
open = url => {
|
||||||
utools.shellOpenExternal(url);
|
utools.shellOpenExternal(url);
|
||||||
}
|
}
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
dirname = __dirname;
|
dirname = __dirname;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user