03a4410272
主要工作是共享同一套“画布内核与通用 UI 源码”,网站和 Tauri 只分别实现宿主适配层。 --------- Co-authored-by: 段舒康 <kdletters@qq.com> Co-authored-by: kdletters <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/136 Co-authored-by: menghao <mh18530625731@163.com> Co-committed-by: menghao <mh18530625731@163.com>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
/* eslint-disable react-refresh/only-export-components */
|
|
|
|
import '@genarrative/image-canvas-react/styles.css';
|
|
import './index.css';
|
|
|
|
import { StrictMode, Suspense } from 'react';
|
|
import { createRoot } from 'react-dom/client';
|
|
|
|
import { FloatingFeedbackEntry } from './components/common/FloatingFeedbackEntry';
|
|
import { stabilizeMobileViewportKeyboardFocus } from './mobileViewportKeyboardFocus';
|
|
import { lockMobileViewportZoom } from './mobileViewportZoomLock';
|
|
import { resolveAppRoute } from './routing/activeAppRoutes';
|
|
import {
|
|
getHostRuntime,
|
|
refreshNativeAppHostRuntime,
|
|
} from './services/host-bridge/hostBridge';
|
|
|
|
type AppRoot = ReturnType<typeof createRoot>;
|
|
|
|
declare global {
|
|
interface Window {
|
|
__tavernRealmsRoot__?: AppRoot;
|
|
}
|
|
}
|
|
|
|
const route = resolveAppRoute(window.location.pathname);
|
|
const rootElement = document.getElementById('root');
|
|
|
|
if (!rootElement) {
|
|
throw new Error('Missing #root container');
|
|
}
|
|
|
|
function markWechatMiniProgramRuntime() {
|
|
if (getHostRuntime().kind === 'wechat_mini_program') {
|
|
document.documentElement.dataset.wechatMiniProgramRuntime = 'true';
|
|
}
|
|
}
|
|
|
|
const root = (window.__tavernRealmsRoot__ ??= createRoot(rootElement));
|
|
const RouteComponent = route.Component;
|
|
const routeElement = <RouteComponent />;
|
|
|
|
lockMobileViewportZoom();
|
|
stabilizeMobileViewportKeyboardFocus();
|
|
markWechatMiniProgramRuntime();
|
|
void refreshNativeAppHostRuntime();
|
|
|
|
root.render(
|
|
<StrictMode>
|
|
<Suspense fallback={null}>{routeElement}</Suspense>
|
|
<FloatingFeedbackEntry />
|
|
</StrictMode>,
|
|
);
|