12345678910111213141516171819202122232425262728293031323334353637383940 |
- "use client";
- import React from "react";
- import dialogManage from "./manager";
- const AutoShowDialog = () => {
- const [data, setData] = React.useState<string[]>([]);
- React.useEffect(() => {
- getData();
- }, []);
- React.useEffect(() => {
- if (!data.length) return;
- setTimeout(() => {
- doShow();
- }, 300);
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [data]);
- const getData = async () => {
- //"ImgDialog",
- setData(["WheelSection", "SignInSection", "HomePromotion"]);
- };
- const doShow = async () => {
- let showIndex = sessionStorage.getItem("dialogShow");
- let startShow = showIndex ? Number(showIndex) : 0;
- if (startShow > data.length - 1) {
- startShow = 0;
- }
- for (let i = startShow; i < data.length; i++) {
- const key = data[i];
- await dialogManage.showDialog(key);
- sessionStorage.setItem("dialogShow", `${i + 1}`);
- }
- };
- return null;
- };
- export default AutoShowDialog;
|