@zhajizhaji/meteo-hooks
TypeScript icon, indicating that this package has built-in type declarations

0.0.20 • Public • Published

meteo-hooks

This library was generated with Nx.

生成文档

全局安装以下两个包吧,方便点 npm install -g typedoc serve

  typedoc --tsconfig tsconfig-doc.json
  serve docs

使用方式

  1. 先设置代理和token ,要求能访问到接口
  2. 使用 useStationInfos 获取站点信息,用以拼合数据
  3. React 环境下使用这个,比如 Nextjs , 注意安装peer依赖
import { DemoPage, setMeteoConfig, useStationInfos } from "@zhajizhaji/meteo-hooks";
import { useEffect } from 'react'

setMeteoConfig({
  host: "https://sszc.sentinels.site",
  sign:"http://shuzicang.sentinels.site/api/public/sign",
  gm:"http://shuzicang.sentinels.site/api/public/gm",
  key:cookie.get("key")
})

const adminCodes = ["330000"];

export default function Meteo() {
  const { data, loading, fetchData } = useStationInfos();

  // 使用 onInitialize 钩子,在组件初始化时触发加载数据
  useEffect(() => {
    if (data === null && !loading) {
      fetchData(adminCodes);
    }
  }, [loading, data, fetchData]);
  return <div className="">
    <DemoPage />
  </div>
}

Dependents (0)

Package Sidebar

Install

npm i @zhajizhaji/meteo-hooks

Weekly Downloads

0

Version

0.0.20

License

none

Unpacked Size

1.47 MB

Total Files

34

Last publish

Collaborators

  • chengzhichao
  • neyio