import { ImportCore } from "@cqsjjb/jjb-common-decorator/module";
import React from "react";

export default class Entry extends React.Component {
  state = {
    Component: undefined,
  };

  componentDidMount() {
    if (process.env.app.appKey) {
      ImportCore({
        name: "$",
        from: "https://cdn.cqjjb.cn/jcloud/use/plugin/b31c9840a57f11ef91cf7f3cabbb7484/latest",
      }).then((res) => {
        if (res.status) {
          this.setState({ Component: res.module?.default });
        }
      });
    }
  }

  render() {
    const { Component } = this.state;
    return (Component && process.env.app.appKey) && (
      <Component
        detail={{ componentKey: process.env.app.appKey }}
        appKey={process.env.app.appKey}
      />
    );
  }
}
