fix(desktop): lock appbar to edge
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Alert, Avatar, Button, Empty, Input, Message, Modal, Select, Spin, Tag, Typography } from '@arco-design/web-react'
|
||||
import {
|
||||
IconApps, IconArrowLeft, IconArrowRight, IconCheckCircle, IconClockCircle,
|
||||
IconApps, IconCheckCircle, IconClockCircle,
|
||||
IconFile, IconFolder, IconPlus, IconRefresh, IconRobot, IconSearch, IconSettings,
|
||||
} from '@arco-design/web-react/icon'
|
||||
import {
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
|
||||
const { Text, Title } = Typography
|
||||
type View = 'home' | 'tasks' | 'notes' | 'ai' | 'more'
|
||||
type DockSide = 'left' | 'right'
|
||||
type Action = 'project' | 'task' | 'cron' | null
|
||||
type ConnectionStatus = 'checking' | 'online' | 'offline'
|
||||
|
||||
@@ -32,21 +31,11 @@ export function App() {
|
||||
const [experts, setExperts] = useState<Expert[]>([])
|
||||
const [aiSessions, setAISessions] = useState<AISession[]>([])
|
||||
const [view, setView] = useState<View>('home')
|
||||
const [dockSide, setDockSide] = useState<DockSide>(() => {
|
||||
if ('__TAURI_INTERNALS__' in window) return 'right'
|
||||
return localStorage.getItem('senlin-mini-dock') === 'left' ? 'left' : 'right'
|
||||
})
|
||||
const [loading, setLoading] = useState(Boolean(session))
|
||||
const [error, setError] = useState('')
|
||||
const [action, setAction] = useState<Action>(null)
|
||||
const refreshGeneration = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.dataset.dock = dockSide
|
||||
localStorage.setItem('senlin-mini-dock', dockSide)
|
||||
void moveDesktopWindow(dockSide)
|
||||
}, [dockSide])
|
||||
|
||||
useEffect(() => {
|
||||
if (!session) return
|
||||
let cancelled = false
|
||||
@@ -89,10 +78,6 @@ export function App() {
|
||||
}
|
||||
}
|
||||
|
||||
async function dock(side: DockSide) {
|
||||
setDockSide(side)
|
||||
}
|
||||
|
||||
if (!session) return <Login onLogin={(next) => { localStorage.setItem('senlin-mini-session', JSON.stringify(next)); setSession(next) }} />
|
||||
|
||||
const activeProject = projects.find((project) => project.id === projectId) ?? projects[0]
|
||||
@@ -112,10 +97,6 @@ export function App() {
|
||||
<span>森林AI</span>
|
||||
<Tag size="small" color="arcoblue">App 1.0</Tag>
|
||||
</div>
|
||||
<div className="window-actions">
|
||||
<Button aria-label="停靠左侧" className={dockSide === 'left' ? 'active' : ''} type="text" size="mini" icon={<IconArrowLeft />} onClick={() => void dock('left')} />
|
||||
<Button aria-label="停靠右侧" className={dockSide === 'right' ? 'active' : ''} type="text" size="mini" icon={<IconArrowRight />} onClick={() => void dock('right')} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="project-switcher">
|
||||
@@ -415,13 +396,3 @@ function errorMessage(error: unknown) {
|
||||
if (error instanceof ApiError || error instanceof Error) return error.message
|
||||
return '操作失败,请稍后重试'
|
||||
}
|
||||
|
||||
async function moveDesktopWindow(side: DockSide) {
|
||||
if (!('__TAURI_INTERNALS__' in window)) return
|
||||
try {
|
||||
const { invoke } = await import('@tauri-apps/api/core')
|
||||
await invoke('dock_window', { side })
|
||||
} catch (requestError) {
|
||||
Message.warning(errorMessage(requestError))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user