23 lines
616 B
TypeScript

import { useState } from "react";
// 页面请求hooks
export const usePageContent = () => {
const [pageContent, setPageContent] = useState("");
const [pageLoading, setPageLoading] = useState<boolean>(true);
const loadPageContent = async (code: string) => {
try {
console.log("Page content loaded:", code);
setPageContent("请求结果");
setTimeout(() => {
setPageLoading(false);
}, 5000);
} catch (error) {
console.error("Error loading page content:", error);
setPageLoading(false);
}
};
return { pageLoading, pageContent, loadPageContent };
};