mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-23 03:23:05 +00:00
refactoring wtutils, and added more stuff to it
This commit is contained in:
parent
9ff47247bd
commit
3fe0839f07
4 changed files with 37 additions and 22 deletions
|
@ -26,8 +26,8 @@ export default {
|
|||
return { langs: [] }
|
||||
},
|
||||
mounted() {
|
||||
var LangDir = wtutils.GetHome + '/locales';
|
||||
console.log('Ged LangDir: ' + LangDir)
|
||||
var LangDir = wtutils.Home + '/locales';
|
||||
console.log('Ged LangDir: ' + LangDir)
|
||||
var fs = require('fs');
|
||||
fs.readdir(LangDir, function(err, items) {
|
||||
console.log('Ged files: ' + items)
|
||||
|
|
|
@ -26,10 +26,10 @@ Vue.use(Buefy);
|
|||
const log = require('electron-log');
|
||||
log.transports.file.level = 'info';
|
||||
log.transports.console.level = 'verbose';
|
||||
log.transports.file.fileName = wtutils.GetAppName;
|
||||
log.transports.file.fileName = wtutils.AppName;
|
||||
console.log = log.log;
|
||||
log.info('*********************************')
|
||||
log.info('Starting ' + wtutils.GetAppName + ' Version:' + wtutils.GetAppVersion);
|
||||
log.info('Starting ' + wtutils.AppName + ' Version:' + wtutils.AppVersion);
|
||||
// Logging ended
|
||||
|
||||
wtutils.MoveToHome('./public/locales');
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import i18n from './i18n'
|
||||
import { shell } from 'electron'
|
||||
|
||||
import { wtutils} from './wtutils';
|
||||
//import { wtconfig } from './wtutils';
|
||||
|
||||
const isDev = require('electron-is-dev');
|
||||
|
||||
var appName = require('electron').remote.app.getName();
|
||||
var appHome = require('electron').remote.app.getPath('home')
|
||||
var logLinux = appHome + '/.config/' + appName + '/logs'
|
||||
var logLinux = wtutils.Home + '/.config/' + wtutils.AppName + '/logs'
|
||||
var logWin = appHome + '\\AppData\\Roaming\\' + appName + '\\logs'
|
||||
var logMac = appHome + '/Library/Logs/' + appName
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
const isLinux = process.platform === 'linux'
|
||||
const isWindows = process.platform === 'win32'
|
||||
//const isMac = process.platform === 'darwin'
|
||||
//const isLinux = process.platform === 'linux'
|
||||
//const isWindows = process.platform === 'win32'
|
||||
|
||||
// Menu template
|
||||
const menuTemplate = [
|
||||
|
@ -20,18 +23,18 @@ const menuTemplate = [
|
|||
label: i18n.t("Common.Menu.File.menuFile"),
|
||||
submenu:
|
||||
[
|
||||
isMac ?
|
||||
wtutils.isMac ?
|
||||
{
|
||||
label: i18n.t("Common.Menu.File.menuOpenLogDir"),
|
||||
click: () => { shell.openItem(logMac) }
|
||||
} :
|
||||
{
|
||||
...isLinux ?
|
||||
...wtutils.isLinux ?
|
||||
{
|
||||
label: i18n.t("Common.Menu.File.menuOpenLogDir"),
|
||||
click: () => { shell.openItem(logLinux) }
|
||||
} : {
|
||||
...isWindows ?
|
||||
...wtutils.isWindows ?
|
||||
{
|
||||
label: i18n.t("Common.Menu.File.menuOpenLogDir"),
|
||||
click: () => { shell.openItem(logWin) }
|
||||
|
|
|
@ -10,24 +10,36 @@ const electron = require('electron');
|
|||
const Store = require('electron-store');
|
||||
const wtconfig = new Store({name: require('electron').remote.app.getName()});
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
const isLinux = process.platform === 'linux'
|
||||
const isWindows = process.platform === 'win32'
|
||||
|
||||
const wtutils = new class WTUtils {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
get isDev() {
|
||||
return require('electron-is-dev');
|
||||
}
|
||||
|
||||
get isMac() {
|
||||
return process.platform === 'darwin'
|
||||
}
|
||||
|
||||
get isLinux() {
|
||||
return process.platform === 'linux'
|
||||
}
|
||||
|
||||
get isWindows() {
|
||||
return process.platform === 'win32'
|
||||
}
|
||||
|
||||
get GetHome() {
|
||||
get Home() {
|
||||
return (electron.app || electron.remote.app).getPath('userData');
|
||||
}
|
||||
|
||||
get GetAppName() {
|
||||
get AppName() {
|
||||
return (electron.app || electron.remote.app).getName();
|
||||
}
|
||||
|
||||
get GetAppVersion() {
|
||||
get AppVersion() {
|
||||
return (electron.app || electron.remote.app).getVersion();
|
||||
}
|
||||
|
||||
|
@ -35,12 +47,12 @@ const wtutils = new class WTUtils {
|
|||
|
||||
MoveToHome(SourceDir) {
|
||||
var last = wtconfig.get('general.transfilescopied', "0")
|
||||
if (!(last == wtutils.GetAppVersion))
|
||||
if (!(last == wtutils.AppVersion))
|
||||
{
|
||||
console.log('We need to copy translation strings over')
|
||||
var fs = require('fs');
|
||||
// Check if userdata/locales exists, and create if not
|
||||
var TargetDir = wtutils.GetHome + '/locales';
|
||||
var TargetDir = wtutils.Home + '/locales';
|
||||
if (!fs.existsSync(TargetDir)){
|
||||
fs.mkdirSync(TargetDir);
|
||||
}
|
||||
|
@ -53,7 +65,7 @@ const wtutils = new class WTUtils {
|
|||
});
|
||||
}
|
||||
});
|
||||
wtconfig.set('general.transfilescopied', wtutils.GetAppVersion)
|
||||
wtconfig.set('general.transfilescopied', wtutils.AppVersion)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,4 +83,4 @@ const wtutils = new class WTUtils {
|
|||
|
||||
|
||||
|
||||
export {wtutils, wtconfig, isLinux, isMac, isWindows};
|
||||
export {wtutils, wtconfig};
|
Loading…
Reference in a new issue