feat(gui): using latest tauri config, remove hacky way
parent
8707feac01
commit
5867740de3
|
|
@ -2178,7 +2178,6 @@ dependencies = [
|
|||
"tauri",
|
||||
"tauri-build",
|
||||
"tokio",
|
||||
"urlencoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3075,12 +3074,6 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
version = "0.7.6"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ tauri = { version = "1.4.1", features = [
|
|||
serde = { version = "1.0.164", features = ["derive"] }
|
||||
serde_json = "1.0.97"
|
||||
tokio = { version = "1.28.2", features = ["time"] }
|
||||
urlencoding = "2.1.2"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
|
|
|
|||
|
|
@ -15,14 +15,12 @@ function onSelectUserClick(e) {
|
|||
}
|
||||
e.preventDefault();
|
||||
|
||||
// very hacky way...
|
||||
window.ipc.postMessage(JSON.stringify({
|
||||
"cmd":"tauri",
|
||||
"callback":0,
|
||||
"error":0,
|
||||
// a little official way...
|
||||
window.__TAURI_INVOKE__({
|
||||
"__tauriModule":"Event",
|
||||
"cmd": "tauri",
|
||||
"message":{"cmd":"emit","event":"login","payload":{"url":element.href}}
|
||||
}))
|
||||
})
|
||||
}
|
||||
function detectAndInject() {
|
||||
const element = document.getElementById('authorize-switch-approval-link');
|
||||
|
|
@ -74,18 +72,13 @@ document.addEventListener("DOMContentLoaded", () => {{
|
|||
|
||||
#[tauri::command]
|
||||
async fn open_login_window(app: tauri::AppHandle, url: String) -> Option<String> {
|
||||
let encoded = urlencoding::encode(&url);
|
||||
let window = WindowBuilder::new(
|
||||
&app,
|
||||
"login",
|
||||
tauri::WindowUrl::App(format!("/redirect?url={encoded}").into()),
|
||||
)
|
||||
.title("Login")
|
||||
.center()
|
||||
.inner_size(1040.0, 960.0)
|
||||
.initialization_script(INIT_SCRIPT)
|
||||
.build()
|
||||
.ok()?;
|
||||
let window = WindowBuilder::new(&app, "login", tauri::WindowUrl::App(url.into()))
|
||||
.title("Login")
|
||||
.center()
|
||||
.inner_size(1040.0, 960.0)
|
||||
.initialization_script(INIT_SCRIPT)
|
||||
.build()
|
||||
.ok()?;
|
||||
let result: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None));
|
||||
let r2 = result.clone();
|
||||
let r3 = result.clone();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"$schema": "https://github.com/tauri-apps/tauri/raw/tauri-v1.4.1/core/tauri-config-schema/schema.json",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
"beforeBuildCommand": "pnpm build",
|
||||
|
|
@ -69,7 +70,16 @@
|
|||
]
|
||||
},
|
||||
"security": {
|
||||
"csp": null
|
||||
"csp": null,
|
||||
"dangerousRemoteDomainIpcAccess": [
|
||||
{
|
||||
"windows": [
|
||||
"login"
|
||||
],
|
||||
"domain": "accounts.nintendo.com",
|
||||
"enableTauriAPI": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"updater": {
|
||||
"active": false,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { Layout } from "components/Layout";
|
|||
import { Home } from "pages/Home";
|
||||
import { Settings } from "pages/Settings";
|
||||
import { Guide } from 'pages/Guide';
|
||||
import { RedirectLogin } from 'pages/RedirectLogin';
|
||||
import { useShowWindow } from 'hooks/useShowWindow';
|
||||
|
||||
function App() {
|
||||
|
|
@ -15,7 +14,6 @@ function App() {
|
|||
<Route index element={<Home />} />
|
||||
<Route path='/settings' element={<Settings />} />
|
||||
<Route path='/guide' element={<Guide />} />
|
||||
<Route path='/redirect' element={<RedirectLogin />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
import { Loading } from 'components/Loading';
|
||||
import React, { useEffect } from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLocation } from 'react-use';
|
||||
|
||||
export const RedirectLogin: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const state = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
const search = state.search ?? '';
|
||||
|
||||
const index = search.indexOf('url=');
|
||||
if (index === -1) {
|
||||
return;
|
||||
}
|
||||
const url = decodeURIComponent(search.substring(index + 4));
|
||||
|
||||
window.location.href = url;
|
||||
}, [state])
|
||||
|
||||
return <div className='h-full flex justify-center items-center'>
|
||||
<span className='flex justify-center items-center gap-1'><Loading className='align-middle' />{t('正在跳转到登录页面...')}</span>
|
||||
</div>
|
||||
}
|
||||
Loading…
Reference in New Issue