Browse Source

0.9.26

pull/104/head
xiaoz 1 year ago
parent
commit
ec72ed4381
  1. 192
      class/Api.php
  2. 9
      controller/admin.php
  3. 50
      controller/api.php
  4. 17
      controller/universal.php
  5. 8
      data/update.log
  6. 10
      db/sql/20221114.sql
  7. 31
      functions/helper.php
  8. BIN
      static/images/error.png
  9. BIN
      static/images/share_tit_bg_5855301.png
  10. 194
      templates/admin/click.php
  11. 1
      templates/admin/footer.php
  12. 1
      templates/admin/left.php
  13. 255
      templates/admin/setting/share.php
  14. 13
      templates/admin/static/embed.js
  15. 4
      templates/default/index.php
  16. 4
      templates/default/info.json
  17. 3
      templates/default/static/style.css
  18. 2
      templates/mobile/assets/index.js
  19. 1
      templates/universal/assets/index.css
  20. 14
      templates/universal/assets/index.js
  21. 16
      templates/universal/index.php
  22. 2
      version.txt

192
class/Api.php

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
* author:xiaoz<xiaoz93@outlook.com>
* blog:xiaoz.me
*/
//载入通用函数
require("./functions/helper.php");
define("API_URL","https://onenav.xiaoz.top");
class Api {
protected $db;
@ -1985,6 +1987,196 @@ class Api { @@ -1985,6 +1987,196 @@ class Api {
}
}
/**
* name:创建分享
*/
public function create_share($data) {
//验证请求
$this->auth($token);
//如果订阅不存在
if ( $this->is_subscribe() === FALSE ) {
$this->return_json(-2000,'','此功能需要订阅后才能使用!');
}
//设置默认数据
//随机8位分享ID
$data['sid'] = GetRandStr(8);
/**
* 判断到期时间
*/
//获取当前时间
$c_time = strtotime( $data['add_time'] );
$e_time = strtotime( $data['expire_time'] );
if( $c_time > $e_time ) {
$this->return_json(-2000,'','到期日期不能小于当前日期!');
}
/**
* 判断密码
*/
if( strlen($data['password']) > 16 ) {
$this->return_json(-2000,'','密码长度不能超过16位!');
}
$pattern = "/[A-Za-z0-9]{4,16}/";
//var_dump(preg_match($pattern,$data['password']));
if( !empty($data['password']) && !preg_match($pattern,$data['password']) ) {
$this->return_json(-2000,'','密码只能由4-16位字母和数字组成!');
}
//插入数据库
$result = $this->db->insert("on_shares",$data);
if( $result ) {
$this->return_json(200,'','success');
}
else{
$this->return_json(-2000,'','写入数据库失败!');
}
}
/**
* 分享列表
*/
public function share_list($data){
//验证请求
$this->auth($token);
$limit = $data['limit'];
$offset = ($data['page'] - 1) * $data['limit'];
//$fid = @$data['category_id'];
$count = $this->db->count('on_shares','*');
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_shares.cid) AS category_name FROM on_shares ORDER BY id DESC LIMIT {$limit} OFFSET {$offset}";
//原生查询
$datas = $this->db->query($sql)->fetchAll();
$datas = [
'code' => 0,
'msg' => '',
'count' => $count,
'data' => $datas
];
exit(json_encode($datas));
}
/**
* name:根据分享的SID查询指定分类下的所有链接
*/
public function get_sid_links($data) {
//获得SID
$sid = $data['sid'];
//获得密码
$password = $data['password'];
//判断SID是否合法
$pattern = "/[A-Za-z0-9]{8}$/";
if( (strlen($sid) !== 8) || !preg_match($pattern,$sid) ) {
$this->return_json(-2000,'','SID不合法!');
}
//根据SID查询得到分类ID
$share_data = $this->db->get("on_shares","*",[
"sid" => $sid
]);
//如果没有查询到数据
if( empty($share_data) ) {
$this->return_json(-2000,'','SID不存在!');
}
$cid = $share_data['cid'];
//查询分类名称
$category_info = $this->db->get("on_categorys",["name"],[
"id" => $cid
]);
$category_name = $category_info["name"];
//如果链接已经过期
$c_time = strtotime( date("Y-m-d H:i:s",time()) );
if ( $c_time > strtotime($share_data['expire_time']) ) {
$this->return_json(-2000,'','链接已过期!');
}
//如果分享密码不为空,则验证密码
if ( !empty($share_data['password']) && ( $share_data['password'] == $password) ) {
//根据分类ID(cid)查询该分类下的所有链接
$results = $this->db->select("on_links","*",[
"fid" => $cid,
"ORDER" => ["weight" => "DESC","id" => "DESC"]
]);
$data = [
"category_name" => $category_name,
"expire_time" => $share_data["expire_time"],
"results" => $results
];
$this->return_json(200,$data,'success');
}
else if ( empty($share_data['password']) ) {
//根据分类ID(cid)查询该分类下的所有链接
$results = $this->db->select("on_links","*",[
"fid" => $cid,
"ORDER" => ["weight" => "DESC","id" => "DESC"]
]);
$data = [
"category_name" => $category_name,
"expire_time" => $share_data["expire_time"],
"results" => $results
];
$this->return_json(200,$data,'success');
}
else{
$this->return_json(401,'','密码错误!');
}
}
/**
* name:删除分享
*/
public function del_share($data) {
//验证请求
$this->auth($token);
$id = $data['id'];
//如果id为空
if( empty($id) ){
$this->return_json(-2000,$results,'ID不能为空!');
}
$data = $this->db->delete('on_shares',[ 'id' => $id] );
if( $data ) {
$this->return_json(200,'','success');
}
else{
$this->return_json(-2000,'','删除失败!');
}
}
/**
* name:获取站点信息,不需要授权
*/
public function site_info() {
//获取当前站点信息
$site = $this->db->get('on_options','value',[ 'key' => "s_site" ]);
$site = unserialize($site);
$this->return_json(200,$site,'success');
}
}

