0.1.39 • Published 14 days ago

@saqu/auto-config-to-routes v0.1.39

Weekly downloads
-
License
ISC
Repository
github
Last release
14 days ago

@saqu/auto-config-to-routes

通过配置文件自动生成路由配置

在项目根目录下创建config/routes.json路由配置文件

[
  {
    "path":"home",// 跳转路由地址
    "element":"@/pages/home" // 页面文件地址
  }
]

参数

export interface AutoConfigToRoutesProps {
  /**
   * 文件是否是默认导出
   * @default false
   */
  isDefault?: boolean;
}

生成路由文件导出内容方式

默认导出

// 配置使用方式 .saqurc.ts
import configCreateRoutes from '@saqu/auto-config-to-routes';
export default {
  plugins: [new configCreateRoutes({isDefault:true})],
}

// 路由加载文件 src/pages/about/index.tsx
export default ()=>{
  return <div>默认导出</div>
}

直接导出element用于渲染

// 配置使用方式 .saqurc.ts
import configCreateRoutes from '@saqu/auto-config-to-routes';
export default {
  plugins: [new configCreateRoutes()],
}

// 路由加载文件  src/pages/about/index.tsx
const Index = ()=>{
  return <div>导出element</div>
}
export const element = <Index />;

导出符合router 6其他参数 通过直接导出变量的方式添加路由配置中其他参数

// 配置使用方式 .saqurc.ts
import configCreateRoutes from '@saqu/auto-config-to-routes';
export default {
  plugins: [new configCreateRoutes()],
}

// 路由加载文件 src/pages/about/index.tsx
const Index = ()=>{
  return <div>导出element</div>
}
export const element = <Index />;
export const loader = ()=>{}
export const action = ()=>{}
const ErrorElement = ()=><div>errorElement</div>
export const errorElement =<ErrorElement />
export const lazy=()=>import("@/about")
export const path="/about"
export const shouldRevalidate=({ currentUrl }) => {
  // only revalidate if the submission originates from
  // the `/meal-plans/new` route.
  return currentUrl.pathname === "/meal-plans/new";
}
0.1.39

14 days ago

0.1.38

1 month ago

0.1.30

9 months ago

0.1.31

9 months ago

0.1.32

9 months ago

0.1.10

10 months ago

0.1.33

9 months ago

0.1.11

10 months ago

0.1.34

8 months ago

0.1.12

10 months ago

0.1.35

8 months ago

0.1.13

10 months ago

0.1.36

8 months ago

0.1.14

10 months ago

0.1.37

6 months ago

0.1.15

10 months ago

0.1.27

9 months ago

0.1.28

9 months ago

0.1.29

9 months ago

0.1.20

9 months ago

0.1.21

9 months ago

0.1.22

9 months ago

0.1.23

9 months ago

0.1.24

9 months ago

0.1.25

9 months ago

0.1.26

9 months ago

0.1.16

10 months ago

0.1.8

10 months ago

0.1.17

9 months ago

0.1.7

10 months ago

0.1.18

9 months ago

0.1.19

9 months ago

0.1.9

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.2

11 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago