This commit is contained in:
tao 2022-08-02 20:46:01 +08:00
parent c528ef2e16
commit 0a958f2b1a
17 changed files with 385 additions and 19 deletions

View File

@ -42,7 +42,7 @@
Fly模板:
一款至简的社区模板。
![alt taoler官网](https://www.aieok.com/storage/1/article_pic/20220802/54c8364fffd9ca1d15856efd90b689bc.png "TaoLerCMS")
![alt taoler官网](https://www.aieok.com/storage/1/article_pic/20220802/edd9bfc2ca1d1ec52a551b2233b5ab62.png "TaoLerCMS")
#### 安装教程
@ -100,6 +100,8 @@
4. 安装前需要先创建mysql数据库(准备:数据库连接地址,数据库用户名,密码,端口)
5. 如果手动导入数据库管理员用户名和密码默认admin/123456前后台的管理员密码一致。前后端管理员账户是独立的前端主要对文章内容的审查管理等操作。
![alt taoler官网](https://www.aieok.com/storage/1/article_pic/20220802/54c8364fffd9ca1d15856efd90b689bc.png "TaoLerAdmin")
#### 前后台独立域名的绑定
1. 支持设置绑定域名

View File

@ -2,7 +2,7 @@
/*
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2022-04-13 09:54:31
* @LastEditTime: 2022-05-02 11:54:00
* @LastEditTime: 2022-05-07 12:00:01
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\controller\Seo.php
@ -106,6 +106,8 @@ class Seo extends AdminController
}
}
}
// 获取Access Token分词的必选参数设置时写入
$baidu['grant_type'] = 'client_credentials';
$res = SetArr::name('taoler')->edit([
'baidu' => $baidu,
]);

View File

@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
namespace app\admin\controller;
use app\common\controller\AdminController;
use think\facade\View;
use think\facade\Request;
use think\facade\Config;
use think\facade\Db;
use taoser\SetArr;
class TagLink extends AdminController
{
public function index()
{
return View::fetch();
}
public function list()
{
$arr = [];
$tag = input('tag');
$tags = Config::get('taglink');
if(count($tags)) {
$arr = ['code'=>0, 'msg'=>'', 'count' => count($tags)];
foreach($tags as $k=>$v) {
$arr['data'][] = ['tag'=>$k, 'link'=>$v];
}
} else {
$arr = ['code'=>-1, 'msg'=>'没有数据'];
}
return json($arr);
}
public function add()
{
if(Request::isAjax()) {
$data = Request::only(['tag','link']);
$link = '\''.$data['link'].'\'';
$arr = [$data['tag'] => $link];
$res = SetArr::name('taglink')->add($arr);
if($res == true){
return json(['code'=>0,'msg'=>'设置成功']);
}
}
return View::fetch();
}
public function edit()
{
$tag = input('tag');
if(Request::isAjax()) {
$data = Request::only(['tag','link']);
$link = '\''.$data['link'].'\'';
$arr = [$data['tag'] => $link];
$res = SetArr::name('taglink')->edit($arr);
if($res == true){
return json(['code'=>0,'msg'=>'设置成功']);
}
}
$link = config('taglink.'.$tag);
View::assign(['tag'=>$tag, 'link'=>$link]);
return View::fetch();
}
public function delete()
{
if(Request::isPost()) {
$tag = input('tag');
$arr = [$tag => null];
$res = SetArr::name('taglink')->delete($arr);
if($res == true){
return json(['code'=>0,'msg'=>'删除成功']);
}
}
}
}

View File

@ -1,18 +1,17 @@
<?php
/*
* @Author: TaoLer <alipey_tao@qq.com>
* @Author: TaoLer <alipay_tao@qq.com>
* @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-21 17:02:15
* @LastEditTime: 2022-05-07 18:33:23
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设
* @Description: admin路由配
* @FilePath: \TaoLer\app\admin\route\route.php
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
*/
use think\facade\Route;
// 动态详情页URL别称
$detail_as = config('taoler.url_rewrite.article_as');
Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index');
Route::get(config('taoler.url_rewrite.article_as').'<id>', '\app\index\controller\Article@detail')->name('detail_id');
Route::get("$detail_as<id>$", '\app\index\controller\Article@detail')->name('detail_id');

View File

@ -0,0 +1,37 @@
{extend name="public/base" /}
{block name="body"}
<div class="layui-form" lay-filter="layuiadmin-form-slider" id="layuiadmin-form-slider" style="padding: 20px 20px 0 0;">
<div class="layui-form-item">
<div class="layui-form-item">
<label class="layui-form-label">Tag</label>
<div class="layui-input-inline">
<input type="text" name="tag" lay-verify="required" placeholder="tag匹配关键词" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">Link</label>
<div class="layui-input-inline">
<input type="text" name="link" lay-verify="required|url" placeholder="http://链接" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="Tag-Link-submit" id="Tag-Link-submit" value="确认">
</div>
</div>
{/block}
{block name="js"}
<script>
layui.config({
base: '/static/admin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form'], function(){
var $ = layui.$
,form = layui.form;
})
</script>
{/block}

View File

@ -0,0 +1,27 @@
{extend name="public/base" /}
{block name="body"}
<div class="layui-form" lay-filter="layuiadmin-form-slider" id="layuiadmin-form-slider" style="padding: 20px 20px 0 0;">
<div class="layui-form-item">
<label class="layui-form-label">Tag</label>
<div class="layui-input-inline">
<input type="text" name="tag" lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input layui-disabled" disabled value="{$tag}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">Link</label>
<div class="layui-input-inline">
<input type="text" name="link" lay-verify="required|url" placeholder="http://链接" autocomplete="off" class="layui-input" value="{$link}" >
</div>
</div>
<div class="layui-form-item layui-hide">
<input type="button" lay-submit lay-filter="Tag-Link-submit" id="Tag-Link-submit" value="确认">
</div>
</div>
{/block}
{block name="js"}
<script>
</script>
{/block}

View File

@ -0,0 +1,185 @@
{extend name="public/base" /}
{block name="body"}
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<!--div class="layui-form layui-card-header layuiadmin-card-header-auto">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">Tag关键词</label>
<div class="layui-input-block">
<input type="text" name="tag" placeholder="请输入关键词" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button class="layui-btn layuiadmin-btn-forum-list" lay-submit lay-filter="Tag-link-search">
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
</button>
</div>
</div>
</div-->
<div class="layui-form" wid100 lay-filter="">
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-normal" id="slid-add">添加</button>
<table id="tag-link" lay-filter="tag-link"></table>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="js"}
<script>
layui.config({
base: '/static/admin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index','layer','table','form'], function(){
var $ = layui.jquery
,layer = layui.layer
,table = layui.table
,form = layui.form;
//第一个实例
table.render({
elem: '#tag-link'
,url: "{:url('TagLink/list')}" //数据接口
,page: true //开启分页
,cols: [[ //表头
{type: 'numbers', fixed: 'left'}
,{field: 'tag', title: 'Tag', width:200}
,{field: 'link', title: 'Link', minWidth:300}
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
]]
,limit: 15
,text: '对不起,加载出现异常!'
});
form.on('submit(Tag-link-search)', function(data){
$.post("{:url('TagLink/list')}", {"tag":data.value}, function (data){
if (data.code == -1){
layer.open({content:data.msg,icon:5,anim:6});
}
}
);
//执行重载
table.reload('tag-link', {
where: {tag: data.value}
,page: {
curr: 1 //重新从第 1 页开始
}
});
});
//监听行工具事件
table.on('tool(tag-link)', function(obj){
var data = obj.data;
var tag = data.tag;
if(obj.event === 'del'){
layer.confirm('真的删除行么', {icon: 3, title:'删除TagLink'}, function(index){
//提交 Ajax 成功后,静态更新表格中的数据
$.post("{:url('TagLink/delete')}", {"tag":tag}, function(data){
if (data.code == 0) {
layer.msg(data.msg,{icon:6,time:2000}, function(){
location.reload();
});
} else {
layer.open({title:'删除失败',content:data.msg,icon:5,anim:6});
}
});
});
layer.close(index);
} else if(obj.event === 'edit'){
layer.open({
type: 2,
title: '编辑TagLink',
content: 'edit.html?tag='+ tag,
maxmin: true,
area : ['400px' , '300px'],
btn: ['确定', '取消'],
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'Tag-Link-submit'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
$.ajax({
type:"post",
url:"{:url('TagLink/edit')}",
data: field,
daType:"json",
success:function (data){
if (data.code == 0) {
layer.msg(data.msg,{icon:6,time:2000}, function(){
location.reload();
});
} else {
layer.open({title:'添加失败',content:data.msg,icon:5,anim:6});
}
}
});
layer.close(index);
});
submit.trigger('click');
}
});
}
});
// 添加
$('#slid-add').on('click', function(){
layer.open({
type: 2,
title: '添加TagLink',
content: 'add.html',
maxmin: true,
area : ['400px' , '300px'],
btn: ['确定', '取消'],
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'Tag-Link-submit'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
//提交 Ajax 成功后,静态更新表格中的数据
$.ajax({
type:"post",
url:"{:url('TagLink/add')}",
data: field,
daType:"json",
success:function (data){
if (data.code == 0) {
layer.msg(data.msg,{icon:6,time:2000}, function(){
location.reload();
});
} else {
layer.open({title:'添加失败',content:data.msg,icon:5,anim:6});
}
}
});
layer.close(index);
});
submit.trigger('click');
}
});
});
});
</script>
{/block}

