@rdyl/node-koa-controller 0.5.8 → 0.6.0
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/CHANGELOG.md +1 -1
- package/dist/cache.js +1 -1
- package/dist/docs/template.ejs +198 -0
- package/dist/utils.js +1 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/cache.js
CHANGED
|
@@ -111,7 +111,7 @@ var ASTCache = /** @class */ (function () {
|
|
|
111
111
|
handlers.forEach(function (handler) {
|
|
112
112
|
var method = handler.method, url = handler.url, name = handler.name, hAuth = handler.auth;
|
|
113
113
|
var path = (0, path_1.join)("/" + ASTCache.prefix, prefix, url);
|
|
114
|
-
var isPublic =
|
|
114
|
+
var isPublic = cAuth.isPublic || hAuth.isPublic;
|
|
115
115
|
if (isPublic) {
|
|
116
116
|
ASTCache.whitelist.push(path);
|
|
117
117
|
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>接口文档</title>
|
|
7
|
+
<style>
|
|
8
|
+
* {
|
|
9
|
+
padding: 0;
|
|
10
|
+
margin: 0;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
*::after {
|
|
16
|
+
border: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
*::before {
|
|
20
|
+
border: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
html,
|
|
24
|
+
body {
|
|
25
|
+
/* font-family: 'ZCOOL XiaoWei', serif; */
|
|
26
|
+
padding: 0;
|
|
27
|
+
margin: 0;
|
|
28
|
+
color: #526680;
|
|
29
|
+
font-size: 14px;
|
|
30
|
+
height: 100vh;
|
|
31
|
+
line-height: 1.1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
body {
|
|
35
|
+
text-rendering: optimizeLegibility;
|
|
36
|
+
-webkit-font-smoothing: antialiased;
|
|
37
|
+
-moz-osx-font-smoothing: grayscale;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#root {
|
|
41
|
+
height: 100%;
|
|
42
|
+
width: 100%;
|
|
43
|
+
/* background-image: linear-gradient(-225deg, #7de2fc 0%, #b9b6e5 100%); */
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ul,
|
|
47
|
+
ol,
|
|
48
|
+
li {
|
|
49
|
+
list-style: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
svg {
|
|
53
|
+
font-size: 1em;
|
|
54
|
+
width: 1em;
|
|
55
|
+
height: 1em;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.content {
|
|
59
|
+
min-width: 100vh;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.modules {
|
|
66
|
+
max-width: 1200px;
|
|
67
|
+
width: 100%;
|
|
68
|
+
padding-top: 180px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.moduleItem {
|
|
72
|
+
width: 100%;
|
|
73
|
+
padding: 24px;
|
|
74
|
+
border-radius: 8px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.moduleItem .t {
|
|
78
|
+
font-weight: 700;
|
|
79
|
+
font-size: 20px;
|
|
80
|
+
height: 42px;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
color: #000;
|
|
84
|
+
margin-bottom: 15px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.items {
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.item {
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 42px;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
padding: 0 12px;
|
|
97
|
+
margin-bottom: 15px;
|
|
98
|
+
border-radius: 4px;
|
|
99
|
+
margin-bottom: 15px;
|
|
100
|
+
border: 1px solid #ddd;
|
|
101
|
+
gap: 12px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.item>span {
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
font-weight: 700;
|
|
107
|
+
border: 1px solid var(--border-s);
|
|
108
|
+
background: #f9f9f9;
|
|
109
|
+
padding: 2px 12px;
|
|
110
|
+
border-radius: 3px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.item>p {
|
|
114
|
+
font-size: 16px;
|
|
115
|
+
font-weight: 500;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.item .copy-url {
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
padding: 0 6px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.get {
|
|
124
|
+
color: green;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.post {
|
|
128
|
+
color: #d87a16;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.patch {
|
|
132
|
+
color: #cf2f86
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.put {
|
|
136
|
+
color: #177ddc
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.delete {
|
|
140
|
+
color: red;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
143
|
+
</head>
|
|
144
|
+
|
|
145
|
+
<body>
|
|
146
|
+
<div class="content">
|
|
147
|
+
<div class="modules">
|
|
148
|
+
<% for (var i=0; i<treeData.length; i++) { %>
|
|
149
|
+
<div class="moduleItem">
|
|
150
|
+
<div class="t"><%= treeData[i].name %>
|
|
151
|
+
<span style="color:red"><%= treeData[i].tag %></span>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="items">
|
|
154
|
+
<% for (var j=0; j<treeData[i].handlers.length; j++) { %>
|
|
155
|
+
<div class="item">
|
|
156
|
+
<span class="<%= treeData[i].handlers[j].method.toLowerCase() %>"><%= treeData[i].handlers[j].method %></span>
|
|
157
|
+
<p><%= treeData[i].handlers[j].url %></p>
|
|
158
|
+
<span style="color:red"><%= treeData[i].handlers[j].tag %></span>
|
|
159
|
+
<button class="copy-url" onclick="onCopy" data-content="<%= treeData[i].handlers[j].jsUrl %>">复制</button>
|
|
160
|
+
</div>
|
|
161
|
+
<% } %>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
<% } %>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</body>
|
|
168
|
+
<script>
|
|
169
|
+
function onCopy(e) {
|
|
170
|
+
const content = e.target.dataset.content
|
|
171
|
+
if (navigator.clipboard) {
|
|
172
|
+
// clipboard api 复制
|
|
173
|
+
navigator.clipboard.writeText(content);
|
|
174
|
+
} else {
|
|
175
|
+
var textarea = document.createElement('textarea');
|
|
176
|
+
document.body.appendChild(textarea);
|
|
177
|
+
// 隐藏此输入框
|
|
178
|
+
textarea.style.position = 'fixed';
|
|
179
|
+
textarea.style.clip = 'rect(0 0 0 0)';
|
|
180
|
+
textarea.style.top = '10px';
|
|
181
|
+
// 赋值
|
|
182
|
+
textarea.value = content;
|
|
183
|
+
// 选中
|
|
184
|
+
textarea.select();
|
|
185
|
+
// 复制
|
|
186
|
+
document.execCommand('copy', true);
|
|
187
|
+
// 移除输入框
|
|
188
|
+
document.body.removeChild(textarea);
|
|
189
|
+
}
|
|
190
|
+
alert('复制成功')
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
document.querySelectorAll('.copy-url').forEach(ele => {
|
|
194
|
+
ele.addEventListener('click', onCopy)
|
|
195
|
+
})
|
|
196
|
+
</script>
|
|
197
|
+
|
|
198
|
+
</html>
|
package/dist/utils.js
CHANGED
|
@@ -152,9 +152,7 @@ function ParsedAuthControl() {
|
|
|
152
152
|
var any = [];
|
|
153
153
|
for (var _a = 0, auths_1 = auths; _a < auths_1.length; _a++) {
|
|
154
154
|
var auth = auths_1[_a];
|
|
155
|
-
var _b = auth.mode, mode = _b === void 0 ? "AND" : _b, _c = auth.name, name_1 = _c === void 0 ? [] : _c
|
|
156
|
-
if (isPublic)
|
|
157
|
-
continue;
|
|
155
|
+
var _b = auth.mode, mode = _b === void 0 ? "AND" : _b, _c = auth.name, name_1 = _c === void 0 ? [] : _c;
|
|
158
156
|
var keys = typeof name_1 === "string" ? [name_1] : name_1;
|
|
159
157
|
if (!keys.length)
|
|
160
158
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdyl/node-koa-controller",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
18
|
-
"build": "tsc && copyfiles -u 1 src/**/*.d.ts src/*.d.ts types && npm run changelog && git add CHANGELOG.md"
|
|
18
|
+
"build": "tsc && copyfiles -u 1 src/**/*.d.ts src/*.d.ts types && copyfiles -u 1 src/**/*.ejs src/*.ejs dist && npm run changelog && git add CHANGELOG.md"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@koa/router": "^15.1.1",
|