* 将所有的 custom element 以正确的方式重新编写 * 可以正确解析 Markdown 文本, 图片, 斜体文本元素且不会杂糅了 * 通过 DOM 操作使得所有的文本聚合在一起, 并且取消了消息自带的填充边距, 删除了原本消息内无法正常工作的 "无边框显示模式" * 添加新的 custom-element: chat-text 和 chat-text-container
41 lines
1.4 KiB
TypeScript
41 lines
1.4 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'
|
|
import './ui/custom-elements/chat-text.ts'
|
|
import './ui/custom-elements/chat-text-container.ts'
|
|
|
|
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 = () => {
|
|
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.innerWidth + 'px')
|
|
// deno-lint-ignore no-window
|
|
document.body.style.setProperty('--whitesilk-window-height', window.innerHeight + 'px')
|
|
}
|
|
// deno-lint-ignore no-window no-window-prefix
|
|
window.addEventListener('resize', onResize)
|
|
onResize()
|
|
|
|
// @ts-ignore 工作正常, 这里是获取为 URL 以便于构建
|
|
import sw from './sw.ts?worker&url'
|
|
|
|
if ("serviceWorker" in navigator)
|
|
try {
|
|
navigator.serviceWorker
|
|
.register(sw as URL)
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|