diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index e39178a6..235008c4 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -4,18 +4,21 @@ 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' + ipc.send('frameCheck', '') + ipc.on('frame', function(event, args) { + 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) { @@ -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') { diff --git a/app/js/post/secure.js b/app/js/post/secure.js index ce66d7f6..9440344b 100644 --- a/app/js/post/secure.js +++ b/app/js/post/secure.js @@ -96,9 +96,9 @@ function cw() { } } //TLでコンテントワーニングを表示トグル -function cw_show(id) { - $('.cw_hide_' + id).toggleClass('cw') - $('.cw-long-' + id).toggleClass('hide') +function cw_show(e) { + $(e).parent().parent().find('.cw_hide').toggleClass('cw') + $(e).parent().find('.cw_long').toggleClass('hide') } $(function() { $('#cw-text').on('change', function(event) { diff --git a/app/js/tl/misskeyparse.js b/app/js/tl/misskeyparse.js index 3e1731e5..32e95077 100644 --- a/app/js/tl/misskeyparse.js +++ b/app/js/tl/misskeyparse.js @@ -360,22 +360,20 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { if ((toot.cw || toot.cw == "") && cw) { var content = escapeHTML(toot.text); var spoil = escapeHTMLtemp(toot.cw); - var spoiler = "cw cw_hide_" + toot.id; + var spoiler = "cw cw_hide"; var api_spoil = "gray"; - var spoiler_show = '' + lang.lang_parse_cwshow + '
'; + var spoiler_show = '' + lang.lang_parse_cwshow + '
'; } else { var ct1 = nl2br(toot.text).split('
').length - 2; var ct2 = nl2br(toot.text).split('
').length - 2; if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; } if ((sent < ct && $.mb_strlen($.strip_tagstemp(toot.text)) > 5) || ($.strip_tagstemp(toot.text).length > ltr && $.mb_strlen($.strip_tagstemp(toot.text)) > 5)) { var content = '' + lang.lang_parse_fulltext + '
' + escapeHTMLtemp(toot.text) - var spoil = '' + $.mb_substr($.strip_tagstemp( + var spoil = '' + $.mb_substr($.strip_tagstemp( toot.text), 0, 100) + '' + lang.lang_parse_autofold + ''; - var spoiler = "cw cw_hide_" + toot.id; - var spoiler_show = '' + lang.lang_parse_more + '
'; + var spoiler = "cw cw_hide"; + var spoiler_show = '' + lang.lang_parse_more + '
'; } else { var content = escapeHTMLtemp(toot.text); if (toot.cw) { diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index f065e7ed..607b1212 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -516,9 +516,9 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { } if (toot.spoiler_text && cw) { var spoil = escapeHTML(toot.spoiler_text) - var spoiler = 'cw cw_hide_' + toot.id + var spoiler = 'cw cw_hide' var api_spoil = 'gray' - var spoiler_show = `${lang.lang_parse_cwshow}
` + var spoiler_show = `${lang.lang_parse_cwshow}
` } else { if (content) { var ct1 = content.split('

').length + content.split('
').length - 2 @@ -538,14 +538,14 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { ($.mb_strlen($.strip_tags(content)) > ltr && $.mb_strlen($.strip_tags(content)) > 5) ) { var content = `${lang.lang_parse_fulltext}
` + content - var spoil = `${$.mb_substr( + var spoil = `${$.mb_substr( $.strip_tags(content), 0, 100 )} ${lang.lang_parse_autofold}` - var spoiler = 'cw cw_hide_' + toot.id - var spoiler_show = ` + var spoiler = 'cw cw_hide' + var spoiler_show = ` ${lang.lang_parse_more}
` } else { diff --git a/app/js/ui/settings.js b/app/js/ui/settings.js index d756810a..92e91b86 100644 --- a/app/js/ui/settings.js +++ b/app/js/ui/settings.js @@ -17,6 +17,9 @@ var envView = new Vue({ if (ls == 'ua_setting') { useragent(val) } + if (ls == 'frame') { + frameSet(val) + } return true } } @@ -504,11 +507,11 @@ function fontList(arg) { var font = arg[i] $('#fonts').append( '
' + - font.family + + font + '
' ) } @@ -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], '*') } diff --git a/app/js/ui/spotify.js b/app/js/ui/spotify.js index e52d1d4b..ba88850b 100644 --- a/app/js/ui/spotify.js +++ b/app/js/ui/spotify.js @@ -53,6 +53,16 @@ function spotifyFlagSave() { M.toast({ html: lang.lang_spotify_imgno, displayLength: 3000 }); } } +function aMusicFlagSave() { + var awk = $("[name=amw]:checked").val(); + if (awk == "yes") { + localStorage.setItem("complete-artwork", "yes"); + M.toast({ html: lang.lang_spotify_img, displayLength: 3000 }); + } else { + localStorage.removeItem("complete-artwork"); + M.toast({ html: lang.lang_spotify_imgno, displayLength: 3000 }); + } +} function nowplaying(mode) { if (mode == "spotify") { var start = "https://thedesk.top/now-playing?at=" + localStorage.getItem("spotify") + "&rt=" + localStorage.getItem("spotify-refresh"); @@ -124,7 +134,7 @@ function nowplaying(mode) { postMessage(["itunes", ""], "*"); } } -function npCore(arg) { +async function npCore(arg) { console.table(arg); var content = localStorage.getItem("np-temp"); if (!content || content == "" || content == "null") { @@ -139,6 +149,9 @@ function npCore(arg) { } else if (platform == "darwin") { if (flag && arg.artwork) { media(arg.artwork, "image/png", "new"); + } else if (flag && localStorage.getItem('complete-artwork')) { + var q = arg.artist + ' ' + arg.album.name + ' ' + arg.name + postMessage(["bmpImage", [await getUnknownAA(q), 0]], "*"); } } var regExp = new RegExp("{song}", "g"); @@ -183,3 +196,15 @@ if (location.search) { } else { } } +async function getUnknownAA(q) { + const start = 'https://itunes.apple.com/search?term=' + q + '&country=JP&entity=song' + let promise = await fetch(start, { + method: 'GET' + }) + const json = await promise.json() + if(!json.resultCount) { + return [] + } + const data = json.results + return data[0].artworkUrl100 +} \ No newline at end of file diff --git a/app/main.js b/app/main.js index af143831..eb1a748f 100644 --- a/app/main.js +++ b/app/main.js @@ -55,13 +55,14 @@ if (process.argv.indexOf('--dev') === -1) { '|||| /////\n' + '||||//////' ) - console.log('Welcome!') + console.log('If it does not show the window, you might forget `npm run construct`.') } var info_path = join(app.getPath('userData'), 'window-size.json') 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,18 @@ function isFile(file) { if (err.code === 'ENOENT') return false } } +try { + var frameRaw = fs.readFileSync(frame_path, 'utf8') + if(frameRaw == 'false') { + var frame = false + var frameTitle = 'hidden' + } else { + var frame = true + var frameTitle = 'default' + } +} catch { + var frame = true +} // 全てのウィンドウが閉じたら終了 app.on('window-all-closed', function() { electron.session.defaultSession.clearCache(() => {}) @@ -142,7 +155,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 +171,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 +187,9 @@ function createWindow() { x: window_size.x, y: window_size.y, simpleFullscreen: true, - show: false + show: false, + titleBarStyle: frameTitle, + frame: frame, } } mainWindow = new BrowserWindow(arg) @@ -282,9 +298,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)) ) - mainWindow.setMenu(null) + if(!frame) { + mainWindow.setMenu(null) + } //CSS css.css(mainWindow) //アップデータとダウンロード diff --git a/app/main/dl.js b/app/main/dl.js index affae9f1..9fc233dc 100644 --- a/app/main/dl.js +++ b/app/main/dl.js @@ -34,11 +34,12 @@ function dl(mainWindow, lang_path, base, dirname) { } }) //アプデDL - ipc.on('download-btn', (e, args) => { + ipc.on('download-btn', async (e, args) => { function dl(url, file, dir, e) { e.sender.webContents.send('mess', 'ダウンロードを開始します。') const opts = { directory: dir, + filename: file, openFolderWhenDone: true, onProgress: function(event) { e.sender.webContents.send('prog', event) @@ -54,29 +55,27 @@ function dl(mainWindow, lang_path, base, dirname) { } var platform = process.platform var bit = process.arch - dialog.showSaveDialog( - null, - { - title: 'Save', - defaultPath: app.getPath('home') + '/' + args[1] - }, - savedFiles => { - console.log(savedFiles) - if (!savedFiles) { - return false - } - if (platform == 'win32') { - var m = savedFiles.match(/(.+)\\(.+)$/) - } else { - var m = savedFiles.match(/(.+)\/(.+)$/) - } - //console.log(m); - if (isExistFile(savedFiles)) { - fs.unlinkSync(savedFiles) - } - dl(args[0], args[1], m[1], e) - } - ) + var options = { + title: 'Save', + defaultPath: app.getPath('home') + '/' + args[1] + } + const file = await dialog.showSaveDialog(null, options) + const savedFiles = file.filePath + console.log(savedFiles) + if (!savedFiles) { + return false + } + if (platform == 'win32') { + var m = savedFiles.match(/(.+)\\(.+)$/) + } else { + var m = savedFiles.match(/(.+)\/(.+)$/) + } + //console.log(m); + if (isExistFile(savedFiles)) { + fs.unlinkSync(savedFiles) + } + console.log(m) + dl(args[0], m[2], m[1], e) }) function isExistFile(file) { diff --git a/app/main/language.js b/app/main/language.js index 07ef568c..8b9beb30 100644 --- a/app/main/language.js +++ b/app/main/language.js @@ -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": "アプリケーション", diff --git a/app/main/system.js b/app/main/system.js index a671f241..7f5cedd8 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -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(); @@ -234,11 +242,10 @@ function system(mainWindow, dir, lang, dirname) { fn(data); // ソート後の配列を返す } ipc.on("fonts", (e, arg) => { - const fm = require("font-manager"); - var fonts = fm.getAvailableFontsSync(); - object_array_sort(fonts, "family", "asc", function(fonts_sorted) { - e.sender.webContents.send("font-list", fonts_sorted); - }); + var SystemFonts = require('system-font-families').default; + var fm = new SystemFonts(); + const fontList = fm.getFontsSync(); + e.sender.webContents.send("font-list", fontList); }); //コピー ipc.on("copy", (e, arg) => { @@ -278,6 +285,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) { diff --git a/app/package.json b/app/package.json index 74ef97cc..b94f5837 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "thedesk", - "version": "20.1.2", + "version": "20.2.0", "description": "TheDesk is a Mastodon client for PC.", "repository": "https://github.com/cutls/TheDesk", "main": "main.js", @@ -51,27 +51,27 @@ ], "license": "GPL-3.0", "dependencies": { - "@fortawesome/fontawesome-free": "^5.12.1", + "@fortawesome/fontawesome-free": "^5.13.0", "custom-electron-titlebar": "^3.2.2-hotfix62", "electron-dl": "^3.0.0", - "jimp": "^0.9.3", + "jimp": "^0.10.1", "jquery": "^3.4.1", "jquery-ui-dist": "^1.12.1", - "json5": "^2.1.1", + "json5": "^2.1.3", "lodash": "^4.17.15", "materialize-css": "git://github.com/cutls/materialize#v1-dev", "sumchecker": "^3.0.1", - "sweetalert2": "^9.7.2", + "sweetalert2": "^9.10.9", + "system-font-families": "^0.4.1", "vue": "^2.6.11" }, "optionalDependencies": { - "font-manager": "0.3.0", "itunes-nowplaying-mac": "0.3.1" }, "devDependencies": { "chokidar": "^3.3.1", "electron": "^8.0.0", - "electron-builder": "^22.1.0", + "electron-builder": "^22.4.1", "electron-rebuild": "^1.10.1", "readline-sync": "1.4.10" }, diff --git a/app/view/make/index.sample.html b/app/view/make/index.sample.html index 431ea2da..49a25c99 100644 --- a/app/view/make/index.sample.html +++ b/app/view/make/index.sample.html @@ -1189,47 +1189,20 @@ HP
GitHub

-