51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
/**
|
||
* @name 能源氢费经营看板
|
||
* @description 嵌入 bi-next #hydrogen/overview · 我司成本三维度(非 OneOS V2) · 口令 lingniu
|
||
*/
|
||
import React, { useEffect, useMemo, useState } from 'react';
|
||
import { createRoot } from 'react-dom/client';
|
||
import {
|
||
type AnnotationSourceDocument,
|
||
type AnnotationViewerOptions,
|
||
} from '@axhub/annotation';
|
||
import { PrototypeAnnotationHost } from '../../common/prototype-annotation-host';
|
||
import { clearHostPrototypeRouteInfo } from '../../common/useHashPage';
|
||
import { EnergyBiAccessGate, isEnergyBiAuthed } from './EnergyBiAccessGate';
|
||
import { EnergyBiBoardApp } from './EnergyBiBoardApp';
|
||
import annotationSourceDocument from './annotation-source.json';
|
||
|
||
function AuthedEnergyBiBoard() {
|
||
const [ok, setOk] = useState(() => isEnergyBiAuthed());
|
||
if (!ok) return <EnergyBiAccessGate onOk={() => setOk(true)} />;
|
||
return <EnergyBiBoardApp />;
|
||
}
|
||
|
||
export default function EnergyH2BiBoardEntry() {
|
||
useEffect(() => {
|
||
clearHostPrototypeRouteInfo();
|
||
}, []);
|
||
|
||
const annotationOptions = useMemo<AnnotationViewerOptions>(
|
||
() => ({ title: '能源氢费经营看板' }),
|
||
[],
|
||
);
|
||
|
||
return (
|
||
<PrototypeAnnotationHost
|
||
source={annotationSourceDocument as unknown as AnnotationSourceDocument}
|
||
options={annotationOptions}
|
||
>
|
||
<AuthedEnergyBiBoard />
|
||
</PrototypeAnnotationHost>
|
||
);
|
||
}
|
||
|
||
if (typeof document !== 'undefined') {
|
||
const container = document.getElementById('root');
|
||
if (container && !container.dataset.energyH2BiBoardMounted) {
|
||
container.dataset.energyH2BiBoardMounted = '1';
|
||
const root = createRoot(container);
|
||
root.render(<EnergyH2BiBoardEntry />);
|
||
}
|
||
}
|