9
controller/admin.php

@ -23,6 +23,12 @@ check_auth($site_setting['user'],$site_setting['password']); @@ -23,6 +23,12 @@ check_auth($site_setting['user'],$site_setting['password']);
$version = new_get_version();
$page = empty($_GET['page']) ? 'index' : $_GET['page'];
//如果是后台首页,则判断是否是手机访问,并决定是否跳转到手机版页面
if( $page == 'index' ) {
jump_mobile();
}
//如果页面是修改edit_category
if ( $page == 'edit_category' ) {
//获取id
@ -122,7 +128,7 @@ if ( $page == "link_list" ) { @@ -122,7 +128,7 @@ if ( $page == "link_list" ) {
}
//如果页面是添加链接页面
if ( ($page == 'add_link') || ($page == 'add_link_tpl') || ($page == 'add_quick_tpl') ) {
if ( ($page == 'add_link') || ($page == 'add_link_tpl') || ($page == 'add_quick_tpl') || ($page == 'setting/share') ) {
//查询所有分类信息
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weight' => 'DESC'] ]);
//checked按钮
@ -185,6 +191,7 @@ if( $page == 'setting/theme' ) { @@ -185,6 +191,7 @@ if( $page == 'setting/theme' ) {
case '..':
case 'admin':
case 'mobile':
case 'universal':
continue;
break;
default:

50
controller/api.php

@ -573,4 +573,54 @@ function down_db() { @@ -573,4 +573,54 @@ function down_db() {
global $api;
$name = $_GET['name'];
$api->down_db($name);
}
//创建分享
function create_share() {
global $api;
$data['add_time'] = date("Y-m-d H:i:s",time());
$data['expire_time'] = $_POST['expire_time'];
$data['password'] = trim($_POST['password']);
$data['cid'] = intval($_POST['cid']);
$data['note'] = $_POST['note'];
$api->create_share($data);
}
//分享列表
function share_list() {
global $api;
$page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
$limit = empty(intval($_REQUEST['limit'])) ? 10 : intval($_REQUEST['limit']);
$data = [
'page' => $page,
'limit' => $limit
];
$api->share_list($data);
}
//获取SID下的链接
function get_sid_links() {
global $api;
$data['sid'] = trim($_POST['sid']);
$data['password'] = trim($_POST['password']);
$api->get_sid_links($data);
}
//删除分享
function del_share() {
global $api;
$data['id'] = intval($_GET['id']);
//var_dump($data['id']);
$api->del_share($data);
}
//站点信息
function site_info() {
global $api;
$api->site_info();
}

17
controller/universal.php

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<?php
/**
* name:一些通用的前端页面控制器
*/
require('functions/helper.php');
//获取版本号
$version = new_get_version();
//获取当前站点信息
$site = $db->get('on_options','value',[ 'key' => "s_site" ]);
$site = unserialize($site);
//载入视图
require('templates/universal/index.php');

8
data/update.log

@ -164,4 +164,10 @@ CREATE INDEX on_options_key_IDX ON on_options ("key"); @@ -164,4 +164,10 @@ CREATE INDEX on_options_key_IDX ON on_options ("key");
3. 前端初始化密码不允许&符号
4. 新增备份数据库下载
5. 默认主题改用本地二维码
6. 新增手机版简易后台
6. 新增手机版简易后台
20221116
1. 过渡页面美化
2. 新增:分类目录分享功能
3. 修复默认主题的一些BUG
4. 其它优化和BUG修复

10
db/sql/20221114.sql

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
CREATE TABLE on_shares (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
sid TEXT(8) NOT NULL,
add_time TEXT(10) NOT NULL,
expire_time TEXT(10) NOT NULL,
password TEXT(16),
cid INTEGER NOT NULL,
note TEXT(2048)
);
CREATE UNIQUE INDEX on_shares_sid_IDX ON on_shares (sid);

31
functions/helper.php

@ -78,3 +78,34 @@ function new_get_version(){ @@ -78,3 +78,34 @@ function new_get_version(){
return $version;
}
}
//随机数生成
function GetRandStr($len)
{
$chars = array(
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
"3", "4", "5", "6", "7", "8", "9"
);
$charsLen = count($chars) - 1;
shuffle($chars);
$output = "";
for ($i=0; $i<$len; $i++)
{
$output .= $chars[mt_rand(0, $charsLen)];
}
return $output;
}
//跳转到手机版页面
function jump_mobile() {
$ua = $_SERVER['HTTP_USER_AGENT'];
if( stristr($ua,'iphone') || stristr($ua,'android') ) {
header("Location: /index.php?c=admin");
exit;
}
}

BIN
static/images/error.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
static/images/share_tit_bg_5855301.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

194
templates/admin/click.php

@ -10,6 +10,9 @@ @@ -10,6 +10,9 @@
<script src = "static/js/jquery.min.js"></script>
<script src="static/bootstrap4/js/bootstrap.min.js"></script>
<style>
body{
background-color:#f3f3f3;
}
.prevent-overflow{
width:260px;
overflow: hidden;/*超出部分隐藏*/
@ -25,6 +28,73 @@ @@ -25,6 +28,73 @@
width:100%;
background-color: #343a40!important;
}
.link-box{
background-color:#FFFFFF;
border-radius:6px;
text-align:center;
}
.link-box .notice-title{
font-size:22px;
color:#2f2f2f;
padding-top:24px;
}
.link-box .notice-des{
color:#888888;
font-size:16px;
}
.link-box .link{
border:border:1px solid;
border-radius:4px;
background:#fafafa;
width:90%;
margin-left:auto;
margin-right:auto;
padding:16px;
margin-top:12px;
text-align:left;
overflow: hidden;/*超出部分隐藏*/
white-space: nowrap;/*不换行*/
text-overflow:ellipsis;/*超出部分文字以...显示dsds*/
}
.link-box .icon{
width:40px;
height:40px;
background:#bcc6d8;
line-height:36px;
border-radius:2px;
text-align:center;
display:inline-block;
/* font-size:20px; */
}
.link-btn a{
margin-top:20px;
margin-bottom:20px;
border-radius:22px;
color:#ea725d;
border:1px solid #ea725d;
background:#FFFFFF;
width:166px;
}
.link-btn a:hover{
border:1px solid #ea725d;
background:#ea725d;
}
.link a{
text-decoration-line: none;
-moz-text-decoration-line: none;
}
.site-title{
text-align:center;
padding-bottom:18px;
}
.site-title h1{
font-size:2.2rem;
}
.site-title a{
color:#333333;
text-decoration-line: none;
-moz-text-decoration-line: none;
}
</style>
<?php echo $site['custom_header']; ?>
<?php
@ -46,30 +116,8 @@ @@ -46,30 +116,8 @@
?>
</head>
<body>
<div id="menu">
<div class="container">
<div class = "row">
<div class="col-sm-8 offset-sm-2">
<!-- 顶部导航菜单 -->
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="/"><?php echo $site['title']; ?></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<!-- 输出自定义菜单 -->
<?php echo $transition_page['menu']; ?>
<!-- 输出自定义菜单END -->
</ul>
</div>
</nav>
<!-- 顶部导航菜单END -->
</div>
</div>
</div>
</div>
<div class="container" style = "margin-top:2em;">
<div class="container" style = "margin-top:24px;">
<!-- 广告1 -->
<div class= "row">
<div class="col-sm-8 offset-sm-2 a_d">
@ -78,66 +126,35 @@ @@ -78,66 +126,35 @@
</div>
<!-- 广告1 END -->
<div class="row">
<!-- 网站名称 -->
<div class="col-sm-8 offset-sm-2">
<!-- 新建一个表格 -->
<h2>链接信息:</h2>
<table class="table">
<tbody>
<tr class="table-info">
<td width="170">标题</td>
<td><?php echo $link['title']; ?></td>
</tr>
<tr class="table-info">
<td>描述</td>
<td><?php echo $link['description']; ?></td>
</tr>
<tr class="table-info">
<td>链接</td>
<td>
<div class = "prevent-overflow">
<a href="<?php echo $link['url']; ?>" rel = "nofollow" title = "<?php echo $link['title']; ?>"><?php echo $link['url']; ?></a>
</div>
</td>
</tr>
<tr class="table-info">
<td>备用链接</td>
<td>
<div class = "prevent-overflow">
<a href="<?php echo $link['url_standby']; ?>" rel = "nofollow" title = "<?php echo $link['title']; ?>"><?php echo $link['url_standby']; ?></a>
</div>
</td>
</tr>
</tbody>
</table>
<!-- 如果备用链接是空的,则显示加载中... -->
<?php if( empty($link['url_standby']) ) { ?>
<!-- 加载中 -->
<div class="spinner-border"></div>
即将打开,请稍等...
<!-- 加载中END -->
<?php }else{ ?>
<!-- 备用链接不为空 -->
<!-- 备用链接提示框 -->
<div class="alert alert-primary">
<strong>存在备用链接,请手动点击您要打开的链接!</strong>
</div>
<!-- 提示框END -->
<?php } ?>
<!-- 表格END -->
<div class="xcdn-content">
<?php echo $msg; ?>
<div class="site-title"><a href="/" title = "<?php echo $site['title']; ?>"><h1><?php echo $site['title']; ?></h1></a></div>
</div>
<!-- 网站名称END -->
<!-- 链接内容 -->
<div class="col-sm-8 offset-sm-2">
<div class="link-box">
<div class="notice-title">即将跳转到外部网站</div>
<div class="notice-des">安全性未知,是否继续</div>
<div class="link" title="主链接">
<span class="icon"><?xml?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M26.2401 16.373L17.1001 7.23303C14.4388 4.57168 10.0653 4.6303 7.33158 7.36397C4.59791 10.0976 4.53929 14.4712 7.20064 17.1325L15.1359 25.0678" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M32.9027 23.0031L40.838 30.9384C43.4994 33.5998 43.4407 37.9733 40.7071 40.707C37.9734 43.4407 33.5999 43.4993 30.9385 40.8379L21.7985 31.6979" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M26.1093 26.1416C28.843 23.4079 28.9016 19.0344 26.2403 16.373" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M21.7989 21.7984C19.0652 24.5321 19.0066 28.9056 21.6679 31.5669" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/></svg></span>
<a href="<?php echo $link['url']; ?>" rel = "nofollow" title = "<?php echo $link['title']; ?>"><?php echo $link['url']; ?></a>
</div>
<?php if( !empty( $link['url_standby'] ) ) { ?>
<div class="link" title = "备用链接">
<span class="icon">
<?xml?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M30 19H20C15.5817 19 12 22.5817 12 27C12 31.4183 15.5817 35 20 35H36C40.4183 35 44 31.4183 44 27C44 24.9711 43.2447 23.1186 42 21.7084" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M6 24.2916C4.75527 22.8814 4 21.0289 4 19C4 14.5817 7.58172 11 12 11H28C32.4183 11 36 14.5817 36 19C36 23.4183 32.4183 27 28 27H18" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/></svg>
</span>
<a href="<?php echo $link['url_standby']; ?>" rel = "nofollow" title = "<?php echo $link['title']; ?>"><?php echo $link['url_standby']; ?></a>
</div>
<?php } ?>
<div class="link-btn">
<a class="btn btn-primary" rel = "nofollow" title = "继续前往:<?php echo $link['title']; ?>" href="<?php echo $link['url']; ?>">继续前往</a>
</div>
</div>
</div>
<!-- 链接内容END -->
</div>
<!-- 广告2 -->
<div class= "row">
@ -146,20 +163,7 @@ @@ -146,20 +163,7 @@
</div>
</div>
<!-- 广告2 END -->
<!-- 底部footer -->
<div class = "row">
<div class="col-sm-8 offset-sm-2">
<hr>
<div class="xcdn-footer">
<?php if( empty($site['custom_footer']) ){ ?>
&copy;2022 Powered by <a href="https://www.xiaoz.me/" title = "小z博客" rel = "nofollow" target = "_blank">xiaoz</a>
<?php }else{
echo $site['custom_footer'];
} ?>
</div>
</div>
</div>
<!-- 底部footer end -->
</div>
</body>
</html>

1
templates/admin/footer.php

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script>
<script src="static/js/md5.min.js"></script>
<script src = "static/js/clipBoard.min.js"></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script>
</body>
</html>

1
templates/admin/left.php

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
<dd><a href="/index.php?c=admin&page=link_list">我的链接</a></dd>
<dd><a href="/index.php?c=admin&page=add_link">添加链接</a></dd>
<dd><a href="/index.php?c=admin&page=imp_link">书签导入</a></dd>
<dd><a href="/index.php?c=admin&page=setting/share">书签分享</a></dd>
</dl>
</li>
</ul>

255
templates/admin/setting/share.php

@ -0,0 +1,255 @@ @@ -0,0 +1,255 @@
<?php echo $transition_page['control']; ?>
<!-- API页面设置 -->
<?php require_once(dirname(__DIR__).'/header.php'); ?>
<?php include_once(dirname(__DIR__).'/left.php'); ?>
<div class="layui-body">
<!-- 内容主体区域 -->
<div class="layui-row content-body place-holder">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="page-msg">
<ol>
<li>订阅用户可以对指定分类下的书签进行分享</li>
<li>比如:您可以将某个私有分类通过设置密码的方式分享给您的好友</li>
<li>若密码留空,则不需要密码也能访问</li>
</ol>
</div>
</div>
<!-- 说明提示框END -->
<!-- 创建分享 -->
<div class="layui-col-lg12">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<label class="layui-form-label">选择分类</label>
<div class="layui-input-block">
<select name="cid" lay-verify="required" lay-search="">
<option value="">请选择要分享的分类</option>
<?php foreach ($categorys as $category) {
# code...
?>
<option value="<?php echo $category['id'] ?>"><?php echo $category['name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">过期时间</label>
<div class="layui-input-block"> <!-- 注意:这一层元素并不是必须的 -->
<input type="text" placeholder = "过期时间不能小于当前时间" lay-verify="required" class="layui-input" name = "expire_time" id="expire_time">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">设置密码</label>
<div class="layui-input-block">
<input type="text" id = "password" name="password" placeholder="如果留空则视为公开分享" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">备注</label>
<div class="layui-input-block">
<textarea name="note" placeholder="请输入备注内容" class="layui-textarea"></textarea>
</div>
</div>
<button class="layui-btn" lay-submit lay-filter="create_share">创建</button>
<a class="layui-btn" href="javascript:;" onclick="new_pass()">更换密码</a>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</form>
</div>
<!-- 创建分享END -->
<div class="layui-col-lg12">
<!-- 数据表格 -->
<table class="layui-hide" id="mytable" lay-filter="mytable"></table>
<!-- 数据表格END -->
<!-- 最右侧的操作选项 -->
<script type="text/html" id="tooloption">
<a class="layui-btn layui-btn-xs" lay-event="copy_link">复制链接</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 操作选项END -->
<!-- 头部工具栏 -->
<script type="text/html" id="toolbarheader">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="share">创建分享</button>
</div>
</script>
<!-- 头部工具栏END -->
</div>
</div>
</div>
<?php include_once(dirname(__DIR__).'/footer.php'); ?>
<script>
//页面加载时,生成一个4位的随机密码
$(document).ready(function(){
$("#password").val(getRandStr(4));
});
layui.use('laydate', function(){
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#expire_time' //指定元素
,type: 'datetime'
});
});
//提交创建分享表单
layui.use('form', function(){
var form = layui.form;
//提交
form.on('submit(create_share)', function(data){
//console.log(data.field);
//return false;
//return false;
$.post("/index.php?c=api&method=create_share",data.field,function(data,status){
if( data.code == 200 ) {
layer.msg("成功!",{icon:1});
//重载表格
layui.use('table', function(){
var table = layui.table;
table.reload('tableid', {
where: { //设定异步数据接口的额外参数,任意设
aaaaaa: 'xxx'
}
,page: {
curr: 1 //重新从第 1 页开始
}
});
});
}
else{
layer.msg(data.msg,{icon:5});
}
});
//阻止表单提交
return false;
});
});
layui.use(['table'],function(){
var table = layui.table;
// 渲染表格
table.render({
elem: '#mytable'
,id: 'tableid'
,page: true
,url:'/index.php?c=api&method=share_list' // 此处为静态模拟数据,实际使用时需换成真实接口
// ,toolbar: '#toolbarheader'
// ,totalRow: true // 开启合计行
,cols: [[
{field:'id', width:80, title: 'ID'}
,{field:'sid', title:'SID',width:110,templet:function(d){
let sid = d.sid;
return `<a href = "/index.php?c=universal#/share/${sid}" target = "_blank" title = "点击打开">${sid}</a>`;
}}
,{field:'category_name', title:'分类名称',width:200}
,{field:'add_time', title: '添加时间', width:240}
,{field:'expire_time', width:240, title: '过期时间',templet:function(d){
let e_time = d.expire_time;
let current_time = new Date( Date.parse(new Date()) );
let expire_time = new Date(Date.parse(d.expire_time));
if( current_time > expire_time ) {
return `<span>${e_time}</span> <button class="layui-btn layui-btn-xs layui-btn-disabled">已过期</button>`;
}
else{
return `<span>${e_time}</span> <button class="layui-btn layui-btn-xs">正常</button>`;
}
}}
,{field:'password', width:200, title: '密码'}
,{field:'password', width:200, title: '备注'}
,{fixed: 'right', title:'操作', toolbar: '#tooloption'}
]]
});
// 渲染表格END
// 表头工具栏
//触发事件
table.on('toolbar(mytable)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
case 'share':
$.get("/index.php?c=api&method=backup_db",function(data,status){
if( data.code == 200 ) {
layer.msg('备份成功!',{icon:1});
//刷新表格
table.reload('tableid', {
where: { //设定异步数据接口的额外参数,任意设
aaaaaa: 'xxx'
}
});
}
else{
layer.msg(data.msg,{icon:5});
}
});
break;
};
});
// 表头工具栏END
//单元格工具事件
table.on('tool(mytable)', function(obj){ // 注:test 是 table 原始标签的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的 DOM 对象(如果有的话)
if(layEvent === 'copy_link'){ //复制分享链接和密码
var copy = new clipBoard(document.getElementById('mytable'), {
beforeCopy: function() {
},
copy: function() {
let link = window.location.href + "index.php?c=universal#/share/" + data.sid;
link = link.replace('index.php?c=admin&page=setting/share','');
let password = data.password;
layer.msg("分享链接已复制!",{icon:1});
return `链接:${link} 密码:${password}`;
},
afterCopy: function() {
}
});
}
else if(layEvent === 'del'){ //删除
layer.confirm('确定删除吗?', {icon:3,title:'提示'},function(index){
$.get("/index.php?c=api&method=del_share&id=" + data.id,function(data,status){
if(data.code == 200) {
obj.del(); // 删除对应行(tr)的 DOM 结构,并更新缓存
layer.close(index);
}
else{
layer.msg(data.msg,{icon:5})
layer.close(index);
}
});
});
}
});
//单元格工具事件END
});
//更换一个新的随机密码
function new_pass(){
$("#password").val(getRandStr(4));
return false;
}
</script>

13
templates/admin/static/embed.js

@ -949,4 +949,17 @@ function check_subscribe(msg) { @@ -949,4 +949,17 @@ function check_subscribe(msg) {
return false;
}
});
}
//随机数生成
function getRandStr(n) {
var chars = ['0','1','2','3','4','5','6','7','8','9',
'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
var res = "";
for(var i = 0; i < n ; i++) {
var id = Math.floor(Math.random()*36);
res += chars[id];
}
return res;
}

4
templates/default/index.php

@ -146,9 +146,9 @@ @@ -146,9 +146,9 @@
</li>
</a>
<?php } else { ?>
<a href="/index.php?c=admin&page=logout" title="退出" class="mdui-hidden-sm-up">
<a href="/index.php?c=mobile" title="后台管理" class="mdui-hidden-sm-up">
<li class="mdui-list-item mdui-ripple">
<div class="mdui-list-item-content category-name"><i class="fa fa-dashboard"></i> 退出</div>
<div class="mdui-list-item-content category-name"><i class="fa fa-dashboard"></i> 后台管理</div>
</li>
</a>
<?php } ?>

4
templates/default/info.json

@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
"description": "OneNav默认主题",
"homepage": "https:\/\/www.xiaoz.me",
"help_url":"https://dwz.ovh/gnae4",
"version": "0.9.20",
"update": "2022\/04\/29",
"version": "0.9.26",
"update": "2022\/11\/16",
"author": "xiaoz<xiaoz93@outlook.com>",
"screenshot": "https:\/\/img.rss.ink\/imgs\/2022\/03\/42ed3ef2c4a50f6d.png",
"demo":"",

3
templates/default/static/style.css

@ -164,4 +164,7 @@ footer a{ @@ -164,4 +164,7 @@ footer a{
/* background-color: #FEFEFE; */
/* box-shadow:1px 0 5px 0 #eeeeee; */
border-right: 0.5px solid rgba(0, 0, 0, 0.12);
}
#qrcode img{
max-width: 200px;
}

2
templates/mobile/assets/index.js

File diff suppressed because one or more lines are too long

1
templates/universal/assets/index.css

File diff suppressed because one or more lines are too long

14
templates/universal/assets/index.js

File diff suppressed because one or more lines are too long

16
templates/universal/index.php

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo $site['title']; ?></title>
<script type="module" crossorigin src="templates/universal/assets/index.js?version=<?php echo $version; ?>"></script>
<link rel="stylesheet" href="templates/universal/assets/index.css?version=<?php echo $version; ?>">
<?php echo $site['custom_header']; ?>
</head>
<body>
<div id="app"></div>
</body>
</html>

2
version.txt

@ -1 +1 @@ @@ -1 +1 @@
v0.9.25-20221107
v0.9.26-20221116
Loading…
Cancel
Save