WIP: introduce new titlebar(ofcouce, it is optional opt-in; now it is as opt-out)
This commit is contained in:
parent
3bff41f3d9
commit
db7c471ec5
|
@ -9,6 +9,14 @@ body {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
color: var(--color);
|
color: var(--color);
|
||||||
}
|
}
|
||||||
|
.titlebar, .menubar-menu-container, .action-menu-item {
|
||||||
|
background-color: var(--notfbox) !important;
|
||||||
|
filter: brightness(110%) !important;
|
||||||
|
color: var(--color) !important;
|
||||||
|
}
|
||||||
|
.action-menu-item:hover {
|
||||||
|
filter: brightness(80%) !important;
|
||||||
|
}
|
||||||
.btn {
|
.btn {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
|
@ -494,7 +502,7 @@ textarea {
|
||||||
background-color: var(--emphasized);
|
background-color: var(--emphasized);
|
||||||
}
|
}
|
||||||
#pageSrc {
|
#pageSrc {
|
||||||
position: fixed;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: calc(50vw - 150px);
|
left: calc(50vw - 150px);
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
var electron = require('electron')
|
var electron = require('electron')
|
||||||
const shell = electron.shell
|
const shell = electron.shell
|
||||||
var ipc = electron.ipcRenderer
|
var ipc = electron.ipcRenderer
|
||||||
|
//title bar
|
||||||
|
const customTitlebar = require('custom-electron-titlebar')
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const file = location.href.substr(-10)
|
||||||
|
if (
|
||||||
|
file == 'index.html' ||
|
||||||
|
file == '/acct.html' ||
|
||||||
|
file == 'tting.html'
|
||||||
|
) {
|
||||||
|
new customTitlebar.Titlebar({
|
||||||
|
backgroundColor: customTitlebar.Color.fromHex('#000'),
|
||||||
|
titleHorizontalAlignment: 'right',
|
||||||
|
icon: '../../img/desk.png'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
onmessage = function(e) {
|
onmessage = function(e) {
|
||||||
if (e.data[0] == 'openUrl') {
|
if (e.data[0] == 'openUrl') {
|
||||||
urls = e.data[1].match(/https?:\/\/(.+)/)
|
urls = e.data[1].match(/https?:\/\/(.+)/)
|
||||||
|
|
|
@ -141,7 +141,9 @@ function createWindow() {
|
||||||
x: window_size.x,
|
x: window_size.x,
|
||||||
y: window_size.y,
|
y: window_size.y,
|
||||||
icon: __dirname + '/desk.png',
|
icon: __dirname + '/desk.png',
|
||||||
show: false
|
show: false,
|
||||||
|
frame: false,
|
||||||
|
resizable: true
|
||||||
}
|
}
|
||||||
} else if (platform == 'win32') {
|
} else if (platform == 'win32') {
|
||||||
var arg = {
|
var arg = {
|
||||||
|
@ -282,6 +284,7 @@ function createWindow() {
|
||||||
Menu.setApplicationMenu(
|
Menu.setApplicationMenu(
|
||||||
Menu.buildFromTemplate(language.template(lang, mainWindow, packaged, dir, dirname))
|
Menu.buildFromTemplate(language.template(lang, mainWindow, packaged, dir, dirname))
|
||||||
)
|
)
|
||||||
|
mainWindow.setMenu(null)
|
||||||
//CSS
|
//CSS
|
||||||
css.css(mainWindow)
|
css.css(mainWindow)
|
||||||
//アップデータとダウンロード
|
//アップデータとダウンロード
|
||||||
|
|
137
app/main/dl.js
137
app/main/dl.js
|
@ -1,126 +1,123 @@
|
||||||
function dl(mainWindow, lang_path, base, dirname) {
|
function dl(mainWindow, lang_path, base, dirname) {
|
||||||
const electron = require("electron");
|
const electron = require('electron')
|
||||||
const shell = electron.shell;
|
const shell = electron.shell
|
||||||
const fs = require("fs");
|
const fs = require('fs')
|
||||||
const { download } = require('electron-dl');
|
const { download } = require('electron-dl')
|
||||||
const BrowserWindow = electron.BrowserWindow;
|
const BrowserWindow = electron.BrowserWindow
|
||||||
const dialog = electron.dialog;
|
const dialog = electron.dialog
|
||||||
var updatewin = null;
|
var updatewin = null
|
||||||
var ipc = electron.ipcMain;
|
var ipc = electron.ipcMain
|
||||||
const app = electron.app;
|
const app = electron.app
|
||||||
const join = require('path').join;
|
const join = require('path').join
|
||||||
ipc.on('update', function (e, x, y) {
|
ipc.on('update', function(e, x, y) {
|
||||||
|
var platform = process.platform
|
||||||
var platform = process.platform;
|
var bit = process.arch
|
||||||
var bit = process.arch;
|
if (platform != 'others') {
|
||||||
if (platform != "others") {
|
|
||||||
updatewin = new BrowserWindow({
|
updatewin = 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: 600,
|
width: 600,
|
||||||
height: 400,
|
height: 400,
|
||||||
"transparent": false, // ウィンドウの背景を透過
|
transparent: false, // ウィンドウの背景を透過
|
||||||
"frame": false, // 枠の無いウィンドウ
|
frame: false, // 枠の無いウィンドウ
|
||||||
"resizable": false
|
resizable: false
|
||||||
})
|
})
|
||||||
var lang = fs.readFileSync(lang_path, 'utf8');
|
var lang = fs.readFileSync(lang_path, 'utf8')
|
||||||
updatewin.loadURL(base + lang + '/update.html');
|
updatewin.loadURL(base + lang + '/update.html')
|
||||||
return "true"
|
return 'true'
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//アプデDL
|
//アプデDL
|
||||||
ipc.on('download-btn', (e, args) => {
|
ipc.on('download-btn', (e, args) => {
|
||||||
function dl(url, file, dir, e) {
|
function dl(url, file, dir, e) {
|
||||||
|
e.sender.webContents.send('mess', 'ダウンロードを開始します。')
|
||||||
e.sender.webContents.send('mess', "ダウンロードを開始します。");
|
|
||||||
const opts = {
|
const opts = {
|
||||||
directory: dir,
|
directory: dir,
|
||||||
openFolderWhenDone: true,
|
openFolderWhenDone: true,
|
||||||
onProgress: function (event) {
|
onProgress: function(event) {
|
||||||
e.sender.webContents.send('prog', event);
|
e.sender.webContents.send('prog', event)
|
||||||
},
|
},
|
||||||
saveAs: false
|
saveAs: false
|
||||||
};
|
}
|
||||||
download(updatewin,
|
download(updatewin, url, opts)
|
||||||
url, opts)
|
|
||||||
.then(dl => {
|
.then(dl => {
|
||||||
e.sender.webContents.send('mess', "ダウンロードが完了しました。");
|
e.sender.webContents.send('mess', 'ダウンロードが完了しました。')
|
||||||
app.quit();
|
app.quit()
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error)
|
||||||
}
|
}
|
||||||
var platform = process.platform;
|
var platform = process.platform
|
||||||
var bit = process.arch;
|
var bit = process.arch
|
||||||
dialog.showSaveDialog(null, {
|
dialog.showSaveDialog(
|
||||||
|
null,
|
||||||
|
{
|
||||||
title: 'Save',
|
title: 'Save',
|
||||||
defaultPath: app.getPath('home') + "/" + args[1]
|
defaultPath: app.getPath('home') + '/' + args[1]
|
||||||
}, (savedFiles) => {
|
},
|
||||||
console.log(savedFiles);
|
savedFiles => {
|
||||||
|
console.log(savedFiles)
|
||||||
if (!savedFiles) {
|
if (!savedFiles) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
if (platform == "win32") {
|
if (platform == 'win32') {
|
||||||
var m = savedFiles.match(/(.+)\\(.+)$/);
|
var m = savedFiles.match(/(.+)\\(.+)$/)
|
||||||
} else {
|
} else {
|
||||||
var m = savedFiles.match(/(.+)\/(.+)$/);
|
var m = savedFiles.match(/(.+)\/(.+)$/)
|
||||||
}
|
}
|
||||||
//console.log(m);
|
//console.log(m);
|
||||||
if (isExistFile(savedFiles)) {
|
if (isExistFile(savedFiles)) {
|
||||||
fs.unlinkSync(savedFiles);
|
fs.unlinkSync(savedFiles)
|
||||||
}
|
}
|
||||||
dl(args[0], args[1], m[1], e);
|
dl(args[0], args[1], m[1], e)
|
||||||
});
|
}
|
||||||
});
|
)
|
||||||
|
})
|
||||||
|
|
||||||
function isExistFile(file) {
|
function isExistFile(file) {
|
||||||
try {
|
try {
|
||||||
fs.statSync(file);
|
fs.statSync(file)
|
||||||
return true
|
return true
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'ENOENT') return false
|
if (err.code === 'ENOENT') return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ipc.on('general-dl', (event, args) => {
|
ipc.on('general-dl', (event, args) => {
|
||||||
|
var name = ''
|
||||||
var name = "";
|
var platform = process.platform
|
||||||
var platform = process.platform;
|
var bit = process.arch
|
||||||
var bit = process.arch;
|
if (args[1] == '') {
|
||||||
if (args[1] == "") {
|
if (platform == 'win32') {
|
||||||
if (platform == "win32") {
|
var dir = app.getPath('home') + '\\Pictures\\TheDesk'
|
||||||
var dir = app.getPath('home') + "\\Pictures\\TheDesk";
|
} else if (platform == 'linux' || platform == 'darwin') {
|
||||||
} else if (platform == "linux" || platform == "darwin") {
|
var dir = app.getPath('home') + '/Pictures/TheDesk'
|
||||||
var dir = app.getPath('home') + "/Pictures/TheDesk";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var dir = args[1];
|
var dir = args[1]
|
||||||
}
|
}
|
||||||
const opts = {
|
const opts = {
|
||||||
directory: dir,
|
directory: dir,
|
||||||
filename: name,
|
filename: name,
|
||||||
openFolderWhenDone: false,
|
openFolderWhenDone: false,
|
||||||
onProgress: function (e) {
|
onProgress: function(e) {
|
||||||
event.sender.webContents.send('general-dl-prog', e);
|
event.sender.webContents.send('general-dl-prog', e)
|
||||||
},
|
},
|
||||||
saveAs: false
|
saveAs: false
|
||||||
};
|
}
|
||||||
download(BrowserWindow.getFocusedWindow(),
|
download(BrowserWindow.getFocusedWindow(), args[0], opts)
|
||||||
args[0], opts)
|
|
||||||
.then(dl => {
|
.then(dl => {
|
||||||
event.sender.webContents.send('general-dl-message', dir);
|
event.sender.webContents.send('general-dl-message', dir)
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
|
||||||
});
|
|
||||||
ipc.on('open-finder', (e, folder) => {
|
ipc.on('open-finder', (e, folder) => {
|
||||||
|
|
||||||
shell.showItemInFolder(folder)
|
shell.showItemInFolder(folder)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
exports.dl = dl;
|
exports.dl = dl
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^5.12.1",
|
"@fortawesome/fontawesome-free": "^5.12.1",
|
||||||
|
"custom-electron-titlebar": "^3.2.2-hotfix62",
|
||||||
"electron-dl": "^3.0.0",
|
"electron-dl": "^3.0.0",
|
||||||
"jimp": "^0.9.3",
|
"jimp": "^0.9.3",
|
||||||
"jquery": "^3.4.1",
|
"jquery": "^3.4.1",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="@@lang@@" style="overflow:scroll">
|
<html lang="@@lang@@">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Settings - TheDesk</title>
|
<title>Settings - TheDesk</title>
|
||||||
|
|
|
@ -861,6 +861,11 @@ crypto-random-string@^1.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
|
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
|
||||||
integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=
|
integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=
|
||||||
|
|
||||||
|
custom-electron-titlebar@^3.2.2-hotfix62:
|
||||||
|
version "3.2.2-hotfix62"
|
||||||
|
resolved "https://registry.yarnpkg.com/custom-electron-titlebar/-/custom-electron-titlebar-3.2.2-hotfix62.tgz#94b908f0f2bf812e4f65447a26b93b88f7a76088"
|
||||||
|
integrity sha512-Kh86xAolkCpqj4AD/H4HcR2pEtxUyIHzMzqwkxqZkSqE7R9tRfN8G3fVpiiNIAJlX8rbN3VwxaoHi1B1sSMn/Q==
|
||||||
|
|
||||||
dashdash@^1.12.0:
|
dashdash@^1.12.0:
|
||||||
version "1.14.1"
|
version "1.14.1"
|
||||||
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
|
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user