Introduce: window-state, with discarded old window size
This commit is contained in:
parent
109170627f
commit
ffaa59cf88
|
@ -514,6 +514,7 @@ function resetNotfFilter(tlid) {
|
||||||
}
|
}
|
||||||
function notfFilter(id, tlid, acct_id) {
|
function notfFilter(id, tlid, acct_id) {
|
||||||
var excludetxt = localStorage.getItem('exclude-' + tlid)
|
var excludetxt = localStorage.getItem('exclude-' + tlid)
|
||||||
|
console.log(excludetxt)
|
||||||
if (excludetxt || excludetxt != '') {
|
if (excludetxt || excludetxt != '') {
|
||||||
excludetxt = excludetxt + '&account_id=' + id
|
excludetxt = excludetxt + '&account_id=' + id
|
||||||
} else {
|
} else {
|
||||||
|
|
63
app/main.js
63
app/main.js
|
@ -12,6 +12,7 @@ const np = require('./main/np.js')
|
||||||
const systemFunc = require('./main/system.js')
|
const systemFunc = require('./main/system.js')
|
||||||
const Menu = electron.Menu
|
const Menu = electron.Menu
|
||||||
const join = require('path').join
|
const join = require('path').join
|
||||||
|
const windowStateKeeper = require('electron-window-state')
|
||||||
|
|
||||||
// アプリケーションをコントロールするモジュール
|
// アプリケーションをコントロールするモジュール
|
||||||
const app = electron.app
|
const app = electron.app
|
||||||
|
@ -58,10 +59,10 @@ if (process.argv.indexOf('--dev') === -1) {
|
||||||
console.log('Welcome!')
|
console.log('Welcome!')
|
||||||
}
|
}
|
||||||
var info_path = join(app.getPath('userData'), 'window-size.json')
|
var info_path = join(app.getPath('userData'), 'window-size.json')
|
||||||
var max_info_path = join(app.getPath('userData'), 'max-window-size.json')
|
|
||||||
var lang_path = join(app.getPath('userData'), 'language')
|
var lang_path = join(app.getPath('userData'), 'language')
|
||||||
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
|
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
|
||||||
var ua_path = join(app.getPath('userData'), 'useragent')
|
var ua_path = join(app.getPath('userData'), 'useragent')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.readFileSync(ha_path, 'utf8')
|
fs.readFileSync(ha_path, 'utf8')
|
||||||
app.disableHardwareAcceleration()
|
app.disableHardwareAcceleration()
|
||||||
|
@ -69,26 +70,6 @@ try {
|
||||||
} catch {
|
} catch {
|
||||||
if (!packaged) console.log('enabled: Hardware Acceleration')
|
if (!packaged) console.log('enabled: Hardware Acceleration')
|
||||||
}
|
}
|
||||||
var window_size
|
|
||||||
try {
|
|
||||||
window_size = JSON.parse(fs.readFileSync(info_path, 'utf8'))
|
|
||||||
} catch (e) {
|
|
||||||
window_size = {
|
|
||||||
width: 1000,
|
|
||||||
height: 750
|
|
||||||
} // デフォルトバリュー
|
|
||||||
}
|
|
||||||
var max_window_size
|
|
||||||
try {
|
|
||||||
max_window_size = JSON.parse(fs.readFileSync(max_info_path, 'utf8'))
|
|
||||||
} catch (e) {
|
|
||||||
max_window_size = {
|
|
||||||
width: 'string',
|
|
||||||
height: 'string',
|
|
||||||
x: 'string',
|
|
||||||
y: 'string'
|
|
||||||
} // デフォルトバリュー
|
|
||||||
}
|
|
||||||
function isFile(file) {
|
function isFile(file) {
|
||||||
try {
|
try {
|
||||||
fs.statSync(file)
|
fs.statSync(file)
|
||||||
|
@ -103,6 +84,10 @@ app.on('window-all-closed', function() {
|
||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
|
let window_size = windowStateKeeper({
|
||||||
|
defaultWidth: 1000,
|
||||||
|
defaultHeight: 750
|
||||||
|
})
|
||||||
if (isFile(lang_path)) {
|
if (isFile(lang_path)) {
|
||||||
var lang = fs.readFileSync(lang_path, 'utf8')
|
var lang = fs.readFileSync(lang_path, 'utf8')
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,7 +162,7 @@ function createWindow() {
|
||||||
mainWindow = new BrowserWindow(arg)
|
mainWindow = new BrowserWindow(arg)
|
||||||
mainWindow.once('page-title-updated', () => {
|
mainWindow.once('page-title-updated', () => {
|
||||||
mainWindow.show()
|
mainWindow.show()
|
||||||
if (window_size.max) {
|
if (window_size.isMaximized) {
|
||||||
mainWindow.maximize()
|
mainWindow.maximize()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -215,9 +200,7 @@ function createWindow() {
|
||||||
.substring(0, N)
|
.substring(0, N)
|
||||||
}
|
}
|
||||||
mainWindow.loadURL(base + lang + '/index.html' + plus, { userAgent: ua })
|
mainWindow.loadURL(base + lang + '/index.html' + plus, { userAgent: ua })
|
||||||
if (!window_size.x && !window_size.y) {
|
window_size.manage(mainWindow)
|
||||||
mainWindow.center()
|
|
||||||
}
|
|
||||||
// ウィンドウが閉じられたらアプリも終了
|
// ウィンドウが閉じられたらアプリも終了
|
||||||
mainWindow.on('closed', function() {
|
mainWindow.on('closed', function() {
|
||||||
electron.ipcMain.removeAllListeners()
|
electron.ipcMain.removeAllListeners()
|
||||||
|
@ -225,7 +208,6 @@ function createWindow() {
|
||||||
})
|
})
|
||||||
closeArg = false
|
closeArg = false
|
||||||
mainWindow.on('close', function(e, arg) {
|
mainWindow.on('close', function(e, arg) {
|
||||||
writePos(mainWindow)
|
|
||||||
if (!closeArg) {
|
if (!closeArg) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
|
@ -244,36 +226,7 @@ function createWindow() {
|
||||||
closeArg = true
|
closeArg = true
|
||||||
mainWindow.close()
|
mainWindow.close()
|
||||||
})
|
})
|
||||||
function writePos(mainWindow) {
|
|
||||||
if (
|
|
||||||
max_window_size.width == mainWindow.getBounds().width &&
|
|
||||||
max_window_size.height == mainWindow.getBounds().height &&
|
|
||||||
max_window_size.x == mainWindow.getBounds().x &&
|
|
||||||
max_window_size.y == mainWindow.getBounds().y
|
|
||||||
) {
|
|
||||||
var size = {
|
|
||||||
width: mainWindow.getBounds().width,
|
|
||||||
height: mainWindow.getBounds().height,
|
|
||||||
x: mainWindow.getBounds().x,
|
|
||||||
y: mainWindow.getBounds().y,
|
|
||||||
max: true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var size = {
|
|
||||||
width: mainWindow.getBounds().width,
|
|
||||||
height: mainWindow.getBounds().height,
|
|
||||||
x: mainWindow.getBounds().x,
|
|
||||||
y: mainWindow.getBounds().y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fs.writeFileSync(info_path, JSON.stringify(size))
|
|
||||||
}
|
|
||||||
mainWindow.on('maximize', function() {
|
|
||||||
writePos(mainWindow)
|
|
||||||
fs.writeFileSync(max_info_path, JSON.stringify(mainWindow.getBounds()))
|
|
||||||
})
|
|
||||||
mainWindow.on('minimize', function() {
|
mainWindow.on('minimize', function() {
|
||||||
writePos(mainWindow)
|
|
||||||
mainWindow.webContents.send('asRead', '')
|
mainWindow.webContents.send('asRead', '')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,301 +1,313 @@
|
||||||
function system(mainWindow, dir, lang, dirname) {
|
function system(mainWindow, dir, lang, dirname) {
|
||||||
const electron = require("electron");
|
const electron = require('electron')
|
||||||
const app = electron.app;
|
const app = electron.app
|
||||||
const join = require("path").join;
|
const join = require('path').join
|
||||||
var Jimp = require("jimp");
|
var Jimp = require('jimp')
|
||||||
const fs = require("fs");
|
const fs = require('fs')
|
||||||
var JSON5 = require("json5");
|
var JSON5 = require('json5')
|
||||||
var ipc = electron.ipcMain;
|
var ipc = electron.ipcMain
|
||||||
const clipboard = electron.clipboard;
|
const clipboard = electron.clipboard
|
||||||
var tmp_img = join(app.getPath("userData"), "tmp.png");
|
var tmp_img = join(app.getPath('userData'), 'tmp.png')
|
||||||
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
|
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
|
||||||
var ua_path = join(app.getPath("userData"), "useragent");
|
var ua_path = join(app.getPath('userData'), 'useragent')
|
||||||
var lang_path = join(app.getPath("userData"), "language");
|
var lang_path = join(app.getPath('userData'), 'language')
|
||||||
var log_dir_path = join(app.getPath("userData"), "logs");
|
var log_dir_path = join(app.getPath('userData'), 'logs')
|
||||||
//ログ
|
//ログ
|
||||||
var today = new Date();
|
var today = new Date()
|
||||||
//今日のやつ
|
//今日のやつ
|
||||||
var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
|
var todayStr = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '.log'
|
||||||
//昨日のやつ
|
//昨日のやつ
|
||||||
today.setDate(today.getDate() - 1);
|
today.setDate(today.getDate() - 1)
|
||||||
var yestStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
|
var yestStr = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '.log'
|
||||||
//一昨日のやつ
|
//一昨日のやつ
|
||||||
today.setDate(today.getDate() - 1);
|
today.setDate(today.getDate() - 1)
|
||||||
var yest2Str = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
|
var yest2Str = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '.log'
|
||||||
|
|
||||||
const BrowserWindow = electron.BrowserWindow;
|
const BrowserWindow = electron.BrowserWindow
|
||||||
const dialog = electron.dialog;
|
const dialog = electron.dialog
|
||||||
const os = require("os");
|
const os = require('os')
|
||||||
const language = require("../main/language.js");
|
const language = require('../main/language.js')
|
||||||
//プラットフォーム
|
//プラットフォーム
|
||||||
ipc.on("getPlatform", function(e, arg) {
|
ipc.on('getPlatform', function(e, arg) {
|
||||||
try {
|
try {
|
||||||
var gitHash = fs.readFileSync("git", "utf8");
|
var gitHash = fs.readFileSync('git', 'utf8')
|
||||||
} catch {
|
} catch {
|
||||||
var gitHash = null;
|
var gitHash = null
|
||||||
}
|
}
|
||||||
e.sender.webContents.send("platform", [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]);
|
e.sender.webContents.send('platform', [
|
||||||
});
|
process.platform,
|
||||||
|
process.arch,
|
||||||
|
process.version,
|
||||||
|
process.versions.chrome,
|
||||||
|
process.versions.electron,
|
||||||
|
gitHash
|
||||||
|
])
|
||||||
|
})
|
||||||
//言語
|
//言語
|
||||||
ipc.on("lang", function(e, arg) {
|
ipc.on('lang', function(e, arg) {
|
||||||
console.log("set:" + arg);
|
console.log('set:' + arg)
|
||||||
fs.writeFileSync(lang_path, arg);
|
fs.writeFileSync(lang_path, arg)
|
||||||
e.sender.webContents.send("langres", arg);
|
e.sender.webContents.send('langres', arg)
|
||||||
});
|
})
|
||||||
//エクスポートのダイアログ
|
//エクスポートのダイアログ
|
||||||
ipc.on("exportSettings", function(e, args) {
|
ipc.on('exportSettings', function(e, args) {
|
||||||
dialog.showSaveDialog(
|
dialog.showSaveDialog(
|
||||||
mainWindow,
|
mainWindow,
|
||||||
{
|
{
|
||||||
title: "Export",
|
title: 'Export',
|
||||||
properties: ["openFile", "createDirectory"],
|
properties: ['openFile', 'createDirectory'],
|
||||||
defaultPath: "export.thedeskconfig.json5"
|
defaultPath: 'export.thedeskconfig.json5'
|
||||||
},
|
},
|
||||||
savedFiles => {
|
savedFiles => {
|
||||||
if (!savedFiles) {
|
if (!savedFiles) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
e.sender.webContents.send("exportSettingsFile", savedFiles);
|
e.sender.webContents.send('exportSettingsFile', savedFiles)
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
//インポートのダイアログ
|
//インポートのダイアログ
|
||||||
ipc.on("importSettings", function(e, args) {
|
ipc.on('importSettings', function(e, args) {
|
||||||
dialog.showOpenDialog(
|
dialog.showOpenDialog(
|
||||||
mainWindow,
|
mainWindow,
|
||||||
{
|
{
|
||||||
title: "Import",
|
title: 'Import',
|
||||||
properties: ["openFile"],
|
properties: ['openFile'],
|
||||||
filters: [{ name: "TheDesk Config", extensions: ["thedeskconfig", "thedeskconfigv2", "json5"] }]
|
filters: [
|
||||||
|
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
fileNames => {
|
fileNames => {
|
||||||
console.log("imported from: ", fileNames)
|
console.log('imported from: ', fileNames)
|
||||||
if (!fileNames) {
|
if (!fileNames) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
e.sender.webContents.send("config", JSON5.parse(fs.readFileSync(fileNames[0], "utf8")));
|
e.sender.webContents.send('config', JSON5.parse(fs.readFileSync(fileNames[0], 'utf8')))
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
//保存フォルダのダイアログ
|
//保存フォルダのダイアログ
|
||||||
ipc.on("savefolder", function(e, args) {
|
ipc.on('savefolder', function(e, args) {
|
||||||
dialog.showOpenDialog(
|
dialog.showOpenDialog(
|
||||||
mainWindow,
|
mainWindow,
|
||||||
{
|
{
|
||||||
title: "Save folder",
|
title: 'Save folder',
|
||||||
properties: ["openDirectory"]
|
properties: ['openDirectory']
|
||||||
},
|
},
|
||||||
fileNames => {
|
fileNames => {
|
||||||
e.sender.webContents.send("savefolder", fileNames[0]);
|
e.sender.webContents.send('savefolder', fileNames[0])
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
//カスタムサウンドのダイアログ
|
//カスタムサウンドのダイアログ
|
||||||
ipc.on("customSound", function(e, arg) {
|
ipc.on('customSound', function(e, arg) {
|
||||||
dialog.showOpenDialog(
|
dialog.showOpenDialog(
|
||||||
mainWindow,
|
mainWindow,
|
||||||
{
|
{
|
||||||
title: "Custom sound",
|
title: 'Custom sound',
|
||||||
properties: ["openFile"],
|
properties: ['openFile'],
|
||||||
filters: [{ name: "Audio", extensions: ["mp3", "aac", "wav", "flac", "m4a"] }, { name: "All", extensions: ["*"] }]
|
filters: [
|
||||||
|
{ name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] },
|
||||||
|
{ name: 'All', extensions: ['*'] }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
fileNames => {
|
fileNames => {
|
||||||
e.sender.webContents.send("customSoundRender", [arg, fileNames[0]]);
|
e.sender.webContents.send('customSoundRender', [arg, fileNames[0]])
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
|
|
||||||
//ハードウェアアクセラレーションの無効化
|
//ハードウェアアクセラレーションの無効化
|
||||||
ipc.on("ha", function(e, arg) {
|
ipc.on('ha', function(e, arg) {
|
||||||
if (arg == "true") {
|
if (arg == 'true') {
|
||||||
fs.writeFileSync(ha_path, arg);
|
fs.writeFileSync(ha_path, arg)
|
||||||
} else {
|
} else {
|
||||||
fs.unlink(ha_path, function(err) {});
|
fs.unlink(ha_path, function(err) {})
|
||||||
}
|
}
|
||||||
app.relaunch();
|
app.relaunch()
|
||||||
app.exit();
|
app.exit()
|
||||||
});
|
})
|
||||||
ipc.on("ua", function(e, arg) {
|
ipc.on('ua', function(e, arg) {
|
||||||
if (arg == "") {
|
if (arg == '') {
|
||||||
fs.unlink(ua_path, function(err) {});
|
fs.unlink(ua_path, function(err) {})
|
||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(ua_path, arg);
|
fs.writeFileSync(ua_path, arg)
|
||||||
}
|
}
|
||||||
app.relaunch();
|
app.relaunch()
|
||||||
app.exit();
|
app.exit()
|
||||||
});
|
})
|
||||||
|
|
||||||
ipc.on("quit", (e, args) => {
|
ipc.on('quit', (e, args) => {
|
||||||
app.quit();
|
app.quit()
|
||||||
});
|
})
|
||||||
ipc.on("about", (e, args) => {
|
ipc.on('about', (e, args) => {
|
||||||
about();
|
about()
|
||||||
});
|
})
|
||||||
function about() {
|
function about() {
|
||||||
var ver = app.getVersion();
|
var ver = app.getVersion()
|
||||||
var window = new BrowserWindow({
|
var window = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
webviewTag: false,
|
webviewTag: false,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
preload: join(dirname, "js", "platform", "preload.js")
|
preload: join(dirname, 'js', 'platform', 'preload.js')
|
||||||
},
|
},
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 500,
|
height: 500,
|
||||||
transparent: false, // ウィンドウの背景を透過
|
transparent: false, // ウィンドウの背景を透過
|
||||||
frame: false, // 枠の無いウィンドウ
|
frame: false, // 枠の無いウィンドウ
|
||||||
resizable: false
|
resizable: false
|
||||||
});
|
})
|
||||||
window.loadURL(dir + "/about.html?ver=" + ver);
|
window.loadURL(dir + '/about.html?ver=' + ver)
|
||||||
return "true";
|
return 'true'
|
||||||
}
|
}
|
||||||
ipc.on("nano", function(e, x, y) {
|
ipc.on('nano', function(e, x, y) {
|
||||||
var nano_info_path = join(app.getPath("userData"), "nano-window-position.json");
|
var nano_info_path = join(app.getPath('userData'), 'nano-window-position.json')
|
||||||
var window_pos;
|
var window_pos
|
||||||
try {
|
try {
|
||||||
window_pos = JSON.parse(fs.readFileSync(nano_info_path, "utf8"));
|
window_pos = JSON.parse(fs.readFileSync(nano_info_path, 'utf8'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window_pos = [0, 0]; // デフォルトバリュー
|
window_pos = [0, 0] // デフォルトバリュー
|
||||||
}
|
}
|
||||||
var nanowindow = new BrowserWindow({
|
var nanowindow = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
webviewTag: false,
|
webviewTag: false,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
preload: join(dirname, "js", "platform", "preload.js")
|
preload: join(dirname, 'js', 'platform', 'preload.js')
|
||||||
},
|
},
|
||||||
width: 350,
|
width: 350,
|
||||||
height: 140,
|
height: 140,
|
||||||
transparent: false, // ウィンドウの背景を透過
|
transparent: false, // ウィンドウの背景を透過
|
||||||
frame: false, // 枠の無いウィンドウ
|
frame: false, // 枠の無いウィンドウ
|
||||||
resizable: false
|
resizable: false
|
||||||
});
|
})
|
||||||
nanowindow.loadURL(dir + "/nano.html");
|
nanowindow.loadURL(dir + '/nano.html')
|
||||||
nanowindow.setAlwaysOnTop(true);
|
nanowindow.setAlwaysOnTop(true)
|
||||||
//nanowindow.toggleDevTools()
|
//nanowindow.toggleDevTools()
|
||||||
nanowindow.setPosition(window_pos[0], window_pos[1]);
|
nanowindow.setPosition(window_pos[0], window_pos[1])
|
||||||
nanowindow.on("close", function() {
|
nanowindow.on('close', function() {
|
||||||
fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition()));
|
fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition()))
|
||||||
});
|
})
|
||||||
return true;
|
return true
|
||||||
});
|
})
|
||||||
var cbTimer1;
|
var cbTimer1
|
||||||
ipc.on("startmem", (e, arg) => {
|
ipc.on('startmem', (e, arg) => {
|
||||||
event = e.sender;
|
event = e.sender
|
||||||
cbTimer1 = setInterval(mems, 1000);
|
cbTimer1 = setInterval(mems, 1000)
|
||||||
});
|
})
|
||||||
function mems() {
|
function mems() {
|
||||||
var mem = os.totalmem() - os.freemem();
|
var mem = os.totalmem() - os.freemem()
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
event.webContents.send("memory", [mem, os.cpus()[0].model, os.totalmem()]);
|
event.webContents.send('memory', [mem, os.cpus()[0].model, os.totalmem()])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ipc.on("endmem", (e, arg) => {
|
ipc.on('endmem', (e, arg) => {
|
||||||
if (cbTimer1) {
|
if (cbTimer1) {
|
||||||
clearInterval(cbTimer1);
|
clearInterval(cbTimer1)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
ipc.on("export", (e, args) => {
|
ipc.on('export', (e, args) => {
|
||||||
fs.writeFileSync(args[0], JSON5.stringify(args[1]));
|
fs.writeFileSync(args[0], JSON5.stringify(args[1]))
|
||||||
e.sender.webContents.send("exportAllComplete", "");
|
e.sender.webContents.send('exportAllComplete', '')
|
||||||
});
|
})
|
||||||
//フォント
|
//フォント
|
||||||
function object_array_sort(data, key, order, fn) {
|
function object_array_sort(data, key, order, fn) {
|
||||||
//デフォは降順(DESC)
|
//デフォは降順(DESC)
|
||||||
var num_a = -1;
|
var num_a = -1
|
||||||
var num_b = 1;
|
var num_b = 1
|
||||||
|
|
||||||
if (order === "asc") {
|
if (order === 'asc') {
|
||||||
//指定があれば昇順(ASC)
|
//指定があれば昇順(ASC)
|
||||||
num_a = 1;
|
num_a = 1
|
||||||
num_b = -1;
|
num_b = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data.sort(function(a, b) {
|
data = data.sort(function(a, b) {
|
||||||
var x = a[key];
|
var x = a[key]
|
||||||
var y = b[key];
|
var y = b[key]
|
||||||
if (x > y) return num_a;
|
if (x > y) return num_a
|
||||||
if (x < y) return num_b;
|
if (x < y) return num_b
|
||||||
return 0;
|
return 0
|
||||||
});
|
})
|
||||||
|
|
||||||
//重複排除
|
//重複排除
|
||||||
var arrObj = {};
|
var arrObj = {}
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
arrObj[data[i]["family"]] = data[i];
|
arrObj[data[i]['family']] = data[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
data = [];
|
data = []
|
||||||
for (var key in arrObj) {
|
for (var key in arrObj) {
|
||||||
data.push(arrObj[key]);
|
data.push(arrObj[key])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn(data); // ソート後の配列を返す
|
fn(data) // ソート後の配列を返す
|
||||||
}
|
}
|
||||||
ipc.on("fonts", (e, arg) => {
|
ipc.on('fonts', (e, arg) => {
|
||||||
const fm = require("font-manager");
|
const fm = require('font-manager')
|
||||||
var fonts = fm.getAvailableFontsSync();
|
var fonts = fm.getAvailableFontsSync()
|
||||||
object_array_sort(fonts, "family", "asc", function(fonts_sorted) {
|
object_array_sort(fonts, 'family', 'asc', function(fonts_sorted) {
|
||||||
e.sender.webContents.send("font-list", fonts_sorted);
|
e.sender.webContents.send('font-list', fonts_sorted)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
//コピー
|
//コピー
|
||||||
ipc.on("copy", (e, arg) => {
|
ipc.on('copy', (e, arg) => {
|
||||||
clipboard.writeText(arg);
|
clipboard.writeText(arg)
|
||||||
});
|
})
|
||||||
//ログ
|
//ログ
|
||||||
ipc.on("log", (e, arg) => {
|
ipc.on('log', (e, arg) => {
|
||||||
var today = new Date();
|
var today = new Date()
|
||||||
var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate();
|
var todayStr = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate()
|
||||||
var log_path = join(log_dir_path, todayStr + ".log");
|
var log_path = join(log_dir_path, todayStr + '.log')
|
||||||
fs.appendFile(log_path, "\n" + arg, function(err) {
|
fs.appendFile(log_path, '\n' + arg, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
ipc.on("getLogs", (e, arg) => {
|
ipc.on('getLogs', (e, arg) => {
|
||||||
var logs=""
|
var logs = ''
|
||||||
var todayLog=""
|
var todayLog = ''
|
||||||
var yestLog=""
|
var yestLog = ''
|
||||||
var yest2Log=""
|
var yest2Log = ''
|
||||||
fs.readdir(log_dir_path, function(err, files) {
|
fs.readdir(log_dir_path, function(err, files) {
|
||||||
if (err) throw err;
|
if (err) throw err
|
||||||
files.filter(function(file) {
|
files.filter(function(file) {
|
||||||
if (file == todayStr) {
|
if (file == todayStr) {
|
||||||
todayLog=fs.readFileSync(join(log_dir_path, file), "utf8")
|
todayLog = fs.readFileSync(join(log_dir_path, file), 'utf8')
|
||||||
}
|
}
|
||||||
if (file == yestStr) {
|
if (file == yestStr) {
|
||||||
yestLog=logs+fs.readFileSync(join(log_dir_path, file), "utf8")
|
yestLog = logs + fs.readFileSync(join(log_dir_path, file), 'utf8')
|
||||||
}
|
}
|
||||||
if (file == yest2Str) {
|
if (file == yest2Str) {
|
||||||
yest2Log=fs.readFileSync(join(log_dir_path, file), "utf8")
|
yest2Log = fs.readFileSync(join(log_dir_path, file), 'utf8')
|
||||||
}
|
}
|
||||||
logs = todayLog + yestLog + yest2Log;
|
logs = todayLog + yestLog + yest2Log
|
||||||
});
|
})
|
||||||
logs = yest2Log + yestLog + todayLog;
|
logs = yest2Log + yestLog + todayLog
|
||||||
e.sender.webContents.send("logData", logs);
|
e.sender.webContents.send('logData', logs)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
//起動時ログディレクトリ存在確認と作成、古ログ削除
|
//起動時ログディレクトリ存在確認と作成、古ログ削除
|
||||||
fs.access(log_dir_path, fs.constants.R_OK | fs.constants.W_OK, error => {
|
fs.access(log_dir_path, fs.constants.R_OK | fs.constants.W_OK, error => {
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.code === "ENOENT") {
|
if (error.code === 'ENOENT') {
|
||||||
fs.mkdirSync(log_dir_path);
|
fs.mkdirSync(log_dir_path)
|
||||||
} else {
|
} else {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fs.readdir(log_dir_path, function(err, files) {
|
fs.readdir(log_dir_path, function(err, files) {
|
||||||
if (err) throw err;
|
if (err) throw err
|
||||||
files.filter(function(file) {
|
files.filter(function(file) {
|
||||||
if (file != todayStr && file != yestStr && file != yest2Str) {
|
if (file != todayStr && file != yestStr && file != yest2Str) {
|
||||||
fs.unlinkSync(join(log_dir_path, file));
|
fs.unlinkSync(join(log_dir_path, file))
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
exports.system = system;
|
exports.system = system
|
||||||
|
|
|
@ -52,12 +52,13 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^5.11.2",
|
"@fortawesome/fontawesome-free": "^5.11.2",
|
||||||
"electron-dl": "^1.14.0",
|
"electron-dl": "^1.14.0",
|
||||||
|
"electron-window-state": "^5.0.3",
|
||||||
"jimp": "^0.9.1",
|
"jimp": "^0.9.1",
|
||||||
"jquery": "^3.4.1",
|
"jquery": "^3.4.1",
|
||||||
"jquery-ui-dist": "^1.12.1",
|
"jquery-ui-dist": "^1.12.1",
|
||||||
"materialize-css": "git://github.com/cutls/materialize",
|
|
||||||
"json5": "^2.1.1",
|
"json5": "^2.1.1",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
|
"materialize-css": "git://github.com/cutls/materialize",
|
||||||
"sumchecker": "^3.0.1",
|
"sumchecker": "^3.0.1",
|
||||||
"sweetalert2": "^9.4.0",
|
"sweetalert2": "^9.4.0",
|
||||||
"vue": "^2.6.10"
|
"vue": "^2.6.10"
|
||||||
|
|
|
@ -1031,6 +1031,14 @@ electron-rebuild@^1.8.8:
|
||||||
spawn-rx "^3.0.0"
|
spawn-rx "^3.0.0"
|
||||||
yargs "^13.2.4"
|
yargs "^13.2.4"
|
||||||
|
|
||||||
|
electron-window-state@^5.0.3:
|
||||||
|
version "5.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/electron-window-state/-/electron-window-state-5.0.3.tgz#4f36d09e3f953d87aff103bf010f460056050aa8"
|
||||||
|
integrity sha512-1mNTwCfkolXl3kMf50yW3vE2lZj0y92P/HYWFBrb+v2S/pCka5mdwN3cagKm458A7NjndSwijynXgcLWRodsVg==
|
||||||
|
dependencies:
|
||||||
|
jsonfile "^4.0.0"
|
||||||
|
mkdirp "^0.5.1"
|
||||||
|
|
||||||
electron@^7.1.1:
|
electron@^7.1.1:
|
||||||
version "7.1.1"
|
version "7.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/electron/-/electron-7.1.1.tgz#98be17d850e64689a09ab6dd1e437b36307f2fcf"
|
resolved "https://registry.yarnpkg.com/electron/-/electron-7.1.1.tgz#98be17d850e64689a09ab6dd1e437b36307f2fcf"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user