import Client from "../api/Client.ts" import data from "../Data.ts" import ChatFragment from "./chat/ChatFragment.jsx" import LoginDialog from "./dialog/LoginDialog.jsx" import ContactsListItem from "./main/ContactsListItem.jsx" import RecentsListItem from "./main/RecentsListItem.jsx" import snackbar from "./snackbar.js" import useEventListener from './useEventListener.js' import { React } from '../Imports.ts' export default function App() { const [recentsList, setRecentsList] = React.useState([ /* { userId: 0, avatar: "https://www.court-records.net/mugshot/aa6-004-maya.png", nickName: "麻油衣酱", content: "成步堂君, 我又坐牢了(" }, { userId: 0, avatar: "https://www.court-records.net/mugshot/aa6-004-maya.png", nickName: "Maya Fey", content: "我是绫里真宵, 是一名灵媒师~" }, */ ]) const [contactsMap, setContactsMap] = React.useState({ 所有: [ /* { userId: 0, avatar: "https://www.court-records.net/mugshot/aa6-004-maya.png", nickName: "麻油衣酱", }, { userId: 0, avatar: "https://www.court-records.net/mugshot/aa6-004-maya.png", nickName: "Maya Fey", }, */ ], }) const [navigationItemSelected, setNavigationItemSelected] = React.useState('Recents') const navigationRailRef = React.useRef(null) useEventListener(navigationRailRef, 'change', (event) => { setNavigationItemSelected(event.target.value) }) const [ loginDialogRef, inputAccountRef, inputPasswordRef, registerButtonRef, loginButtonRef ] = [React.useRef(null), React.useRef(null), React.useRef(null), React.useRef(null), React.useRef(null)] React.useEffect(() => { ; (async () => { Client.connect() const re = await Client.invoke("User.auth", { access_token: data.access_token, }) if (re.code == 401) loginDialogRef.current.show() else if (re.code != 200) snackbar("驗證失敗: " + re.msg) })() return () => { } }, []) return (
{ // 移动端用 页面调试 // 換個地方弄 // (new URL(location.href).searchParams.get('debug') == 'true') && } { // 侧边列表 } { // 分割线 } {/*
*/} { // 聊天页面 }
) }