@e7w/easy-routes 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,26 @@
1
1
  # 自用React-router配置
2
+
3
+ /src/pages/\*\*/page.tsx为页面
4
+
5
+ ```ts
6
+ export function Page() {}
7
+ ```
8
+
9
+ ---
10
+
11
+ /src/pages/\*\*/layout.tsx为layout
12
+
13
+ ```ts
14
+ export function Layout() {
15
+ return <><Outlet /></>
16
+ }
17
+ ```
18
+
19
+ ---
20
+
21
+ /src/pages/\*\*/meta.ts配置如下
22
+
23
+ ```ts
24
+ export const permission: number = 0b0; // 默认是0b0代表需要登录,只有最右边的一位代表登录,其他位可以自己定enum代表权限
25
+ export const loader: Loader = async (ctx, meta) => {}; // 可以动态修改ctx,ctx.data是返回给页面组件的值,ctx.title是页面的title,signed代表是否登录成功,noPermission代表是否没有权限
26
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e7w/easy-routes",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,7 +36,7 @@ export const system = provide(
36
36
  return (this.router.permission & permission) === permission;
37
37
  }
38
38
 
39
- getCtx(params: Params, request: Request, permission = 0): Ctx {
39
+ getCtx(params: Params, request: Request, permission = 1): Ctx {
40
40
  return {
41
41
  title: this.router.defaultTitle || document.title,
42
42
  signed: (permission & 1) === 0 || this.hasPermission(1),