码农笔录博客源码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

118 行
4.6 KiB

{{template "header" .}}
<title>博客 - 云悦</title>
<link type="text/css" rel="styleSheet" href="/static/css/me.css"/>
</head>
<body style="background-color: #f9f9f9">
<div class="root-container">
{{template "nav" .}}
{{template "memenu" .}}
<div class="me-blog-root">
<div class="me-blog-list">
<div class="breadcrumb-container">
<span class="layui-breadcrumb">
<a href="/">首页</a>
<a href="">个人中心</a>
<a href="/me/note">我的收藏</a>
<a><cite>管理文件夹</cite></a>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" style="margin-left: 30px" id="newBtn">新增</button>
</span>
</div>
</div>
{{range .Note}}
<div class="me-blog-list">
<div style="display: flex">
<p style="flex:1">{{.Title}}<span class="badge" style="margin-left: 3px">{{.Count}}</span></p>
<span style="width: 35px;"><a href="javascript:void(0)" style="color: #F84822"
onclick="del(this,{{.Id}})">删除</a></span>
<span style="width: 42px;margin-left: 10px;"><a href="javascript:void(0)" style="color: #F84822"
onclick="rename(this,{{.Id}},{{.Title}})">重命名</a></span>
</div>
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 6px;"/>
</div>
{{end}}
</div>
</div>
</div>
</body>
<script>
function rename(obj, id, name) {
layer.prompt({title: '请输入文件夹名称',value: name}, function (val, index) {
if (val.trim().length < 3) {
layer.msg('文件夹名称最低三个字哦', function () {
});
layer.close(index);
return
}
$.post('/api/notecoll/edit', {
title: val.trim(),
id: id
},
function (data) {
if (data.Status == 0) {
layer.close(index);
layer.msg("修改成功", {icon: 6});
window.location.href=window.location.href
} else if (data.Status == 401) {
window.location.href = "/login"
} else if (data.Status == 403) {
layer.msg("暂无权限", {icon: 5});
} else {
layer.msg("服务器异常", {icon: 5});
}
}, 'json')
});
}
function del(obj, id) {
layer.confirm('文件夹下的所有笔记都将会删除', {
btn: ['确认', '手滑了'] //按钮
}, function () {
$.post('/api/notecol/del/' + id,
function (data) {
if (data.Status == 0) {
$(obj).parent().parent().remove()
layer.msg("删除成功", {icon: 6});
} else if (data.Status == 401) {
window.location.href = "/login"
} else if (data.Status == 403) {
layer.msg("暂无权限", {icon: 5});
} else {
layer.msg("服务器异常", {icon: 5});
}
}, 'json')
}, function () {
});
}
$(function () {
if ({{.Note|len}} == 0){
layer.msg('请先添加文件夹', function () {
});
}
$("#newBtn").click(function () {
layer.prompt({title: '请输入文件夹名称'}, function (val, index) {
if (val.trim().length < 3) {
layer.msg('文件夹名称最低三个字哦', function () {
});
layer.close(index);
return
}
$.post('/api/notecoll/save', {
title: val.trim()
},
function (data) {
if (data.Status == 0) {
layer.close(index);
parent.layer.msg("保存成功", {icon: 6});
window.location.href=window.location.href
}
}, 'json')
});
})
})
</script>
</html>