28 lines
766 B
TypeScript
28 lines
766 B
TypeScript
import Taro from "@tarojs/taro";
|
|
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("请求结果");
|
|
await Taro.setNavigationBarColor({
|
|
frontColor: "#000000",
|
|
backgroundColor: "#000000",
|
|
});
|
|
setTimeout(() => {
|
|
setPageLoading(false);
|
|
}, 400);
|
|
} catch (error) {
|
|
console.error("Error loading page content:", error);
|
|
setPageLoading(false);
|
|
}
|
|
};
|
|
|
|
return { pageLoading, pageContent, loadPageContent };
|
|
};
|