second instance to customurl
This commit is contained in:
parent
e9aa22f5cf
commit
28f6ccbfee
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -21,6 +21,7 @@ app/view/cs
|
|||
app/view/ps
|
||||
app/view/es-AR
|
||||
app/view/it-IT
|
||||
app/view/pl-PL
|
||||
app/git
|
||||
*.code-workspace
|
||||
releasenote.md
|
||||
|
|
|
@ -91,13 +91,13 @@ option {
|
|||
height: 100%;
|
||||
}
|
||||
#imagewrap img.rotate-90 {
|
||||
transform: rotate(-90deg)
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
#imagewrap img.rotate-180 {
|
||||
transform: rotate(-180deg)
|
||||
transform: rotate(-180deg);
|
||||
}
|
||||
#imagewrap img.rotate-270 {
|
||||
transform: rotate(-270deg)
|
||||
transform: rotate(-270deg);
|
||||
}
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
|
@ -417,13 +417,23 @@ input[type='color']::-webkit-color-swatch {
|
|||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
width: 13rem;
|
||||
height: 3.1rem;
|
||||
min-width: 150px;
|
||||
width: 50%;
|
||||
height: 2.5rem;
|
||||
cursor: pointer;
|
||||
color: var(--text);
|
||||
}
|
||||
#tltype .type div {
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
#tltype .type span {
|
||||
width: calc(100% - 2.3rem);
|
||||
width: calc(100% - 4rem);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
word-break: break-word;
|
||||
overflow: hidden;
|
||||
}
|
||||
#tltype .type:hover {
|
||||
background-color: var(--beforehover);
|
||||
|
@ -498,7 +508,8 @@ textarea {
|
|||
font-size: 1rem !important;
|
||||
font-family: inherit;
|
||||
}
|
||||
.swal2-popup, .swal2-header {
|
||||
.swal2-popup,
|
||||
.swal2-header {
|
||||
background-color: var(--subcolor) !important;
|
||||
}
|
||||
.swal2-title,
|
||||
|
@ -558,6 +569,7 @@ h2.swal2-title {
|
|||
background-color: var(--emphasized);
|
||||
}
|
||||
#pageSrc {
|
||||
border-radius: 10px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: calc(50vw - 11.53rem);
|
||||
|
@ -565,10 +577,22 @@ h2.swal2-title {
|
|||
max-width: 100%;
|
||||
background-color: var(--subcolor);
|
||||
z-index: 501;
|
||||
padding: 0.4rem;
|
||||
}
|
||||
#pageSrcInput {
|
||||
width: 12.3rem;
|
||||
.pageSrcBtn:hover {
|
||||
background-color: var(--active);
|
||||
}
|
||||
.srcQ {
|
||||
margin-top: 0.4rem;
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.lastPSB {
|
||||
margin-bottom: 0.4rem;
|
||||
}
|
||||
.pageSrcBtn {
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
.voice {
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
|
|
|
@ -423,10 +423,6 @@ function login(url) {
|
|||
versionChecker(url)
|
||||
$('#add').hide()
|
||||
postMessage(['openUrl', auth], '*')
|
||||
if ($('#linux:checked').val() == 'on') {
|
||||
} else {
|
||||
postMessage(['sendSinmpleIpc', 'quit'], '*')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,7 +621,7 @@ function misskeyAuth(url, mkc) {
|
|||
|
||||
//テキストボックスにURL入れた
|
||||
function instance() {
|
||||
var url = $('#url').val()
|
||||
var url = $('#autocomplete-input').val()
|
||||
if (url.indexOf('@') != -1 || url.indexOf('https') != -1) {
|
||||
alert('入力形式が違います。(Cutls@mstdn.jpにログインする場合、入力するのは"mstdn.jp"です。)')
|
||||
return false
|
||||
|
@ -634,6 +630,7 @@ function instance() {
|
|||
}
|
||||
//コード入れてAccessTokenゲット
|
||||
function code(code) {
|
||||
var red = localStorage.getItem('redirect')
|
||||
localStorage.removeItem('redirect')
|
||||
if (!code) {
|
||||
var code = $('#code').val()
|
||||
|
@ -696,7 +693,7 @@ function code(code) {
|
|||
}
|
||||
return
|
||||
} else {
|
||||
var red = 'urn:ietf:wg:oauth:2.0:oob'
|
||||
if (!red) red = 'urn:ietf:wg:oauth:2.0:oob'
|
||||
if (~url.indexOf('pixelfed')) {
|
||||
red = 'https://thedesk.top/hello.html'
|
||||
}
|
||||
|
@ -720,6 +717,7 @@ function code(code) {
|
|||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error: cannot complete', displayLength: 5000 })
|
||||
setLog(start, this.status, json)
|
||||
}
|
||||
if (json['access_token']) {
|
||||
|
@ -1089,15 +1087,14 @@ function coloradd(key, bg, txt) {
|
|||
//入力時にハッシュタグと@をサジェスト
|
||||
var timer = null
|
||||
|
||||
var input = document.getElementById('url')
|
||||
|
||||
var input = document.getElementById('autocomplete-input')
|
||||
var prev_val = input.value
|
||||
var oldSuggest
|
||||
var suggest
|
||||
input.addEventListener(
|
||||
'focus',
|
||||
function () {
|
||||
$('#ins-suggest').html('')
|
||||
const instance = M.Autocomplete.getInstance(input)
|
||||
window.clearInterval(timer)
|
||||
timer = window.setInterval(function () {
|
||||
var new_val = input.value
|
||||
|
@ -1125,21 +1122,20 @@ input.addEventListener(
|
|||
})
|
||||
.then(function (json) {
|
||||
if (!json.error) {
|
||||
var urls = 'Suggest:'
|
||||
let data = {}
|
||||
Object.keys(json.data).forEach(function (key) {
|
||||
var url = json.data[key]
|
||||
urls =
|
||||
urls +
|
||||
`<a onclick="login('${url.uri}')" class="pointer" title="${url.uri}">${escapeHTML(url.title ? url.title : url.uri)}</a>, `
|
||||
data[url.uri] = escapeHTML(url.title ? url.title : url.uri)
|
||||
})
|
||||
$('#ins-suggest').html(urls)
|
||||
instance.updateData(data)
|
||||
instance.open()
|
||||
} else {
|
||||
console.error(json.error)
|
||||
}
|
||||
})
|
||||
}
|
||||
oldSuggest = suggest
|
||||
prev_value = new_val
|
||||
prev_val = new_val
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
@ -1157,3 +1153,12 @@ input.addEventListener(
|
|||
function asReadEnd() {
|
||||
postMessage(['asReadComp', ''], '*')
|
||||
}
|
||||
|
||||
// Or with jQuery
|
||||
|
||||
$(document).ready(function(){
|
||||
$('input.autocomplete').autocomplete({
|
||||
data: {},
|
||||
});
|
||||
});
|
||||
|
|
@ -186,7 +186,7 @@ onmessage = function (e) {
|
|||
} else if (e.data[0] == 'asReadEnd') {
|
||||
asReadEnd()
|
||||
} else if (e.data[0] == 'accessibility') {
|
||||
console.log('atrue')
|
||||
console.log('accessibility mode')
|
||||
$('body').addClass('accessibility')
|
||||
$('.window-title').before('<div class="accessMark">Screen Reader Optimized</div>')
|
||||
} else if (e.data[0] == 'logData') {
|
||||
|
@ -200,6 +200,22 @@ onmessage = function (e) {
|
|||
})
|
||||
} else if (e.data[0] == 'twitterLoginComplete') {
|
||||
location.reload()
|
||||
} else if (e.data[0] == 'customUrl') {
|
||||
const mode = e.data[1][0]
|
||||
const codex = e.data[1][1]
|
||||
if (mode === 'share') {
|
||||
$('textarea').focus()
|
||||
$('#textarea').val(decodeURI(codex))
|
||||
show()
|
||||
$('body').removeClass('mini-post')
|
||||
$('.mini-btn').text('expand_less')
|
||||
} else if (mode === 'manager' || mode === 'login') {
|
||||
code(codex)
|
||||
} else if (mode === 'spotify') {
|
||||
var coder = codex.split(':')
|
||||
localStorage.setItem('spotify', coder[0])
|
||||
localStorage.setItem('spotify-refresh', coder[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
/* PWA */
|
||||
|
@ -236,3 +252,34 @@ const connection = function (event) {
|
|||
}
|
||||
window.onoffline = connection
|
||||
window.ononline = connection
|
||||
|
||||
let lastSelection = null
|
||||
let isSame = true
|
||||
$(document).on('keyup mouseup', function (e) {
|
||||
lastSelection = (window.getSelection().toString() !== '') ? window.getSelection().getRangeAt(0) : null
|
||||
if (!isSame) $('#pageSrc').addClass('hide')
|
||||
})
|
||||
|
||||
// カスタム右クリックメニュー
|
||||
$(document).on('contextmenu', function (e) {
|
||||
// テキスト選択中であれば何もしない
|
||||
if (lastSelection !== null) {
|
||||
const currentSelection = window.getSelection().getRangeAt(0)
|
||||
for (let key in currentSelection) {
|
||||
if (currentSelection[key] != lastSelection[key]) {
|
||||
isSame = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (isSame && currentSelection != '') {
|
||||
$('#pageSrc').removeClass('hide')
|
||||
$('#pageSrc').css('left', e.pageX)
|
||||
$('#pageSrc').css('top', e.pageY)
|
||||
$('.srcQ').text(currentSelection)
|
||||
}
|
||||
}
|
||||
})
|
||||
$('textarea, input').on('contextmenu', function (e) {
|
||||
postMessage(['textareaContextMenu', { x: e.pageX, y: e.pageY }], '*')
|
||||
})
|
36
app/main.js
36
app/main.js
|
@ -14,12 +14,12 @@ const dl = require('./main/dl.js')
|
|||
const img = require('./main/img.js')
|
||||
const np = require('./main/np.js')
|
||||
const systemFunc = require('./main/system.js')
|
||||
const Menu = electron.Menu
|
||||
const { Menu, MenuItem, BrowserWindow, ipcMain } = electron
|
||||
const join = require('path').join
|
||||
// ウィンドウを作成するモジュール
|
||||
const BrowserWindow = electron.BrowserWindow
|
||||
// メインウィンドウはGCされないようにグローバル宣言
|
||||
let mainWindow
|
||||
let opening = true
|
||||
|
||||
// アプリが多重起動しないようにする
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
@ -27,9 +27,12 @@ const gotTheLock = app.requestSingleInstanceLock()
|
|||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
// 多重起動を試みた場合、既に存在するウィンドウにフォーカスを移す
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
app.on('second-instance', (event, commandLine, workingDirector) => {
|
||||
opening = false
|
||||
const m = commandLine[2].match(/([a-zA-Z0-9]+)\/\?[a-zA-Z-0-9]+=(.+)/)
|
||||
if (m) {
|
||||
mainWindow.send('customUrl', [m[1], m[2]])
|
||||
}
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
|
@ -39,7 +42,7 @@ if (!gotTheLock) {
|
|||
|
||||
// 全てのウィンドウが閉じたら終了
|
||||
app.on('window-all-closed', function () {
|
||||
electron.session.defaultSession.clearCache(() => {})
|
||||
electron.session.defaultSession.clearCache(() => { })
|
||||
app.quit()
|
||||
})
|
||||
function isFile(file) {
|
||||
|
@ -76,25 +79,26 @@ function createWindow() {
|
|||
if (!packaged) console.log('launch:' + lang)
|
||||
//Opening
|
||||
const package = fs.readFileSync(__dirname + '/package.json')
|
||||
if(lang == 'ja') {
|
||||
if (lang == 'ja') {
|
||||
const maxims = JSON.parse(fs.readFileSync(__dirname + '/maxim.ja.json'))
|
||||
var show = maxims[Math.floor(Math.random() * maxims.length)]
|
||||
} else if(lang == 'ja-KS') {
|
||||
} else if (lang == 'ja-KS') {
|
||||
//ja-KSも作れたらいいね
|
||||
const maxims = JSON.parse(fs.readFileSync(__dirname + '/maxim.ja.json'))
|
||||
var show = maxims[Math.floor(Math.random() * maxims.length)]
|
||||
} else{
|
||||
} else {
|
||||
var show = 'TheDesk 2018'
|
||||
}
|
||||
const data = JSON.parse(package)
|
||||
const version = data.version
|
||||
const codename = data.codename
|
||||
var openingWindow = new BrowserWindow({
|
||||
const openingWindow = new BrowserWindow({
|
||||
width: 300,
|
||||
height: 400,
|
||||
transparent: false,
|
||||
frame: false,
|
||||
resizable: false,
|
||||
show: opening
|
||||
})
|
||||
openingWindow.loadURL(`${__dirname}/opening.html?ver=${version}&codename=${codename}&maxim=${encodeURI(show)}`)
|
||||
|
||||
|
@ -133,7 +137,7 @@ function createWindow() {
|
|||
if (!packaged) console.log('enabled: Hardware Acceleration')
|
||||
}
|
||||
let webviewEnabled = false
|
||||
if(fs.existsSync(wv_path, 'utf8')) webviewEnabled = true
|
||||
if (fs.existsSync(wv_path, 'utf8')) webviewEnabled = true
|
||||
var window_size
|
||||
try {
|
||||
window_size = JSON.parse(fs.readFileSync(info_path, 'utf8'))
|
||||
|
@ -190,13 +194,13 @@ function createWindow() {
|
|||
})
|
||||
mainWindow.webContents.on('page-title-updated', () => {
|
||||
const url = mainWindow.webContents.getURL()
|
||||
if(url.match(/https:\/\/crowdin.com\/profile/)) {
|
||||
if (url.match(/https:\/\/crowdin.com\/profile/)) {
|
||||
app.relaunch()
|
||||
app.exit()
|
||||
}
|
||||
})
|
||||
if (!packaged) mainWindow.toggleDevTools()
|
||||
electron.session.defaultSession.clearCache(() => {})
|
||||
electron.session.defaultSession.clearCache(() => { })
|
||||
if (process.argv) {
|
||||
if (process.argv[1]) {
|
||||
var m = process.argv[1].match(/([a-zA-Z0-9]+)\/\?[a-zA-Z-0-9]+=(.+)/)
|
||||
|
@ -229,7 +233,7 @@ function createWindow() {
|
|||
}
|
||||
// ウィンドウが閉じられたらアプリも終了
|
||||
mainWindow.on('closed', function () {
|
||||
electron.ipcMain.removeAllListeners()
|
||||
ipcMain.removeAllListeners()
|
||||
mainWindow = null
|
||||
})
|
||||
closeArg = false
|
||||
|
@ -242,7 +246,7 @@ function createWindow() {
|
|||
mainWindow.send('asReadEnd', '')
|
||||
let wait = 3000
|
||||
const url = mainWindow.webContents.getURL()
|
||||
if(!url.match(/index.html/)) wait = 0
|
||||
if (!url.match(/index.html/)) wait = 0
|
||||
setTimeout(function () {
|
||||
resolve()
|
||||
}, wait)
|
||||
|
@ -252,7 +256,7 @@ function createWindow() {
|
|||
mainWindow.close()
|
||||
})
|
||||
})
|
||||
electron.ipcMain.on('sendMarkersComplete', function (e, arg) {
|
||||
ipcMain.on('sendMarkersComplete', function (e, arg) {
|
||||
closeArg = true
|
||||
mainWindow.close()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user