feat: 换种方式实现 loading 效果, 比之前出现的更早

This commit is contained in:
lihao.ylh 2021-06-30 14:19:53 +08:00
parent f018e09868
commit 511b00f8f0
5 changed files with 30 additions and 13 deletions

View File

@ -90,19 +90,8 @@ export function createSimulator(
<html class="engine-design-mode">
<head><meta charset="utf-8"/>
${styleFrags}
<style>
#engine-skeleton-wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 90vh;
}
</style>
</head>
<body>
<div id="app">
<div id="engine-skeleton-wrapper"><img width="154" height="100" src="https://img.alicdn.com/tfs/TB1CmVgayERMeJjy0FcXXc7opXa-308-200.gif" /></div>
</div>
${scriptFrags}
</body>
</html>`);

View File

@ -4,8 +4,26 @@ import { Designer } from '../designer';
import { BuiltinSimulatorHostView } from '../builtin-simulator';
import './project.less';
class Loading extends Component {
render() {
return (
<div id="engine-loading-wrapper">
<img width="154" height="100" src="https://img.alicdn.com/tfs/TB1CmVgayERMeJjy0FcXXc7opXa-308-200.gif" />
</div>
);
}
}
@observer
export class ProjectView extends Component<{ designer: Designer }> {
componentDidMount() {
const { designer } = this.props;
const { project } = designer;
project.onRendererReady(() => {
this.forceUpdate();
});
}
render() {
const { designer } = this.props;
const { project } = designer;
@ -15,6 +33,7 @@ export class ProjectView extends Component<{ designer: Designer }> {
return (
<div className="lc-project">
<div className="lc-simulator-shell">
{!project?.simulator?.renderer && <Loading />}
<Simulator {...simulatorProps} />
</div>
</div>

View File

@ -18,3 +18,10 @@
height: 100%;
}
}
#engine-loading-wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 90vh;
}

View File

@ -1,6 +1,7 @@
import { Component as ReactComponent, ComponentType } from 'react';
import { ComponentMetadata, NodeSchema } from '@ali/lowcode-types';
import { ISensor, Point, ScrollTarget, IScrollable, LocateEvent, LocationData } from './designer';
import { BuiltinSimulatorRenderer } from './builtin-simulator/renderer';
import { Node, ParentalNode } from './document';
export type AutoFit = '100%';
@ -76,6 +77,7 @@ export interface ISimulatorHost<P = object> extends ISensor {
readonly viewport: IViewport;
readonly contentWindow?: Window;
readonly contentDocument?: Document;
readonly renderer?: BuiltinSimulatorRenderer;
// dependsAsset // like react jQuery lodash
// themesAsset

View File

@ -46,11 +46,11 @@ export interface EngineOptions {
/**
* false
*/
disableDefaultSettingPanel: boolean,
disableDefaultSettingPanel: boolean;
/**
* false
*/
disableDefaultSetters: boolean,
disableDefaultSetters: boolean;
/**
* Vision-polyfill settings
*/