Add: cool frame of the window, default: off

This commit is contained in:
cutls 2020-03-19 13:17:02 +09:00
parent d44724d784
commit 3531c338de
10 changed files with 95 additions and 18 deletions

View File

@ -4,6 +4,8 @@ var ipc = electron.ipcRenderer
//title bar //title bar
const customTitlebar = require('custom-electron-titlebar') const customTitlebar = require('custom-electron-titlebar')
window.addEventListener('DOMContentLoaded', () => { window.addEventListener('DOMContentLoaded', () => {
ipc.send('frameCheck', '')
ipc.on('frame', function(event, args) {
const file = location.href.substr(-10) const file = location.href.substr(-10)
if ( if (
file == 'index.html' || file == 'index.html' ||
@ -17,6 +19,7 @@ window.addEventListener('DOMContentLoaded', () => {
}) })
} }
}) })
})
onmessage = function(e) { onmessage = function(e) {
if (e.data[0] == 'openUrl') { if (e.data[0] == 'openUrl') {
@ -65,6 +68,8 @@ onmessage = function(e) {
ipc.send('theme-json-request', e.data[1]) ipc.send('theme-json-request', e.data[1])
} else if (e.data[0] == 'ha') { } else if (e.data[0] == 'ha') {
ipc.send('ha', e.data[1]) ipc.send('ha', e.data[1])
} else if (e.data[0] == 'frameSet') {
ipc.send('frameSet', e.data[1])
} else if (e.data[0] == 'ua') { } else if (e.data[0] == 'ua') {
ipc.send('ua', e.data[1]) ipc.send('ua', e.data[1])
} else if (e.data[0] == 'aboutData') { } else if (e.data[0] == 'aboutData') {

View File

@ -17,6 +17,9 @@ var envView = new Vue({
if (ls == 'ua_setting') { if (ls == 'ua_setting') {
useragent(val) useragent(val)
} }
if (ls == 'frame') {
frameSet(val)
}
return true return true
} }
} }
@ -764,6 +767,9 @@ function hardwareAcceleration(had) {
function useragent(val) { function useragent(val) {
postMessage(['ua', val], '*') postMessage(['ua', val], '*')
} }
function frameSet(val) {
postMessage(['frameSet', val], '*')
}
function customSound(key) { function customSound(key) {
postMessage(['customSound', key], '*') postMessage(['customSound', key], '*')
} }

View File

@ -62,6 +62,7 @@ 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')
var frame_path = join(app.getPath('userData'), 'frame')
try { try {
fs.readFileSync(ha_path, 'utf8') fs.readFileSync(ha_path, 'utf8')
app.disableHardwareAcceleration() app.disableHardwareAcceleration()
@ -97,6 +98,16 @@ function isFile(file) {
if (err.code === 'ENOENT') return false if (err.code === 'ENOENT') return false
} }
} }
try {
var frameRaw = fs.readFileSync(frame_path, 'utf8')
if(frameRaw == 'false') {
var frame = false
} else {
var frame = true
}
} catch {
var frame = true
}
// 全てのウィンドウが閉じたら終了 // 全てのウィンドウが閉じたら終了
app.on('window-all-closed', function() { app.on('window-all-closed', function() {
electron.session.defaultSession.clearCache(() => {}) electron.session.defaultSession.clearCache(() => {})
@ -142,7 +153,7 @@ function createWindow() {
y: window_size.y, y: window_size.y,
icon: __dirname + '/desk.png', icon: __dirname + '/desk.png',
show: false, show: false,
frame: false, frame: frame,
resizable: true resizable: true
} }
} else if (platform == 'win32') { } else if (platform == 'win32') {
@ -158,7 +169,8 @@ function createWindow() {
x: window_size.x, x: window_size.x,
y: window_size.y, y: window_size.y,
simpleFullscreen: true, simpleFullscreen: true,
show: false show: false,
frame: frame
} }
} else if (platform == 'darwin') { } else if (platform == 'darwin') {
var arg = { var arg = {
@ -173,7 +185,8 @@ function createWindow() {
x: window_size.x, x: window_size.x,
y: window_size.y, y: window_size.y,
simpleFullscreen: true, simpleFullscreen: true,
show: false show: false,
frame: frame,
} }
} }
mainWindow = new BrowserWindow(arg) mainWindow = new BrowserWindow(arg)
@ -282,9 +295,11 @@ function createWindow() {
var platform = process.platform var platform = process.platform
var bit = process.arch var bit = process.arch
Menu.setApplicationMenu( Menu.setApplicationMenu(
Menu.buildFromTemplate(language.template(lang, mainWindow, packaged, dir, dirname)) Menu.buildFromTemplate(language.template(lang, mainWindow, packaged, dir, dirname, frame))
) )
if(!frame) {
mainWindow.setMenu(null) mainWindow.setMenu(null)
}
//CSS //CSS
css.css(mainWindow) css.css(mainWindow)
//アップデータとダウンロード //アップデータとダウンロード

View File

@ -1,12 +1,19 @@
// Create the Application's main menu // Create the Application's main menu
function templete(lang, mainWindow, packaged, dir, dirname) { function templete(lang, mainWindow, packaged, dir, dirname, frame) {
//フレーム
if(lang !="ja" && lang != "en"){ if(lang !="ja" && lang != "en"){
lang = "en" lang = "en"
} }
const electron = require("electron"); const electron = require("electron");
const ipc = electron.ipcMain;
const app = electron.app; const app = electron.app;
const BrowserWindow = electron.BrowserWindow; const BrowserWindow = electron.BrowserWindow;
const join = require('path').join; const join = require('path').join;
ipc.on("frameCheck", function(e, arg) {
if(!frame) {
e.sender.webContents.send("frame", "");
}
});
const dict = { const dict = {
"application": { "application": {
"ja": "アプリケーション", "ja": "アプリケーション",

View File

@ -12,6 +12,7 @@ function system(mainWindow, dir, lang, dirname) {
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 frame_path = join(app.getPath("userData"), "frame");
//ログ //ログ
var today = new Date(); var today = new Date();
//今日のやつ //今日のやつ
@ -115,6 +116,7 @@ function system(mainWindow, dir, lang, dirname) {
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) {});
@ -124,6 +126,12 @@ function system(mainWindow, dir, lang, dirname) {
app.relaunch(); app.relaunch();
app.exit(); app.exit();
}); });
//フレームのありなし
ipc.on("frameSet", function(e, arg) {
fs.writeFileSync(frame_path, arg);
app.relaunch();
app.exit();
});
ipc.on("quit", (e, args) => { ipc.on("quit", (e, args) => {
app.quit(); app.quit();
@ -278,6 +286,7 @@ function system(mainWindow, dir, lang, dirname) {
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) {

View File

@ -4,6 +4,8 @@
"yes": "Yes", "yes": "Yes",
"no": "No", "no": "No",
"none": "None", "none": "None",
"show": "Show",
"hide": "Hide",
"default": "Default", "default": "Default",
"change": "Change", "change": "Change",
"select": "Select", "select": "Select",
@ -34,6 +36,8 @@
"savefolderwarn": "TheDesk uses this value when it try to save pictures or take screenshots.", "savefolderwarn": "TheDesk uses this value when it try to save pictures or take screenshots.",
"useragent":"User agent", "useragent":"User agent",
"useragentWarn":"Restart when changed", "useragentWarn":"Restart when changed",
"frame": "Window frame",
"frameWarn": "If 'off', the window looks cool.",
"absolute": "absolute value", "absolute": "absolute value",
"srcUrl": "Search engine", "srcUrl": "Search engine",
"srcUrlWarn": "{q} will be replaced to query.", "srcUrlWarn": "{q} will be replaced to query.",

View File

@ -4,6 +4,8 @@
"yes": "はい", "yes": "はい",
"no": "いいえ", "no": "いいえ",
"none": "なし", "none": "なし",
"show": "表示",
"hide": "非表示",
"default": "既定", "default": "既定",
"change": "変更", "change": "変更",
"select": "選択", "select": "選択",
@ -33,6 +35,8 @@
"savefolderwarn": "画像ダウンロードやスクリーンショットはここに保存や。", "savefolderwarn": "画像ダウンロードやスクリーンショットはここに保存や。",
"useragent":"ユーザーエージェント", "useragent":"ユーザーエージェント",
"useragentWarn":"再起動すんで。", "useragentWarn":"再起動すんで。",
"frame": "ウィンドウのフレーム",
"frameWarn": "フレーム無しやとタイトルバーがシュッとするで。再起動すんで。",
"absolute": "絶対指定", "absolute": "絶対指定",
"srcUrl": "検索エンジン", "srcUrl": "検索エンジン",
"srcUrlWarn": "{q}が検索文字列になるで。", "srcUrlWarn": "{q}が検索文字列になるで。",

View File

@ -4,6 +4,8 @@
"yes": "はい", "yes": "はい",
"no": "いいえ", "no": "いいえ",
"none": "なし", "none": "なし",
"show": "表示",
"hide": "非表示",
"default": "既定", "default": "既定",
"change": "変更", "change": "変更",
"select": "選択", "select": "選択",
@ -34,6 +36,8 @@
"savefolderwarn": "画像ダウンロードやスクリーンショットに影響します。", "savefolderwarn": "画像ダウンロードやスクリーンショットに影響します。",
"useragent":"ユーザーエージェント", "useragent":"ユーザーエージェント",
"useragentWarn":"再起動します。", "useragentWarn":"再起動します。",
"frame": "ウィンドウのフレーム",
"frameWarn": "フレーム無しだと、タイトルバーのデザインがクールになります。再起動します。",
"absolute": "絶対指定", "absolute": "絶対指定",
"srcUrl": "検索エンジン", "srcUrl": "検索エンジン",
"srcUrlWarn": "{q}が検索文字列に置換されます。", "srcUrlWarn": "{q}が検索文字列に置換されます。",

View File

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html lang="@@lang@@"> <html lang="@@lang@@" style="overflow-y:scroll">
<head> <head>
<title>Settings - TheDesk</title> <title>Settings - TheDesk</title>
@ -25,6 +25,9 @@
.pcr-result { .pcr-result {
height: 1rem !important; height: 1rem !important;
} }
.container-after-titlebar {
padding: 20px;
}
</style> </style>
@@pwa@@ @@pwa@@
</head> </head>

View File

@ -142,6 +142,26 @@ var envConstruction = [
desc: '@@srcUrlWarn@@', desc: '@@srcUrlWarn@@',
after: '' after: ''
} }
},
{
id: 'frame',
storage: 'frame',
checkbox: true,
setValue: true,
text: {
head: '@@frame@@',
desc: '@@frameWarn@@',
checkbox: [
{
text: '@@show@@',
value: 'true'
},
{
text: '@@hide@@',
value: 'false'
}
]
}
} }
] ]
var tlConstruction = [ var tlConstruction = [