-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,10 @@ public String code(@RequestParam String id) { | |
String remark = null; | ||
String htmlLast = " </code>\n" + | ||
" </pre>\n" + | ||
"<button id=\"button\" class=\"btn btn-success\">一键复制</button>"+ | ||
"<button id=\"button\" class=\"btn btn-success\" class=\"btn btn-success\" onclick=\"copy()\" data-clipboard-target=\"#code\" data-clipboard-action=\"copy\">一键复制</button>"+ | ||
" <script src=\"js/prism.js\"></script>\n"+ | ||
"<script src=\"js/jquery-3.6.0.min.js\"></script>\n" + | ||
"<script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js\"></script>\n"+ | ||
"<script src=\"js/code.js\"></script>\n" + | ||
"<script src=\"https://cdn.bootcdn.net/ajax/libs/toastr.js/latest/js/toastr.min.js\"></script>"; | ||
|
||
|
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mewhz/paste/controller/LoginController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mewhz.paste.controller; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
|
||
@Controller | ||
public class LoginController { | ||
|
||
@ResponseBody | ||
@RequestMapping("/login") | ||
public String login(@RequestParam String user, @RequestParam String pass){ | ||
System.out.println(user + " " + pass); | ||
return user + " " + pass; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
url = jdbc:mysql://127.0.0.1:3306/code_mewhz_com?useSSL=false&characterEncoding=UTF-8 | ||
|
||
user = root | ||
pass = root | ||
pass = root | ||
|
||
# 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时 | ||
initialSize = 1 | ||
# 最大连接池数量 | ||
maxActive = 8 | ||
# 最小连接池数量 | ||
minIdle = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,12 @@ | |
} | ||
</code> | ||
</pre> | ||
<button id="button" class="btn btn-success">一键复制</button> | ||
<button id="button" class="btn btn-success" onclick="copy()" data-clipboard-target="#code" data-clipboard-action="copy">一键复制</button> | ||
<script src="js/prism.js"></script> | ||
<script src="js/prism-c.min.js"></script> | ||
<script src="js/prism-cpp.min.js"></script> | ||
<script src="js/jquery-3.6.0.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js"></script> | ||
<script src="js/code.js"></script> | ||
<script src="https://cdn.bootcdn.net/ajax/libs/toastr.js/latest/js/toastr.min.js"></script> | ||
<!-- <script src="js/prism-java.min.js"></script>--> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
$(document).ready(()=>{ | ||
$("#button").click(()=>{ | ||
let text = $("#code").text(); | ||
navigator.clipboard.writeText(text); | ||
// $(document).ready(()=>{ | ||
// $("#button").click(()=>{ | ||
// let text = $("#code").text(); | ||
// navigator.clipboard.writeText(text); | ||
// toastr.success("复制成功,快去粘贴吧!"); | ||
// }); | ||
// }); | ||
function copy(){ | ||
let clipboard = new ClipboardJS('#button'); | ||
clipboard.on('success', function(e) { | ||
e.clearSelection(); | ||
clipboard.destroy(); | ||
// 释放内存,如果不释放,下次总会多复制 | ||
toastr.success("复制成功,快去粘贴吧!"); | ||
}); | ||
}); | ||
|
||
clipboard.on('error', function(e) { | ||
toastr.error("一键复制失败,请手动复制!") | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>登录后台</title> | ||
</head> | ||
<body> | ||
<form action="/login" method="post"> | ||
<input type="text" placeholder="用户名" name="user"><br> | ||
<input type="password" placeholder="密码" name="pass"><br> | ||
<button>登录</button> | ||
</form> | ||
</body> | ||
</html> |