on about window open link with external browser

This commit is contained in:
cutls 2022-10-11 01:03:14 +09:00
parent 03b2fed9ef
commit 7ba34c1074
3 changed files with 51 additions and 37 deletions

View File

@ -124,8 +124,9 @@
} }
$('#hash').html('<a href="https://github.com/cutls/TheDesk/commits/' + about[3] + '" target="_blank">' + about[3].slice(0, 7) + '</a>') $('#hash').html('<a href="https://github.com/cutls/TheDesk/commits/' + about[3] + '" target="_blank">' + about[3].slice(0, 7) + '</a>')
$(document).on('click', 'a', (e) => { $(document).on('click', 'a', (e) => {
e.preventDefault()
var url = $(e.target).attr('href') var url = $(e.target).attr('href')
postMessage(['openUrl', url], '*') postMessage(['openUrlMainProcess', url], '*')
return false return false
}) })
</script> </script>

View File

@ -7,12 +7,17 @@ window.addEventListener('DOMContentLoaded', () => {
ipc.send('acsCheck', '') ipc.send('acsCheck', '')
}) })
onmessage = function(e) { onmessage = async function (e) {
if (e.data[0] == 'openUrl') { if (e.data[0] == 'openUrl') {
urls = e.data[1].match(/https?:\/\/(.+)/) urls = e.data[1].match(/https?:\/\/(.+)/)
if (urls) { if (urls) {
shell.openExternal(e.data[1]) shell.openExternal(e.data[1])
} }
} else if (e.data[0] == 'openUrlMainProcess') {
urls = e.data[1].match(/https?:\/\/(.+)/)
if (urls) {
ipc.send('openUrl', e.data[1])
}
} else if (e.data[0] == 'sendSinmpleIpc') { } else if (e.data[0] == 'sendSinmpleIpc') {
ipc.send(e.data[1], '') ipc.send(e.data[1], '')
} else if (e.data[0] == 'dialogStore') { } else if (e.data[0] == 'dialogStore') {
@ -91,17 +96,16 @@ onmessage = function(e) {
} }
//version.js //version.js
ipc.send('getPlatform', '') ipc.send('getPlatform', '')
ipc.on('platform', function(event, args) { ipc.on('platform', function (event, args) {
localStorage.setItem('platform', args[0]) localStorage.setItem('platform', args[0])
localStorage.setItem('bit', args[1]) localStorage.setItem('bit', args[1])
localStorage.setItem('about', JSON.stringify([args[2], args[3], args[4], args[5]])) localStorage.setItem('about', JSON.stringify([args[2], args[3], args[4], args[5]]))
}) })
ipc.on('reload', function (event, arg) {
ipc.on('reload', function(event, arg) {
location.reload() location.reload()
}) })
//Native Notf //Native Notf
ipc.on('shownotf', function(event, args) { ipc.on('shownotf', function (event, args) {
if (args['type'] == 'toot') { if (args['type'] == 'toot') {
postMessage(['details', [id, acct_id]], '*') postMessage(['details', [id, acct_id]], '*')
} else if (args['type'] == 'userdata') { } else if (args['type'] == 'userdata') {
@ -110,7 +114,7 @@ ipc.on('shownotf', function(event, args) {
}) })
//first.js //first.js
ipc.on('custom-css-response', function(event, arg) { ipc.on('custom-css-response', function (event, arg) {
if (arg == '') { if (arg == '') {
return false return false
} }
@ -121,7 +125,7 @@ ipc.on('custom-css-response', function(event, arg) {
styleNode.append(content) styleNode.append(content)
document.getElementsByTagName('head')[0].append(styleNode) document.getElementsByTagName('head')[0].append(styleNode)
}) })
ipc.on('theme-css-response', function(event, arg) { ipc.on('theme-css-response', function (event, arg) {
if (arg == '') { if (arg == '') {
return false return false
} }
@ -133,7 +137,7 @@ ipc.on('theme-css-response', function(event, arg) {
document.getElementsByTagName('head')[0].append(styleNode) document.getElementsByTagName('head')[0].append(styleNode)
}) })
//img.js //img.js
ipc.on('bmp-img-comp', function(event, b64) { ipc.on('bmp-img-comp', function (event, b64) {
if (b64[2]) { if (b64[2]) {
var stamped = true var stamped = true
} else { } else {
@ -141,12 +145,12 @@ ipc.on('bmp-img-comp', function(event, b64) {
} }
postMessage(['media', [b64[0], 'image/png', b64[1], stamped]], '*') postMessage(['media', [b64[0], 'image/png', b64[1], stamped]], '*')
}) })
ipc.on('resizeJudgement', function(event, b64) { ipc.on('resizeJudgement', function (event, b64) {
var resize = localStorage.getItem('uploadCrop') * 1 var resize = localStorage.getItem('uploadCrop') * 1
if (resize > 0) { if (resize > 0) {
var element = new Image() var element = new Image()
var width var width
element.onload = function() { element.onload = function () {
var width = element.naturalWidth var width = element.naturalWidth
var height = element.naturalHeight var height = element.naturalHeight
if (width > resize || height > resize) { if (width > resize || height > resize) {
@ -161,88 +165,88 @@ ipc.on('resizeJudgement', function(event, b64) {
} }
}) })
//ui,img.js //ui,img.js
ipc.on('general-dl-prog', function(event, arg) { ipc.on('general-dl-prog', function (event, arg) {
console.log('Progress: ' + arg) console.log('Progress: ' + arg)
}) })
ipc.on('general-dl-message', function(event, arg) { ipc.on('general-dl-message', function (event, arg) {
var argC = arg.replace(/\\/g, '\\\\') var argC = arg.replace(/\\/g, '\\\\')
console.log('saved') console.log('saved')
postMessage(['toastSaved', [arg, argC]], '*') postMessage(['toastSaved', [arg, argC]], '*')
}) })
//setting.js //setting.js
ipc.on('langres', function(event, arg) { ipc.on('langres', function (event, arg) {
location.href = '../' + arg + '/setting.html' location.href = '../' + arg + '/setting.html'
}) })
ipc.on('exportSettingsFile', function(event, arg) { ipc.on('exportSettingsFile', function (event, arg) {
postMessage(['exportSettingsCore', arg], '*') postMessage(['exportSettingsCore', arg], '*')
}) })
ipc.on('exportAllComplete', function(event, arg) { ipc.on('exportAllComplete', function (event, arg) {
postMessage(['alert', 'Complete'], '*') postMessage(['alert', 'Complete'], '*')
}) })
ipc.on('config', function(event, arg) { ipc.on('config', function (event, arg) {
postMessage(['importSettingsCore', arg], '*') postMessage(['importSettingsCore', arg], '*')
}) })
ipc.on('savefolder', function(event, arg) { ipc.on('savefolder', function (event, arg) {
localStorage.setItem('savefolder', arg) localStorage.setItem('savefolder', arg)
}) })
ipc.on('font-list', function(event, arg) { ipc.on('font-list', function (event, arg) {
postMessage(['fontList', arg], '*') postMessage(['fontList', arg], '*')
}) })
ipc.on('customSoundRender', function(event, args) { ipc.on('customSoundRender', function (event, args) {
postMessage(['customSoundSave', [args[0], args[1]]], '*') postMessage(['customSoundSave', [args[0], args[1]]], '*')
}) })
ipc.on('theme-json-list-response', function(event, args) { ipc.on('theme-json-list-response', function (event, args) {
postMessage(['ctLoadCore', args], '*') postMessage(['ctLoadCore', args], '*')
}) })
ipc.on('theme-json-delete-complete', function(event, args) { ipc.on('theme-json-delete-complete', function (event, args) {
postMessage(['ctLoad', ''], '*') postMessage(['ctLoad', ''], '*')
}) })
ipc.on('theme-json-response', function(event, args) { ipc.on('theme-json-response', function (event, args) {
postMessage(['customConnect', args], '*') postMessage(['customConnect', args], '*')
}) })
ipc.on('theme-json-create-complete', function(event, args) { ipc.on('theme-json-create-complete', function (event, args) {
if(args != '') alert(args) if (args != '') alert(args)
postMessage(['clearCustomImport', ''], '*') postMessage(['clearCustomImport', ''], '*')
postMessage(['ctLoad', ''], '*') postMessage(['ctLoad', ''], '*')
}) })
//spotify.js //spotify.js
ipc.on('itunes-np', function(event, arg) { ipc.on('itunes-np', function (event, arg) {
postMessage(['npCore', arg], '*') postMessage(['npCore', arg], '*')
}) })
//tips.js //tips.js
ipc.on('memory', function(event, arg) { ipc.on('memory', function (event, arg) {
var use = arg[0] var use = arg[0]
var cpu = arg[1] var cpu = arg[1]
var total = arg[2] var total = arg[2]
postMessage(['renderMem', [use, cpu, total, arg[3], arg[4]]], '*') postMessage(['renderMem', [use, cpu, total, arg[3], arg[4]]], '*')
}) })
//log //log
ipc.on('logData', function(event, args) { ipc.on('logData', function (event, args) {
postMessage(['logData', args], '*') postMessage(['logData', args], '*')
}) })
//update.html //update.html
ipc.on('prog', function(event, arg) { ipc.on('prog', function (event, arg) {
postMessage(['updateProg', arg], '*') postMessage(['updateProg', arg], '*')
}) })
ipc.on('mess', function(event, arg) { ipc.on('mess', function (event, arg) {
postMessage(['updateMess', arg], '*') postMessage(['updateMess', arg], '*')
}) })
//misc //misc
ipc.on('asRead', function(event, arg) { ipc.on('asRead', function (event, arg) {
postMessage(['asRead', ''], '*') postMessage(['asRead', ''], '*')
}) })
ipc.on('asReadEnd', function(event, arg) { ipc.on('asReadEnd', function (event, arg) {
postMessage(['asReadEnd', ''], '*') postMessage(['asReadEnd', ''], '*')
}) })
ipc.on('accessibility', function(event, arg) { ipc.on('accessibility', function (event, arg) {
postMessage(['accessibility', 'true'], '*') postMessage(['accessibility', 'true'], '*')
}) })
ipc.on('twitterLoginComplete', function(event, arg) { ipc.on('twitterLoginComplete', function (event, arg) {
postMessage(['twitterLoginComplete', ''], '*') postMessage(['twitterLoginComplete', ''], '*')
}) })
ipc.on('alert', function(event, arg) { ipc.on('alert', function (event, arg) {
postMessage(['alert', arg], '*') postMessage(['alert', arg], '*')
}) })
ipc.on('customUrl', function(event, args) { ipc.on('customUrl', function (event, args) {
postMessage(['customUrl', args], '*') postMessage(['customUrl', args], '*')
}) })

View File

@ -1,3 +1,5 @@
const { shell } = require('electron')
function system(mainWindow, dir, lang, dirname) { function system(mainWindow, dir, lang, dirname) {
const electron = require('electron') const electron = require('electron')
const app = electron.app const app = electron.app
@ -144,6 +146,9 @@ function system(mainWindow, dir, lang, dirname) {
ipc.on('about', (e, args) => { ipc.on('about', (e, args) => {
about() about()
}) })
ipc.on('openUrl', function (event, arg) {
shell.openExternal(arg)
})
function about() { function about() {
var ver = app.getVersion() var ver = app.getVersion()
var window = new BrowserWindow({ var window = new BrowserWindow({
@ -151,7 +156,9 @@ function system(mainWindow, dir, lang, dirname) {
webviewTag: false, webviewTag: false,
nodeIntegration: false, nodeIntegration: false,
contextIsolation: true, contextIsolation: true,
preload: join(dirname, 'js', 'platform', 'preload.js'), spellcheck: false,
sandbox: false,
preload: join(__dirname, 'js', 'platform', 'preload.js'),
}, },
width: 300, width: 300,
height: 500, height: 500,
@ -175,6 +182,7 @@ function system(mainWindow, dir, lang, dirname) {
webviewTag: false, webviewTag: false,
nodeIntegration: false, nodeIntegration: false,
contextIsolation: true, contextIsolation: true,
sandbox: false,
preload: join(dirname, 'js', 'platform', 'preload.js'), preload: join(dirname, 'js', 'platform', 'preload.js'),
}, },
width: 350, width: 350,
@ -321,6 +329,7 @@ function system(mainWindow, dir, lang, dirname) {
webviewTag: false, webviewTag: false,
nodeIntegration: false, nodeIntegration: false,
contextIsolation: true, contextIsolation: true,
sandbox: false,
preload: join(dirname, 'js', 'platform', 'preload.js'), preload: join(dirname, 'js', 'platform', 'preload.js'),
}, },
width: 414, width: 414,