Skip to content

Commit c9e850e

Browse files
committed
开源迁移
1 parent a1b01e4 commit c9e850e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5606
-1
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Local
2+
.DS_Store
3+
*.local
4+
*.log*
5+
6+
# Dist
7+
node_modules
8+
dist/
9+
10+
# IDE
11+
.vscode/*
12+
!.vscode/extensions.json
13+
.idea
14+
15+
pnpm-lock.yaml
16+
package-lock.json
17+
yarn.lock

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,49 @@
1-
# react-security-router
1+
# React Security Router
2+
23
React 安全路由器
4+
5+
# 框架说明
6+
7+
rsr 是 react security router 的简写,一个基于 react router 实现路由级别控制的安全框架。
8+
9+
功能简介:
10+
11+
- 认证与授权
12+
- 权限检测
13+
- 二次签证(签名:如要求再次输入密码等)
14+
- 等等
15+
16+
# 版本兼容
17+
18+
注意:不兼容 react router 7 版本,在 v7 😒 版本上的 `useBlocker` 逻辑变更了,暂时不考虑兼容。
19+
20+
# 简单例子
21+
22+
``` tsx
23+
24+
export default withSecurityBlocker(Root, bundler => {
25+
return bundler
26+
.context(builder => {
27+
return builder
28+
// 可选层级权限
29+
// .hierarchy('superadmin>admin;admin>users;users>guest')
30+
.resource(rb => rb.patterns('/login', '/logout', '/denied', '/signature').anonymous().build())
31+
.resource(rb => rb.patterns('/sheet').permissions('admin').signatured().build())
32+
.resource(rb => rb.patterns('/*').authenticated().build())
33+
.build();
34+
})
35+
.manager(builder => {
36+
return builder
37+
.behave({
38+
notAuthenticationPath: '/login',
39+
notSignaturePath: '/signature',
40+
accessDeniedPath: '/denied',
41+
})
42+
.build();
43+
})
44+
// .addons()
45+
.build()
46+
47+
});
48+
49+
```

biome.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"vcs": {
7+
"enabled": true,
8+
"defaultBranch": "main",
9+
"clientKind": "git",
10+
"useIgnoreFile": true
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "space"
15+
},
16+
"css": {
17+
"parser": {
18+
"cssModules": true
19+
}
20+
},
21+
"javascript": {
22+
"formatter": {
23+
"quoteStyle": "single",
24+
"arrowParentheses": "asNeeded",
25+
"jsxQuoteStyle": "double",
26+
"lineWidth": 160
27+
}
28+
},
29+
"linter": {
30+
"enabled": true,
31+
"rules": {
32+
"recommended": true,
33+
"suspicious": {
34+
"noDuplicateFontNames": "off",
35+
"noExplicitAny": "off"
36+
},
37+
"style": {
38+
"noUselessElse": "off"
39+
},
40+
"complexity": {
41+
"noUselessSwitchCase": "off",
42+
"noForEach": "off"
43+
}
44+
}
45+
},
46+
"files": {
47+
"ignoreUnknown": true,
48+
"ignore": [".vscode/**/*", "node_modules/**/*", "dist/**/*"]
49+
}
50+
}

package.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"name": "@lanaqi/rsr",
3+
"version": "0.0.1-rc.1",
4+
"type": "module",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"import": "./dist/index.js"
9+
}
10+
},
11+
"module": "./dist/index.js",
12+
"types": "./dist/index.d.ts",
13+
"files": [
14+
"dist"
15+
],
16+
"keywords": [
17+
"react",
18+
"router",
19+
"security",
20+
"react-security",
21+
"router-security",
22+
"react-security-router",
23+
"react-router-security",
24+
"guard",
25+
"react-guard",
26+
"router-guard",
27+
"react-router-guard",
28+
"react-router",
29+
"react-router-dom",
30+
"modern-js",
31+
"modernjs",
32+
"安全",
33+
"鉴权",
34+
"守护",
35+
"认证",
36+
"授权",
37+
"权限",
38+
"安全框架",
39+
"路由安全",
40+
"认证授权",
41+
"路由守护"
42+
],
43+
"description": "React 安全路由器",
44+
"scripts": {
45+
"build": "rslib build",
46+
"lint": "biome lint",
47+
"check": "biome check",
48+
"format": "biome format --write",
49+
"release": "npm run build && npm publish"
50+
},
51+
"devDependencies": {
52+
"@biomejs/biome": "^1.9.4",
53+
"@rsbuild/plugin-react": "^1.1.1",
54+
"@rslib/core": "^0.5.5",
55+
"@types/react": "^18.3.19",
56+
"@types/react-dom": "^18.3.5",
57+
"react": "^18.3.1",
58+
"react-dom": "^18.3.1",
59+
"react-router-dom": "^6.30.0",
60+
"typescript": "^5.8.2"
61+
},
62+
"peerDependencies": {
63+
"react": ">=17.0.0",
64+
"react-dom": ">=17.0.0",
65+
"react-router-dom": "^6.0.0"
66+
},
67+
"private": false,
68+
"publishConfig": {
69+
"access": "public",
70+
"registry": "https://registry.npmjs.org"
71+
}
72+
}

rslib.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { pluginReact } from '@rsbuild/plugin-react';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
source: {
6+
entry: {
7+
index: ['./src/index.ts'],
8+
},
9+
},
10+
lib: [
11+
{
12+
bundle: true,
13+
dts: true,
14+
format: 'esm',
15+
},
16+
],
17+
output: {
18+
target: 'web',
19+
},
20+
plugins: [pluginReact()],
21+
});

0 commit comments

Comments
 (0)