Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/9575

Vanessafcdc2f87188c
diff --git a/app/stage/auth.html b/app/stage/auth.html
index ff0ad56542..ec9a62e980 100644
--- a/app/stage/auth.html
+++ b/app/stage/auth.html
@@ -418,120 +418,124 @@
<div class="b3-snackbar__content"></div>
</div>
<script>
- if ({{.appearanceModeOS}} && window.matchMedia('(prefers-color-scheme: dark)').matches || {{.appearanceMode}} === 1) {
- document.body.classList.add('dark')
- }
- if (window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {
- document.querySelector('.b3-button--white').remove()
- }
-
- try {
const {ipcRenderer} = require('electron')
- ipcRenderer.on('siyuan-save-close', (event, close) => {
- exitSiYuan()
- })
- } catch (e) {
- // console.log(e)
- }
+ if ({{.appearanceModeOS}} && window.matchMedia('(prefers-color-scheme: dark)').matches || {{.appearanceMode}} ===1) {
+ document.body.classList.add('dark')
+ }
+ if (window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {
+ document.querySelector('.b3-button--white').remove()
+ }
- const exitApp = () => {
try {
- const {ipcRenderer} = require('electron')
- ipcRenderer.send('siyuan-quit', window.location.port)
+ ipcRenderer.on('siyuan-save-close', (event, close) => {
+ exitSiYuan()
+ })
} catch (e) {
- if ((window.webkit && window.webkit.messageHandlers) || window.JSAndroid) {
- window.location.href = 'siyuan://api/system/exit'
- } else {
- window.location.reload()
- }
+ // console.log(e)
}
- }
- const exitSiYuan = () => {
- try {
- fetch('/api/system/exit', {
- method: 'POST',
- body: JSON.stringify({force: false}),
- }).then((response) => {
- return response.json()
- }).then((response) => {
- if (response.code === 1) {
- document.querySelector('#message').classList.add('b3-snackbar--show')
- document.querySelector('#message').firstElementChild.textContent = response.msg
- const buttonElement = document.querySelector(`#message button`)
- if (buttonElement) {
- buttonElement.addEventListener('click', () => {
- fetch('/api/system/exit', {
+
+ const exitApp = () => {
+ try {
+ const {ipcRenderer} = require('electron')
+ ipcRenderer.send('siyuan-quit', window.location.port)
+ } catch (e) {
+ if ((window.webkit && window.webkit.messageHandlers) || window.JSAndroid) {
+ window.location.href = 'siyuan://api/system/exit'
+ } else {
+ window.location.reload()
+ }
+ }
+ }
+ const exitSiYuan = () => {
+ try {
+ fetch('/api/system/exit', {
method: 'POST',
- body: JSON.stringify({force: true}),
- }).then((response) => {
+ body: JSON.stringify({force: false}),
+ }).then((response) => {
return response.json()
- }).then(() => {
+ }).then((response) => {
+ if (response.code === 1) {
+ document.querySelector('#message').classList.add('b3-snackbar--show')
+ document.querySelector('#message').firstElementChild.textContent = response.msg
+ const buttonElement = document.querySelector(`#message button`)
+ if (buttonElement) {
+ buttonElement.addEventListener('click', () => {
+ fetch('/api/system/exit', {
+ method: 'POST',
+ body: JSON.stringify({force: true}),
+ }).then((response) => {
+ return response.json()
+ }).then(() => {
+ exitApp()
+ })
+ })
+ }
+ } else {
+ exitApp()
+ }
+ }).catch(() => {
exitApp()
- })
})
- }
- } else {
- exitApp()
+ } catch (e) {
+ exitApp()
}
- }).catch(() => {
- exitApp()
- })
- } catch (e) {
- exitApp()
}
- }
- const inputElement = document.getElementById('authCode')
- const captchaElement = document.getElementById('captcha')
- inputElement.focus()
- inputElement.addEventListener('keydown', (event) => {
- if (event.key === 'Enter') {
- submitAuth()
- }
- })
+ const inputElement = document.getElementById('authCode')
+ const captchaElement = document.getElementById('captcha')
+ inputElement.focus()
+ inputElement.addEventListener('keydown', (event) => {
+ if (event.key === 'Enter') {
+ submitAuth()
+ }
+ })
- captchaElement.previousElementSibling.addEventListener('click', function () {
- this.src = `/api/system/getCaptcha?v=${new Date().getTime()}`
- })
+ captchaElement.previousElementSibling.addEventListener('click', function () {
+ this.src = `/api/system/getCaptcha?v=${new Date().getTime()}`
+ })
- const submitAuth = () => {
- fetch('/api/system/loginAuth', {
- method: 'POST',
- body: JSON.stringify({
- authCode: inputElement.value,
- captcha: captchaElement.value,
- }),
- }).then((response) => {
- return response.json()
- }).then((response) => {
- if (0 === response.code) {
- const url = new URL(window.location)
- window.location.href = url.searchParams.get("to") || "/"
- return
- }
+ const submitAuth = () => {
+ fetch('/api/system/loginAuth', {
+ method: 'POST',
+ body: JSON.stringify({
+ authCode: inputElement.value,
+ captcha: captchaElement.value,
+ }),
+ }).then((response) => {
+ return response.json()
+ }).then((response) => {
+ if (0 === response.code) {
+ const url = new URL(window.location)
+ window.location.href = url.searchParams.get("to") || "/"
+ return
+ }
- if (response.code === 1) {
- captchaElement.previousElementSibling.src = `/api/system/getCaptcha?v=${new Date().getTime()}`
- captchaElement.parentElement.style.display = 'block'
- } else {
- captchaElement.parentElement.style.display = 'none'
- captchaElement.previousElementSibling.src = ''
- }
+ if (response.code === 1) {
+ captchaElement.previousElementSibling.src = `/api/system/getCaptcha?v=${new Date().getTime()}`
+ captchaElement.parentElement.style.display = 'block'
+ } else {
+ captchaElement.parentElement.style.display = 'none'
+ captchaElement.previousElementSibling.src = ''
+ }
- document.querySelector('#message').classList.add('b3-snackbar--show')
- document.querySelector('#message').firstElementChild.textContent = response.msg
- inputElement.value = ''
- captchaElement.value = ''
- inputElement.focus()
- setTimeout(() => {
- document.querySelector('#message').classList.remove('b3-snackbar--show')
- document.querySelector('#message').firstElementChild.textContent = ''
- }, 6000)
- })
- }
+ document.querySelector('#message').classList.add('b3-snackbar--show')
+ document.querySelector('#message').firstElementChild.textContent = response.msg
+ inputElement.value = ''
+ captchaElement.value = ''
+ inputElement.focus()
+ setTimeout(() => {
+ document.querySelector('#message').classList.remove('b3-snackbar--show')
+ document.querySelector('#message').firstElementChild.textContent = ''
+ }, 6000)
+ })
+ }
- // 用于授权页保持连接,避免非常驻内存内核自动退出 https://github.com/siyuan-note/insider/issues/1099
- new WebSocket((window.location.protocol === 'https:' ? 'wss' : 'ws') + '://' + window.location.host + '/ws?app=siyuan&id=auth')
+ // 用于授权页保持连接,避免非常驻内存内核自动退出 https://github.com/siyuan-note/insider/issues/1099
+ new WebSocket((window.location.protocol === 'https:' ? 'wss' : 'ws') + '://' + window.location.host + '/ws?app=siyuan&id=auth')
+ ipcRenderer.send("siyuan-hotkey", {
+ languages: {},
+ hotkeys: ['{{.keymapGeneralToggleWin}}']
+ });
</script>
</body>
</html>