fix(mini): preserve taskbar and restore login

This commit is contained in:
2026-07-22 19:03:24 +08:00
parent aeb5276a73
commit b01928a5e4
9 changed files with 49 additions and 16 deletions

View File

@@ -307,13 +307,27 @@ function MoreView({ workspace, openAction }: ViewProps) {
function Login({ onLogin }: { onLogin: (session: ApiSession) => void }) {
const [server, setServer] = useState('http://localhost:9150')
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [email, setEmail] = useState('demo@senlin.ai')
const [password, setPassword] = useState('password123')
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
async function submitLogin() {
if (loading) return
setLoading(true)
setError('')
try {
onLogin(await login(server, email.trim(), password))
} catch (requestError) {
setError(errorMessage(requestError))
} finally {
setLoading(false)
}
}
return (
<div className="mini-login">
<div className="login-note">
<form className="login-note" onSubmit={(event) => { event.preventDefault(); void submitLogin() }}>
<img src="/senlinai-icon.svg" alt="" />
<Title heading={3}>AI Mini</Title>
<Text type="secondary"></Text>
@@ -321,9 +335,9 @@ function Login({ onLogin }: { onLogin: (session: ApiSession) => void }) {
<label><Input value={email} onChange={setEmail} /></label>
<label><Input.Password value={password} onChange={setPassword} /></label>
{error ? <Alert type="error" content={error} /> : null}
<Button type="primary" long loading={loading} onClick={async () => { setLoading(true); setError(''); try { onLogin(await login(server, email, password)) } catch (requestError) { setError(errorMessage(requestError)) } finally { setLoading(false) } }}></Button>
<Button type="primary" htmlType="submit" long loading={loading}></Button>
<small>v1.0 </small>
</div>
</form>
</div>
)
}

View File

@@ -192,7 +192,9 @@ function useSessionBase(session: ApiSession) {
}
function normalizeBaseUrl(value: string) {
return value.trim().replace(/\/+$/, '')
const normalized = value.trim().replace(/\/+$/, '')
if (!normalized || /^https?:\/\//i.test(normalized)) return normalized
return `http://${normalized}`
}
function slugify(value: string) {