Fix: cannot show when dled imga

This commit is contained in:
cutls 2020-05-11 18:42:52 +09:00
parent c005b546ba
commit c2f1aec8b6
4 changed files with 224 additions and 221 deletions

View File

@ -49,7 +49,7 @@ onmessage = function(e) {
} else if (e.data[0] == 'generalDL') {
ipc.send('general-dl', e.data[1])
} else if (e.data[0] == 'openFinder') {
ipc.send('open-finder', e.data[1])
ipc.send('openFinder', e.data[1])
} else if (e.data[0] == 'columnDel') {
ipc.send('column-del', e.data[1])
} else if (e.data[0] == 'lang') {
@ -156,12 +156,12 @@ ipc.on('resizeJudgement', function(event, b64) {
var width = element.naturalWidth
var height = element.naturalHeight
if (width > resize || height > resize) {
ipc.send('resize-image', [b64, resize])
ipc.send('resize-image', [b64[0], resize])
} else {
postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
}
}
element.src = b64
element.src = 'data:image/png;base64,' + b64[0]
} else {
postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
}
@ -171,7 +171,7 @@ ipc.on('general-dl-prog', function(event, arg) {
console.log('Progress: ' + arg)
})
ipc.on('general-dl-message', function(event, arg) {
var argC = arg.replace(/\\/g, '\\\\') + '\\\\.'
var argC = arg.replace(/\\/g, '\\\\')
console.log('saved')
postMessage(['toastSaved', [arg, argC]], '*')
})

View File

@ -95,6 +95,7 @@ function dl(mainWindow, lang_path, base, dirname) {
var name = ''
var platform = process.platform
var bit = process.arch
const filename = args[0].match(/https:\/\/.+\/(.+\..+)$/)
if (args[1] == '') {
if (platform == 'win32') {
var dir = app.getPath('home') + '\\Pictures\\TheDesk'
@ -115,11 +116,21 @@ function dl(mainWindow, lang_path, base, dirname) {
}
download(BrowserWindow.getFocusedWindow(), args[0], opts)
.then(dl => {
event.sender.webContents.send('general-dl-message', dir)
if(filename[1]) {
if (platform == 'win32') {
var name = dir + '\\' + filename[1]
} else if (platform == 'linux' || platform == 'darwin') {
var name = dir + '/' + filename[1]
}
} else {
var name = dir
}
event.sender.webContents.send('general-dl-message', name)
})
.catch(console.error)
})
ipc.on('open-finder', (e, folder) => {
ipc.on('openFinder', (e, folder) => {
console.log(folder)
shell.showItemInFolder(folder)
})
}

View File

@ -1,314 +1,303 @@
function system(mainWindow, dir, lang, dirname) {
const electron = require("electron");
const app = electron.app;
const join = require("path").join;
var Jimp = require("jimp");
const fs = require("fs");
var JSON5 = require("json5");
var ipc = electron.ipcMain;
const clipboard = electron.clipboard;
var tmp_img = join(app.getPath("userData"), "tmp.png");
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
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");
const electron = require('electron')
const app = electron.app
const join = require('path').join
var Jimp = require('jimp')
const fs = require('fs')
var JSON5 = require('json5')
var ipc = electron.ipcMain
const clipboard = electron.clipboard
var tmp_img = join(app.getPath('userData'), 'tmp.png')
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
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();
var today = new Date()
//今日のやつ
var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
var todayStr = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '.log'
//昨日のやつ
today.setDate(today.getDate() - 1);
var yestStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
today.setDate(today.getDate() - 1)
var yestStr = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '.log'
//一昨日のやつ
today.setDate(today.getDate() - 1);
var yest2Str = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
today.setDate(today.getDate() - 1)
var yest2Str = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '.log'
const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog;
const os = require("os");
const language = require("../main/language.js");
const BrowserWindow = electron.BrowserWindow
const dialog = electron.dialog
const os = require('os')
const language = require('../main/language.js')
//プラットフォーム
ipc.on("getPlatform", function(e, arg) {
ipc.on('getPlatform', function (e, arg) {
try {
var gitHash = fs.readFileSync("git", "utf8");
var gitHash = fs.readFileSync('git', 'utf8')
} catch {
var gitHash = null;
var gitHash = null
}
e.sender.webContents.send("platform", [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]);
});
e.sender.webContents.send('platform', [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash])
})
//言語
ipc.on("lang", function(e, arg) {
console.log("set:" + arg);
fs.writeFileSync(lang_path, arg);
e.sender.webContents.send("langres", arg);
});
ipc.on('lang', function (e, arg) {
console.log('set:' + arg)
fs.writeFileSync(lang_path, arg)
e.sender.webContents.send('langres', arg)
})
//エクスポートのダイアログ
ipc.on("exportSettings", function(e, args) {
dialog.showSaveDialog(
mainWindow,
{
title: "Export",
properties: ["openFile", "createDirectory"],
defaultPath: "export.thedeskconfig.json5"
},
savedFiles => {
ipc.on('exportSettings', function (e, args) {
let savedFiles = dialog.showSaveDialogSync(mainWindow, {
title: 'Export',
properties: ['openFile', 'createDirectory'],
defaultPath: 'export.thedeskconfig.json5',
})
if (!savedFiles) {
return false;
return false
}
e.sender.webContents.send("exportSettingsFile", savedFiles);
}
);
});
e.sender.webContents.send('exportSettingsFile', savedFiles)
})
//インポートのダイアログ
ipc.on("importSettings", function(e, args) {
dialog.showOpenDialog(
mainWindow,
{
title: "Import",
properties: ["openFile"],
filters: [{ name: "TheDesk Config", extensions: ["thedeskconfig", "thedeskconfigv2", "json5"] }]
},
fileNames => {
console.log("imported from: ", fileNames)
ipc.on('importSettings', function (e, args) {
let fileNames = dialog.showOpenDialogSync(mainWindow, {
title: 'Import',
properties: ['openFile'],
filters: [{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] }],
})
console.log('imported from: ', fileNames)
if (!fileNames) {
return false;
return false
}
e.sender.webContents.send("config", JSON5.parse(fs.readFileSync(fileNames[0], "utf8")));
}
);
});
e.sender.webContents.send('config', JSON5.parse(fs.readFileSync(fileNames[0], 'utf8')))
})
//保存フォルダのダイアログ
ipc.on("savefolder", function(e, args) {
dialog.showOpenDialog(
ipc.on('savefolder', function (e, args) {
let fileNames = dialog.showOpenDialogSync(
mainWindow,
{
title: "Save folder",
properties: ["openDirectory"]
},
fileNames => {
e.sender.webContents.send("savefolder", fileNames[0]);
title: 'Save folder',
properties: ['openDirectory'],
}
);
});
)
e.sender.webContents.send('savefolder', fileNames[0])
})
//カスタムサウンドのダイアログ
ipc.on("customSound", function(e, arg) {
dialog.showOpenDialog(
ipc.on('customSound', function (e, arg) {
let fileNames = dialog.showOpenDialogSync(
mainWindow,
{
title: "Custom sound",
properties: ["openFile"],
filters: [{ name: "Audio", extensions: ["mp3", "aac", "wav", "flac", "m4a"] }, { name: "All", extensions: ["*"] }]
},
fileNames => {
e.sender.webContents.send("customSoundRender", [arg, fileNames[0]]);
title: 'Custom sound',
properties: ['openFile'],
filters: [
{ name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] },
{ name: 'All', extensions: ['*'] },
],
}
);
});
)
e.sender.webContents.send('customSoundRender', [arg, fileNames[0]])
})
//ハードウェアアクセラレーションの無効化
ipc.on("ha", function(e, arg) {
if (arg == "true") {
fs.writeFileSync(ha_path, arg);
ipc.on('ha', function (e, arg) {
if (arg == 'true') {
fs.writeFileSync(ha_path, arg)
} else {
fs.unlink(ha_path, function(err) {});
fs.unlink(ha_path, function (err) {})
}
app.relaunch();
app.exit();
});
app.relaunch()
app.exit()
})
//ユーザーエージェント
ipc.on("ua", function(e, arg) {
if (arg == "") {
fs.unlink(ua_path, function(err) {});
ipc.on('ua', function (e, arg) {
if (arg == '') {
fs.unlink(ua_path, function (err) {})
} else {
fs.writeFileSync(ua_path, arg);
fs.writeFileSync(ua_path, arg)
}
app.relaunch();
app.exit();
});
app.relaunch()
app.exit()
})
//フレームのありなし
ipc.on("frameSet", function(e, arg) {
fs.writeFileSync(frame_path, arg);
app.relaunch();
app.exit();
});
ipc.on('frameSet', function (e, arg) {
fs.writeFileSync(frame_path, arg)
app.relaunch()
app.exit()
})
//スクリーンリーダー
ipc.on("acsCheck", function(e, arg) {
ipc.on('acsCheck', function (e, arg) {
if (app.accessibilitySupportEnabled) {
mainWindow.webContents.send('accessibility', 'true')
}
});
ipc.on("quit", (e, args) => {
app.quit();
});
ipc.on("about", (e, args) => {
about();
});
})
ipc.on('quit', (e, args) => {
app.quit()
})
ipc.on('about', (e, args) => {
about()
})
function about() {
var ver = app.getVersion();
var ver = app.getVersion()
var window = new BrowserWindow({
webPreferences: {
webviewTag: false,
nodeIntegration: false,
contextIsolation: true,
preload: join(dirname, "js", "platform", "preload.js")
preload: join(dirname, 'js', 'platform', 'preload.js'),
},
width: 300,
height: 500,
transparent: false, // ウィンドウの背景を透過
frame: false, // 枠の無いウィンドウ
resizable: false
});
window.loadURL(dir + "/about.html?ver=" + ver);
return "true";
resizable: false,
})
window.loadURL(dir + '/about.html?ver=' + ver)
return 'true'
}
ipc.on("nano", function(e, x, y) {
var nano_info_path = join(app.getPath("userData"), "nano-window-position.json");
var window_pos;
ipc.on('nano', function (e, x, y) {
var nano_info_path = join(app.getPath('userData'), 'nano-window-position.json')
var window_pos
try {
window_pos = JSON.parse(fs.readFileSync(nano_info_path, "utf8"));
window_pos = JSON.parse(fs.readFileSync(nano_info_path, 'utf8'))
} catch (e) {
window_pos = [0, 0]; // デフォルトバリュー
window_pos = [0, 0] // デフォルトバリュー
}
var nanowindow = new BrowserWindow({
webPreferences: {
webviewTag: false,
nodeIntegration: false,
contextIsolation: true,
preload: join(dirname, "js", "platform", "preload.js")
preload: join(dirname, 'js', 'platform', 'preload.js'),
},
width: 350,
height: 140,
transparent: false, // ウィンドウの背景を透過
frame: false, // 枠の無いウィンドウ
resizable: false
});
nanowindow.loadURL(dir + "/nano.html");
nanowindow.setAlwaysOnTop(true);
resizable: false,
})
nanowindow.loadURL(dir + '/nano.html')
nanowindow.setAlwaysOnTop(true)
//nanowindow.toggleDevTools()
nanowindow.setPosition(window_pos[0], window_pos[1]);
nanowindow.on("close", function() {
fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition()));
});
return true;
});
var cbTimer1;
ipc.on("startmem", (e, arg) => {
event = e.sender;
cbTimer1 = setInterval(mems, 1000);
});
nanowindow.setPosition(window_pos[0], window_pos[1])
nanowindow.on('close', function () {
fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition()))
})
return true
})
var cbTimer1
ipc.on('startmem', (e, arg) => {
event = e.sender
cbTimer1 = setInterval(mems, 1000)
})
function mems() {
var mem = os.totalmem() - os.freemem();
var mem = os.totalmem() - os.freemem()
if (mainWindow) {
event.webContents.send("memory", [mem, os.cpus()[0].model, os.totalmem()]);
event.webContents.send('memory', [mem, os.cpus()[0].model, os.totalmem()])
}
}
ipc.on("endmem", (e, arg) => {
ipc.on('endmem', (e, arg) => {
if (cbTimer1) {
clearInterval(cbTimer1);
clearInterval(cbTimer1)
}
});
})
ipc.on("export", (e, args) => {
fs.writeFileSync(args[0], JSON5.stringify(args[1]));
e.sender.webContents.send("exportAllComplete", "");
});
ipc.on('export', (e, args) => {
fs.writeFileSync(args[0], JSON5.stringify(args[1]))
e.sender.webContents.send('exportAllComplete', '')
})
//フォント
function object_array_sort(data, key, order, fn) {
//デフォは降順(DESC)
var num_a = -1;
var num_b = 1;
var num_a = -1
var num_b = 1
if (order === "asc") {
if (order === 'asc') {
//指定があれば昇順(ASC)
num_a = 1;
num_b = -1;
num_a = 1
num_b = -1
}
data = data.sort(function (a, b) {
var x = a[key];
var y = b[key];
if (x > y) return num_a;
if (x < y) return num_b;
return 0;
});
var x = a[key]
var y = b[key]
if (x > y) return num_a
if (x < y) return num_b
return 0
})
//重複排除
var arrObj = {};
var arrObj = {}
for (var i = 0; i < data.length; i++) {
arrObj[data[i]["family"]] = data[i];
arrObj[data[i]['family']] = data[i]
}
data = [];
data = []
for (var key in arrObj) {
data.push(arrObj[key]);
data.push(arrObj[key])
}
fn(data); // ソート後の配列を返す
fn(data) // ソート後の配列を返す
}
ipc.on("fonts", (e, arg) => {
var SystemFonts = require('system-font-families').default;
var fm = new SystemFonts();
const fontList = fm.getFontsSync();
e.sender.webContents.send("font-list", fontList);
});
ipc.on('fonts', (e, arg) => {
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) => {
clipboard.writeText(arg);
});
ipc.on('copy', (e, arg) => {
clipboard.writeText(arg)
})
//ログ
ipc.on("log", (e, arg) => {
var today = new Date();
var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate();
var log_path = join(log_dir_path, todayStr + ".log");
fs.appendFile(log_path, "\n" + arg, function(err) {
ipc.on('log', (e, arg) => {
var today = new Date()
var todayStr = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate()
var log_path = join(log_dir_path, todayStr + '.log')
fs.appendFile(log_path, '\n' + arg, function (err) {
if (err) {
throw err;
throw err
}
});
});
ipc.on("getLogs", (e, arg) => {
var logs=""
var todayLog=""
var yestLog=""
var yest2Log=""
})
})
ipc.on('getLogs', (e, arg) => {
var logs = ''
var todayLog = ''
var yestLog = ''
var yest2Log = ''
fs.readdir(log_dir_path, function (err, files) {
if (err) throw err;
if (err) throw err
files.filter(function (file) {
if (file == todayStr) {
todayLog=fs.readFileSync(join(log_dir_path, file), "utf8")
todayLog = fs.readFileSync(join(log_dir_path, file), 'utf8')
}
if (file == yestStr) {
yestLog=logs+fs.readFileSync(join(log_dir_path, file), "utf8")
yestLog = logs + fs.readFileSync(join(log_dir_path, file), 'utf8')
}
if (file == yest2Str) {
yest2Log=fs.readFileSync(join(log_dir_path, file), "utf8")
yest2Log = fs.readFileSync(join(log_dir_path, file), 'utf8')
}
logs = todayLog + yestLog + yest2Log;
});
logs = yest2Log + yestLog + todayLog;
e.sender.webContents.send("logData", logs);
});
});
logs = todayLog + yestLog + yest2Log
})
logs = yest2Log + yestLog + todayLog
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.code === "ENOENT") {
fs.mkdirSync(log_dir_path);
if (error.code === 'ENOENT') {
fs.mkdirSync(log_dir_path)
} else {
return;
return
}
} else {
fs.readdir(log_dir_path, function (err, files) {
if (err) throw err;
if (err) throw err
files.filter(function (file) {
if (file != todayStr && file != yestStr && file != yest2Str) {
fs.unlinkSync(join(log_dir_path, file));
fs.unlinkSync(join(log_dir_path, file))
}
});
});
})
})
}
});
})
}
exports.system = system;
exports.system = system

