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
const customTitlebar = require('custom-electron-titlebar')
window.addEventListener('DOMContentLoaded', () => {
ipc.send('frameCheck', '')
ipc.on('frame', function(event, args) {
const file = location.href.substr(-10)
if (
file == 'index.html' ||
@ -16,6 +18,7 @@ window.addEventListener('DOMContentLoaded', () => {
icon: '../../img/desk.png'
})
}
})
})
onmessage = function(e) {
@ -65,6 +68,8 @@ onmessage = function(e) {
ipc.send('theme-json-request', e.data[1])
} else if (e.data[0] == 'ha') {
ipc.send('ha', e.data[1])
} else if (e.data[0] == 'frameSet') {
ipc.send('frameSet', e.data[1])
} else if (e.data[0] == 'ua') {
ipc.send('ua', e.data[1])
} else if (e.data[0] == 'aboutData') {

View File

@ -17,6 +17,9 @@ var envView = new Vue({
if (ls == 'ua_setting') {
useragent(val)
}
if (ls == 'frame') {
frameSet(val)
}
return true
}
}
@ -764,6 +767,9 @@ function hardwareAcceleration(had) {
function useragent(val) {
postMessage(['ua', val], '*')
}
function frameSet(val) {
postMessage(['frameSet', val], '*')
}
function 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 ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
var ua_path = join(app.getPath('userData'), 'useragent')
var frame_path = join(app.getPath('userData'), 'frame')
try {
fs.readFileSync(ha_path, 'utf8')
app.disableHardwareAcceleration()
@ -97,6 +98,16 @@ function isFile(file) {
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() {
electron.session.defaultSession.clearCache(() => {})
@ -142,7 +153,7 @@ function createWindow() {
y: window_size.y,
icon: __dirname + '/desk.png',
show: false,
frame: false,
frame: frame,
resizable: true
}
} else if (platform == 'win32') {
@ -158,7 +169,8 @@ function createWindow() {
x: window_size.x,
y: window_size.y,
simpleFullscreen: true,
show: false
show: false,
frame: frame
}
} else if (platform == 'darwin') {
var arg = {
@ -173,7 +185,8 @@ function createWindow() {
x: window_size.x,
y: window_size.y,
simpleFullscreen: true,
show: false
show: false,
frame: frame,
}
}
mainWindow = new BrowserWindow(arg)
@ -282,9 +295,11 @@ function createWindow() {
var platform = process.platform
var bit = process.arch
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)
}
//CSS
css.css(mainWindow)
//アップデータとダウンロード

View File

@ -1,12 +1,19 @@
// 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"){
lang = "en"
}
const electron = require("electron");
const ipc = electron.ipcMain;
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const join = require('path').join;
ipc.on("frameCheck", function(e, arg) {
if(!frame) {
e.sender.webContents.send("frame", "");
}
});
const dict = {
"application": {
"ja": "アプリケーション",

View File

@ -12,6 +12,7 @@ function system(mainWindow, dir, lang, dirname) {
var ua_path = join(app.getPath("userData"), "useragent");
var lang_path = join(app.getPath("userData"), "language");
var log_dir_path = join(app.getPath("userData"), "logs");
var frame_path = join(app.getPath("userData"), "frame");
//ログ
var today = new Date();
//今日のやつ
@ -115,6 +116,7 @@ function system(mainWindow, dir, lang, dirname) {
app.relaunch();
app.exit();
});
//ユーザーエージェント
ipc.on("ua", function(e, arg) {
if (arg == "") {
fs.unlink(ua_path, function(err) {});
@ -124,6 +126,12 @@ function system(mainWindow, dir, lang, dirname) {
app.relaunch();
app.exit();
});
//フレームのありなし
ipc.on("frameSet", function(e, arg) {
fs.writeFileSync(frame_path, arg);
app.relaunch();
app.exit();
});
ipc.on("quit", (e, args) => {
app.quit();
@ -278,6 +286,7 @@ function system(mainWindow, dir, lang, dirname) {
e.sender.webContents.send("logData", logs);
});
});
//起動時ログディレクトリ存在確認と作成、古ログ削除
fs.access(log_dir_path, fs.constants.R_OK | fs.constants.W_OK, error => {
if (error) {

View File

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

View File

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

View File

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

View File

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

View File

@ -142,6 +142,26 @@ var envConstruction = [
desc: '@@srcUrlWarn@@',
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 = [