http接口增加了头设置
("Access-Control-Allow-Headers", "Content-Type")
This commit is contained in:
parent
04f8913815
commit
fe8849c6bb
@ -8,19 +8,14 @@ import site.deercloud.identityverification.Utils.MyLogger;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBody;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
import static site.deercloud.identityverification.Utils.Utils.*;
|
||||
|
||||
public class Ban implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange){
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("POST")){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "POST");
|
||||
|
||||
JSONObject jsonObject = getBody(exchange);
|
||||
String uuid = jsonObject.getString("uuid");
|
||||
|
@ -13,8 +13,7 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getQuery;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
import static site.deercloud.identityverification.Utils.Utils.*;
|
||||
|
||||
public class GetInviter implements HttpHandler {
|
||||
@ -22,11 +21,7 @@ public class GetInviter implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) {
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("GET")) {
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "GET");
|
||||
|
||||
Map<String, String> params = getQuery(exchange);
|
||||
|
||||
|
@ -14,18 +14,13 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBody;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBodyArray;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
|
||||
public class GetProfiles implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) {
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("POST")) {
|
||||
Response.err_method_not_allowed(exchange);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "POST");
|
||||
JSONArray profiles_json = getBodyArray(exchange);
|
||||
if (profiles_json.size() > 5) {
|
||||
Response.success_no_content(exchange);
|
||||
|
@ -13,19 +13,14 @@ import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBody;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
|
||||
public class Login implements HttpHandler {
|
||||
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("POST")) {
|
||||
Response.err_method_not_allowed(exchange);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "POST");
|
||||
JSONObject request = getBody(exchange);
|
||||
String username = request.getString("username");
|
||||
String password = request.getString("password");
|
||||
|
@ -9,17 +9,13 @@ import com.sun.net.httpserver.HttpHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.requestHeader;
|
||||
|
||||
public class MetaData implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange){
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("GET")){
|
||||
exchange.sendResponseHeaders(405, 0);
|
||||
exchange.close();
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "GET");
|
||||
String title = "A Minecraft Server";
|
||||
String description = "Minecraft is a 3D sandbox game developed by Mojang Studios where players interact with a fully modifiable three-dimensional environment made of blocks and entities. ";
|
||||
Boolean use_yag = true; // 是否使用外置登录
|
||||
|
@ -13,20 +13,19 @@ import site.deercloud.identityverification.Utils.RandomCode;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBody;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
|
||||
public class GetEmailCode implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) {
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("POST")){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "POST");
|
||||
JSONObject request = getBody(exchange);
|
||||
String email = request.getString("email");
|
||||
if (email == null || email.equals("")){
|
||||
jsonResponse(exchange, 400, "邮箱不能为空", null);
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证邮箱唯一性
|
||||
if (UserDAO.selectByEmail(email) != null) {
|
||||
|
@ -8,19 +8,14 @@ import site.deercloud.identityverification.Utils.MyLogger;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getQuery;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
import static site.deercloud.identityverification.Utils.Utils.*;
|
||||
|
||||
public class GetOnlineProfile implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange){
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("GET")){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "GET");
|
||||
|
||||
Map<String, String> params = getQuery(exchange);
|
||||
|
||||
|
@ -15,20 +15,14 @@ import site.deercloud.identityverification.Utils.MyLogger;
|
||||
import site.deercloud.identityverification.Utils.UnsignedUUID;
|
||||
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBody;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
import static site.deercloud.identityverification.Utils.Utils.*;
|
||||
|
||||
public class Registration implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange){
|
||||
try {
|
||||
// 设置响应头
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("POST")){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "POST");
|
||||
|
||||
JSONObject jsonObject = getBody(exchange);
|
||||
|
||||
|
@ -11,17 +11,13 @@ import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getQuery;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
|
||||
public class VerifyCode implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange){
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("GET")){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "GET");
|
||||
Map<String, String> params = getQuery(exchange);
|
||||
String code = params.get("code");
|
||||
|
||||
|
@ -14,19 +14,14 @@ import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.util.Objects;
|
||||
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.getBody;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.jsonResponse;
|
||||
import static site.deercloud.identityverification.HttpServer.HttpServerManager.*;
|
||||
import static site.deercloud.identityverification.Utils.Utils.*;
|
||||
|
||||
public class SignWhiteList implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
if (!exchange.getRequestMethod().equals("POST")){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return;
|
||||
}
|
||||
requestHeader(exchange, "POST");
|
||||
JSONObject jsonObject = getBody(exchange);
|
||||
|
||||
String id = jsonObject.getString("id"); // 身份证(实名认证用)
|
||||
|
@ -121,6 +121,21 @@ public class HttpServerManager {
|
||||
exchange.getResponseBody().close();
|
||||
}
|
||||
|
||||
public static boolean requestHeader(HttpExchange exchange, String Method) {
|
||||
try {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/json; charset=UTF-8");
|
||||
exchange.getResponseHeaders().add("Access-Control-Allow-Origin", "*");
|
||||
exchange.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type");
|
||||
if (!exchange.getRequestMethod().equals(Method)){
|
||||
jsonResponse(exchange, 405, "Method Not Allowed", null);
|
||||
return false;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
MyLogger.debug(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static JSONObject getBody(HttpExchange exchange) throws IOException {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exchange.getRequestBody(), "utf-8"));
|
||||
StringBuilder requestBodyContent = new StringBuilder();
|
||||
|
69
src/web/package-lock.json
generated
69
src/web/package-lock.json
generated
@ -8,6 +8,7 @@
|
||||
"name": "web",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.2.0",
|
||||
"unplugin-auto-import": "^0.12.0",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.1.6"
|
||||
@ -541,8 +542,17 @@
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"dev": true
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.2.0.tgz",
|
||||
"integrity": "sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
@ -669,7 +679,6 @@
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
@ -847,7 +856,6 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
@ -1401,11 +1409,23 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
@ -1989,7 +2009,6 @@
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@ -1998,7 +2017,6 @@
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
@ -2314,6 +2332,11 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/psl": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmmirror.com/psl/-/psl-1.9.0.tgz",
|
||||
@ -3651,8 +3674,17 @@
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"dev": true
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.2.0.tgz",
|
||||
"integrity": "sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.2",
|
||||
@ -3759,7 +3791,6 @@
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
@ -3909,8 +3940,7 @@
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
|
||||
},
|
||||
"domexception": {
|
||||
"version": "4.0.0",
|
||||
@ -4231,11 +4261,15 @@
|
||||
"to-regex-range": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
@ -4698,14 +4732,12 @@
|
||||
"mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "1.52.0"
|
||||
}
|
||||
@ -4956,6 +4988,11 @@
|
||||
"integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==",
|
||||
"dev": true
|
||||
},
|
||||
"proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"psl": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmmirror.com/psl/-/psl-1.9.0.tgz",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.2.0",
|
||||
"unplugin-auto-import": "^0.12.0",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.1.6"
|
||||
|
@ -14,6 +14,9 @@ import { h } from 'vue'
|
||||
import { RouterLink, RouterView } from 'vue-router'
|
||||
import { NMenu, NGrid, NGridItem, NLayout, NLayoutHeader, NLayoutContent, NLayoutFooter } from 'naive-ui';
|
||||
import type { MenuOption } from 'naive-ui'
|
||||
import axios from "axios";
|
||||
|
||||
axios.defaults.baseURL = 'http://127.0.0.1:11520/';
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<n-grid :x-gap="12">
|
||||
<n-grid-item span="24">
|
||||
<n-form-item label="电子邮箱">
|
||||
<n-input placeholder="" v-model:value="email" />
|
||||
<n-input @input="checkEmail" placeholder="" v-model:value="email" />
|
||||
</n-form-item>
|
||||
</n-grid-item>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
<n-grid-item span="12">
|
||||
<n-form-item label=" ">
|
||||
<n-button @click="send_email_code" style="width: 100%">{{send_code_text}}</n-button>
|
||||
<n-button :disabled="send_code_btn_disabled" @click="getEmailCode" style="width: 100%">{{send_code_text}}</n-button>
|
||||
</n-form-item>
|
||||
</n-grid-item>
|
||||
|
||||
@ -61,6 +61,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { NButton, NForm, NFormItem, NInput, NGrid, NGridItem } from 'naive-ui'
|
||||
import axios from "axios";
|
||||
|
||||
const email = ref('')
|
||||
const email_code = ref('')
|
||||
@ -68,6 +69,8 @@ const password = ref('')
|
||||
const invite_code = ref('')
|
||||
|
||||
const send_code_text = ref('发送验证码')
|
||||
const send_code_btn_disabled = ref(false)
|
||||
|
||||
const verify_invite_code_text = ref('验证邀请码')
|
||||
const profile_name_text = ref('验证可用性')
|
||||
|
||||
@ -80,5 +83,50 @@ const send_email_code = () => {
|
||||
console.log('send email code')
|
||||
}
|
||||
|
||||
function getEmailCode() {
|
||||
if (email.value == '') {
|
||||
alert('请输入邮箱')
|
||||
return
|
||||
}
|
||||
if (checkEmail(email.value) == false) {
|
||||
alert('邮箱格式不正确')
|
||||
return
|
||||
}
|
||||
send_code_text.value = '发送中...'
|
||||
send_code_btn_disabled.value = true
|
||||
axios.post('/api/getEmailCode', {
|
||||
email: email.value
|
||||
}).then(function (response) {
|
||||
send_code_text.value = '发送成功'
|
||||
console.log(response);
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
countDown();
|
||||
}
|
||||
|
||||
// 60秒后才能再次发送验证码
|
||||
function countDown() {
|
||||
let time = 60
|
||||
let timer = setInterval(() => {
|
||||
time--
|
||||
send_code_text.value = time + '秒后重试'
|
||||
if (time == 0) {
|
||||
clearInterval(timer)
|
||||
send_code_text.value = '发送验证码'
|
||||
send_code_btn_disabled.value = false
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
// 正则表达式检查邮箱格式
|
||||
function checkEmail(email) {
|
||||
let reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
|
||||
if (!reg.test(email)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user