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;
|
||||
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 {
|
||||
margin: 5px;
|
||||
text-transform: none;
|
||||
|
@ -494,7 +502,7 @@ textarea {
|
|||
background-color: var(--emphasized);
|
||||
}
|
||||
#pageSrc {
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: calc(50vw - 150px);
|
||||
width: 300px;
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
var electron = require('electron')
|
||||
const shell = electron.shell
|
||||
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) {
|
||||
if (e.data[0] == 'openUrl') {
|
||||
urls = e.data[1].match(/https?:\/\/(.+)/)
|
||||
|
|
|
@ -141,7 +141,9 @@ function createWindow() {
|
|||
x: window_size.x,
|
||||
y: window_size.y,
|
||||
icon: __dirname + '/desk.png',
|
||||
show: false
|
||||
show: false,
|
||||
frame: false,
|
||||
resizable: true
|
||||
}
|
||||
} else if (platform == 'win32') {
|
||||
var arg = {
|
||||
|
@ -282,6 +284,7 @@ function createWindow() {
|
|||
Menu.setApplicationMenu(
|
||||
Menu.buildFromTemplate(language.template(lang, mainWindow, packaged, dir, dirname))
|
||||
)
|
||||
mainWindow.setMenu(null)
|
||||
//CSS
|
||||
css.css(mainWindow)
|
||||
//アップデータとダウンロード
|
||||
|
|
139
app/main/dl.js
139
app/main/dl.js
|
@ -1,126 +1,123 @@
|
|||
function dl(mainWindow, lang_path, base, dirname) {
|
||||
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;
|
||||
var updatewin = null;
|
||||
var ipc = electron.ipcMain;
|
||||
const app = electron.app;
|
||||
const join = require('path').join;
|
||||
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
|
||||
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") {
|
||||
var platform = process.platform
|
||||
var bit = process.arch
|
||||
if (platform != 'others') {
|
||||
updatewin = new BrowserWindow({
|
||||
webPreferences: {
|
||||
webviewTag: false,
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
preload: join(dirname,"js", "platform", "preload.js")
|
||||
preload: join(dirname, 'js', 'platform', 'preload.js')
|
||||
},
|
||||
width: 600,
|
||||
height: 400,
|
||||
"transparent": false, // ウィンドウの背景を透過
|
||||
"frame": false, // 枠の無いウィンドウ
|
||||
"resizable": false
|
||||
transparent: false, // ウィンドウの背景を透過
|
||||
frame: false, // 枠の無いウィンドウ
|
||||
resizable: false
|
||||
})
|
||||
var lang = fs.readFileSync(lang_path, 'utf8');
|
||||
updatewin.loadURL(base + lang + '/update.html');
|
||||
return "true"
|
||||
var lang = fs.readFileSync(lang_path, 'utf8')
|
||||
updatewin.loadURL(base + lang + '/update.html')
|
||||
return 'true'
|
||||
} else {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
})
|
||||
//アプデDL
|
||||
ipc.on('download-btn', (e, args) => {
|
||||
function dl(url, file, dir, e) {
|
||||
|
||||
e.sender.webContents.send('mess', "ダウンロードを開始します。");
|
||||
e.sender.webContents.send('mess', 'ダウンロードを開始します。')
|
||||
const opts = {
|
||||
directory: dir,
|
||||
openFolderWhenDone: true,
|
||||
onProgress: function(event) {
|
||||
e.sender.webContents.send('prog', event);
|
||||
e.sender.webContents.send('prog', event)
|
||||
},
|
||||
saveAs: false
|
||||
};
|
||||
download(updatewin,
|
||||
url, opts)
|
||||
}
|
||||
download(updatewin, url, opts)
|
||||
.then(dl => {
|
||||
e.sender.webContents.send('mess', "ダウンロードが完了しました。");
|
||||
app.quit();
|
||||
e.sender.webContents.send('mess', 'ダウンロードが完了しました。')
|
||||
app.quit()
|
||||
})
|
||||
.catch(console.error);
|
||||
.catch(console.error)
|
||||
}
|
||||
var platform = process.platform;
|
||||
var bit = process.arch;
|
||||
dialog.showSaveDialog(null, {
|
||||
var platform = process.platform
|
||||
var bit = process.arch
|
||||
dialog.showSaveDialog(
|
||||
null,
|
||||
{
|
||||
title: 'Save',
|
||||
defaultPath: app.getPath('home') + "/" + args[1]
|
||||
}, (savedFiles) => {
|
||||
console.log(savedFiles);
|
||||
defaultPath: app.getPath('home') + '/' + args[1]
|
||||
},
|
||||
savedFiles => {
|
||||
console.log(savedFiles)
|
||||
if (!savedFiles) {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
if (platform == "win32") {
|
||||
var m = savedFiles.match(/(.+)\\(.+)$/);
|
||||
if (platform == 'win32') {
|
||||
var m = savedFiles.match(/(.+)\\(.+)$/)
|
||||
} else {
|
||||
var m = savedFiles.match(/(.+)\/(.+)$/);
|
||||
var m = savedFiles.match(/(.+)\/(.+)$/)
|
||||
}
|
||||
//console.log(m);
|
||||
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) {
|
||||
try {
|
||||
fs.statSync(file);
|
||||
fs.statSync(file)
|
||||
return true
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ipc.on('general-dl', (event, args) => {
|
||||
|
||||
var name = "";
|
||||
var platform = process.platform;
|
||||
var bit = process.arch;
|
||||
if (args[1] == "") {
|
||||
if (platform == "win32") {
|
||||
var dir = app.getPath('home') + "\\Pictures\\TheDesk";
|
||||
} else if (platform == "linux" || platform == "darwin") {
|
||||
var dir = app.getPath('home') + "/Pictures/TheDesk";
|
||||
var name = ''
|
||||
var platform = process.platform
|
||||
var bit = process.arch
|
||||
if (args[1] == '') {
|
||||
if (platform == 'win32') {
|
||||
var dir = app.getPath('home') + '\\Pictures\\TheDesk'
|
||||
} else if (platform == 'linux' || platform == 'darwin') {
|
||||
var dir = app.getPath('home') + '/Pictures/TheDesk'
|
||||
}
|
||||
} else {
|
||||
var dir = args[1];
|
||||
var dir = args[1]
|
||||
}
|
||||
const opts = {
|
||||
directory: dir,
|
||||
filename: name,
|
||||
openFolderWhenDone: false,
|
||||
onProgress: function(e) {
|
||||
event.sender.webContents.send('general-dl-prog', e);
|
||||
event.sender.webContents.send('general-dl-prog', e)
|
||||
},
|
||||
saveAs: false
|
||||
};
|
||||
download(BrowserWindow.getFocusedWindow(),
|
||||
args[0], opts)
|
||||
.then(dl => {
|
||||
event.sender.webContents.send('general-dl-message', dir);
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
ipc.on('open-finder', (e, folder) => {
|
||||
|
||||
shell.showItemInFolder(folder)
|
||||
});
|
||||
}
|
||||
exports.dl = dl;
|
||||
download(BrowserWindow.getFocusedWindow(), args[0], opts)
|
||||
.then(dl => {
|
||||
event.sender.webContents.send('general-dl-message', dir)
|
||||
})
|
||||
.catch(console.error)
|
||||
})
|
||||
ipc.on('open-finder', (e, folder) => {
|
||||
shell.showItemInFolder(folder)
|
||||
})
|
||||
}
|
||||
exports.dl = dl
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.12.1",
|
||||
"custom-electron-titlebar": "^3.2.2-hotfix62",
|
||||
"electron-dl": "^3.0.0",
|
||||
"jimp": "^0.9.3",
|
||||
"jquery": "^3.4.1",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang="@@lang@@" style="overflow:scroll">
|
||||
<html lang="@@lang@@">
|
||||
|
||||
<head>
|
||||
<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"
|
||||
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:
|
||||
version "1.14.1"
|
||||
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
|
||||
|
|
Loading…
Reference in New Issue
Block a user