View File

@ -7,6 +7,7 @@ use think\facade\Db;
use think\facade\Cache;
use think\facade\Session;
use taoser\think\Auth;
// 应用公共文件
function mailto($to,$title,$content)
{
@ -98,8 +99,6 @@ function getArtContent($content)
return mb_substr(strip_tags($content),0,150).'...';
}
//根据帖子收藏主键ID查询帖子名称
if(!function_exists('getArticName'))
{

View File

@ -71,6 +71,8 @@ class Article extends BaseController
$page = input('page') ? input('page') : 1;
$article = new ArticleModel();
$artDetail = $article->getArtDetail($id,$page);
// 设置tag内链
$artDetail['content'] = $this->setArtTagLink($artDetail['content']);
$arId = $artDetail['cate_id'];
$tpl = Db::name('cate')->where('id',$arId)->value('detpl');
$download = $artDetail['upzip'] ? download($artDetail['upzip'],'file') : '';
@ -510,4 +512,18 @@ class Article extends BaseController
return $data;
}
//设置文章内容tag
protected function setArtTagLink($content)
{
// tag链接数组
$tag = Config::get('taglink');
if(count($tag)) {
foreach($tag as $key=>$value) {
$content = str_replace("$key", 'a('.$value.')['.$key.']',$content);
}
}
return $content;
}
}

