mirror of https://github.com/halo-dev/halo
133 lines
5.4 KiB
Plaintext
133 lines
5.4 KiB
Plaintext
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
|
<link rel="stylesheet" href="/static/plugins/bootstrap/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/static/plugins/toast/css/jquery.toast.min.css">
|
|
<link rel="stylesheet" href="/static/plugins/fileinput/fileinput.min.css">
|
|
<link rel="stylesheet" href="/static/css/AdminLTE.min.css">
|
|
<style type="text/css" rel="stylesheet">
|
|
.form-horizontal .control-label{
|
|
text-align: left;
|
|
}
|
|
.alert-info{
|
|
color: #31708f!important;
|
|
background-color: #d9edf7!important;
|
|
border-color: #bce8f1!important;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container-fluid">
|
|
<section class="content">
|
|
<div class="nav-tabs-custom">
|
|
<ul class="nav nav-tabs">
|
|
<li class="active">
|
|
<a href="#server" data-toggle="tab">本地</a>
|
|
</li>
|
|
<li>
|
|
<a href="#url" data-toggle="tab">从URL添加</a>
|
|
</li>
|
|
</ul>
|
|
<div class="tab-content">
|
|
<div class="tab-pane active" id="server">
|
|
<div class="row" id="uploadForm">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<div class="file-loading">
|
|
<input id="uploadServer" class="file-loading" type="file" name="file" multiple>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane" id="url">
|
|
<form method="post" class="form-horizontal" id="attachForm">
|
|
<div class="box-body">
|
|
<div class="form-group">
|
|
<label for="attachName" class="col-sm-2 control-label"><@spring.message code='admin.attachments.modal.form.attach-name' /></label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="attachName" name="attachName">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="attachPath" class="col-sm-2 control-label"><@spring.message code='admin.attachments.modal.form.attach-path' /></label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="attachPath" name="attachPath">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="attachSmallPath" class="col-sm-2 control-label"><@spring.message code='admin.attachments.modal.form.attach-small-path' /></label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="attachSmallPath" name="attachSmallPath">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="box-footer">
|
|
<button type="button" class="btn btn-primary btn-sm" onclick="addFromUrl()"><@spring.message code='common.btn.define-add' /></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</body>
|
|
<script src="/static/plugins/jquery/jquery.min.js"></script>
|
|
<script src="/static/plugins/bootstrap/js/bootstrap.min.js"></script>
|
|
<script src="/static/plugins/fileinput/fileinput.min.js"></script>
|
|
<#if (options.blog_locale!'zh_CN')=='zh_CN'>
|
|
<script src="/static/plugins/fileinput/zh.min.js"></script>
|
|
</#if>
|
|
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
|
<script src="/static/plugins/layer/layer.js"></script>
|
|
<script src="/static/js/halo.min.js"></script>
|
|
<script>
|
|
var halo = new $.halo();
|
|
|
|
$(document).ready(function () {
|
|
loadFileInput();
|
|
});
|
|
|
|
/**
|
|
* 初始化上传组件
|
|
*/
|
|
function loadFileInput() {
|
|
$('#uploadServer').fileinput({
|
|
language: 'zh',
|
|
uploadUrl: '/admin/attachments/upload',
|
|
uploadAsync: true,
|
|
allowedFileExtensions: ['jpg','gif','png','jpeg','svg'],
|
|
maxFileCount: 100,
|
|
enctype : 'multipart/form-data',
|
|
showClose: false
|
|
}).on("filebatchuploadcomplete",function (event, files, extra) {
|
|
$("#uploadForm").hide(400);
|
|
halo.showMsgAndReload('上传成功!','success',1000);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 添加外部链接
|
|
*/
|
|
function addFromUrl() {
|
|
var param = $("#attachForm").serialize();
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/admin/attachments/addFromUrl',
|
|
async: false,
|
|
data: param,
|
|
success: function (data) {
|
|
if(data.code==1){
|
|
halo.showMsgAndParentRedirect(data.msg,'success',1000,"/admin/attachments");
|
|
}else{
|
|
halo.showMsg(data.msg,"error",2000);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</html>
|