feat(gui): using latest tauri config, remove hacky way
parent
8707feac01
commit
5867740de3
|
|
@ -2178,7 +2178,6 @@ dependencies = [
|
||||||
"tauri",
|
"tauri",
|
||||||
"tauri-build",
|
"tauri-build",
|
||||||
"tokio",
|
"tokio",
|
||||||
"urlencoding",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -3075,12 +3074,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "urlencoding"
|
|
||||||
version = "2.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf-8"
|
name = "utf-8"
|
||||||
version = "0.7.6"
|
version = "0.7.6"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ tauri = { version = "1.4.1", features = [
|
||||||
serde = { version = "1.0.164", features = ["derive"] }
|
serde = { version = "1.0.164", features = ["derive"] }
|
||||||
serde_json = "1.0.97"
|
serde_json = "1.0.97"
|
||||||
tokio = { version = "1.28.2", features = ["time"] }
|
tokio = { version = "1.28.2", features = ["time"] }
|
||||||
urlencoding = "2.1.2"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,12 @@ function onSelectUserClick(e) {
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// very hacky way...
|
// a little official way...
|
||||||
window.ipc.postMessage(JSON.stringify({
|
window.__TAURI_INVOKE__({
|
||||||
"cmd":"tauri",
|
|
||||||
"callback":0,
|
|
||||||
"error":0,
|
|
||||||
"__tauriModule":"Event",
|
"__tauriModule":"Event",
|
||||||
|
"cmd": "tauri",
|
||||||
"message":{"cmd":"emit","event":"login","payload":{"url":element.href}}
|
"message":{"cmd":"emit","event":"login","payload":{"url":element.href}}
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
function detectAndInject() {
|
function detectAndInject() {
|
||||||
const element = document.getElementById('authorize-switch-approval-link');
|
const element = document.getElementById('authorize-switch-approval-link');
|
||||||
|
|
@ -74,12 +72,7 @@ document.addEventListener("DOMContentLoaded", () => {{
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn open_login_window(app: tauri::AppHandle, url: String) -> Option<String> {
|
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(url.into()))
|
||||||
let window = WindowBuilder::new(
|
|
||||||
&app,
|
|
||||||
"login",
|
|
||||||
tauri::WindowUrl::App(format!("/redirect?url={encoded}").into()),
|
|
||||||
)
|
|
||||||
.title("Login")
|
.title("Login")
|
||||||
.center()
|
.center()
|
||||||
.inner_size(1040.0, 960.0)
|
.inner_size(1040.0, 960.0)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://github.com/tauri-apps/tauri/raw/tauri-v1.4.1/core/tauri-config-schema/schema.json",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev",
|
"beforeDevCommand": "pnpm dev",
|
||||||
"beforeBuildCommand": "pnpm build",
|
"beforeBuildCommand": "pnpm build",
|
||||||
|
|
@ -69,7 +70,16 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null,
|
||||||
|
"dangerousRemoteDomainIpcAccess": [
|
||||||
|
{
|
||||||
|
"windows": [
|
||||||
|
"login"
|
||||||
|
],
|
||||||
|
"domain": "accounts.nintendo.com",
|
||||||
|
"enableTauriAPI": true
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"active": false,
|
"active": false,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { Layout } from "components/Layout";
|
||||||
import { Home } from "pages/Home";
|
import { Home } from "pages/Home";
|
||||||
import { Settings } from "pages/Settings";
|
import { Settings } from "pages/Settings";
|
||||||
import { Guide } from 'pages/Guide';
|
import { Guide } from 'pages/Guide';
|
||||||
import { RedirectLogin } from 'pages/RedirectLogin';
|
|
||||||
import { useShowWindow } from 'hooks/useShowWindow';
|
import { useShowWindow } from 'hooks/useShowWindow';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|
@ -15,7 +14,6 @@ function App() {
|
||||||
<Route index element={<Home />} />
|
<Route index element={<Home />} />
|
||||||
<Route path='/settings' element={<Settings />} />
|
<Route path='/settings' element={<Settings />} />
|
||||||
<Route path='/guide' element={<Guide />} />
|
<Route path='/guide' element={<Guide />} />
|
||||||
<Route path='/redirect' element={<RedirectLogin />} />
|
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</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