View File

@ -266,6 +266,7 @@ INSERT INTO `tao_auth_rule` VALUES ('97', 'addons', '插件', '', '1', '1', '0',
INSERT INTO `tao_auth_rule` VALUES ('98', 'Addons/index', '插件市场', '', '1', '1', '97', '1', '', '1', '0', '', '1635757426', '0', '0');
INSERT INTO `tao_auth_rule` VALUES ('99', 'Addons/addonsList', '插件列表', '', '1', '1', '98', '2', '', '-1', '0', '', '1638775199', '0', '0');
INSERT INTO `tao_auth_rule` VALUES ('111','Seo/index','SEO', '', '1','1','0','0','layui-icon-component','1','7','','1649829142','0','0');
INSERT INTO `tao_auth_rule` VALUES ('112', 'TagLink/index', 'TagLinks', '', '1', '1', '93', '1', '', '1', '0', '', '1652053762', '1652053830', '0');
-- ----------------------------
-- Table structure for tao_cate
@ -436,6 +437,20 @@ CREATE TABLE `tao_message_to` (
-- Records of tao_message_to
-- ----------------------------
--
-- 表的结构 `tao_push_jscode`
--
CREATE TABLE `tao_push_jscode` (
`id` int(2) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '平台名',
`jscode` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'js代码',
`create_time` int NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int NOT NULL DEFAULT '0' COMMENT '更新时间',
`delete_time` int NOT NULL DEFAULT '0' COMMENT '删除时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='站长平台自动推送js代码';
-- ----------------------------
-- Table structure for tao_slider
-- ----------------------------

3
config/taglink.php Normal file
View File

@ -0,0 +1,3 @@
<?php
return [
];

1
public/.gitignore vendored
View File

@ -1,2 +1,3 @@
install.lock
/home
*.xml

View File

@ -515,7 +515,7 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'imgcom'],
//XSS
content = util.escape(content||'')
//转义图片
//转义图片
.replace(/img\[([^\s]+?)\]/g, function(img){
return '<div style="text-align: center;"><img src="' + img.replace(/(^img\[)|(\]$)/g, '') + '"></div>';
})
@ -538,7 +538,7 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'imgcom'],
var text = (str.match(/\)\[([\s\S]*?)\]/)||[])[1];
if(!href) return str;
var rel = /^(http(s)*:\/\/)\b(?!(\w+\.)*(sentsin.com|layui.com))\b/.test(href.replace(/\s/g, ''));
return '<a href="'+ href +'" target="_blank"'+ (rel ? ' rel="nofollow"' : '') +'>'+ (text||href) +'</a>';
return '<a href="'+ href +'" style="color: red;" target="_blank"'+ (rel ? ' rel="nofollow"' : '') +'>'+ (text||href) +'</a>';
})
//转义横线

View File

@ -5,7 +5,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '334c91212372abf2e9a2441668700e9a794b635d',
'reference' => 'a9887fb4dd7614f13e14e21e16a876c3d435b23b',
'name' => 'taoser/taoler',
'dev' => true,
),
@ -160,7 +160,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '334c91212372abf2e9a2441668700e9a794b635d',
'reference' => 'a9887fb4dd7614f13e14e21e16a876c3d435b23b',
'dev_requirement' => false,
),
'taoser/think-addons' => array(

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2022-05-04 14:24:24
// This file is automatically generated at:2022-05-09 13:09:05
declare (strict_types = 1);
return array (
0 => 'taoser\\addons\\Service',

View File

@ -2,7 +2,7 @@
/*
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2022-04-14 16:05:35
* @LastEditTime: 2022-04-20 14:49:27
* @LastEditTime: 2022-05-09 11:31:00
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\vendor\taoser\think-setarr\src\SetArr.php
@ -692,7 +692,7 @@ class SetArr
echo $k.'不存在 ';
return false;
}
$patk = '/[^\n]*\'' . $v . '\'(.*?)\r?\n/';
$patk = '/[^\n]*\'' . $k . '\'(.*?)\r?\n/';
}
// 正则查找然后替换

View File

@ -1,6 +1,6 @@
{extend name="public:base" /}
{block name="title"}{$sysInfo.webname}-{$sysInfo.webtitle}{/block}
{block name="title"}{$sysInfo.webtitle}{/block}
{block name="keywords"}{$sysInfo.keywords}{/block}
{block name="description"}{$sysInfo.descript}{/block}
{block name="column"}{include file="public/column" /}{/block}