Browse Source

默认主题增加右键管理菜单

pull/4/merge 0.9.7
xiaoz 4 years ago
parent
commit
b369eab6a7
  1. 6
      controller/index.php
  2. 22
      templates/default/index.php
  3. 143
      templates/default/static/embed.js
  4. 11
      templates/default/static/style.css
  5. 2
      version.txt

6
controller/index.php

@ -19,6 +19,8 @@ if( is_login() ){ @@ -19,6 +19,8 @@ if( is_login() ){
]);
return $links;
}
//右键菜单标识
$onenav['right_menu'] = 'admin_menu();';
}
//如果没有登录,只获取公有链接
else{
@ -38,6 +40,8 @@ else{ @@ -38,6 +40,8 @@ else{
]);
return $links;
}
//右键菜单标识
$onenav['right_menu'] = 'user_menu();';
}
@ -111,6 +115,8 @@ if( file_exists('templates/admin/static/extend.js') ) { @@ -111,6 +115,8 @@ if( file_exists('templates/admin/static/extend.js') ) {
else{
$onenav['extend'] = '';
}
// 载入前台首页模板
require('templates/'.TEMPLATE.'/index.php');
?>

22
templates/default/index.php

@ -115,7 +115,7 @@ @@ -115,7 +115,7 @@
//var_dump($link);
?>
<div class="mdui-col-lg-3 mdui-col-md-4 mdui-col-xs-12 link-space" id = "id_<?php echo $link['id']; ?>">
<div class="mdui-col-lg-3 mdui-col-md-4 mdui-col-xs-12 link-space" id = "id_<?php echo $link['id']; ?>" link-title = "<?php echo $link['title']; ?>">
<!--定义一个卡片-->
<div class="mdui-card link-line mdui-hoverable">
<!-- 如果是私有链接,则显示角标 -->
@ -129,7 +129,7 @@ @@ -129,7 +129,7 @@
<div class="mdui-card-primary" style = "padding-top:16px;">
<div class="mdui-card-primary-title link-title">
<img src="https://favicon.rss.ink/v1/<?php echo base64($link['url']); ?>" alt="HUAN" width="16" height="16">
<span><?php echo $link['title']; ?></span>
<span class="link_title"><?php echo $link['title']; ?></span>
</div>
</div>
@ -147,20 +147,7 @@ @@ -147,20 +147,7 @@
</div>
<!-- row end -->
<!-- 删除提示框 -->
<div class="mdui-row">
<!-- 删除提示框 -->
<div class="mdui-dialog" id="link_delete">
<div class="mdui-dialog-title">确认删除?</div>
<div class="mdui-dialog-content">一旦删除将无法恢复,请确认。</div>
<div class="mdui-dialog-actions">
<button class="mdui-btn mdui-ripple" mdui-dialog-close>取消</button>
<button class="mdui-btn mdui-ripple" mdui-dialog-confirm>确认</button>
</div>
</div>
<!-- 删除提示框END -->
</div>
<!-- 删除提示框 -->
</div>
<div class="mdui-divider" style = "margin-top:2em;"></div>
<!--正文内容部分END-->
@ -177,4 +164,7 @@ @@ -177,4 +164,7 @@
<script src = 'https://libs.xiaoz.top/jQuery-contextMenu/2.9.2/jquery.contextMenu.min.js'></script>
<script src = "templates/<?php echo TEMPLATE; ?>/static/holmes.js"></script>
<script src="templates/<?php echo TEMPLATE; ?>/static/embed.js?v=<?php echo $version; ?>"></script>
<script>
<?php echo $onenav['right_menu']; ?>
</script>
</html>

143
templates/default/static/embed.js

@ -40,35 +40,122 @@ var h = holmes({ @@ -40,35 +40,122 @@ var h = holmes({
});
//鼠标移动到链接修改为原始URL
//js获取协议和域名部分
function get_domain(){
//获取协议
var protocol = window.location.protocol;
protocol = protocol + '//';
//获取端口号
var port = window.location.port;
if( (port == 80) || (port == 443) ){
port = '';
}
var hostname = window.location.hostname;
domain = protocol + port + hostname;
return domain;
}
$(document).ready(function(){
//初始化菜单
$.contextMenu({
selector: '.link-space',
callback: function(key, options) {
link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
},
items: {
"open":{name: "打开",icon:"fa-external-link",callback:function(key,opt){
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
var tempwindow=window.open('_blank');
tempwindow.location='index.php?c=click&id='+link_id;
}},
"edit": {name: "编辑", icon: "edit",callback:function(key,opt){
function admin_menu() {
// 加载管理员右键菜单
//初始化菜单
$.contextMenu({
selector: '.link-space',
callback: function(key, options) {
link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
},
items: {
"open":{name: "打开",icon:"fa-external-link",callback:function(key,opt){
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
var tempwindow=window.open('_blank');
tempwindow.location='index.php?c=click&id='+link_id;
}},
"edit": {name: "编辑", icon: "edit",callback:function(key,opt){
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
var tempwindow=window.open('_blank');
tempwindow.location='index.php?c=admin&page=edit_link&id='+link_id;
}},
"delete": {name: "删除", icon: "delete",callback:function(){
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
mdui.confirm('确认删除?',
function(){
$.post("index.php?c=api&method=del_link",{id:link_id},function(data,status){
//如果删除成功,则移除元素
if(data.code == 0) {
$("#id_" + link_id).remove();
}
else{
//删除失败
mdui.alert(data.err_msg);
}
});
},
function(){
//点击取消按钮,不做操作
return true;
}
);
}},
"sep1": "---------",
"qrcode": {name: "二维码", icon:"fa-qrcode",callback:function(data,status){
var link_title = $(this).attr('link-title');
link_title = link_title.substr(0,8);
// link_title = link_title + '...';
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
var domain = get_domain();
var url = domain + '/index.php?c=click&id=' + link_id;
mdui.dialog({
'title':link_title,
'cssClass':'show_qrcode',
'content':'<img src = "https://qr.png.pub/v1/?text=' + url + '" />'
});
}}
}
});
// 加载右键菜单END
}
function user_menu() {
// 加载游客右键菜单
//初始化菜单
$.contextMenu({
selector: '.link-space',
callback: function(key, options) {
link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
},
items: {
"open":{name: "打开",icon:"fa-external-link",callback:function(key,opt){
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
var tempwindow=window.open('_blank');
tempwindow.location='index.php?c=click&id='+link_id;
}},
"sep1": "---------",
"qrcode": {name: "二维码", icon:"fa-qrcode",callback:function(data,status){
var link_title = $(this).attr('link-title');
link_title = link_title.substr(0,8);
link_title = link_title + '...';
var link_id = $(this).attr('id');
link_id = link_id.replace('id_','');
var tempwindow=window.open('_blank');
tempwindow.location='index.php?c=admin&page=edit_link&id='+link_id;
}},
"delete": {name: "删除", icon: "delete",callback:function(){
}},
"sep1": "---------",
"qrcode": {name: "二维码", icon:"fa-qrcode"}
}
var domain = get_domain();
var url = domain + '/index.php?c=click&id=' + link_id;
mdui.dialog({
'title':link_title,
'cssClass':'show_qrcode',
'content':'<img src = "https://qr.png.pub/v1/?text=' + url + '" />'
});
}}
}
});
});
// 加载游客右键菜单END
};

11
templates/default/static/style.css

@ -87,4 +87,15 @@ footer a{ @@ -87,4 +87,15 @@ footer a{
}
.hidden {
display: none;
}
/* 显示二维码 */
.show_qrcode{
height: 300px;
width: 260px;
text-align: center;
}
.show_qrcode img{
text-align: center;
max-height: 200px;
max-width: 200px;
}

2
version.txt

@ -1 +1 @@ @@ -1 +1 @@
v0.9.6-20201222
v0.9.7-20201223
Loading…
Cancel
Save