Files
LingChair/client/index.ts
CrescentLeaf 6c9ee005fd fix: 橫豎屏切換 resize 時的大小不當
* 橫屏時, 測試 Via 瀏覽器時 可能是因為全屏不當, 大小不正確, 也因此需要手動縮小, 繼續切豎屏正常
2025-10-03 12:47:19 +08:00

39 lines
1.5 KiB
TypeScript

import 'mdui/mdui.css'
import 'mdui'
import { $ } from "mdui/jq"
import { breakpoint, Dialog } from "mdui"
import * as React from 'react'
import ReactDOM from 'react-dom/client'
import './ui/custom-elements/chat-image.ts'
import './ui/custom-elements/chat-video.ts'
import './ui/custom-elements/chat-file.ts'
const urlParams = new URL(location.href).searchParams
// deno-lint-ignore no-window no-window-prefix
urlParams.get('debug') == 'true' && window.addEventListener('error', ({ message, filename, lineno, colno, error }) => {
const m = $("#ErrorDialog_Message")
const d = $("#ErrorDialog").get(0) as Dialog
const s = d.open
d.open = true
m.html((s ? `${m.html()}<br/><br/>` : '') + `${message} (${filename || 'unknown'}:${lineno}:${colno})`)
})
import App from './ui/App.tsx'
import AppMobile from './ui/AppMobile.tsx'
import isMobileUI from "./ui/isMobileUI.ts"
ReactDOM.createRoot(document.getElementById('app') as HTMLElement).render(React.createElement(isMobileUI() ? AppMobile : App, null))
const onResize = () => setTimeout(() => {
document.body.style.setProperty('--whitesilk-widget-message-maxwidth', breakpoint().down('md') ? "80%" : "70%")
// deno-lint-ignore no-window
document.body.style.setProperty('--whitesilk-window-width', window.screen.availWidth + 'px')
// deno-lint-ignore no-window
document.body.style.setProperty('--whitesilk-window-height', window.screen.availHeight + 'px')
}, 100)
// deno-lint-ignore no-window no-window-prefix
window.addEventListener('resize', onResize)
onResize()