From b8c9fdbb2586bf41ae5aca5c22aa44025f990d36 Mon Sep 17 00:00:00 2001 From: jeesun Date: Fri, 17 May 2019 18:17:21 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BD=BF=E7=94=A8Element=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BB=A3=E6=9B=BFlayer=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/simon/common/utils/BuildTree.java | 89 ------- .../java/com/simon/common/utils/DictUtil.java | 67 ------ api/src/main/resources/templates/code/add.ftl | 2 +- .../main/resources/templates/code/edit.ftl | 2 +- .../main/resources/templates/code/list.ftl | 4 +- .../java/com/simon/ApiApplicationTest.java | 17 +- web/src/main/resources/templates/code/add.ftl | 2 +- .../main/resources/templates/code/edit.ftl | 2 +- .../main/resources/templates/code/list.ftl | 4 +- .../templates/vue/authority/add.html | 4 +- .../templates/vue/authority/edit.html | 4 +- .../templates/vue/authority/list.html | 4 +- .../resources/templates/vue/bill/list.html | 4 +- .../resources/templates/vue/dictType/add.html | 4 +- .../templates/vue/dictType/edit.html | 4 +- .../templates/vue/dictType/list.html | 4 +- .../templates/vue/dictType/subAdd.html | 4 +- .../templates/vue/dictType/subEdit.html | 4 +- .../templates/vue/fontAwesome/add.html | 2 +- .../templates/vue/fontAwesome/edit.html | 4 +- .../templates/vue/fontAwesome/list.html | 4 +- .../main/resources/templates/vue/index.html | 42 ++-- .../templates/vue/loggingEvent/list.html | 4 +- .../resources/templates/vue/newsInfo/add.html | 2 +- .../templates/vue/newsInfo/edit.html | 2 +- .../templates/vue/newsInfo/list.html | 4 +- .../templates/vue/oauthUser/add.html | 4 +- .../templates/vue/oauthUser/edit.html | 4 +- .../templates/vue/oauthUser/list.html | 4 +- .../templates/vue/quartzJob/add.html | 2 +- .../templates/vue/quartzJob/edit.html | 2 +- .../templates/vue/quartzJob/list.html | 8 +- .../vue/roleAuthority/auth_config.html | 4 +- .../templates/vue/roleAuthority/list.html | 4 +- .../resources/templates/vue/sideMenu/add.html | 4 +- .../templates/vue/sideMenu/edit.html | 4 +- .../templates/vue/sideMenu/list.html | 4 +- .../templates/vue/sideMenu/subAdd.html | 4 +- .../templates/vue/sideMenu/subEdit.html | 4 +- .../templates/vue/table/code_generate.html | 2 +- .../resources/templates/vue/table/list.html | 4 +- .../resources/templates/vue/bill/add.html | 190 --------------- .../resources/templates/vue/bill/edit.html | 191 --------------- .../resources/templates/vue/bill/list.html | 223 ------------------ .../resources/templates/vue/columnUi/add.html | 126 ---------- .../templates/vue/columnUi/edit.html | 127 ---------- .../templates/vue/columnUi/list.html | 202 ---------------- .../resources/templates/vue/newsInfo/add.html | 142 ----------- .../templates/vue/newsInfo/edit.html | 143 ----------- .../templates/vue/newsInfo/list.html | 211 ----------------- .../templates/vue/quartzJob/add.html | 150 ------------ .../templates/vue/quartzJob/edit.html | 151 ------------ .../templates/vue/quartzJob/list.html | 212 ----------------- 53 files changed, 97 insertions(+), 2318 deletions(-) delete mode 100644 api/src/main/java/com/simon/common/utils/BuildTree.java delete mode 100644 api/src/main/java/com/simon/common/utils/DictUtil.java delete mode 100644 web/src/test/resources/templates/vue/bill/add.html delete mode 100644 web/src/test/resources/templates/vue/bill/edit.html delete mode 100644 web/src/test/resources/templates/vue/bill/list.html delete mode 100644 web/src/test/resources/templates/vue/columnUi/add.html delete mode 100644 web/src/test/resources/templates/vue/columnUi/edit.html delete mode 100644 web/src/test/resources/templates/vue/columnUi/list.html delete mode 100644 web/src/test/resources/templates/vue/newsInfo/add.html delete mode 100644 web/src/test/resources/templates/vue/newsInfo/edit.html delete mode 100644 web/src/test/resources/templates/vue/newsInfo/list.html delete mode 100644 web/src/test/resources/templates/vue/quartzJob/add.html delete mode 100644 web/src/test/resources/templates/vue/quartzJob/edit.html delete mode 100644 web/src/test/resources/templates/vue/quartzJob/list.html diff --git a/api/src/main/java/com/simon/common/utils/BuildTree.java b/api/src/main/java/com/simon/common/utils/BuildTree.java deleted file mode 100644 index d7691a2..0000000 --- a/api/src/main/java/com/simon/common/utils/BuildTree.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.simon.common.utils; - -import com.simon.dto.Tree; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class BuildTree { - - public static Tree build(List> nodes) { - - if (nodes == null) { - return null; - } - List> topNodes = new ArrayList>(); - - for (Tree children : nodes) { - - String pid = children.getParentId(); - if (pid == null || "0".equals(pid)) { - topNodes.add(children); - - continue; - } - - for (Tree parent : nodes) { - String id = parent.getId(); - if (id != null && id.equals(pid)) { - parent.getChildren().add(children); - children.setHasParent(true); - parent.setHasChildren(true); - continue; - } - } - - } - - Tree root = new Tree(); - if (topNodes.size() == 1) { - root = topNodes.get(0); - } else { - root.setId("-1"); - root.setParentId(""); - root.setHasParent(false); - root.setHasChildren(true); - root.setChecked(true); - root.setChildren(topNodes); - root.setText("顶级节点"); - Map state = new HashMap<>(16); - state.put("opened", true); - root.setState(state); - } - - return root; - } - - public static List> buildList(List> nodes, String idParam) { - if (nodes == null) { - return null; - } - List> topNodes = new ArrayList>(); - - for (Tree children : nodes) { - - String pid = children.getParentId(); - if (pid == null || idParam.equals(pid)) { - topNodes.add(children); - - continue; - } - - for (Tree parent : nodes) { - String id = parent.getId(); - if (id != null && id.equals(pid)) { - parent.getChildren().add(children); - children.setHasParent(true); - parent.setHasChildren(true); - - continue; - } - } - - } - return topNodes; - } - -} \ No newline at end of file diff --git a/api/src/main/java/com/simon/common/utils/DictUtil.java b/api/src/main/java/com/simon/common/utils/DictUtil.java deleted file mode 100644 index 4b18e5a..0000000 --- a/api/src/main/java/com/simon/common/utils/DictUtil.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.simon.common.utils; - -import com.google.common.base.Joiner; -import com.simon.model.DictType; -import com.simon.service.DictTypeService; -import lombok.var; -import org.apache.commons.lang3.StringUtils; -import org.springframework.context.ApplicationContext; - -import java.util.List; - -/** - * 字典工具类 - * - * @author simon - * @create 2018-09-06 11:25 - **/ - -public class DictUtil { - private static ApplicationContext applicationContext = SpringUtils.getApplicationContext(); - private static DictTypeService dictTypeService = applicationContext.getBean(DictTypeService.class); - - /** - * 字典查询 - * @param groupCode 字典组编码 - * @param typeCode 字典编码(多个逗号拼接) - * @return 字典编码名称(多个逗号拼接) - */ - public static String getTypeName(String groupCode, String typeCode){ - var types = dictTypeService.getTypeByGroupCode(groupCode); - if(null == types || types.size() <= 0){ - return null; - } - if(StringUtils.isEmpty(typeCode)){ - return null; - } - - String[] typeCodes = typeCode.split(","); - String[] typeCodeNames = new String[typeCodes.length]; - - for(var i = 0; i < typeCodes.length; i++){ - var code = typeCodes[i]; - for(var j = 0; j < types.size(); j++){ - var type = types.get(j); - if(code.equals(type.getTypeCode())){ - typeCodeNames[i] = type.getTypeName(); - break; - } - } - if(StringUtils.isEmpty(typeCodeNames[i])){ - typeCodeNames[i] = ""; - } - } - - //数组合并成字符串,用逗号隔开 - return Joiner.on(",").join(typeCodeNames); - } - - /** - * 获取字典组编码对应的字典列表 - * @param groupCode 字典组编码 - * @return 字典编码名称(多个逗号拼接) - */ - public static List getTypeNames(String groupCode){ - return dictTypeService.getTypeByGroupCode(groupCode); - } -} diff --git a/api/src/main/resources/templates/code/add.ftl b/api/src/main/resources/templates/code/add.ftl index f579b7f..047c199 100644 --- a/api/src/main/resources/templates/code/add.ftl +++ b/api/src/main/resources/templates/code/add.ftl @@ -104,7 +104,7 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/api/src/main/resources/templates/code/edit.ftl b/api/src/main/resources/templates/code/edit.ftl index 72a0305..77f6b82 100644 --- a/api/src/main/resources/templates/code/edit.ftl +++ b/api/src/main/resources/templates/code/edit.ftl @@ -104,7 +104,7 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/api/src/main/resources/templates/code/list.ftl b/api/src/main/resources/templates/code/list.ftl index 7922480..d444b5c 100644 --- a/api/src/main/resources/templates/code/list.ftl +++ b/api/src/main/resources/templates/code/list.ftl @@ -137,7 +137,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -187,7 +187,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/api/src/test/java/com/simon/ApiApplicationTest.java b/api/src/test/java/com/simon/ApiApplicationTest.java index 6d9c105..620f208 100644 --- a/api/src/test/java/com/simon/ApiApplicationTest.java +++ b/api/src/test/java/com/simon/ApiApplicationTest.java @@ -1,10 +1,5 @@ package com.simon; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSender; - /** * 测试 * @@ -15,18 +10,18 @@ import org.springframework.mail.javamail.JavaMailSender; //@RunWith(SpringRunner.class) //@SpringBootTest public class ApiApplicationTest { - @Autowired - private JavaMailSender mailSender; + /*@Autowired + private JavaMailSender mailSender;*/ - @Value("${spring.mail.username}") - private String sender; //读取配置文件中的参数 + /*@Value("${spring.mail.username}") + private String sender; //读取配置文件中的参数*/ //@Test public void contextLoads() { } //@Test - public void sendEmail(){ + /*public void sendEmail(){ StringBuffer emailContent = new StringBuffer(); emailContent.append("请勿回复本邮件.点击下面的链接,重设密码,本邮件超过30分钟,链接将会失效,需要重新申请找回密码。"); emailContent.append("http://localhost:8081" + "/users/resetPassword?sid=" + "1" + "&id=" + 1); @@ -39,5 +34,5 @@ public class ApiApplicationTest { message.setSubject("主题:密码重置"); message.setText(emailContent.toString()); mailSender.send(message); - } + }*/ } diff --git a/web/src/main/resources/templates/code/add.ftl b/web/src/main/resources/templates/code/add.ftl index f579b7f..047c199 100644 --- a/web/src/main/resources/templates/code/add.ftl +++ b/web/src/main/resources/templates/code/add.ftl @@ -104,7 +104,7 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/code/edit.ftl b/web/src/main/resources/templates/code/edit.ftl index 72a0305..77f6b82 100644 --- a/web/src/main/resources/templates/code/edit.ftl +++ b/web/src/main/resources/templates/code/edit.ftl @@ -104,7 +104,7 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/code/list.ftl b/web/src/main/resources/templates/code/list.ftl index 7922480..c7fc418 100644 --- a/web/src/main/resources/templates/code/list.ftl +++ b/web/src/main/resources/templates/code/list.ftl @@ -137,7 +137,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showSuccess("发生错误"); }); }, //每页显示数据量变更 @@ -187,7 +187,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/authority/add.html b/web/src/main/resources/templates/vue/authority/add.html index 8cb2b07..cd6173b 100644 --- a/web/src/main/resources/templates/vue/authority/add.html +++ b/web/src/main/resources/templates/vue/authority/add.html @@ -89,13 +89,13 @@ console.log(JSON.stringify(this.ruleForm)); this.$http.post(requestUrls.add, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/authority/edit.html b/web/src/main/resources/templates/vue/authority/edit.html index 4e049e7..aa96d7b 100644 --- a/web/src/main/resources/templates/vue/authority/edit.html +++ b/web/src/main/resources/templates/vue/authority/edit.html @@ -83,13 +83,13 @@ this.ruleForm.authority = this.ruleForm.authorities.join(","); this.$http.patch(requestUrls.add, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/authority/list.html b/web/src/main/resources/templates/vue/authority/list.html index 778d0ca..f444151 100644 --- a/web/src/main/resources/templates/vue/authority/list.html +++ b/web/src/main/resources/templates/vue/authority/list.html @@ -120,7 +120,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -188,7 +188,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.userId) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/bill/list.html b/web/src/main/resources/templates/vue/bill/list.html index bf87eeb..e2a7c1d 100644 --- a/web/src/main/resources/templates/vue/bill/list.html +++ b/web/src/main/resources/templates/vue/bill/list.html @@ -154,7 +154,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -204,7 +204,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/dictType/add.html b/web/src/main/resources/templates/vue/dictType/add.html index ea70afc..a3f1fe7 100644 --- a/web/src/main/resources/templates/vue/dictType/add.html +++ b/web/src/main/resources/templates/vue/dictType/add.html @@ -71,13 +71,13 @@ if (valid) { this.$http.post(requestUrls.add, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/dictType/edit.html b/web/src/main/resources/templates/vue/dictType/edit.html index 45888fe..187d01a 100644 --- a/web/src/main/resources/templates/vue/dictType/edit.html +++ b/web/src/main/resources/templates/vue/dictType/edit.html @@ -71,13 +71,13 @@ if (valid) { this.$http.patch(requestUrls.edit, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("更新成功"); + parent.showSuccess("更新成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/dictType/list.html b/web/src/main/resources/templates/vue/dictType/list.html index 8d8f7c5..4297dd9 100644 --- a/web/src/main/resources/templates/vue/dictType/list.html +++ b/web/src/main/resources/templates/vue/dictType/list.html @@ -120,7 +120,7 @@ }).catch(response => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -220,7 +220,7 @@ this.$http.delete(requestUrls.delete, { params: params_ }).then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/dictType/subAdd.html b/web/src/main/resources/templates/vue/dictType/subAdd.html index dd2d549..cfa2a10 100644 --- a/web/src/main/resources/templates/vue/dictType/subAdd.html +++ b/web/src/main/resources/templates/vue/dictType/subAdd.html @@ -93,13 +93,13 @@ if (valid) { this.$http.post(requestUrls.add, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/dictType/subEdit.html b/web/src/main/resources/templates/vue/dictType/subEdit.html index 0fe81d7..c89e11e 100644 --- a/web/src/main/resources/templates/vue/dictType/subEdit.html +++ b/web/src/main/resources/templates/vue/dictType/subEdit.html @@ -94,13 +94,13 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("更新成功"); + parent.showSuccess("更新成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/fontAwesome/add.html b/web/src/main/resources/templates/vue/fontAwesome/add.html index 7993517..e7a3d9e 100644 --- a/web/src/main/resources/templates/vue/fontAwesome/add.html +++ b/web/src/main/resources/templates/vue/fontAwesome/add.html @@ -84,7 +84,7 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/vue/fontAwesome/edit.html b/web/src/main/resources/templates/vue/fontAwesome/edit.html index 2eee830..7b87ada 100644 --- a/web/src/main/resources/templates/vue/fontAwesome/edit.html +++ b/web/src/main/resources/templates/vue/fontAwesome/edit.html @@ -84,13 +84,13 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/fontAwesome/list.html b/web/src/main/resources/templates/vue/fontAwesome/list.html index 94e3ceb..23d6520 100644 --- a/web/src/main/resources/templates/vue/fontAwesome/list.html +++ b/web/src/main/resources/templates/vue/fontAwesome/list.html @@ -121,7 +121,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -196,7 +196,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/index.html b/web/src/main/resources/templates/vue/index.html index 5f4d104..98cd2ee 100644 --- a/web/src/main/resources/templates/vue/index.html +++ b/web/src/main/resources/templates/vue/index.html @@ -353,13 +353,19 @@ if(valid){ this.$http.post(requestUrls.changePassword, this.changePwdForm).then((response) => { closeLoading(); - showMsg("修改密码成功"); + this.$message({ + message: "修改密码成功", + type: 'success' + }); this.dialogChangePwdFormVisible = false; }).catch((error) => { console.error(error); console.error(error.response.data.message); closeLoading(); - showMsg(error.response.data.message); + this.$message({ + message: error.response.data.message, + type: 'error' + }); }); }else{ closeLoading(); @@ -370,8 +376,14 @@ return false; } }); + }, + showMessage(message, type) { + this.$message({ + message: message, + type: type + }); } - } + }//methods }); app.addTab('94108390556434432', '了解OauthServer', '/vue/home', false); @@ -411,24 +423,20 @@ }); } - function showMsg(message) { - layer.msg(message, { - icon: 1, - offset: 't', - anim: 0 - }); - } - function showSuccess(message) { - showMsg(message); + app.showMessage(message, 'success'); } + function showWarning(message) { + app.showMessage(message, 'warning'); + } + + function showInfo(message) { + app.showMessage(message, 'info'); + } + function showError(message) { - layer.msg(message, { - icon: 2, - offset: 't', - anim: 0 - }); + app.showMessage(message, 'error'); } function openLoading() { diff --git a/web/src/main/resources/templates/vue/loggingEvent/list.html b/web/src/main/resources/templates/vue/loggingEvent/list.html index 89b7251..21d203e 100644 --- a/web/src/main/resources/templates/vue/loggingEvent/list.html +++ b/web/src/main/resources/templates/vue/loggingEvent/list.html @@ -113,7 +113,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -188,7 +188,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/newsInfo/add.html b/web/src/main/resources/templates/vue/newsInfo/add.html index 192982f..316b97d 100644 --- a/web/src/main/resources/templates/vue/newsInfo/add.html +++ b/web/src/main/resources/templates/vue/newsInfo/add.html @@ -88,7 +88,7 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/vue/newsInfo/edit.html b/web/src/main/resources/templates/vue/newsInfo/edit.html index c79d410..e2323d5 100644 --- a/web/src/main/resources/templates/vue/newsInfo/edit.html +++ b/web/src/main/resources/templates/vue/newsInfo/edit.html @@ -89,7 +89,7 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/vue/newsInfo/list.html b/web/src/main/resources/templates/vue/newsInfo/list.html index 124daa8..3e879a3 100644 --- a/web/src/main/resources/templates/vue/newsInfo/list.html +++ b/web/src/main/resources/templates/vue/newsInfo/list.html @@ -142,7 +142,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -192,7 +192,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/oauthUser/add.html b/web/src/main/resources/templates/vue/oauthUser/add.html index 2f74f6c..5bbfbdd 100644 --- a/web/src/main/resources/templates/vue/oauthUser/add.html +++ b/web/src/main/resources/templates/vue/oauthUser/add.html @@ -153,13 +153,13 @@ if (valid) { this.$http.post(requestUrls.add, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/oauthUser/edit.html b/web/src/main/resources/templates/vue/oauthUser/edit.html index e623554..e524600 100644 --- a/web/src/main/resources/templates/vue/oauthUser/edit.html +++ b/web/src/main/resources/templates/vue/oauthUser/edit.html @@ -154,13 +154,13 @@ if (valid) { this.$http.patch(requestUrls.edit, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("更新成功"); + parent.showSuccess("更新成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/oauthUser/list.html b/web/src/main/resources/templates/vue/oauthUser/list.html index 257c700..24f8775 100644 --- a/web/src/main/resources/templates/vue/oauthUser/list.html +++ b/web/src/main/resources/templates/vue/oauthUser/list.html @@ -172,7 +172,7 @@ }).catch(response => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -240,7 +240,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/quartzJob/add.html b/web/src/main/resources/templates/vue/quartzJob/add.html index bd8ffa9..90de615 100644 --- a/web/src/main/resources/templates/vue/quartzJob/add.html +++ b/web/src/main/resources/templates/vue/quartzJob/add.html @@ -77,7 +77,7 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/vue/quartzJob/edit.html b/web/src/main/resources/templates/vue/quartzJob/edit.html index dbd539b..8790adf 100644 --- a/web/src/main/resources/templates/vue/quartzJob/edit.html +++ b/web/src/main/resources/templates/vue/quartzJob/edit.html @@ -79,7 +79,7 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/vue/quartzJob/list.html b/web/src/main/resources/templates/vue/quartzJob/list.html index c32d231..e1eb57a 100644 --- a/web/src/main/resources/templates/vue/quartzJob/list.html +++ b/web/src/main/resources/templates/vue/quartzJob/list.html @@ -137,7 +137,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -177,7 +177,7 @@ jobStatus: 1 }).then((response) => { parent.closeLoading(); - parent.showMsg("任务已启动"); + parent.showSuccess("任务已启动"); parent.updateListData(); closeLayer(); }).catch((error) => { @@ -196,7 +196,7 @@ jobStatus: 0 }).then((response) => { parent.closeLoading(); - parent.showMsg("任务已停止"); + parent.showSuccess("任务已停止"); parent.updateListData(); closeLayer(); }).catch((error) => { @@ -229,7 +229,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.id) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/roleAuthority/auth_config.html b/web/src/main/resources/templates/vue/roleAuthority/auth_config.html index b0dbda0..de7aab6 100644 --- a/web/src/main/resources/templates/vue/roleAuthority/auth_config.html +++ b/web/src/main/resources/templates/vue/roleAuthority/auth_config.html @@ -96,13 +96,13 @@ if (valid) { this.$http.post(requestUrls.updateAuth, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("更新成功"); + parent.showSuccess("更新成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/roleAuthority/list.html b/web/src/main/resources/templates/vue/roleAuthority/list.html index 64edc5d..995d8b1 100644 --- a/web/src/main/resources/templates/vue/roleAuthority/list.html +++ b/web/src/main/resources/templates/vue/roleAuthority/list.html @@ -113,7 +113,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -181,7 +181,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.userId) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/sideMenu/add.html b/web/src/main/resources/templates/vue/sideMenu/add.html index 2924edc..dcbb286 100644 --- a/web/src/main/resources/templates/vue/sideMenu/add.html +++ b/web/src/main/resources/templates/vue/sideMenu/add.html @@ -108,13 +108,13 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/sideMenu/edit.html b/web/src/main/resources/templates/vue/sideMenu/edit.html index be70446..db5ef9e 100644 --- a/web/src/main/resources/templates/vue/sideMenu/edit.html +++ b/web/src/main/resources/templates/vue/sideMenu/edit.html @@ -89,13 +89,13 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/sideMenu/list.html b/web/src/main/resources/templates/vue/sideMenu/list.html index 1712ecf..999a4bd 100644 --- a/web/src/main/resources/templates/vue/sideMenu/list.html +++ b/web/src/main/resources/templates/vue/sideMenu/list.html @@ -143,7 +143,7 @@ }).catch(response => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -243,7 +243,7 @@ this.$http.delete(requestUrls.delete, { params: params_ }).then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/main/resources/templates/vue/sideMenu/subAdd.html b/web/src/main/resources/templates/vue/sideMenu/subAdd.html index 5a96e79..0516fdd 100644 --- a/web/src/main/resources/templates/vue/sideMenu/subAdd.html +++ b/web/src/main/resources/templates/vue/sideMenu/subAdd.html @@ -136,13 +136,13 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/sideMenu/subEdit.html b/web/src/main/resources/templates/vue/sideMenu/subEdit.html index 2182eab..9390f5e 100644 --- a/web/src/main/resources/templates/vue/sideMenu/subEdit.html +++ b/web/src/main/resources/templates/vue/sideMenu/subEdit.html @@ -123,13 +123,13 @@ if (valid) { this.$http.patch(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("修改成功"); + parent.showSuccess("修改成功"); parent.updateListData(); closeLayer(); }).catch((response) => { console.error(response); parent.closeLoading(); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); } else { parent.closeLoading(); diff --git a/web/src/main/resources/templates/vue/table/code_generate.html b/web/src/main/resources/templates/vue/table/code_generate.html index 25cdb42..3579b0c 100644 --- a/web/src/main/resources/templates/vue/table/code_generate.html +++ b/web/src/main/resources/templates/vue/table/code_generate.html @@ -172,7 +172,7 @@ if (valid) { this.$http.post(requestUrls.url, this.ruleForm).then((response) => { parent.closeLoading(); - parent.showMsg("新增成功"); + parent.showSuccess("新增成功"); parent.updateListData(); closeLayer(); }).catch((error) => { diff --git a/web/src/main/resources/templates/vue/table/list.html b/web/src/main/resources/templates/vue/table/list.html index f33396d..0923a7d 100644 --- a/web/src/main/resources/templates/vue/table/list.html +++ b/web/src/main/resources/templates/vue/table/list.html @@ -116,7 +116,7 @@ }).catch((response) => { this.tableLoading = false; console.error(response); - parent.showMsg("发生错误"); + parent.showError("发生错误"); }); }, //每页显示数据量变更 @@ -190,7 +190,7 @@ doDelete(index, row) { this.$http.delete(requestUrls.delete + row.userId) .then((response) => { - parent.showMsg("删除成功"); + parent.showSuccess("删除成功"); this.loadData(this.pageNo, this.pageSize); }).catch((response) => { console.error(response); diff --git a/web/src/test/resources/templates/vue/bill/add.html b/web/src/test/resources/templates/vue/bill/add.html deleted file mode 100644 index b7218f4..0000000 --- a/web/src/test/resources/templates/vue/bill/add.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/bill/edit.html b/web/src/test/resources/templates/vue/bill/edit.html deleted file mode 100644 index ba2285e..0000000 --- a/web/src/test/resources/templates/vue/bill/edit.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/bill/list.html b/web/src/test/resources/templates/vue/bill/list.html deleted file mode 100644 index 49c3188..0000000 --- a/web/src/test/resources/templates/vue/bill/list.html +++ /dev/null @@ -1,223 +0,0 @@ - - - - -
- -
- - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/columnUi/add.html b/web/src/test/resources/templates/vue/columnUi/add.html deleted file mode 100644 index 1c14721..0000000 --- a/web/src/test/resources/templates/vue/columnUi/add.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - -
- - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/columnUi/edit.html b/web/src/test/resources/templates/vue/columnUi/edit.html deleted file mode 100644 index 91d8522..0000000 --- a/web/src/test/resources/templates/vue/columnUi/edit.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - -
- - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/columnUi/list.html b/web/src/test/resources/templates/vue/columnUi/list.html deleted file mode 100644 index e4abd5f..0000000 --- a/web/src/test/resources/templates/vue/columnUi/list.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - -
- -
- - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/newsInfo/add.html b/web/src/test/resources/templates/vue/newsInfo/add.html deleted file mode 100644 index 192982f..0000000 --- a/web/src/test/resources/templates/vue/newsInfo/add.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/newsInfo/edit.html b/web/src/test/resources/templates/vue/newsInfo/edit.html deleted file mode 100644 index 3d9c1b4..0000000 --- a/web/src/test/resources/templates/vue/newsInfo/edit.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/newsInfo/list.html b/web/src/test/resources/templates/vue/newsInfo/list.html deleted file mode 100644 index 4d750e1..0000000 --- a/web/src/test/resources/templates/vue/newsInfo/list.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - -
- -
- - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/quartzJob/add.html b/web/src/test/resources/templates/vue/quartzJob/add.html deleted file mode 100644 index cba5708..0000000 --- a/web/src/test/resources/templates/vue/quartzJob/add.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/quartzJob/edit.html b/web/src/test/resources/templates/vue/quartzJob/edit.html deleted file mode 100644 index aa41b3d..0000000 --- a/web/src/test/resources/templates/vue/quartzJob/edit.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 提交 - 关闭 - - - - -
- - - - - \ No newline at end of file diff --git a/web/src/test/resources/templates/vue/quartzJob/list.html b/web/src/test/resources/templates/vue/quartzJob/list.html deleted file mode 100644 index 7b03ca6..0000000 --- a/web/src/test/resources/templates/vue/quartzJob/list.html +++ /dev/null @@ -1,212 +0,0 @@ - - - - -
- -
- - - - \ No newline at end of file -- Gitee From 366da82e9ba26bebae431b60848b8c8b4262968a Mon Sep 17 00:00:00 2001 From: jeesun Date: Sun, 19 May 2019 20:05:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=EF=BC=9B=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E5=AE=9E=E7=8E=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/main/resources/templates/code/add.ftl | 2 +- .../com/simon/common/config/AppConfig.java | 5 + .../simon/common/utils/CreateImageCode.java | 227 +++++++++++++++++ .../aspect/ControllerLogInterceptor.java | 7 +- .../common/config/WebSecurityConfig.java | 4 +- .../com/simon/controller/DemoController.java | 4 +- .../simon/controller/OauthUserController.java | 29 +++ .../controller/RandCodeImageController.java | 230 ------------------ .../main/resources/static/js/login/vcode.js | 134 ---------- .../plugins/jquery-session/jquerysession.js | 19 ++ .../main/resources/templates/code/edit.ftl | 2 +- web/src/main/resources/templates/login.html | 123 ++++++++-- .../templates/vue/authority/add.html | 9 +- .../templates/vue/authority/edit.html | 9 +- .../templates/vue/authority/list.html | 9 +- .../resources/templates/vue/bill/list.html | 9 +- .../resources/templates/vue/dictType/add.html | 9 +- .../templates/vue/dictType/edit.html | 9 +- .../templates/vue/dictType/list.html | 9 +- .../templates/vue/dictType/subAdd.html | 9 +- .../templates/vue/dictType/subEdit.html | 9 +- .../templates/vue/fontAwesome/edit.html | 9 +- .../templates/vue/fontAwesome/list.html | 9 +- .../templates/vue/loggingEvent/list.html | 9 +- .../templates/vue/newsInfo/edit.html | 2 +- .../templates/vue/newsInfo/list.html | 9 +- .../templates/vue/oauthUser/add.html | 9 +- .../templates/vue/oauthUser/edit.html | 9 +- .../templates/vue/oauthUser/list.html | 9 +- .../templates/vue/quartzJob/list.html | 9 +- .../vue/roleAuthority/auth_config.html | 9 +- .../templates/vue/roleAuthority/list.html | 9 +- .../resources/templates/vue/sideMenu/add.html | 9 +- .../templates/vue/sideMenu/edit.html | 9 +- .../templates/vue/sideMenu/list.html | 9 +- .../templates/vue/sideMenu/subAdd.html | 9 +- .../templates/vue/sideMenu/subEdit.html | 8 +- .../resources/templates/vue/table/list.html | 10 +- 38 files changed, 549 insertions(+), 464 deletions(-) create mode 100644 common/src/main/java/com/simon/common/utils/CreateImageCode.java delete mode 100644 web/src/main/java/com/simon/controller/RandCodeImageController.java delete mode 100644 web/src/main/resources/static/js/login/vcode.js create mode 100644 web/src/main/resources/static/js/plugins/jquery-session/jquerysession.js diff --git a/api/src/main/resources/templates/code/add.ftl b/api/src/main/resources/templates/code/add.ftl index 047c199..d47d987 100644 --- a/api/src/main/resources/templates/code/add.ftl +++ b/api/src/main/resources/templates/code/add.ftl @@ -108,11 +108,11 @@ parent.updateListData(); closeLayer(); }).catch((error) => { + parent.closeLoading(); let errorMessage = "发生错误"; if (error.response) { errorMessage = error.response.data.message; } - parent.closeLoading(); parent.showError(errorMessage); }); } else { diff --git a/common/src/main/java/com/simon/common/config/AppConfig.java b/common/src/main/java/com/simon/common/config/AppConfig.java index ed97337..a218c30 100644 --- a/common/src/main/java/com/simon/common/config/AppConfig.java +++ b/common/src/main/java/com/simon/common/config/AppConfig.java @@ -73,4 +73,9 @@ public class AppConfig { e.printStackTrace(); } } + + /** + * 存储在session中的验证码key + */ + public static final String SESSION_VERI_CODE = "code"; } \ No newline at end of file diff --git a/common/src/main/java/com/simon/common/utils/CreateImageCode.java b/common/src/main/java/com/simon/common/utils/CreateImageCode.java new file mode 100644 index 0000000..9197a66 --- /dev/null +++ b/common/src/main/java/com/simon/common/utils/CreateImageCode.java @@ -0,0 +1,227 @@ +package com.simon.common.utils; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Random; + +public class CreateImageCode { + // 图片的宽度。 + private int width = 160; + // 图片的高度。 + private int height = 40; + // 验证码字符个数 + private int codeCount = 4; + // 验证码干扰线数 + private int lineCount = 20; + // 验证码 + private String code = null; + // 验证码图片Buffer + private BufferedImage buffImg = null; + Random random = new Random(); + + public CreateImageCode() { + creatImage(); + } + + public CreateImageCode(int width, int height) { + this.width = width; + this.height = height; + creatImage(); + } + + public CreateImageCode(int width, int height, int codeCount) { + this.width = width; + this.height = height; + this.codeCount = codeCount; + creatImage(); + } + + public CreateImageCode(int width, int height, int codeCount, int lineCount) { + this.width = width; + this.height = height; + this.codeCount = codeCount; + this.lineCount = lineCount; + creatImage(); + } + + // 生成图片 + private void creatImage() { + int fontWidth = width / codeCount;// 字体的宽度 + int fontHeight = height - 5;// 字体的高度 + int codeY = height - 8; + + // 图像buffer + buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics g = buffImg.getGraphics(); + //Graphics2D g = buffImg.createGraphics(); + // 设置背景色 + g.setColor(getRandColor(200, 250)); + g.fillRect(0, 0, width, height); + + + + // 设置字体 + //Font font1 = getFont(fontHeight); + Font font = new Font("Fixedsys", Font.BOLD, fontHeight); + g.setFont(font); + + // 设置干扰线 + for (int i = 0; i < lineCount; i++) { + int xs = random.nextInt(width); + int ys = random.nextInt(height); + int xe = xs + random.nextInt(width); + int ye = ys + random.nextInt(height); + g.setColor(getRandColor(1, 255)); + g.drawLine(xs, ys, xe, ye); + } + + // 添加噪点 + float yawpRate = 0.01f;// 噪声率 + int area = (int) (yawpRate * width * height); + for (int i = 0; i < area; i++) { + int x = random.nextInt(width); + int y = random.nextInt(height); + + buffImg.setRGB(x, y, random.nextInt(255)); + } + + + String str1 = randomStr(codeCount);// 得到随机字符 + this.code = str1; + for (int i = 0; i < codeCount; i++) { + String strRand = str1.substring(i, i + 1); + g.setColor(getRandColor(1, 255)); + // g.drawString(a,x,y); + // a为要画出来的东西,x和y表示要画的东西最左侧字符的基线位于此图形上下文坐标系的 (x, y) 位置处 + + g.drawString(strRand, i*fontWidth+3, codeY); + } + + + } + + // 得到随机字符 + private String randomStr(int n) { + String str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; + String str2 = ""; + int len = str1.length() - 1; + double r; + for (int i = 0; i < n; i++) { + r = (Math.random()) * len; + str2 = str2 + str1.charAt((int) r); + } + return str2; + } + + // 得到随机颜色 + private Color getRandColor(int fc, int bc) {// 给定范围获得随机颜色 + if (fc > 255) + fc = 255; + if (bc > 255) + bc = 255; + int r = fc + random.nextInt(bc - fc); + int g = fc + random.nextInt(bc - fc); + int b = fc + random.nextInt(bc - fc); + return new Color(r, g, b); + } + + /** + * 产生随机字体 + */ + private Font getFont(int size) { + Random random = new Random(); + Font font[] = new Font[5]; + font[0] = new Font("Ravie", Font.PLAIN, size); + font[1] = new Font("Antique Olive Compact", Font.PLAIN, size); + font[2] = new Font("Fixedsys", Font.PLAIN, size); + font[3] = new Font("Wide Latin", Font.PLAIN, size); + font[4] = new Font("Gill Sans Ultra Bold", Font.PLAIN, size); + return font[random.nextInt(5)]; + } + + // 扭曲方法 + private void shear(Graphics g, int w1, int h1, Color color) { + shearX(g, w1, h1, color); + shearY(g, w1, h1, color); + } + + private void shearX(Graphics g, int w1, int h1, Color color) { + + int period = random.nextInt(2); + + boolean borderGap = true; + int frames = 1; + int phase = random.nextInt(2); + + for (int i = 0; i < h1; i++) { + double d = (double) (period >> 1) + * Math.sin((double) i / (double) period + + (6.2831853071795862D * (double) phase) + / (double) frames); + g.copyArea(0, i, w1, 1, (int) d, 0); + if (borderGap) { + g.setColor(color); + g.drawLine((int) d, i, 0, i); + g.drawLine((int) d + w1, i, w1, i); + } + } + + } + + private void shearY(Graphics g, int w1, int h1, Color color) { + + int period = random.nextInt(40) + 10; // 50; + + boolean borderGap = true; + int frames = 20; + int phase = 7; + for (int i = 0; i < w1; i++) { + double d = (double) (period >> 1) + * Math.sin((double) i / (double) period + + (6.2831853071795862D * (double) phase) + / (double) frames); + g.copyArea(i, 0, 1, h1, 0, (int) d); + if (borderGap) { + g.setColor(color); + g.drawLine(i, (int) d, i, 0); + g.drawLine(i, (int) d + h1, i, h1); + } + + } + + } + + + + public void write(OutputStream sos) throws IOException { + ImageIO.write(buffImg, "png", sos); + sos.close(); + } + + public BufferedImage getBuffImg() { + return buffImg; + } + + public String getCode() { + return code.toLowerCase(); + } + + //使用方法 + /*public void getCode3(HttpServletRequest req, HttpServletResponse response,HttpSession session) throws IOException{ + // 设置响应的类型格式为图片格式 + response.setContentType("image/jpeg"); + //禁止图像缓存。 + response.setHeader("Pragma", "no-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + + + CreateImageCode vCode = new CreateImageCode(100,30,5,10); + session.setAttribute("code", vCode.getCode()); + vCode.write(response.getOutputStream()); + }*/ + +} \ No newline at end of file diff --git a/web/src/main/java/com/simon/common/aspect/ControllerLogInterceptor.java b/web/src/main/java/com/simon/common/aspect/ControllerLogInterceptor.java index 92fcb6d..2380c4f 100644 --- a/web/src/main/java/com/simon/common/aspect/ControllerLogInterceptor.java +++ b/web/src/main/java/com/simon/common/aspect/ControllerLogInterceptor.java @@ -15,6 +15,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; +import javax.servlet.http.HttpSession; import java.util.*; import java.util.stream.Collectors; @@ -60,13 +61,11 @@ public class ControllerLogInterceptor { //序列化时过滤掉request和response List objs = Arrays.stream(args) - .filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse))) + .filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse) && !(arg instanceof HttpSession) && !(arg instanceof ExtendedServletRequestDataBinder) && !(arg instanceof HttpServletResponseWrapper))) .collect(Collectors.toList()); for (int i = 0; i < objs.size(); i++) { - if (!(objs.get(i) instanceof ExtendedServletRequestDataBinder) && !(objs.get(i) instanceof HttpServletResponseWrapper)) { - paramMap.put(argNames[i], objs.get(i)); - } + paramMap.put(argNames[i], objs.get(i)); } if (paramMap.size() > 0) { //log.info("[{}]类名1:{}", uuid, joinPoint.getTarget().getClass().getName()); diff --git a/web/src/main/java/com/simon/common/config/WebSecurityConfig.java b/web/src/main/java/com/simon/common/config/WebSecurityConfig.java index c27dc08..c223e80 100644 --- a/web/src/main/java/com/simon/common/config/WebSecurityConfig.java +++ b/web/src/main/java/com/simon/common/config/WebSecurityConfig.java @@ -118,8 +118,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { .and() .authorizeRequests() .antMatchers("/img/**", "/js/**", "/css/**", "/webjars/**", "/video/**", "/plug-in/**", "/font/**").permitAll() - .antMatchers("/login", "/logout", "/register", "/register_result", "/forget_password", "/reset_password", "/users/sendEmail", "/users/resetPassword", "/users/forgetPwd","/users/check", "/users/resetPwd", "/users/test", "/users/checkExists").permitAll() - .antMatchers("/just_test", "/upload", "/users/uuid/**", "/users/loopCheck/**", "/users/register", "/hello").permitAll() + .antMatchers("/login", "/logout", "/register", "/register_result", "/forget_password", "/reset_password", "/users/sendEmail", "/users/resetPassword", "/users/forgetPwd","/users/check", "/users/resetPwd", "/users/test", "/users/checkExists", "/api/oauthUsers/getVeriCode", "/api/oauthUsers/checkVeriCode").permitAll() + .antMatchers("/just_test", "/upload", "/users/uuid/**", "/users/loopCheck/**", "/users/register", "/hello", "/api/demos/**").permitAll() .anyRequest().authenticated() .and() .rememberMe(); diff --git a/web/src/main/java/com/simon/controller/DemoController.java b/web/src/main/java/com/simon/controller/DemoController.java index 413d83a..ad7f133 100644 --- a/web/src/main/java/com/simon/controller/DemoController.java +++ b/web/src/main/java/com/simon/controller/DemoController.java @@ -3,6 +3,7 @@ package com.simon.controller; import com.simon.common.domain.EasyUIDataGridResult; import com.simon.common.domain.ResultMsg; import com.simon.service.ProvinceService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -19,7 +20,7 @@ import java.util.Map; * @author simon * @date 2018-12-29 **/ - +@Slf4j @Controller @RequestMapping("/api/demos") public class DemoController { @@ -52,4 +53,5 @@ public class DemoController { return ResultMsg.success(provinceService.findAll()); } + } diff --git a/web/src/main/java/com/simon/controller/OauthUserController.java b/web/src/main/java/com/simon/controller/OauthUserController.java index 1ed2e07..08c2e55 100644 --- a/web/src/main/java/com/simon/controller/OauthUserController.java +++ b/web/src/main/java/com/simon/controller/OauthUserController.java @@ -7,12 +7,14 @@ import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.metadata.Sheet; import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.fastjson.JSON; +import com.simon.common.config.AppConfig; import com.simon.common.controller.BaseController; import com.simon.common.domain.EasyUIDataGridResult; import com.simon.common.domain.ResultCode; import com.simon.common.domain.ResultMsg; import com.simon.common.domain.UserEntity; import com.simon.common.utils.BeanUtils; +import com.simon.common.utils.CreateImageCode; import com.simon.dto.ChangePasswordDto; import com.simon.model.OauthUser; import com.simon.service.DictTypeService; @@ -36,6 +38,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -304,4 +307,30 @@ public class OauthUserController extends BaseController { return new ResponseEntity<>(ResultMsg.success(), HttpStatus.OK); } + + @ApiOperation(value = "获取验证码图片", notes = "前端获取session中的值很麻烦,不刷新页面无法获取最新值。所以最好前端再访问后台接口校验验证码图片。") + @PermitAll + @GetMapping("getVeriCode") + public void getCode3(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException { + // 设置响应的类型格式为图片格式 + response.setContentType("image/jpeg"); + //禁止图像缓存。 + response.setHeader("Pragma", "no-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + CreateImageCode vCode = new CreateImageCode(100, 30, 4, 10); + session.setAttribute(AppConfig.SESSION_VERI_CODE, vCode.getCode()); + vCode.write(response.getOutputStream()); + } + + @ApiOperation(value = "校验验证码图片") + @PermitAll + @PostMapping("checkVeriCode") + @ResponseBody + public Boolean checkCode(HttpServletRequest request, HttpServletResponse response, HttpSession session, @ApiParam(value = "验证码", required = true) @RequestParam String veriCode) { + if (veriCode.equals(session.getAttribute(AppConfig.SESSION_VERI_CODE).toString())) { + return true; + } + return false; + } } \ No newline at end of file diff --git a/web/src/main/java/com/simon/controller/RandCodeImageController.java b/web/src/main/java/com/simon/controller/RandCodeImageController.java deleted file mode 100644 index 533d9f3..0000000 --- a/web/src/main/java/com/simon/controller/RandCodeImageController.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.simon.controller; - -import io.swagger.annotations.Api; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -import javax.imageio.ImageIO; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.Random; - - -/** - * @author simon - * @date 2019-05-08 - */ -@Slf4j -@Controller -@RequestMapping("/randCodeImages") -@Api(description = "随机验证码") -public class RandCodeImageController { - /** - * 要统一常量 - */ - private static final String SESSION_KEY_OF_RAND_CODE = "randCode"; - /** - * - */ - private static final int count = 200; - - /** - * 定义图形大小 - */ - private static final int width = 105; - /** - * 定义图形大小 - */ - private static final int height = 35; - // private Font mFont = new Font("Arial Black", Font.PLAIN, 15); //设置字体 - /** - * 干扰线的长度=1.414*lineWidth - */ - private static final int lineWidth = 2; - - @GetMapping - public void doGet(final HttpServletRequest request, - final HttpServletResponse response) throws ServletException, - IOException { - // 设置页面不缓存 - response.setHeader("Pragma", "No-cache"); - response.setHeader("Cache-Control", "no-cache"); - response.setDateHeader("Expires", 0); - // response.setContentType("image/png"); - - // 在内存中创建图象 - final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - // 获取图形上下文 - final Graphics2D graphics = (Graphics2D) image.getGraphics(); - - // 设定背景颜色 - graphics.setColor(Color.WHITE); // ---1 - graphics.fillRect(0, 0, width, height); - // 设定边框颜色 -// graphics.setColor(getRandColor(100, 200)); // ---2 - graphics.drawRect(0, 0, width - 1, height - 1); - - final Random random = new Random(); - // 随机产生干扰线,使图象中的认证码不易被其它程序探测到 - for (int i = 0; i < count; i++) { - graphics.setColor(getRandColor(150, 200)); // ---3 - - final int x = random.nextInt(width - lineWidth - 1) + 1; // 保证画在边框之内 - final int y = random.nextInt(height - lineWidth - 1) + 1; - final int xl = random.nextInt(lineWidth); - final int yl = random.nextInt(lineWidth); - graphics.drawLine(x, y, x + xl, y + yl); - } - - // 取随机产生的认证码(4位数字) - final String resultCode = exctractRandCode(); - for (int i = 0; i < resultCode.length(); i++) { - // 将认证码显示到图象中,调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成 - // graphics.setColor(new Color(20 + random.nextInt(130), 20 + random - // .nextInt(130), 20 + random.nextInt(130))); - - // 设置字体颜色 - graphics.setColor(Color.BLACK); - // 设置字体样式 -// graphics.setFont(new Font("Arial Black", Font.ITALIC, 18)); - graphics.setFont(new Font("Times New Roman", Font.BOLD, 24)); - // 设置字符,字符间距,上边距 - graphics.drawString(String.valueOf(resultCode.charAt(i)), (23 * i) + 8, 26); - } - - // 将认证码存入SESSION - request.getSession().setAttribute(SESSION_KEY_OF_RAND_CODE, resultCode); - // 图象生效 - graphics.dispose(); - - // 输出图象到页面 - ImageIO.write(image, "JPEG", response.getOutputStream()); - } - - /** - * @return 随机码 - */ - private String exctractRandCode() { - final String randCodeType = "5"; - int randCodeLength = 4; - if (randCodeType == null) { - return RandCodeImageEnum.NUMBER_CHAR.generateStr(randCodeLength); - } else { - switch (randCodeType.charAt(0)) { - case '1': - return RandCodeImageEnum.NUMBER_CHAR.generateStr(randCodeLength); - case '2': - return RandCodeImageEnum.LOWER_CHAR.generateStr(randCodeLength); - case '3': - return RandCodeImageEnum.UPPER_CHAR.generateStr(randCodeLength); - case '4': - return RandCodeImageEnum.LETTER_CHAR.generateStr(randCodeLength); - case '5': - return RandCodeImageEnum.ALL_CHAR.generateStr(randCodeLength); - - default: - return RandCodeImageEnum.NUMBER_CHAR.generateStr(randCodeLength); - } - } - } - - /** - * 描述: - * - * @param fc - * 描述: - * @param bc - * 描述: - * - * @return 描述: - */ - private Color getRandColor(int fc, int bc) { // 取得给定范围随机颜色 - final Random random = new Random(); - if (fc > 255) { - fc = 255; - } - if (bc > 255) { - bc = 255; - } - - final int r = fc + random.nextInt(bc - fc); - final int g = fc + random.nextInt(bc - fc); - final int b = fc + random.nextInt(bc - fc); - - return new Color(r, g, b); - } -} - -/** - * 验证码辅助类 - * - * @author 张国明 guomingzhang2008@gmail.com
- * 2012-2-28 下午2:15:14 - * - */ -enum RandCodeImageEnum { - - /** - * 混合字符串 - */ - ALL_CHAR("0123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ"), // 去除小写的l和o这个两个不容易区分的字符; - /** - * 字符 - */ - LETTER_CHAR("abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ"), - /** - * 小写字母 - */ - LOWER_CHAR("abcdefghijkmnopqrstuvwxyz"), - /** - * 数字 - */ - NUMBER_CHAR("0123456789"), - /** - * 大写字符 - */ - UPPER_CHAR("ABCDEFGHJKLMNOPQRSTUVWXYZ"); - - /** - * 待生成的字符串 - */ - private String charStr; - - /** - * @param charStr - */ - private RandCodeImageEnum(final String charStr) { - this.charStr = charStr; - } - - /** - * 生产随机验证码 - * - * @param codeLength 验证码的长度 - * @return 验证码 - */ - public String generateStr(final int codeLength) { - final StringBuffer sb = new StringBuffer(); - final Random random = new Random(); - final String sourseStr = getCharStr(); - - for (int i = 0; i < codeLength; i++) { - sb.append(sourseStr.charAt(random.nextInt(sourseStr.length()))); - } - - return sb.toString(); - } - - /** - * @return the {@link #charStr} - */ - public String getCharStr() { - return charStr; - } -} \ No newline at end of file diff --git a/web/src/main/resources/static/js/login/vcode.js b/web/src/main/resources/static/js/login/vcode.js deleted file mode 100644 index f63ade1..0000000 --- a/web/src/main/resources/static/js/login/vcode.js +++ /dev/null @@ -1,134 +0,0 @@ -var code = ""; - -function validate(value) { - let result = (value.toUpperCase() === code.toUpperCase()); - /*if(!result){ - $("#codeimg").click();//主动触发单击事件,更换验证码 - }*/ - return result; -} -$().ready(function() { - //将函数返回值赋给code - code = createCode(); - - //点击canvas图片更换验证码 - $("#codeimg").click(function () { - code = createCode(); - }); - - /*随机字符函数*/ - function rand(){ - //去掉i,I,l,o,O等易混淆字母 - var str="abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789"; - //将字符串分隔为数组 - var arr=str.split(""); - //随机字符在[0,56]之间 - var ranNum=Math.floor(Math.random()*57); - var captcha=arr[ranNum]; - return captcha; - } - - /*随机干扰线条函数*/ - function drawline(canvas, context) { - //若省略beginPath,则每点击一次验证码会累积干扰线的条数 - context.beginPath(); - //起点与终点在canvas宽高内随机 - context.moveTo(Math.floor(Math.random() * canvas.width), Math.floor(Math.random() * canvas.height)); - context.lineTo(Math.floor(Math.random() * canvas.width), Math.floor(Math.random() * canvas.height)); - context.lineWidth = 1; - context.strokeStyle = '#275DB3'; - context.stroke(); - } - - /*生成验证码*/ - function createCode(){ - //每次生成code先将其清空防止叠加 - code = ""; - var canvas = document.getElementById("codeimg"); - if(!canvas){ - return null; - } - var context = canvas.getContext("2d"); - - //清空画布 - context.clearRect(0, 0, canvas.width, canvas.height); - - context.strokeStyle = "#FFF"; - context.strokeRect(0, 0, canvas.width, canvas.height); - - //生成干扰线,数量随意 - for (var i = 0; i < 10; i++) { - drawline(canvas, context); - } - - //循环生成4位验证码 - for (var k = 0; k < 4; k++) { - context.font='76px Arial'; - //将初始状态保存 - context.save(); - //获得-1到1的随机数 - var rA = 1-Math.random()*2; - //获取随机倾斜角 - var angle = rA / 8 ; - var ranNum = rand(); - //旋转生成的随机字符 - context.rotate(angle); - //把rand()生成的随机数文本依次填充到canvas中,注意x坐标 - context.fillText(ranNum,20+45*k,100); - //恢复初始状态,以便下一次循环 - context.restore(); - code += ranNum; - } - //返回生成的验证码字符串 - return code; - } - - - jQuery.validator.addMethod("password", function (value, element, param) { - var rex = /^(?![A-Z]+$)(?![a-z]+$)(?!\d+$)(?![\W_]+$)\S{6,16}$/; - return this.optional(element) || (rex.test(value)); - }, "必须包含数字、字母或特殊字符"); - - jQuery.validator.addMethod("veriCode", function (value, element, param) { - return this.optional(element) || validate(value); - }, "验证码错误"); - - function validForm() { - return $("#loginForm").validate({ - onsubmit:true,// 是否在提交是验证 - onfocusout:false,// 是否在获取焦点时验证 - onkeyup :false,// 是否在敲击键盘时验证 - rules:{ - username: { - required: true, - minlength: 1 - }, - password: { - required: true, - rangelength: [6,20], - password: true - }, - veriCode: { - required: true, - minlength: 4, - veriCode: true - } - }, - errorPlacement: function(error, element) { - error.appendTo(element.parent()); - }, - errorElement: "span", - //单条校验失败,后会调用此方法,在此方法中,编写错误消息如何显示 及 校验失败回调方法 - showErrors : function(errorMap, errorList) { - if (errorMap || errorList) { - //重新生成验证码 - code = createCode(); - } - // 此处注意,一定要调用默认方法,这样保证提示消息的默认效果 - this.defaultShowErrors(); - } - }); - } - - $(validForm()); -}); \ No newline at end of file diff --git a/web/src/main/resources/static/js/plugins/jquery-session/jquerysession.js b/web/src/main/resources/static/js/plugins/jquery-session/jquerysession.js new file mode 100644 index 0000000..74835e3 --- /dev/null +++ b/web/src/main/resources/static/js/plugins/jquery-session/jquerysession.js @@ -0,0 +1,19 @@ +(function($){$.session={_id:null,_cookieCache:undefined,_init:function() +{if(!window.name){window.name=Math.random();} +this._id=window.name;this._initCache();var matches=(new RegExp(this._generatePrefix()+"=([^;]+);")).exec(document.cookie);if(matches&&document.location.protocol!==matches[1]){this._clearSession();for(var key in this._cookieCache){try{window.sessionStorage.setItem(key,this._cookieCache[key]);}catch(e){};}} +document.cookie=this._generatePrefix()+"="+document.location.protocol+';path=/;expires='+(new Date((new Date).getTime()+120000)).toUTCString();},_generatePrefix:function() +{return '__session:'+this._id+':';},_initCache:function() +{var cookies=document.cookie.split(';');this._cookieCache={};for(var i in cookies){var kv=cookies[i].split('=');if((new RegExp(this._generatePrefix()+'.+')).test(kv[0])&&kv[1]){this._cookieCache[kv[0].split(':',3)[2]]=kv[1];}}},_setFallback:function(key,value,onceOnly) +{var cookie=this._generatePrefix()+key+"="+value+"; path=/";if(onceOnly){cookie+="; expires="+(new Date(Date.now()+120000)).toUTCString();} +document.cookie=cookie;this._cookieCache[key]=value;return this;},_getFallback:function(key) +{if(!this._cookieCache){this._initCache();} +return this._cookieCache[key];},_clearFallback:function() +{for(var i in this._cookieCache){document.cookie=this._generatePrefix()+i+'=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';} +this._cookieCache={};},_deleteFallback:function(key) +{document.cookie=this._generatePrefix()+key+'=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';delete this._cookieCache[key];},get:function(key) +{return window.sessionStorage.getItem(key)||this._getFallback(key);},set:function(key,value,onceOnly) +{try{window.sessionStorage.setItem(key,value);}catch(e){} +this._setFallback(key,value,onceOnly||false);return this;},'delete':function(key){return this.remove(key);},remove:function(key) +{try{window.sessionStorage.removeItem(key);}catch(e){};this._deleteFallback(key);return this;},_clearSession:function() +{try{window.sessionStorage.clear();}catch(e){for(var i in window.sessionStorage){window.sessionStorage.removeItem(i);}}},clear:function() +{this._clearSession();this._clearFallback();return this;}};$.session._init();})(jQuery); \ No newline at end of file diff --git a/web/src/main/resources/templates/code/edit.ftl b/web/src/main/resources/templates/code/edit.ftl index 77f6b82..ac6bca0 100644 --- a/web/src/main/resources/templates/code/edit.ftl +++ b/web/src/main/resources/templates/code/edit.ftl @@ -108,11 +108,11 @@ parent.updateListData(); closeLayer(); }).catch((error) => { + parent.closeLoading(); let errorMessage = "发生错误"; if (error.response) { errorMessage = error.response.data.message; } - parent.closeLoading(); parent.showError(errorMessage); }); } else { diff --git a/web/src/main/resources/templates/login.html b/web/src/main/resources/templates/login.html index 22ed029..9c32636 100644 --- a/web/src/main/resources/templates/login.html +++ b/web/src/main/resources/templates/login.html @@ -4,6 +4,8 @@ + +