diff --git a/sm.php b/sm.php
new file mode 100644
index 0000000..fe07fa5
--- /dev/null
+++ b/sm.php
@@ -0,0 +1,68 @@
+
+
+
+
+
+
该功能可以将图片上传至SM.MS图床。
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/static/embed.js b/static/embed.js
index 91ffc57..35b1a4b 100644
--- a/static/embed.js
+++ b/static/embed.js
@@ -1,3 +1,7 @@
+//layui 根目录配置
+layui.config({
+ base: '/static/layui/',
+})
//载入layui组建
layui.use(['layer', 'form','element','upload','flow'], function(){
var form = layui.form;
@@ -10,10 +14,11 @@ layui.use(['layer', 'form','element','upload','flow'], function(){
// elem:'#found-img img'
// });
- //拖拽上传
+ //首页拖拽上传
upload.render({
elem: '#upimg'
,url: 'functions/upload.php'
+ ,size: 2048 //限制上传大小为2M
,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading
}
@@ -48,6 +53,38 @@ layui.use(['layer', 'form','element','upload','flow'], function(){
}
}
});
+ //上传到sm.ms
+ upload.render({
+ elem: '#sm'
+ ,url: 'https://sm.ms/api/upload'
+ ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
+ layer.load(); //上传loading
+ }
+ ,done: function(res){
+ //如果上传失败
+ if(res.code == 'error'){
+ layer.open({
+ title: '温馨提示'
+ ,content: res.msg
+ });
+ layer.closeAll('loading');
+ }
+ else if(res.code == 'success'){
+ layer.closeAll('loading');
+ $("#showpic a").attr('href',res.data.url);
+ $("#showpic img").attr('src',res.data.url);
+ $("#url").val(res.data.url);
+ $("#html").val("
");
+ $("#markdown").val("![](" + res.data.url + ")");
+ $("#bbcode").val("[img]" + res.data.url + "[/img]");
+ $("#upok").show();
+ $.post("./functions/sm.php",{data:res.data},function(data,status){
+
+ });
+ }
+ }
+ });
+ //上传到sm.ms end
});
//复制链接
@@ -69,6 +106,25 @@ function copy(info){
layer.msg('复制成功!', {time: 2000})
});
}
+//后台复制URL
+function copyurl(url){
+ var copy = new clipBoard(document.getElementById('adminpic'), {
+ beforeCopy: function() {
+
+ },
+ copy: function() {
+ return url;
+ },
+ afterCopy: function() {
+
+ }
+ });
+ layui.use('layer', function(){
+ var layer = layui.layer;
+
+ layer.msg('链接已复制!', {time: 2000})
+ });
+}
//用户登录方法
function login(){
@@ -128,6 +184,39 @@ function adminshow(imgurl,id){
});
}
+//后台管理员查看SM.MS图片
+function smshow(imgurl,id){
+ var showimg = "
";
+ layui.use('layer', function(){
+ var layer = layui.layer;
+ layer.open({
+ type: 1,
+ title:"图片预览",
+ area: ['80%', '80%'],
+ content: showimg,
+ btn: ['压缩', '删除'],
+ yes: function(index, layero){
+ layer.msg('SM.MS图片不支持压缩!', {time: 2000})
+ }
+ //删除按钮
+ ,btn2: function(index, layero){
+ layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){
+ $.get("./delete.php?type=sm&id="+id,function(data,status){
+ if(data == 'ok') {
+ $("#imgid"+id).remove();
+ }
+ else{
+ alert(data);
+ }
+ });
+
+ layer.close(index);
+ });
+ }
+ });
+ });
+}
+
//删除某张图片
function deleteimg(id){
layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){
@@ -143,6 +232,21 @@ function deleteimg(id){
layer.close(index);
});
}
+//删除SM.MS图片
+function deletesm(id){
+ layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){
+ $.get("./delete.php?type=sm&id="+id,function(data,status){
+ if(data == 'ok') {
+ $("#imgid"+id).remove();
+ }
+ else{
+ alert(data);
+ }
+ });
+
+ layer.close(index);
+ });
+}
//取消图片可疑状态
function cdubious(id){
diff --git a/static/style.css b/static/style.css
index 07a6efc..3f63e53 100644
--- a/static/style.css
+++ b/static/style.css
@@ -34,7 +34,7 @@
margin-left:auto;
margin-right:auto;
- margin-top:4em;
+ margin-top:2em;
width:94.6%;
left:0%;
background-color:#F9F9F9;
@@ -76,7 +76,7 @@
margin-right:auto;
}
.msg{
- width:100%;
+ /* width:100%; */
background-color:#f2f2f2;
line-height: 1em;
padding:12px;
@@ -119,4 +119,43 @@
#about ul{
margin-top:1em;
margin-bottom:1em;
+}
+
+.smfile{
+ width:100%;
+ height:188px;
+ border: 1px dashed #e2e2e2;
+ margin-top:2em;
+}
+.smfile .file {
+ position: relative;
+ display: inline-block;
+ /* background: #D0EEFF; */
+ /* border: 1px solid #99D3F5;
+ border-radius: 4px;
+ padding: 4px 12px; */
+ overflow: hidden;
+ color: #009688;
+ text-decoration: none;
+ text-indent: 0;
+ line-height: 188px;
+ display: block;
+ height: 100%;
+ text-align: center;
+ margin-left:auto;
+ margin-right:auto;
+ background-color: #F9F9F9;
+}
+.smfile .file input {
+ position: absolute;
+ font-size: 100px;
+ right: 0;
+ top: 0;
+ opacity: 0;
+}
+.smfile .file:hover {
+ /* background: #AADFFD;
+ border-color: #78C3F3; */
+ color:#009688;
+ text-decoration: none;
}
\ No newline at end of file
diff --git a/tpl/admin/footer.php b/tpl/admin/footer.php
index 671961d..7807935 100644
--- a/tpl/admin/footer.php
+++ b/tpl/admin/footer.php
@@ -13,6 +13,6 @@
-
+