View File

@ -1199,12 +1199,15 @@
<a href="https://thedesk.top" target="_blank">HP</a><br />
<a href="https://github.com/cutls/TheDesk" target="_blank">GitHub</a><br />
<br />
<div id="release-21-0-0_Mayu" class="release-do" style="display:none; ">
<div id="release-21-0-1_Mayu" class="release-do" style="display:none; ">
<br />
<a href="https://ja.mstdn.wiki/TheDesk" target="_blank">機能一覧</a><br />
Pixiv
FanboxやPatreonでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。最低月一更新。<br />
困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。
<h5>Release Note 21.0.1 (Mayu)</h5>
・画像がアップロードできない <a onclick="udgEx('popn_ja@popon.pptdn.jp','main')" class="contributor"><img src="https://avatars3.githubusercontent.com/u/24523508?s=88&v=4">kaias1jp </a><a onclick="udgEx('Cutls@cutls.com','main')" class="contributor"><img src="https://media.thedesk.top/accounts/avatars/000/000/001/original/d34ef8bb49d5e011.png">cutls</a><br>
<h5>Release Note 21.0.0 (Mayu)</h5>
・フォロリクをストリーミングで受け取ったときにNo status hereになる <a onclick="udgEx('Cutls@cutls.com','main')" class="contributor"><img src="https://media.thedesk.top/accounts/avatars/000/000/001/original/d34ef8bb49d5e011.png">cutls</a><br>
・Apple MusicのNowPlayingでアルバム情報がないときの挙動を改善 <a onclick="udgEx('Cutls@cutls.com','main')" class="contributor"><img src="https://media.thedesk.top/accounts/avatars/000/000/001/original/d34ef8bb49d5e011.png">cutls</a><br>