feat:完成短链接生成基本功能

This commit is contained in:
Naccl
2021-03-24 22:52:54 +08:00
parent 5b47c1884f
commit b8de8e31dc
15 changed files with 363 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>短链接生成</title>
<link rel="stylesheet" href="/css/base.css">
</head>
<body>
<div class="box">
<input type="text" id="long">
<button type="button" id="generate">生成</button>
<input type="text" id="short">
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<script>
$('#generate').click(() => {
let longURL = $('#long').val();
if (longURL) {
$.post("/generate", {
longURL
}, function (res) {
if (res.code === 200) {
$('#short').val(res.data);
} else {
alert(res.msg);
}
}, "json").fail(() => {
alert('异常错误');
});
} else {
alert('请输入原始链接');
}
})
</script>
</body>
</html>