More prettier

This commit is contained in:
Cutls
2019-05-19 16:39:30 +09:00
parent de6e9c6f11
commit 06eb347cf8
101 changed files with 20094 additions and 16766 deletions

View File

@@ -8,11 +8,11 @@ function css(mainWindow) {
const join = require('path').join;
var customcss = join(app.getPath("userData"), "custom.css");
ipc.on('custom-css-create', function(e, arg) {
ipc.on('custom-css-create', function (e, arg) {
fs.writeFileSync(customcss, arg);
mainWindow.webContents.send('custom-css-create-complete', "");
})
ipc.on('custom-css-request', function(e, arg) {
ipc.on('custom-css-request', function (e, arg) {
try {
var css = fs.readFileSync(customcss, 'utf8');
} catch (e) {
@@ -20,7 +20,7 @@ function css(mainWindow) {
}
mainWindow.webContents.send('custom-css-response', css);
})
ipc.on('theme-json-create', function(e, arg) {
ipc.on('theme-json-create', function (e, arg) {
var themecss = join(app.getPath("userData"), JSON5.parse(arg)["id"] +
".thedesktheme");
fs.writeFileSync(themecss, JSON.stringify(JSON5.parse(arg)));
@@ -30,19 +30,19 @@ function css(mainWindow) {
mainWindow.webContents.send('theme-json-create-complete', "error");
}
})
ipc.on('theme-json-delete', function(e, arg) {
ipc.on('theme-json-delete', function (e, arg) {
var themecss = join(app.getPath("userData"), arg + ".thedesktheme");
console.log(themecss);
fs.unlink(themecss, function(err) {
fs.unlink(themecss, function (err) {
mainWindow.webContents.send('theme-json-delete-complete', "");
});
})
ipc.on('theme-json-request', function(e, arg) {
ipc.on('theme-json-request', function (e, arg) {
var themecss = join(app.getPath("userData"), arg + ".thedesktheme");
var json = JSON.parse(fs.readFileSync(themecss, 'utf8'));
mainWindow.webContents.send('theme-json-response', json);
})
ipc.on('theme-css-request', function(e, arg) {
ipc.on('theme-css-request', function (e, arg) {
var themecss = join(app.getPath("userData"), arg + ".thedesktheme");
try {
var json = JSON.parse(fs.readFileSync(themecss, 'utf8'));
@@ -82,10 +82,10 @@ function css(mainWindow) {
}
})
ipc.on('theme-json-list', function(e, arg) {
fs.readdir(app.getPath("userData"), function(err, files) {
ipc.on('theme-json-list', function (e, arg) {
fs.readdir(app.getPath("userData"), function (err, files) {
if (err) throw err;
var fileList = files.filter(function(file) {
var fileList = files.filter(function (file) {
var tfile = join(app.getPath("userData"), file);
return fs.statSync(tfile).isFile() && /.*\.thedesktheme$/.test(tfile); //絞り込み
})

View File

@@ -1,38 +1,38 @@
function dl(mainWindow,lang_path,base) {
const electron = require("electron");
const shell=electron.shell;
function dl(mainWindow, lang_path, base) {
const electron = require("electron");
const shell = electron.shell;
const fs = require("fs");
const {download} = require('electron-dl');
const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog;
const { download } = require('electron-dl');
const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog;
var updatewin = null;
var ipc = electron.ipcMain;
const app = electron.app;
const join = require('path').join;
ipc.on('update', function(e, x, y) {
var platform = process.platform;
var bit = process.arch;
if (platform != "others") {
updatewin = new BrowserWindow({
width: 600,
height: 400,
"transparent": false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ
"resizable": false,
"modal": true
});
var lang = fs.readFileSync(lang_path, 'utf8');
updatewin.loadURL(base + lang + '/update.html');
var ipc = electron.ipcMain;
const app = electron.app;
const join = require('path').join;
ipc.on('update', function (e, x, y) {
return "true"
} else {
return false;
}
})
//アプデDL
var platform = process.platform;
var bit = process.arch;
if (platform != "others") {
updatewin = new BrowserWindow({
width: 600,
height: 400,
"transparent": false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ
"resizable": false,
"modal": true
});
var lang = fs.readFileSync(lang_path, 'utf8');
updatewin.loadURL(base + lang + '/update.html');
return "true"
} else {
return false;
}
})
//アプデDL
ipc.on('download-btn', (e, args) => {
var platform = process.platform;
var bit = process.arch;
dialog.showSaveDialog(null, {
@@ -66,18 +66,18 @@ function dl(mainWindow,lang_path,base) {
}
function dl(url, file, dir) {
updatewin.webContents.send('mess', "ダウンロードを開始します。");
const opts = {
directory: dir,
openFolderWhenDone: true,
onProgress: function(e) {
onProgress: function (e) {
updatewin.webContents.send('prog', e);
},
saveAs: false
};
download(BrowserWindow.getFocusedWindow(),
url, opts)
url, opts)
.then(dl => {
updatewin.webContents.send('mess', "ダウンロードが完了しました。");
app.quit();
@@ -86,7 +86,7 @@ function dl(mainWindow,lang_path,base) {
.catch(console.error);
}
ipc.on('general-dl', (e, args) => {
var name = "";
var platform = process.platform;
var bit = process.arch;
@@ -103,21 +103,21 @@ function dl(mainWindow,lang_path,base) {
directory: dir,
filename: name,
openFolderWhenDone: false,
onProgress: function(e) {
onProgress: function (e) {
mainWindow.webContents.send('general-dl-prog', e);
},
saveAs: false
};
download(BrowserWindow.getFocusedWindow(),
args[0], opts)
args[0], opts)
.then(dl => {
mainWindow.webContents.send('general-dl-message', dir);
})
.catch(console.error);
});
ipc.on('open-finder', (e, folder) => {
});
ipc.on('open-finder', (e, folder) => {
shell.showItemInFolder(folder)
});
});
}
exports.dl = dl;

View File

@@ -1,4 +1,4 @@
function img(mainWindow,dir){
function img(mainWindow, dir) {
const electron = require("electron");
const dialog = electron.dialog;
const fs = require("fs");
@@ -6,66 +6,66 @@ function img(mainWindow,dir){
var ipc = electron.ipcMain;
const BrowserWindow = electron.BrowserWindow;
ipc.on('file-select', (e, args) => {
dialog.showOpenDialog(null, {
properties: ['openFile', 'multiSelections'],
title: '添付ファイルを選択',
defaultPath: '.',
filters: [
{name: 'メディアファイル', extensions: ['jpg', 'png', 'gif', 'bmp', 'jpeg','mp4','webm']},
{name: '画像', extensions: ['jpg', 'png', 'gif', 'bmp', 'jpeg']},
{name: '動画', extensions: ['mp4','webm']},
{name: '全てのファイル', extensions: ['*']}
{ name: 'メディアファイル', extensions: ['jpg', 'png', 'gif', 'bmp', 'jpeg', 'mp4', 'webm'] },
{ name: '画像', extensions: ['jpg', 'png', 'gif', 'bmp', 'jpeg'] },
{ name: '動画', extensions: ['mp4', 'webm'] },
{ name: '全てのファイル', extensions: ['*'] }
]
}, (fileNames) => {
if(!fileNames){
if (!fileNames) {
return false;
}
for(var i=0;i<fileNames.length;i++){
var path=fileNames[i];
for (var i = 0; i < fileNames.length; i++) {
var path = fileNames[i];
var bin = fs.readFileSync(path, 'base64');
mainWindow.webContents.send('bmp-img-comp', [bin,'new']);
mainWindow.webContents.send('bmp-img-comp', [bin, 'new']);
}
});
});
ipc.on('adobe', (e, arg) => {
if(!arg){
const options = {
type: 'info',
title: 'Adobeフォトエディタ',
message: "「許可」または「永続的に許可」をクリックするとTheDeskとAdobeで情報を共有します。\n次のウィンドウを開いている時以外は一切提供しません。",
buttons: ['拒否', '許可','永続的に許可']
}
dialog.showMessageBox(options, function(index) {
if(index===2){
mainWindow.webContents.send('adobeagree', "true");
}
if(index>0){
adobeWindow();
}
})
}else{
adobeWindow();
if (!arg) {
const options = {
type: 'info',
title: 'Adobeフォトエディタ',
message: "「許可」または「永続的に許可」をクリックするとTheDeskとAdobeで情報を共有します。\n次のウィンドウを開いている時以外は一切提供しません。",
buttons: ['拒否', '許可', '永続的に許可']
}
dialog.showMessageBox(options, function (index) {
if (index === 2) {
mainWindow.webContents.send('adobeagree', "true");
}
if (index > 0) {
adobeWindow();
}
})
} else {
adobeWindow();
}
});
function adobeWindow(){
var window = new BrowserWindow({
width: 1000,
height: 750
});
window.loadURL(dir + '/adobe.html');
}
ipc.on('bmp-image', (e, args) => {
var m = args[0].match(/(.+)\\(.+)\.(.+)$/);
Jimp.read(args[0], function (err, lenna) {
if (err) throw err;
lenna.getBase64(Jimp.MIME_PNG, function (err, src) {
mainWindow.webContents.send('bmp-img-comp', [src,args[1]]);
});
});
});
});
function adobeWindow() {
var window = new BrowserWindow({
width: 1000,
height: 750
});
window.loadURL(dir + '/adobe.html');
}
ipc.on('bmp-image', (e, args) => {
var m = args[0].match(/(.+)\\(.+)\.(.+)$/);
Jimp.read(args[0], function (err, lenna) {
if (err) throw err;
lenna.getBase64(Jimp.MIME_PNG, function (err, src) {
mainWindow.webContents.send('bmp-img-comp', [src, args[1]]);
});
});
});
}
exports.img = img;

View File

@@ -1,85 +1,90 @@
// Create the Application's main menu
function templete(lang,mainWindow,packaged,dir){
function templete(lang, mainWindow, packaged, dir) {
const electron = require("electron");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const dict={
"application":{
"ja":"アプリケーション",
"en":"Application"
const dict = {
"application": {
"ja": "アプリケーション",
"en": "Application"
},
"about":{
"ja":"TheDeskについて",
"en":"About TheDesk"
"about": {
"ja": "TheDeskについて",
"en": "About TheDesk"
},
"quit":{
"ja":"終了",
"en":"Quit"
"quit": {
"ja": "終了",
"en": "Quit"
},
"edit":{
"ja":"編集",
"en":"Edit"
"edit": {
"ja": "編集",
"en": "Edit"
},
"undo":{
"ja":"元に戻す",
"en":"Undo"
"undo": {
"ja": "元に戻す",
"en": "Undo"
},
"redo":{
"ja":"やり直す",
"en":"Redo"
"redo": {
"ja": "やり直す",
"en": "Redo"
},
"cut":{
"ja":"切り取り",
"en":"Cut"
"cut": {
"ja": "切り取り",
"en": "Cut"
},
"copy":{
"ja":"コピー",
"en":"Copy"
"copy": {
"ja": "コピー",
"en": "Copy"
},
"paste":{
"ja":"貼り付け",
"en":"Paste"
"paste": {
"ja": "貼り付け",
"en": "Paste"
},
"selall":{
"ja":"すべて選択",
"en":"Select All"
"selall": {
"ja": "すべて選択",
"en": "Select All"
},
"view":{
"ja":"表示",
"en":"View"
"view": {
"ja": "表示",
"en": "View"
},
"reload":{
"ja":"再読み込み",
"en":"Reload"
"reload": {
"ja": "再読み込み",
"en": "Reload"
},
"window":{
"ja":"ウィンドウ",
"en":"Window"
"window": {
"ja": "ウィンドウ",
"en": "Window"
},
"minimun":{
"ja":"最小化",
"en":"Minimarize"
"minimun": {
"ja": "最小化",
"en": "Minimarize"
},
"close":{
"ja":"閉じる",
"en":"Close"
"close": {
"ja": "閉じる",
"en": "Close"
}
}
const menu = [{
label: dict.application[lang],
submenu: [
{ label: dict.about[lang], click: function() {
var ver=app.getVersion()
var window = new BrowserWindow({width: 300, height: 460,
"transparent": false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ
"resizable": false });
window.loadURL(dir + '/about.html?ver='+ver);
} },
{
label: dict.about[lang], click: function () {
var ver = app.getVersion()
var window = new BrowserWindow({
width: 300, height: 460,
"transparent": false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ
"resizable": false
});
window.loadURL(dir + '/about.html?ver=' + ver);
}
},
{ type: "separator" },
{ label: dict.quit[lang], accelerator: "Command+Q", click: function() { app.quit(); }}
]}, {
{ label: dict.quit[lang], accelerator: "Command+Q", click: function () { app.quit(); } }
]
}, {
label: dict.edit[lang],
submenu: [
{ label: dict.undo[lang], accelerator: "CmdOrCtrl+Z", selector: "undo:" },
@@ -89,57 +94,58 @@ function templete(lang,mainWindow,packaged,dir){
{ label: dict.copy[lang], accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: dict.paste[lang], accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: dict.selall[lang], accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
]},{
]
}, {
label: dict.view[lang],
submenu: [
{
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
click: function() { if(!packaged){mainWindow.toggleDevTools();} }
},
{
label: dict.reload[lang],
accelerator: 'CmdOrCtrl+R',
click: function() { mainWindow.webContents.send('reload', " "); }
}
click: function () { if (!packaged) { mainWindow.toggleDevTools(); } }
},
{
label: dict.reload[lang],
accelerator: 'CmdOrCtrl+R',
click: function () { mainWindow.webContents.send('reload', " "); }
}
]
},
{
},
{
label: dict.window[lang],
role: 'window',
submenu: [
{
{
label: dict.minimun[lang],
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
},
{
label: dict.close[lang],
accelerator: 'CmdOrCtrl+W',
role: 'close'
},
]
}
},
]
}
];
return menu;
}
function delsel(lang){
const dict={
"delete":{
"ja":"カラム削除",
"en":"Delete this column"
function delsel(lang) {
const dict = {
"delete": {
"ja": "カラム削除",
"en": "Delete this column"
},
"mess":{
"ja":"カラムを削除しますか?(すべてのカラムのリンク解析がOFFになります。)",
"en":"Delete this column(URL analyzes of all windows will be disabled.)"
"mess": {
"ja": "カラムを削除しますか?(すべてのカラムのリンク解析がOFFになります。)",
"en": "Delete this column(URL analyzes of all windows will be disabled.)"
},
"yes":{
"ja":"はい",
"en":"Yes"
"yes": {
"ja": "はい",
"en": "Yes"
},
"no":{
"ja":"いいえ",
"en":"No"
"no": {
"ja": "いいえ",
"en": "No"
}
}
const options = {
@@ -147,8 +153,8 @@ function delsel(lang){
title: dict.delete[lang],
message: dict.mess[lang],
buttons: [dict.no[lang], dict.yes[lang]]
}
return options;
}
return options;
}
exports.template = templete;

View File

@@ -1,4 +1,4 @@
function np(mainWindow){
function np(mainWindow) {
const electron = require("electron");
const join = require('path').join;
const app = electron.app;
@@ -7,65 +7,65 @@ function np(mainWindow){
ipc.on('itunes', async (e, args) => {
//Verified on Windows
console.log("Access");
if(args[0]=="set"){
var {NowPlaying,PlayerName} = require("nowplaying-node");
var nppath=join(app.getPath("userData"), "nowplaying");
if (args[0] == "set") {
var { NowPlaying, PlayerName } = require("nowplaying-node");
var nppath = join(app.getPath("userData"), "nowplaying");
var npProvider;
try {
npProvider = args[1];
} catch (e) {
npProvider="AIMP";
npProvider = "AIMP";
}
var myAIMP = new NowPlaying({
fetchCover: true,
player: PlayerName[npProvider],
});
fs.writeFileSync(nppath, npProvider);
}else{
var platform=process.platform;
var bit=process.arch;
if(platform=="darwin"){
try {
const nowplaying = require("itunes-nowplaying-mac");
const value = await nowplaying.getRawData();
mainWindow.webContents.send('itunes-np', value);
} catch (error) {
// エラーを返す
console.error(error);
mainWindow.webContents.send('itunes-np', error);
}
}else{
var {NowPlaying,PlayerName} = require("nowplaying-node");
var nppath=join(app.getPath("userData"), "nowplaying");
} else {
var platform = process.platform;
var bit = process.arch;
if (platform == "darwin") {
try {
const nowplaying = require("itunes-nowplaying-mac");
const value = await nowplaying.getRawData();
mainWindow.webContents.send('itunes-np', value);
} catch (error) {
// エラーを返す
console.error(error);
mainWindow.webContents.send('itunes-np', error);
}
} else {
var { NowPlaying, PlayerName } = require("nowplaying-node");
var nppath = join(app.getPath("userData"), "nowplaying");
var npProvider;
try {
npProvider = fs.readFileSync(nppath, 'utf8');
} catch (e) {
npProvider="AIMP";
npProvider = "AIMP";
}
var myAIMP = new NowPlaying({
fetchCover: true,
player: PlayerName[npProvider],
});
myAIMP.update();
var path=myAIMP.getCoverPath();
if(path){
var path = myAIMP.getCoverPath();
if (path) {
var bin = fs.readFileSync(path, 'base64');
}else{
var bin=false;
} else {
var bin = false;
}
var value={
win:true,
name:myAIMP.getTitle(),
artist:myAIMP.getArtist(),
album:myAIMP.getAlbum(),
path:bin
var value = {
win: true,
name: myAIMP.getTitle(),
artist: myAIMP.getArtist(),
album: myAIMP.getAlbum(),
path: bin
}
mainWindow.webContents.send('itunes-np', value);
}
}
}
});
}
exports.TheDeskNowPlaying = np;

View File

@@ -1,6 +1,6 @@
function system(mainWindow, dir, lang) {
const electron = require("electron");
const app = electron.app;
const electron = require("electron");
const app = electron.app;
const join = require('path').join;
var Jimp = require("jimp");
const fs = require("fs");
@@ -11,15 +11,15 @@ function system(mainWindow, dir, lang) {
const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog;
const os = require('os')
const language=require("../main/language.js");
ipc.on('native-notf', function(e, args) {
const language = require("../main/language.js");
ipc.on('native-notf', function (e, args) {
var platform = process.platform;
var bit = process.arch;
if (platform == "win32") {
const notifier = require('node-notifier')
var tmp_imge = tmp_img;
Jimp.read(args[2], function(err, lenna) {
Jimp.read(args[2], function (err, lenna) {
if (!err && lenna) {
lenna.write(tmp_img);
var tmp_imge = tmp_img;
@@ -27,49 +27,49 @@ function system(mainWindow, dir, lang) {
var tmp_imge = "";
}
notifier.notify({
appID: "top.thedesk",
message: args[1],
title: args[0],
icon: tmp_imge,
sound: false,
wait: true,
},
function(err, response) {
appID: "top.thedesk",
message: args[1],
title: args[0],
icon: tmp_imge,
sound: false,
wait: true,
},
function (err, response) {
console.log(err, response)
});
});
}
});
//言語
ipc.on('lang', function(e, arg) {
console.log("set:" + arg);
fs.writeFileSync(lang_path, arg);
mainWindow.webContents.send('langres', "");
})
//ハードウェアアクセラレーションの無効化
ipc.on('ha', function(e, arg) {
ipc.on('lang', function (e, arg) {
console.log("set:" + arg);
fs.writeFileSync(lang_path, arg);
mainWindow.webContents.send('langres', "");
})
//ハードウェアアクセラレーションの無効化
ipc.on('ha', function (e, arg) {
if (arg == "true") {
fs.writeFileSync(ha_path, arg);
} else {
fs.unlink(ha_path, function(err) {});
fs.unlink(ha_path, function (err) { });
}
app.relaunch()
app.exit()
})
ipc.on('quit', (e, args) => {
app.quit();
});
ipc.on('about', (e, args) => {
about();
});
function about() {
var ver = app.getVersion()
var window = new BrowserWindow({
width: 300,
@@ -82,15 +82,15 @@ function system(mainWindow, dir, lang) {
return "true"
}
ipc.on('column-del', (e, args) => {
console.log(lang);
var options = language.delsel(lang)
dialog.showMessageBox(options, function(index) {
dialog.showMessageBox(options, function (index) {
mainWindow.webContents.send('column-del-reply', index);
})
});
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 window_pos;
@@ -110,7 +110,7 @@ function system(mainWindow, dir, lang) {
nanowindow.setAlwaysOnTop(true);
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()));
});
return true;
@@ -149,7 +149,7 @@ function system(mainWindow, dir, lang) {
num_b = -1;
}
data = data.sort(function(a, b) {
data = data.sort(function (a, b) {
var x = a[key];
var y = b[key];
if (x > y) return num_a;
@@ -173,7 +173,7 @@ function system(mainWindow, dir, lang) {
ipc.on('fonts', (e, arg) => {
const fm = require('font-manager');
var fonts = fm.getAvailableFontsSync();
object_array_sort(fonts, 'family', 'asc', function(fonts_sorted) {
object_array_sort(fonts, 'family', 'asc', function (fonts_sorted) {
mainWindow.webContents.send('font-list', fonts_sorted);
});
});