diff --git a/admin.html b/admin.html
index b06eb73..0f11d9d 100644
--- a/admin.html
+++ b/admin.html
@@ -14,7 +14,7 @@
background: #f5f7fa;
}
.container {
- max-width: 1200px;
+ max-width: 1320px;
margin: 20px auto;
padding: 0 16px 24px;
}
@@ -51,6 +51,9 @@
margin-top: 12px;
text-align: right;
}
+ .route-table .el-table__cell .cell {
+ white-space: nowrap;
+ }
@@ -72,18 +75,18 @@
路由配置(routes)
新增路由
-
-
+
+
{{ scope.row.apiName || "-" }}
-
+
{{ scope.row.route }}
-
+
{{ scope.row.filePath }}
@@ -98,7 +101,7 @@
-
+
-
+ >
+
+
@@ -328,6 +341,22 @@
activeMainTab: "routes",
apiList: [],
mockFiles: [],
+ commonStatusCodes: [
+ { value: 200, label: "200 OK" },
+ { value: 201, label: "201 Created" },
+ { value: 204, label: "204 No Content" },
+ { value: 400, label: "400 Bad Request" },
+ { value: 401, label: "401 Unauthorized" },
+ { value: 403, label: "403 Forbidden" },
+ { value: 404, label: "404 Not Found" },
+ { value: 409, label: "409 Conflict" },
+ { value: 422, label: "422 Unprocessable Entity" },
+ { value: 429, label: "429 Too Many Requests" },
+ { value: 500, label: "500 Internal Server Error" },
+ { value: 501, label: "501 Not Implemented" },
+ { value: 502, label: "502 Bad Gateway" },
+ { value: 503, label: "503 Service Unavailable" },
+ ],
routePagination: {
currentPage: 1,
pageSize: 10,
@@ -397,6 +426,13 @@
var start = (currentPage - 1) * pageSize;
return source.slice(start, start + pageSize);
},
+ normalizeStatusCode: function (value) {
+ var numeric = Number(value);
+ if (Number.isInteger(numeric) && numeric >= 100 && numeric <= 599) {
+ return numeric;
+ }
+ return 200;
+ },
handleRoutePageChange: function (page) {
this.routePagination.currentPage = page;
},
@@ -418,7 +454,9 @@
rawRoute: rawRoute,
route: route,
filePath: routesObj[rawRoute],
- statusCode: Number(routeStatusesObj && routeStatusesObj[rawRoute]) || 200,
+ statusCode: self.normalizeStatusCode(
+ routeStatusesObj && routeStatusesObj[rawRoute],
+ ),
apiName: matched ? matched.name : "",
selectedApiRoute: matched ? matched.route : "",
enabled: enabled,
@@ -438,12 +476,13 @@
return obj;
},
toRouteStatusObject: function (routeArray) {
+ var self = this;
var obj = {};
(routeArray || []).forEach(function (item) {
var route = (item.route || "").trim();
if (!route) return;
var routeKey = item.enabled === false ? "#" + route : route;
- var statusCode = Number(item.statusCode) || 200;
+ var statusCode = self.normalizeStatusCode(item.statusCode);
obj[routeKey] = statusCode;
});
return obj;
@@ -501,7 +540,7 @@
originalRawRoute: item.rawRoute || item.route || "",
route: item.route || "",
filePath: item.filePath || "mock/",
- statusCode: Number(item.statusCode) || 200,
+ statusCode: this.normalizeStatusCode(item.statusCode),
enabled: item.enabled !== false,
};
this.routeDialog.visible = true;
@@ -660,6 +699,7 @@
}
var payload = Object.assign({}, this.routeDialog.form, {
useExistingFile: true,
+ statusCode: this.normalizeStatusCode(this.routeDialog.form.statusCode),
});
try {
var resp = await fetch("/__routes", {