tag表增加keywords、description、title字段
This commit is contained in:
parent
43013c2e39
commit
89ece07993
@ -292,84 +292,98 @@ abstract class BaseController
|
||||
|
||||
/**
|
||||
* 关键词
|
||||
* 通过百度分词接口获取关键词或者标签
|
||||
* flag 1.为word时获取分词,2.为tag时获取标签
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setKeywords($data)
|
||||
{
|
||||
$keywords = [];
|
||||
// 百度分词自动生成关键词
|
||||
if(!empty(config('taoler.baidu.client_id')) == true) {
|
||||
//headers数组内的格式
|
||||
$headers = array();
|
||||
$headers[] = "Content-Type:application/json";
|
||||
|
||||
if($data['flag'] == 'on') {
|
||||
// 百度分词自动生成关键词
|
||||
if(!empty(config('taoler.baidu.client_id')) == true) {
|
||||
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
|
||||
switch($data['flag']) {
|
||||
//分词
|
||||
case 'word':
|
||||
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
|
||||
$body = ["text" => $data['keywords']];
|
||||
break;
|
||||
//标签
|
||||
case 'tag':
|
||||
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/keyword?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
|
||||
$body = ['title' => $data['keywords'], 'content'=>$data['content']];
|
||||
break;
|
||||
default:
|
||||
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
|
||||
$body = ["text" => $data['keywords']];
|
||||
}
|
||||
|
||||
$postBody = json_encode($body);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);//设置请求头
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postBody);//设置请求体
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');//使用一个自定义的请求信息来代替"GET"或"HEAD"作为HTTP请求。(这个加不加没啥影响)
|
||||
$datas = curl_exec($curl);
|
||||
if($datas == false) {
|
||||
echo '接口无法链接';
|
||||
} else {
|
||||
$res = stripos($datas,'error_code');
|
||||
// 接收返回的数据
|
||||
$dataItem = json_decode($datas);
|
||||
if($res == false) {
|
||||
// 数据正常
|
||||
$items = $dataItem->items;
|
||||
foreach($items as $item) {
|
||||
|
||||
switch($data['flag']) {
|
||||
case 'word':
|
||||
if($item->pos == 'n' && !in_array($item->item,$keywords)){
|
||||
$keywords[] = $item->item;
|
||||
}
|
||||
break;
|
||||
case 'tag':
|
||||
if(!in_array($item->tag,$keywords)){
|
||||
$keywords[] = $item->tag;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if($item->pos == 'n' && !in_array($item->item,$keywords)){
|
||||
$keywords[] = $item->item;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 接口正常但获取数据失败,可能参数错误,重新获取token
|
||||
$url = 'https://aip.baidubce.com/oauth/2.0/token';
|
||||
$post_data['grant_type'] = config('taoler.baidu.grant_type');;
|
||||
$post_data['client_id'] = config('taoler.baidu.client_id');
|
||||
$post_data['client_secret'] = config('taoler.baidu.client_secret');
|
||||
|
||||
//headers数组内的格式
|
||||
$headers = array();
|
||||
$headers[] = "Content-Type:application/json";
|
||||
$body = array(
|
||||
"text" => $data['$keywords']
|
||||
);
|
||||
$postBody = json_encode($body);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);//设置请求头
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postBody);//设置请求体
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');//使用一个自定义的请求信息来代替"GET"或"HEAD"作为HTTP请求。(这个加不加没啥影响)
|
||||
$datas = curl_exec($curl);
|
||||
if($datas == false) {
|
||||
echo '接口无法链接';
|
||||
} else {
|
||||
$res = stripos($datas,'error_code');
|
||||
// 接收返回的数据
|
||||
$dataItem = json_decode($datas);
|
||||
if($res == false) {
|
||||
// 数据正常
|
||||
$items = $dataItem->items;
|
||||
foreach($items as $item) {
|
||||
if($item->pos == 'n' && !in_array($item->item,$keywords)){
|
||||
$keywords[] = $item->item;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 接口正常但获取数据失败,可能参数错误,重新获取token
|
||||
$url = 'https://aip.baidubce.com/oauth/2.0/token';
|
||||
$post_data['grant_type'] = config('taoler.baidu.grant_type');;
|
||||
$post_data['client_id'] = config('taoler.baidu.client_id');
|
||||
$post_data['client_secret'] = config('taoler.baidu.client_secret');
|
||||
|
||||
$o = "";
|
||||
foreach ( $post_data as $k => $v )
|
||||
{
|
||||
$o.= "$k=" . urlencode( $v ). "&" ;
|
||||
}
|
||||
$post_data = substr($o,0,-1);
|
||||
$res = $this->request_post($url, $post_data);
|
||||
// 写入token
|
||||
SetArr::name('taoler')->edit([
|
||||
'baidu'=> [
|
||||
'access_token' => json_decode($res)->access_token,
|
||||
]
|
||||
]);
|
||||
echo 'api接口数据错误 - ';
|
||||
echo $dataItem->error_msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 手动添加关键词
|
||||
// 中文一个或者多个空格转换为英文空格
|
||||
$str = preg_replace('/\s+/',' ',$data['keywords']);
|
||||
$att = explode(' ', $str);
|
||||
foreach($att as $v){
|
||||
if ($v !='') {
|
||||
$keywords[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$o = "";
|
||||
foreach ( $post_data as $k => $v )
|
||||
{
|
||||
$o.= "$k=" . urlencode( $v ). "&" ;
|
||||
}
|
||||
$post_data = substr($o,0,-1);
|
||||
$res = $this->request_post($url, $post_data);
|
||||
// 写入token
|
||||
SetArr::name('taoler')->edit([
|
||||
'baidu'=> [
|
||||
'access_token' => json_decode($res)->access_token,
|
||||
]
|
||||
]);
|
||||
echo 'api接口数据错误 - ';
|
||||
echo $dataItem->error_msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
return json(['code'=>0,'data'=>$keywords]);
|
||||
}
|
||||
|
||||
|
@ -409,11 +409,11 @@ class Forum extends AdminController
|
||||
public function edit($id)
|
||||
{
|
||||
$article = Article::find($id);
|
||||
|
||||
if(Request::isAjax()){
|
||||
|
||||
$data = Request::only(['id','cate_id','title','title_color','content','upzip','keywords','description','captcha']);
|
||||
$tagId = input('tagid');
|
||||
$data['user_id'] = 1;
|
||||
|
||||
//调用验证器
|
||||
$validate = new \app\common\validate\Article();
|
||||
$res = $validate->scene('Artadd')->check($data);
|
||||
@ -466,20 +466,8 @@ class Forum extends AdminController
|
||||
return $editRes;
|
||||
}
|
||||
}
|
||||
// 查询标签
|
||||
$tag = $article->tags;
|
||||
$tags = [];
|
||||
if(!is_null($tag)) {
|
||||
$attr = explode(',',$tag);
|
||||
foreach($attr as $key => $v){
|
||||
if ($v !='') {
|
||||
$tags[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
View::assign(['article'=>$article,'tags'=>$tags]);
|
||||
View::assign(['article'=>$article]);
|
||||
//1.查询分类表获取所有分类
|
||||
$cateList = Db::name('cate')->where(['status'=>1,'delete_time'=>0])->order('sort','asc')->cache('catename',3600)->select();
|
||||
|
||||
|
@ -336,7 +336,7 @@ class Set extends AdminController
|
||||
$arr['url_rewrite'][$k] = '';
|
||||
}
|
||||
}
|
||||
if(empty($arr['url_rewrite']['cate_as'])) return json(['code'=>-1,'msg'=>'分类不能为空']);
|
||||
// if(empty($arr['url_rewrite']['cate_as'])) return json(['code'=>-1,'msg'=>'分类不能为空']);
|
||||
|
||||
if(!array_key_exists('url_rewrite',config('taoler'))){
|
||||
$result = SetArr::name('taoler')->add($arr);
|
||||
|
@ -41,7 +41,7 @@ class Tag extends AdminController
|
||||
if(count($tags)) {
|
||||
$arr = ['code'=>0, 'msg'=>'', 'count' => count($tags)];
|
||||
foreach($tags as $k=>$v) {
|
||||
$arr['data'][] = ['id'=>$v['id'],'name'=>$v['name'], 'ename'=>$v['ename'],'time'=>$v['create_time']];
|
||||
$arr['data'][] = ['id'=>$v['id'],'name'=>$v['name'], 'ename'=>$v['ename'], 'keywords'=>$v['keywords'], 'description'=>$v['description'], 'title'=>$v['title'],'time'=>$v['create_time']];
|
||||
}
|
||||
} else {
|
||||
$arr = ['code'=>-1, 'msg'=>'没有数据'];
|
||||
@ -52,7 +52,10 @@ class Tag extends AdminController
|
||||
public function add()
|
||||
{
|
||||
if(Request::isAjax()) {
|
||||
$data = Request::only(['name','ename']);
|
||||
$data = Request::only(['name','ename','keywords','description','title']);
|
||||
// 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串
|
||||
$data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords'])))));
|
||||
|
||||
$tagModel = new TagModel;
|
||||
$res = $tagModel->saveTag($data);
|
||||
if($res == true){
|
||||
@ -67,13 +70,17 @@ class Tag extends AdminController
|
||||
$tagModel = new TagModel;
|
||||
|
||||
if(Request::isAjax()) {
|
||||
$data = Request::only(['name','ename','id']);
|
||||
$data = Request::only(['name','ename','id','keywords','description','title']);
|
||||
// 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串
|
||||
$data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords'])))));
|
||||
|
||||
$res =$tagModel::update($data);
|
||||
if($res == true){
|
||||
return json(['code'=>0,'msg'=>'设置成功']);
|
||||
}
|
||||
}
|
||||
$tag = $tagModel->getTag(input('id'));
|
||||
|
||||
View::assign('tag',$tag);
|
||||
return view();
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ class Upgrade extends AdminController
|
||||
*/
|
||||
public function database_operation($file)
|
||||
{
|
||||
$mysqli = new mysqli('localhost','root','root','test');
|
||||
$mysqli = new \mysqli('localhost','root','root','test');
|
||||
if($mysqli->connect_errno)
|
||||
{
|
||||
return json(['code'=>0,'msg'=>'Connect failed:'.$mysqli->connect_error]);
|
||||
|
@ -21,6 +21,4 @@ Route::get("$detail_as<id>$", '\app\index\controller\Article@detail')
|
||||
])
|
||||
->name('article_detail');
|
||||
|
||||
//tag
|
||||
|
||||
|
||||
|
@ -104,14 +104,14 @@ var artId = "{$article.id}";
|
||||
var addTags = xmSelect.render({
|
||||
el: '#tag',
|
||||
name: 'tagid',
|
||||
layVerify: 'required',
|
||||
layVerify: '',
|
||||
layVerType: 'msg',
|
||||
paging: true,
|
||||
pageSize: 5,
|
||||
data: []
|
||||
});
|
||||
//2.动态赋值
|
||||
$.get("{:url('tag/getArtTag')}",{id:artId},function(res){
|
||||
$.get("{:url('tag/getArticleTag')}",{id:artId},function(res){
|
||||
if(res.code == 0){
|
||||
addTags.setValue(
|
||||
res.data
|
||||
|
@ -339,16 +339,16 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">Index前端</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="index" value="{$index}" class="layui-input">
|
||||
<input type="text" name="index" required lay-verify="required" placeholder="只需填写子域如www" value="{$index}" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">如:www.aieok.com</div>
|
||||
<div class="layui-form-mid layui-word-aux">访问则为www.aieok.com</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">Admin后端</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="admin" value="{$admin}" class="layui-input">
|
||||
<input type="text" name="admin" required lay-verify="required" placeholder="只需填写子域如admin" value="{$admin}" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">如:admin.aieok.com</div>
|
||||
<div class="layui-form-mid layui-word-aux">访问则为admin.aieok.com</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
@ -388,14 +388,14 @@
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-form" wid100 lay-filter="url_rewrite">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">帖子别名</label>
|
||||
<label class="layui-form-label">帖子url字段</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="article_as" required value="{$url_re['article_as']}" class="layui-input">
|
||||
</div>
|
||||
<div id="artdesc" class="layui-form-mid layui-word-aux">如:www.aieok.com/article/1.html</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类别名</label>
|
||||
<label class="layui-form-label">分类url字段</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="cate_as" required value="{$url_re['cate_as']}" class="layui-input">
|
||||
</div>
|
||||
|
@ -25,6 +25,24 @@
|
||||
<input type="text" name="ename" lay-verify="required" placeholder="英文或者拼音别名" autocomplete="off" class="layui-input" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">关键词</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="keywords" lay-verify="required" 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 type="text" name="description" lay-verify="required" placeholder="请输入内容" autocomplete="off" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">seo标题</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="title" lay-verify="required" placeholder="tag标题" autocomplete="off" class="layui-input" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="Tag-submit" id="Tag-submit" value="确认">
|
||||
</div>
|
||||
|
@ -23,6 +23,24 @@
|
||||
<input type="text" name="ename" lay-verify="required" placeholder="英文或者拼音别名" class="layui-input" value="{$tag.ename}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">关键词</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="keywords" lay-verify="required" placeholder="关键词 多个以逗号,隔开" autocomplete="off" class="layui-input" value="{$tag.keywords}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">摘要</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea type="text" name="description" lay-verify="required" placeholder="请输入内容" autocomplete="off" class="layui-textarea">{$tag.description}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">seo标题</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="title" lay-verify="required" placeholder="tag标题" autocomplete="off" class="layui-input" value="{$tag.title}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="text" name="id" class="layui-input layui-hide" value="{$tag.id}">
|
||||
<input type="button" lay-submit lay-filter="Tag-submit" id="Tag-submit" value="确认">
|
||||
|
@ -56,8 +56,11 @@
|
||||
,page: true //开启分页
|
||||
,cols: [[ //表头
|
||||
{type: 'numbers', fixed: 'left'}
|
||||
,{field: 'name', title: '名称', width:200}
|
||||
,{field: 'ename', title: '别名', minWidth:300}
|
||||
,{field: 'name', title: '名称', width:100}
|
||||
,{field: 'ename', title: '别名', width:100}
|
||||
,{field: 'keywords', title: '关键词', width:150}
|
||||
,{field: 'description', title: '摘要', minWidth:300}
|
||||
,{field: 'title', title: 'seo标题', width:200}
|
||||
,{field: 'time', title: '时间', minWidth:100}
|
||||
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
|
||||
]]
|
||||
@ -105,7 +108,7 @@
|
||||
title: '编辑Tag',
|
||||
content: 'edit.html?id='+ id,
|
||||
maxmin: true,
|
||||
area : ['400px' , '300px'],
|
||||
area : ['450px' , '80%'],
|
||||
btn: ['确定', '取消'],
|
||||
yes: function(index, layero){
|
||||
var iframeWindow = window['layui-layer-iframe'+ index]
|
||||
@ -144,7 +147,7 @@
|
||||
title: '添加Tag',
|
||||
content: 'add.html',
|
||||
maxmin: true,
|
||||
area : ['400px' , '300px'],
|
||||
area : ['450px' , '80%'],
|
||||
btn: ['确定', '取消'],
|
||||
yes: function(index, layero){
|
||||
var iframeWindow = window['layui-layer-iframe'+ index]
|
||||
|
@ -324,7 +324,13 @@ class Article extends Model
|
||||
}
|
||||
}
|
||||
|
||||
// 标签列表
|
||||
/**
|
||||
* 标签列表
|
||||
*
|
||||
* @param [type] $tagId 标签id
|
||||
* @param [type] $limit 输出数量
|
||||
* @return void
|
||||
*/
|
||||
public function getAllTags($tagId)
|
||||
{
|
||||
$allTags = $this::hasWhere('taglist',['tag_id'=>$tagId])
|
||||
@ -335,7 +341,6 @@ class Article extends Model
|
||||
}])
|
||||
->where(['status'=>1])
|
||||
->order('pv desc')
|
||||
->limit(50)
|
||||
->append(['url'])
|
||||
->select()
|
||||
->toArray();
|
||||
@ -343,6 +348,60 @@ class Article extends Model
|
||||
return $allTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* 相关文章(标签)
|
||||
* 相同标签文章,不包含自己
|
||||
* @param [type] $tagId
|
||||
* @param [type] $limit
|
||||
* @return void
|
||||
*/
|
||||
public function getRelationTags($tagId,$id,$limit)
|
||||
{
|
||||
$allTags = $this::hasWhere('taglist',['tag_id'=>$tagId])
|
||||
->with(['user' => function($query){
|
||||
$query->field('id,name,nickname,user_img,area_id,vip');
|
||||
},'cate' => function($query){
|
||||
$query->where('delete_time',0)->field('id,catename,ename');
|
||||
}])
|
||||
->where(['status'=>1])
|
||||
// ->where('article.id', '<>', $id)
|
||||
->order('pv desc')
|
||||
->limit($limit)
|
||||
->append(['url'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $allTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上下文
|
||||
*
|
||||
* @param [type] $id 当前文章ID
|
||||
* @param [type] $cid 当前分类ID
|
||||
* @return void
|
||||
*/
|
||||
public function getPrevNextArticle($id,$cid)
|
||||
{
|
||||
//上一篇
|
||||
$previous = $this::field('id,title,cate_id')
|
||||
->where([
|
||||
['id', '<', $id],
|
||||
['cate_id', '=', $cid],
|
||||
['status', '=',1]
|
||||
])->order('id desc')->limit(1)->append(['url'])->select()->toArray();
|
||||
|
||||
//下一篇
|
||||
$next = $this::field('id,title,cate_id')
|
||||
->where([
|
||||
['id', '>', $id],
|
||||
['cate_id', '=', $cid],
|
||||
['status', '=',1]
|
||||
])->limit(1)->append(['url'])->select()->toArray();
|
||||
|
||||
return ['previous' => $previous, 'next' => $next];
|
||||
}
|
||||
|
||||
// 获取url
|
||||
public function getUrlAttr($value,$data)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* @Author: TaoLer <alipay_tao@qq.com>
|
||||
* @Date: 2021-12-06 16:04:50
|
||||
* @LastEditTime: 2022-08-15 13:37:58
|
||||
* @LastEditTime: 2022-08-16 12:18:29
|
||||
* @LastEditors: TaoLer
|
||||
* @Description: 评论模型
|
||||
* @FilePath: \TaoLer\app\common\model\Comment.php
|
||||
@ -83,9 +83,9 @@ class Comment extends Model
|
||||
public function getUserCommentList(int $id) {
|
||||
$userCommList = $this::field('id,user_id,create_time,delete_time,article_id,content')
|
||||
->with(['article' => function(\think\model\Relation $query){
|
||||
$query->withField('id,title,cate_id,delete_time')->where(['status' => 1,'delete_time' => 0]);
|
||||
$query->withField('id,title,cate_id,delete_time')->where(['status' => 1]);
|
||||
}])
|
||||
->where(['user_id' => $id,'status' => 1,'delete_time'=>0])
|
||||
->where(['user_id' => $id,'status' => 1])
|
||||
//->append(['url'])
|
||||
->order(['create_time' => 'desc'])
|
||||
//->cache(3600)
|
||||
|
@ -2,17 +2,16 @@
|
||||
/*
|
||||
* @Author: TaoLer <317927823@qq.com>
|
||||
* @Date: 2021-12-06 16:04:50
|
||||
* @LastEditTime: 2022-07-27 21:25:14
|
||||
* @LastEditTime: 2022-08-16 12:01:52
|
||||
* @LastEditors: TaoLer
|
||||
* @Description: 优化版
|
||||
* @FilePath: \github\TaoLer\app\common\model\MessageTo.php
|
||||
* @FilePath: \TaoLer\app\common\model\MessageTo.php
|
||||
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
||||
*/
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
use think\Db;
|
||||
|
||||
class MessageTo extends Model
|
||||
{
|
||||
@ -34,9 +33,11 @@ class MessageTo extends Model
|
||||
//得到消息数
|
||||
public function getMsgNum($id)
|
||||
{
|
||||
$msg = $this::field('id')->where(['receve_id'=>$id,'is_read'=>0])->column('id');
|
||||
if(!is_null($msg)) {
|
||||
return count($msg);
|
||||
$msg = $this::where(['receve_id'=>$id,'is_read'=>0])->column('id');
|
||||
if($num = count($msg)) {
|
||||
return $num;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,18 +2,15 @@
|
||||
/*
|
||||
* @Author: TaoLer <317927823@qq.com>
|
||||
* @Date: 2021-12-06 16:04:50
|
||||
* @LastEditTime: 2022-08-14 07:32:32
|
||||
* @LastEditTime: 2022-08-16 12:20:49
|
||||
* @LastEditors: TaoLer
|
||||
* @Description: 签到模型
|
||||
* @FilePath: \github\TaoLer\app\common\model\Sign.php
|
||||
* @FilePath: \TaoLer\app\common\model\Sign.php
|
||||
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
||||
*/
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
use think\Db;
|
||||
use think\facade\Session;
|
||||
|
||||
class Sign extends Model
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* @Author: TaoLer <alipay_tao@qq.com>
|
||||
* @Date: 2021-12-06 16:04:50
|
||||
* @LastEditTime: 2022-06-28 13:54:55
|
||||
* @LastEditTime: 2022-08-16 12:21:14
|
||||
* @LastEditors: TaoLer
|
||||
* @Description: 链接设置
|
||||
* @FilePath: \TaoLer\app\common\model\Slider.php
|
||||
@ -43,7 +43,7 @@ class Slider extends Model
|
||||
{
|
||||
$sliders = Cache::get('slider'.$type);
|
||||
if(!$sliders){
|
||||
$sliders = $this::where(['slid_status'=>1,'delete_time'=>0,'slid_type'=>$type])->whereTime('slid_over','>=',time())->select()->toArray();
|
||||
$sliders = $this::where(['slid_status'=>1,'slid_type'=>$type])->whereTime('slid_over','>=',time())->select()->toArray();
|
||||
Cache::tag('tagSlider'.$type)->set('slider'.$type,$sliders,3600);
|
||||
}
|
||||
return $sliders;
|
||||
|
@ -91,22 +91,29 @@ class Article extends BaseController
|
||||
//赞列表
|
||||
$userZanList = [];
|
||||
$userZan = UserZan::where(['article_id'=>$id,'type'=>1])->select();
|
||||
foreach($userZan as $v){
|
||||
$userZanList[] = ['userImg'=>$v->user->user_img,'name'=>$v->user->name];
|
||||
if(count($userZan)) {
|
||||
foreach($userZan as $v){
|
||||
$userZanList[] = ['userImg'=>$v->user->user_img,'name'=>$v->user->name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 设置内容的tag内链
|
||||
$artDetail['content'] = $this->setArtTagLink($artDetail['content']);
|
||||
|
||||
// 标签
|
||||
$tags = [];
|
||||
$relationArticle = [];
|
||||
$artTags = Db::name('taglist')->where('article_id',$id)->select();
|
||||
// halt($artTags);
|
||||
foreach($artTags as $v) {
|
||||
$tag = Db::name('tag')->find($v['tag_id']);
|
||||
$tags[] = ['name'=>$tag['name'],'url'=> (string) url('tag_list',['ename'=>$tag['ename']])];
|
||||
}
|
||||
|
||||
if(count($artTags)) {
|
||||
foreach($artTags as $v) {
|
||||
$tag = Db::name('tag')->find($v['tag_id']);
|
||||
if(!is_null($tag))
|
||||
$tags[] = ['name'=>$tag['name'],'url'=> (string) url('tag_list',['ename'=>$tag['ename']])];
|
||||
}
|
||||
//相关帖子
|
||||
$relationArticle = $article->getRelationTags($artTags[0]['tag_id'],$id,5);
|
||||
}
|
||||
|
||||
$tpl = Db::name('cate')->where('id', $artDetail['cate_id'])->value('detpl');
|
||||
$download = $artDetail['upzip'] ? download($artDetail['upzip'],'file') : '';
|
||||
@ -115,6 +122,19 @@ class Article extends BaseController
|
||||
Db::name('article')->where('id',$id)->inc('pv')->update();
|
||||
$pv = Db::name('article')->field('pv')->where('id',$id)->value('pv');
|
||||
|
||||
//上一篇下一篇
|
||||
$upDownArt = $article->getPrevNextArticle($id,$artDetail['cate_id']);
|
||||
if(empty($upDownArt['previous'][0])) {
|
||||
$previous = '前面已经没有了!';
|
||||
} else {
|
||||
$previous = '<a href="' . $upDownArt['previous'][0]['url'] . '" rel="prev">' . $upDownArt['previous'][0]['title'] . '</a>';
|
||||
}
|
||||
if(empty($upDownArt['next'][0])) {
|
||||
$next = '已经是最新的内容了!';
|
||||
} else {
|
||||
$next = '<a href="' . $upDownArt['next'][0]['url'] . '" rel="prev">' . $upDownArt['next'][0]['title'] . '</a>';
|
||||
}
|
||||
|
||||
//评论
|
||||
$comments = $this->getComments($id, $page);
|
||||
//最新评论时间
|
||||
@ -128,7 +148,7 @@ class Article extends BaseController
|
||||
//分类钻展赞助
|
||||
$ad_comm = $ad->getSliderList(7);
|
||||
//push
|
||||
$push_js = Db::name('push_jscode')->where(['delete_time'=>0])->cache(true)->select();
|
||||
$push_js = Db::name('push_jscode')->where(['delete_time'=>0,'type'=>1])->cache(true)->select();
|
||||
|
||||
View::assign([
|
||||
'article' => $artDetail,
|
||||
@ -137,6 +157,9 @@ class Article extends BaseController
|
||||
'ad_art' => $ad_artImg,
|
||||
'ad_comm' => $ad_comm,
|
||||
'tags' => $tags,
|
||||
'relationArticle' => $relationArticle,
|
||||
'previous' => $previous,
|
||||
'next' => $next,
|
||||
'page' => $page,
|
||||
'comments' => $comments,
|
||||
'push_js' => $push_js,
|
||||
@ -310,7 +333,6 @@ class Article extends BaseController
|
||||
if(Request::isAjax()){
|
||||
$data = Request::only(['id','cate_id','title','title_color','user_id','content','upzip','keywords','description','captcha']);
|
||||
$tagId = input('tagid');
|
||||
|
||||
|
||||
// 验证码
|
||||
if(Config::get('taoler.config.post_captcha') == 1)
|
||||
@ -372,20 +394,8 @@ class Article extends BaseController
|
||||
return $editRes;
|
||||
}
|
||||
}
|
||||
// 查询标签
|
||||
$tag = $article->tags;
|
||||
$tags = [];
|
||||
if(!is_null($tag)) {
|
||||
$attr = explode(',',$tag);
|
||||
foreach($attr as $key => $v){
|
||||
if ($v !='') {
|
||||
$tags[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
View::assign(['article'=>$article,'tags'=>$tags,'jspage'=>'jie']);
|
||||
View::assign(['article'=>$article,'jspage'=>'jie']);
|
||||
// 编辑多模板支持
|
||||
$tpl = Db::name('cate')->where('id', $article['cate_id'])->value('detpl');
|
||||
$appName = $this->app->http->getName();
|
||||
@ -471,7 +481,7 @@ class Article extends BaseController
|
||||
*/
|
||||
public function keywords()
|
||||
{
|
||||
$data = Request::only(['keywords','flag']);
|
||||
$data = Request::only(['flag','keywords','content']);
|
||||
return $this->setKeywords($data);
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
/*
|
||||
* @Author: TaoLer <317927823@qq.com>
|
||||
* @Date: 2021-12-06 16:04:50
|
||||
* @LastEditTime: 2022-07-27 21:29:43
|
||||
* @LastEditTime: 2022-08-16 12:12:11
|
||||
* @LastEditors: TaoLer
|
||||
* @Description: 优化版
|
||||
* @FilePath: \github\TaoLer\app\index\controller\Message.php
|
||||
* @FilePath: \TaoLer\app\index\controller\Message.php
|
||||
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
||||
*/
|
||||
namespace app\index\controller;
|
||||
@ -25,10 +25,10 @@ class Message extends BaseController
|
||||
{
|
||||
$messgeto = new MessageTo();
|
||||
$num = $messgeto->getMsgNum($this->uid);
|
||||
if(!is_null($num)){
|
||||
if($num){
|
||||
$res = ['status' =>0,'count' => $num, 'msg' => 'ok'];
|
||||
} else {
|
||||
$res = ['status' =>-1,'count' => 0, 'msg' => 'message error'];
|
||||
$res = ['status' =>0,'count' => 0, 'msg' => 'no message'];
|
||||
}
|
||||
return json($res);
|
||||
}
|
||||
@ -37,18 +37,18 @@ class Message extends BaseController
|
||||
public function find()
|
||||
{
|
||||
$msg = MessageApi::receveMsg($this->uid);
|
||||
$count = $msg->count();
|
||||
|
||||
$count = count($msg);
|
||||
$res = [];
|
||||
if($count){
|
||||
$res = ['status'=>0,'msg'=>'','count'=>$count];
|
||||
foreach ($msg as $k => $v){
|
||||
$data = ['id'=>$v['id'],'name'=>$v['name'],'title'=>$v['title'],'content'=>$v['content'],'time'=>date("Y-m-d H:i",$v['create_time']),'link'=>$v['link'],'read'=>$v['is_read'] ? '已读':'未读','type'=>$v['message_type']];
|
||||
$res['rows'][] = $data;
|
||||
$res['rows'][] = ['id'=>$v['id'],'name'=>$v['name'],'title'=>$v['title'],'content'=>$v['content'],'time'=>date("Y-m-d H:i",$v['create_time']),'link'=>$v['link'],'read'=>$v['is_read'] ? '已读':'未读','type'=>$v['message_type']];
|
||||
|
||||
}
|
||||
} else {
|
||||
$res = ['status'=>-1,'msg'=>'message find error','rows'=>''];;
|
||||
$res = ['status'=>0,'msg'=>'message find error','rows'=>''];;
|
||||
}
|
||||
//var_dump($res);
|
||||
return json($res);
|
||||
}
|
||||
|
||||
@ -57,9 +57,12 @@ class Message extends BaseController
|
||||
{
|
||||
$id =input('id');
|
||||
if($id){
|
||||
$msg = MessageTo::field('id,message_id')->with(['messages' => function($query){
|
||||
$query->where('delete_time',0)->field('id,content');
|
||||
}])->where('id',$id)->find();
|
||||
$msg = MessageTo::field('id,message_id')
|
||||
->with(['messages' => function($query){
|
||||
$query->field('id,content');
|
||||
}])
|
||||
->where('id',$id)
|
||||
->find();
|
||||
//改变读状态
|
||||
if($msg->is_read == 0){
|
||||
$result = $msg->update(['id'=>$id,'is_read'=>1]);
|
||||
|
@ -31,9 +31,9 @@ class Tag extends BaseController
|
||||
{
|
||||
//
|
||||
$tagEname = Request::param('ename');
|
||||
$tagId = Db::name('tag')->where('ename',$tagEname)->value('id');
|
||||
$tag = Db::name('tag')->where('ename',$tagEname)->find();
|
||||
|
||||
$artList = Article::getAllTags($tagId);
|
||||
$artList = Article::getAllTags($tag['id']);
|
||||
$slider = new Slider();
|
||||
//首页右栏
|
||||
$ad_comm = $slider->getSliderList(2);
|
||||
@ -41,7 +41,7 @@ class Tag extends BaseController
|
||||
$artHot = Article::getArtHot(10);
|
||||
|
||||
$assign = [
|
||||
'tag'=>$tagEname,
|
||||
'tag'=>$tag,
|
||||
'artList'=>$artList,
|
||||
'ad_comm'=>$ad_comm,
|
||||
'artHot'=>$artHot,
|
||||
|
@ -88,6 +88,8 @@ return [
|
||||
'special column' => '选择专栏',
|
||||
'tags' => '标签',
|
||||
'add tags' => '添加标签',
|
||||
'add keywords' => '添加关键词',
|
||||
'description' => '描述',
|
||||
|
||||
//Sign in/up
|
||||
'username' => '用户',
|
||||
@ -107,7 +109,7 @@ return [
|
||||
'register now' => '立即注册',
|
||||
'mail/username/mobile' => '邮箱/用户名/手机号',
|
||||
'6-16 characters' => '6-16 字符',
|
||||
'strong type encryption' => '经过强类型加密',
|
||||
'strong type encryption' => '强类型加密',
|
||||
'it cannot be changed' => '不能更改',
|
||||
'the only way to get back your password' => '找回密码唯一途径',
|
||||
'please input the password' => '请输入密码',
|
||||
|
@ -489,7 +489,7 @@ CREATE TABLE `tao_system` (
|
||||
`uptype` varchar(255) NOT NULL DEFAULT '0' COMMENT '上传文件类型',
|
||||
`copyright` varchar(100) NOT NULL DEFAULT '' COMMENT '版权',
|
||||
`keywords` tinytext NOT NULL COMMENT '网站关键字',
|
||||
`descript` tinytext NOT NULL COMMENT '网站描述',
|
||||
`descript` text NOT NULL COMMENT '网站描述',
|
||||
`state` tinytext CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '网站声明',
|
||||
`is_open` enum('0','1') NOT NULL DEFAULT '1' COMMENT '是否开启站点1开启0关闭',
|
||||
`is_comment` enum('0','1') NOT NULL DEFAULT '1' COMMENT '是否开启评论1开启0关闭',
|
||||
@ -519,6 +519,9 @@ CREATE TABLE `tao_tag` (
|
||||
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'tag自增id',
|
||||
`name` varchar(20) NOT NULL COMMENT '名称',
|
||||
`ename` varchar(20) NOT NULL COMMENT '英文名',
|
||||
`keywords` varchar(255) NOT NULL COMMENT '关键词',
|
||||
`description` text NOT NULL COMMENT '摘要',
|
||||
`title` varchar(100) NOT NULL COMMENT '标签',
|
||||
`create_time` int NOT NULL COMMENT '创建时间',
|
||||
`update_time` int NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: TaoLer <317927823@qq.com>
|
||||
* @Date: 2021-12-06 16:04:50
|
||||
* @LastEditTime: 2022-08-16 12:09:28
|
||||
* @LastEditors: TaoLer
|
||||
* @Description: 优化版
|
||||
* @FilePath: \TaoLer\extend\taoler\com\Message.php
|
||||
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
||||
*/
|
||||
|
||||
namespace taoler\com;
|
||||
|
||||
@ -45,7 +54,7 @@ class Message
|
||||
*/
|
||||
public static function receveMsg($uid)
|
||||
{
|
||||
$msg = Db::name('message_to')
|
||||
return Db::name('message_to')
|
||||
->alias('t')
|
||||
->join('message m','t.message_id = m.id' )
|
||||
->join('user u','t.send_id = u.id')
|
||||
@ -53,8 +62,7 @@ class Message
|
||||
->where('t.receve_id',$uid)
|
||||
->where(['t.delete_time'=>0])
|
||||
->order(['t.is_read'=>'asc','t.create_time'=>'desc'])
|
||||
->select();
|
||||
return $msg;
|
||||
->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,10 +75,10 @@ class Message
|
||||
public static function insertMsg(int $uid)
|
||||
{
|
||||
//得到所有系统消息
|
||||
$sysmsg = MessageModel::where(['type'=>0,'delete_time'=>0])->select();
|
||||
$sysmsg = MessageModel::where(['type'=>0])->select();
|
||||
foreach($sysmsg as $smg){
|
||||
//检验通知ID是否被写入个人收件箱
|
||||
$msgId = Db::name('message_to')->where('message_id',$smg['id'])->find();
|
||||
$msgId = Db::name('message_to')->where(['message_id'=>$smg['id'],'delete_time'=>0])->find();
|
||||
if(!$msgId){
|
||||
$result = MessageTo::create(['send_id'=>$smg['user_id'],'receve_id'=>$uid,'message_id'=>$smg['id'],'message_type'=>$smg['type']]);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="layui-row layui-col-space15 layui-form-item layui-hide" id="LAY_quiz">
|
||||
<!-- <div class="layui-row layui-col-space15 layui-form-item layui-hide" id="LAY_quiz">
|
||||
<div class="layui-col-md3">
|
||||
<label class="layui-form-label">所属产品</label>
|
||||
<div class="layui-input-block">
|
||||
@ -70,41 +70,34 @@
|
||||
<input type="text" id="L_browser" value="" name="browser" placeholder="浏览器名称及版本,如:IE 11" autocomplete="off" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<div class="layui-input-block">
|
||||
<textarea
|
||||
id="L_content"
|
||||
name="content"
|
||||
required
|
||||
lay-verify="required"
|
||||
placeholder="{:lang('please input the content')}"
|
||||
class="layui-textarea fly-editor"
|
||||
style="height: 260px">
|
||||
</textarea>
|
||||
<textarea id="L_content" name="content" required lay-verify="required" placeholder="{:lang('please input the content')}" class="layui-textarea fly-editor"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">{:lang('enclosure')}</label>
|
||||
<div class="layui-input-inline" style="width: 190px">
|
||||
<input type="text" class="layui-input" name="upzip" value="" placeholder="zip,image文件" title="上传附件" />
|
||||
<input type="text" class="layui-input" name="upzip" value="" placeholder="zip,image" title="上传附件" />
|
||||
</div>
|
||||
<button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>{:lang('uploads')}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{:lang('描述')}</label>
|
||||
{//描述}
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">{:lang('description')}</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="description" class="layui-textarea" placeholder="SEO描述"></textarea>
|
||||
<textarea name="description" class="layui-textarea" placeholder="SEO {:lang('description')}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
{//关键词}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{:lang('添加关键词')}</label>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">{:lang('add keywords')}</label>
|
||||
<div class="layui-input-block">
|
||||
<!-- <input type="text" class="layui-input" name="" id="inputTags" value="" placeholder="多个回车添加" title="添加关键词" /> -->
|
||||
<input type="text" class="layui-input" name="keywords" value="" placeholder="多个用逗号隔开" title="添加关键词" />
|
||||
<input type="text" class="layui-input" name="keywords" value="" placeholder="多个用逗号隔开" title="{:lang('add keywords')}" />
|
||||
</div>
|
||||
</div>
|
||||
{//tag}
|
||||
@ -154,19 +147,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="public/menu" /} {/block}
|
||||
{include file="public/menu" /}
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
{:hook('taonyeditor')}
|
||||
<script src="/static/xm-select.js"></script>
|
||||
<script>
|
||||
layui.use(["fly", "plyr",'inputTags'], function () {
|
||||
layui.use(["fly", "plyr"], function () {
|
||||
var $ = layui.jquery,
|
||||
fly = layui.fly,
|
||||
form = layui.form,
|
||||
colorpicker = layui.colorpicker,
|
||||
upload = layui.upload,
|
||||
plyr = layui.plyr;
|
||||
|
||||
//获取百度标签标志,tag或者word;
|
||||
var flag = 'word';
|
||||
|
||||
|
||||
//如果你是采用模版自带的编辑器,你需要开启以下语句来解析。
|
||||
@ -178,26 +175,13 @@
|
||||
var othis = $(this), html = othis.html();
|
||||
othis.attr(fly.content(html));
|
||||
})
|
||||
}
|
||||
|
||||
var inputTags = layui.inputTags;
|
||||
//关键词
|
||||
inputTags.render({
|
||||
elem:'#inputTags',
|
||||
content: [],
|
||||
aldaBtn: false,
|
||||
done: function(value){
|
||||
//console.log(value)
|
||||
var keywords = this.content.join(',');
|
||||
$("input[name='keywords']").val(keywords);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//1.渲染标签
|
||||
var addTags = xmSelect.render({
|
||||
el: '#tag',
|
||||
name: 'tagid',
|
||||
layVerify: 'required',
|
||||
layVerify: '',
|
||||
layVerType: 'msg',
|
||||
paging: true,
|
||||
pageSize: 5,
|
||||
@ -218,77 +202,80 @@
|
||||
if (conf !== "1") {
|
||||
$("#L_title").on("blur", function () {
|
||||
var title = $(this).val();
|
||||
var flag = "on";
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "{:url('article/keywords')}",
|
||||
data: { keywords: keywords, flag: flag },
|
||||
daType: "json",
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
$("input[name='keywords']").val(res.data);
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 百度词条
|
||||
var baidu_title_switch = "{:config('taoler.config.baidu_title_switch')}";
|
||||
if(baidu_title_switch == 1) {
|
||||
$("#L_title").bind('input propertychange',function () {
|
||||
var title = $(this).val();
|
||||
var str = '';
|
||||
if(title.length > 0 ) {
|
||||
$.post("{:url('article/getWordList')}",{title:title},function(res){
|
||||
// 动态生成ur>li内容
|
||||
if (res.code == 0) {
|
||||
// 显示动态框
|
||||
$(".bdsug").removeClass('layui-hide');
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
//str += '<li data-key=' + res.data[i].q + '><b>' + res.data[i].q.replace(title,'') + '</b></li>';
|
||||
str += '<li data-key=' + res.data[i].q + '><b>' + res.data[i].q + '</b></li>';
|
||||
}
|
||||
// 清空ul并追加li
|
||||
$('.wordlist').empty().append(str);
|
||||
// 点击李获取li值并复制给#L_title input的value
|
||||
$(".bdsug li").on('click',function(){
|
||||
var word = $(this).attr('data-key');
|
||||
var words = title + '(' + word + ')';
|
||||
$("#L_title").val(words);
|
||||
// 关闭动态框
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
});
|
||||
} else {
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
}
|
||||
var content = $("#L_content").val();
|
||||
getBdiduWords(flag,title,content);
|
||||
});
|
||||
}
|
||||
|
||||
// 从详情页自动调用端口过滤,获取描述信息
|
||||
$("#L_content").mouseleave(function() {
|
||||
var content = $(this).val().replace(/[\r\n]/g,"").replace(/\n/g, '').replace(/\s/g, '').replace(/\t/g, '');
|
||||
var title = $("#L_title").val();
|
||||
$.post("{:url('article/getDescription')}", { content: content }, function(data){
|
||||
if (data.code == 0) {
|
||||
$('[name="description"]').val(data.data);
|
||||
}
|
||||
});
|
||||
getBdiduWords(flag,title,content);
|
||||
});
|
||||
|
||||
// 获取百度分词接口的关键词
|
||||
function getBdiduWords(flag,title,content) {
|
||||
console.log(flag,title,content)
|
||||
$.post("{:url('article/keywords')}",{ keywords: title, content:content, flag: flag }, function (res) {
|
||||
if (res.code == 0) {
|
||||
$("input[name='keywords']").val(res.data.join(','));
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// 改变标题颜色
|
||||
colorpicker.render({
|
||||
elem: "#color",
|
||||
color: "#393d49",
|
||||
predefine: true, // 开启预定义颜色
|
||||
done: function (color) {
|
||||
//譬如你可以在回调中把得到的 color 赋值给表单
|
||||
$("#L_title_color").val(color);
|
||||
$("#L_title").css("color", color);
|
||||
},
|
||||
// 百度词条
|
||||
(function(){
|
||||
var baidu_title_switch = "{:config('taoler.config.baidu_title_switch')}";
|
||||
if(baidu_title_switch == 1) {
|
||||
$("#L_title").bind('input propertychange',function () {
|
||||
var title = $(this).val();
|
||||
var str = '';
|
||||
if(title.length > 0 ) {
|
||||
$.post("{:url('article/getWordList')}",{title:title},function(res){
|
||||
// 动态生成ur>li内容
|
||||
if (res.code == 0) {
|
||||
// 显示动态框
|
||||
$(".bdsug").removeClass('layui-hide');
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
//str += '<li data-key=' + res.data[i].q + '><b>' + res.data[i].q.replace(title,'') + '</b></li>';
|
||||
str += '<li data-key=' + res.data[i].q + '><b>' + res.data[i].q + '</b></li>';
|
||||
}
|
||||
// 清空ul并追加li
|
||||
$('.wordlist').empty().append(str);
|
||||
// 点击李获取li值并复制给#L_title input的value
|
||||
$(".bdsug li").on('click',function(){
|
||||
var word = $(this).attr('data-key');
|
||||
var words = title + '(' + word + ')';
|
||||
$("#L_title").val(words);
|
||||
// 关闭动态框
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
});
|
||||
} else {
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
}())
|
||||
|
||||
//关闭百度词条
|
||||
$(function(){
|
||||
$(".bdsug").mouseleave(function(){
|
||||
$(this).addClass('layui-hide');
|
||||
// $("#LAY_ucm").click(function(){
|
||||
// $(this).addClass('layui-hide');
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
// 发布文章
|
||||
@ -316,6 +303,18 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
// 改变标题颜色
|
||||
colorpicker.render({
|
||||
elem: "#color",
|
||||
color: "#393d49",
|
||||
predefine: true, // 开启预定义颜色
|
||||
done: function (color) {
|
||||
//譬如你可以在回调中把得到的 color 赋值给表单
|
||||
$("#L_title_color").val(color);
|
||||
$("#L_title").css("color", color);
|
||||
},
|
||||
});
|
||||
|
||||
//上传附件
|
||||
upload.render({
|
||||
elem: "#zip-button",
|
||||
|
@ -46,11 +46,13 @@
|
||||
<div class="detail-body-wenda photos" id="content">{$article.content|raw}</div>
|
||||
|
||||
<div style="margin-top: 25px">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div>
|
||||
{notempty name="tags"}
|
||||
<div style="margin-top: 15px">标签
|
||||
{volist name="tags" id="vo" }
|
||||
<a href="{$vo.url}"><span class="layui-btn layui-btn-xs layui-btn-normal layui-btn-radius">{$vo.name}</span></a>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
<div style="margin: 20px 0px 15px 0px; color: rgb(130, 125, 125)">
|
||||
<p>{$sysInfo.state}</p>
|
||||
</div>
|
||||
|
@ -100,20 +100,19 @@
|
||||
<button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">{:lang('描述')}</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="description" class="layui-textarea" placeholder="SEO描述">{$article.description}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
{//关键词}
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">{:lang('添加关键词')}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" class="layui-input" name="keywords" value="{$article.keywords}" placeholder="多个英文逗号隔开" title="添加关键词" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{//tag}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{:lang('add tags')}</label>
|
||||
@ -121,7 +120,6 @@
|
||||
<div id="tag"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if config('taoler.config.post_captcha') == 1}
|
||||
<div class="layui-form-item">
|
||||
<label for="L_vercode" class="layui-form-label">{:lang('captcha')}</label>
|
||||
@ -156,7 +154,7 @@ var artId = "{$article.id}";
|
||||
var addTags = xmSelect.render({
|
||||
el: '#tag',
|
||||
name: 'tagid',
|
||||
layVerify: 'required',
|
||||
layVerify: '',
|
||||
layVerType: 'msg',
|
||||
paging: true,
|
||||
pageSize: 5,
|
||||
@ -189,6 +187,9 @@ $.get("{:url('get_all_tag')}",function(res){
|
||||
,upload = layui.upload
|
||||
,plyr = layui.plyr;
|
||||
|
||||
//获取百度标签标志,tag或者word;
|
||||
var flag = 'word';
|
||||
|
||||
|
||||
//如果你是采用模版自带的编辑器,你需要开启以下语句来解析。
|
||||
var taonystatus = "{:hook('taonystatus')}";
|
||||
@ -201,56 +202,88 @@ $.get("{:url('get_all_tag')}",function(res){
|
||||
})
|
||||
}
|
||||
|
||||
//预定义颜色项
|
||||
colorpicker.render({
|
||||
elem: '#color'
|
||||
,color: "{$article.title_color ?? '#333'}"
|
||||
,predefine: true // 开启预定义颜色
|
||||
,done: function(color){
|
||||
//console.log(color);
|
||||
//譬如你可以在回调中把得到的 color 赋值给表单
|
||||
$('#L_title_color').val(color);
|
||||
//改变标题颜色
|
||||
$('#L_title').css("color", color);
|
||||
}
|
||||
});
|
||||
|
||||
// 获取描述的内容
|
||||
$("#L_content").bind('input propertychange', function(){
|
||||
var content = $(this).val()
|
||||
$.ajax({
|
||||
type:"post",
|
||||
url:"{:url('article/getDescription')}",
|
||||
data:{"content":content},
|
||||
daType:"json",
|
||||
success:function (data){
|
||||
if (data.code == 0) {
|
||||
$('[name="description"]').val(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
})
|
||||
|
||||
// 获取百度获取的关键词内容
|
||||
// 通过标题内容自动获取tag的内容
|
||||
var conf = "{:empty(config('taoler.baidu.client_id'))}";
|
||||
if(conf !== '1'){
|
||||
$("#L_title").on('blur', function(){
|
||||
var title = $(this).val();
|
||||
var flag = 'on';
|
||||
$.ajax({
|
||||
type:"post",
|
||||
url:"{:url('article/keywords')}",
|
||||
data:{"keywords":keywords,"flag":flag},
|
||||
daType:"json",
|
||||
success:function (data){
|
||||
$("input[name='keywords']").val(res.data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
var content = $("#L_content").val();
|
||||
getBdiduWords(flag,title,content);
|
||||
})
|
||||
}
|
||||
|
||||
// 从详情页自动调用端口过滤,获取描述信息
|
||||
$("#L_content").bind('input propertychange', function(){
|
||||
var content = $(this).val()
|
||||
var title = $("#L_title").val();
|
||||
$.post("{:url('article/getDescription')}", { content: content }, function(data){
|
||||
if (data.code == 0) {
|
||||
$('[name="description"]').val(data.data);
|
||||
}
|
||||
});
|
||||
getBdiduWords(flag,title,content);
|
||||
})
|
||||
|
||||
// 获取百度分词接口的关键词
|
||||
function getBdiduWords(flag,title,content) {
|
||||
console.log(flag,title,content)
|
||||
$.post("{:url('article/keywords')}",{ keywords: title, content:content, flag: flag }, function (res) {
|
||||
if (res.code == 0) {
|
||||
console.log(res.data)
|
||||
$("input[name='keywords']").val(res.data.join(','));
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// 百度词条
|
||||
(function(){
|
||||
var baidu_title_switch = "{:config('taoler.config.baidu_title_switch')}";
|
||||
if(baidu_title_switch == 1) {
|
||||
$("#L_title").bind('input propertychange',function () {
|
||||
var title = $(this).val();
|
||||
var str = '';
|
||||
if(title.length > 0 ) {
|
||||
$.post("{:url('article/getWordList')}",{title:title},function(res){
|
||||
// 动态生成ur>li内容
|
||||
if (res.code == 0) {
|
||||
// 显示动态框
|
||||
$(".bdsug").removeClass('layui-hide');
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
//str += '<li data-key=' + res.data[i].q + '><b>' + res.data[i].q.replace(title,'') + '</b></li>';
|
||||
str += '<li data-key=' + res.data[i].q + '><b>' + res.data[i].q + '</b></li>';
|
||||
}
|
||||
// 清空ul并追加li
|
||||
$('.wordlist').empty().append(str);
|
||||
// 点击李获取li值并复制给#L_title input的value
|
||||
$(".bdsug li").on('click',function(){
|
||||
var word = $(this).attr('data-key');
|
||||
var words = title + '(' + word + ')';
|
||||
$("#L_title").val(words);
|
||||
// 关闭动态框
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
});
|
||||
} else {
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(".bdsug").addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
}())
|
||||
|
||||
//关闭百度词条
|
||||
$(function(){
|
||||
$(".bdsug").mouseleave(function(){
|
||||
$(this).addClass('layui-hide');
|
||||
// $("#LAY_ucm").click(function(){
|
||||
// $(this).addClass('layui-hide');
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
//编辑文章
|
||||
form.on('submit(article-edit)', function(data){
|
||||
var field = data.field;
|
||||
@ -273,6 +306,20 @@ $.get("{:url('get_all_tag')}",function(res){
|
||||
return false;
|
||||
});
|
||||
|
||||
//预定义颜色项
|
||||
colorpicker.render({
|
||||
elem: '#color'
|
||||
,color: "{$article.title_color ?? '#333'}"
|
||||
,predefine: true // 开启预定义颜色
|
||||
,done: function(color){
|
||||
//console.log(color);
|
||||
//譬如你可以在回调中把得到的 color 赋值给表单
|
||||
$('#L_title_color').val(color);
|
||||
//改变标题颜色
|
||||
$('#L_title').css("color", color);
|
||||
}
|
||||
});
|
||||
|
||||
//指定允许上传的文件类型
|
||||
upload.render({
|
||||
elem: '#zip-button'
|
||||
|
@ -33,11 +33,13 @@
|
||||
{// 内容}
|
||||
<div class="detail-body photos" style="font-size: 18px;line-height: 200%;" id="content">{$article.content|raw}</div>
|
||||
<div style="margin-top: 25px;">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div>
|
||||
{notempty name="tags"}
|
||||
<div style="margin-top: 15px">标签
|
||||
{volist name="tags" id="vo" }
|
||||
<a href="{$vo.url}"><span class="layui-btn layui-btn-xs layui-btn-normal layui-btn-radius">{$vo.name}</span></a>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
<div style="margin: 20px 0px 15px 0px; color: rgb(130, 125, 125);">
|
||||
<p>{$sysInfo.state}</p>
|
||||
</div>
|
||||
|
@ -55,11 +55,13 @@
|
||||
{// 内容}
|
||||
<div class="detail-body photos mce-content-body" id="content">{$article.content|raw}</div>
|
||||
<div style="margin-top: 25px;">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div>
|
||||
{notempty name="tags"}
|
||||
<div style="margin-top: 15px">标签
|
||||
{volist name="tags" id="vo" }
|
||||
<a href="{$vo.url}"><span class="layui-btn layui-btn-xs layui-btn-normal layui-btn-radius">{$vo.name}</span></a>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
<div style="margin: 20px 0px 15px 0px; color: rgb(130, 125, 125);">
|
||||
<p>{$sysInfo.state}</p>
|
||||
</div>
|
||||
|
@ -37,7 +37,7 @@
|
||||
<li class="layui-nav-item"><a class="iconfont icon-touxiang" href="{:url('user_login')}"></a></li>
|
||||
<li class="layui-nav-item layui-hide-xs"><a href="{:url('user_login')}">{:lang('login')}</a></li>
|
||||
<li class="layui-nav-item layui-hide-xs"><a href="{:url('user_reg')}">{:lang('register')}</a></li>
|
||||
<li class="layui-nav-item layui-hide-xs" >
|
||||
<li class="layui-nav-item layui-hide-xs layui-hide">
|
||||
<select name="language" style="width:50px;" lay-filter="language" lay-verify="" id="language">
|
||||
<option value="cn" {if cookie('think_lang') == 'zh-cn'} selected {/if} >{:lang('chinese')}</option>
|
||||
<option value="tw" {if cookie('think_lang') == 'zh-tw'} selected {/if} >{:lang('tChinese')}</option>
|
||||
|
@ -8,19 +8,18 @@
|
||||
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
|
||||
-->
|
||||
{extend name="public/base" /}
|
||||
{block name="title"}{$tag} - {$sysInfo.webname}{/block}
|
||||
{block name="keywords"}{$tag},{$sysInfo.keywords}{/block}
|
||||
{block name="description"}{$tag},{$sysInfo.descript}{/block}
|
||||
{block name="ogtitle"}<meta property="og:title" content="{$tag} - {$sysInfo.webtitle}" />{/block}
|
||||
{block name="ogdescription"}<meta property="og:description" content="{$tag},{$sysInfo.descript}" />{/block}
|
||||
{block name="ogimage"}<meta property="og:image" content="{$Request.domain}{$sysInfo.logo}" />{/block}
|
||||
{block name="title"}{$tag.title} - {$sysInfo.webname}{/block}
|
||||
{block name="keywords"}{$tag.keywords}{/block}
|
||||
{block name="description"}{$tag.description}{/block}
|
||||
{block name="ogtitle"}<meta property="og:title" content="{$tag.title} - {$sysInfo.webtitle}" />{/block}
|
||||
{block name="ogdescription"}<meta property="og:description" content="{$tag.description}" />{/block}
|
||||
{block name="column"}{include file="public/column" /}{/block}
|
||||
{block name="content"}
|
||||
<div class="layui-container">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-md8">
|
||||
<div class="fly-panel" style="margin-bottom: 0;">
|
||||
<div class="fly-panel-title fly-filter"><a href="" class="layui-this">共{:count($artList)}条结果</a></div>
|
||||
<div class="fly-panel-title fly-filter"><a href="" class="layui-this">{$tag.name}共{:count($artList)}条结果</a></div>
|
||||
<ul class="fly-list">
|
||||
{volist name="artList" id="art"}
|
||||
<li>
|
||||
@ -55,11 +54,13 @@
|
||||
{/volist}
|
||||
</dl>
|
||||
<!--自定义-->
|
||||
{notempty name="ad_comm"}
|
||||
<div class="fly-panel" style="padding: 5px 0; text-align: center;">
|
||||
{volist name="ad_comm" id="vo"}
|
||||
<a href="{$vo.slid_href}" target="_blank"><img src="{$Request.domain}{$vo.slid_img}" style="max-width: 100%;"></a>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,11 +37,6 @@
|
||||
<i class="iconfont icon-chengshi"></i><span>{:session('user_id') ? '来自'.$u.city: lang('log in to view')}</span>
|
||||
</p>
|
||||
<p class="fly-home-sign">({$u.sign ? $u.sign|raw : lang('it is not signed yet')})</p>
|
||||
|
||||
<div class="fly-sns" data-user="">
|
||||
<a href="javascript:;" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend">{:lang('add friends')}</a>
|
||||
<a href="javascript:;" class="layui-btn layui-btn-normal fly-imActive" data-type="chat">{:lang('start a chat')}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-container">
|
||||
|
@ -97,11 +97,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form layui-form-pane layui-tab-item">
|
||||
<div class="layui-form layui-form-pane layui-tab-item layui-hide">
|
||||
<ul class="app-bind">
|
||||
<li class="fly-msg app-havebind">
|
||||
<i class="iconfont icon-qq"></i>
|
||||
<span>已成功绑定,您可以使用QQ帐号直接登录Fly社区,当然,您也可以</span>
|
||||
<span>已成功绑定,您可以使用QQ帐号直接登录社区,当然,您也可以</span>
|
||||
<a href="javascript:;" class="acc-unbind" type="qq_id">解除绑定</a>
|
||||
<!-- <a href="" onclick="layer.msg('正在绑定微博QQ', {icon:16, shade: 0.1, time:0})" class="acc-bind" type="qq_id">立即绑定</a>
|
||||
<span>,即可使用QQ帐号登录Fly社区</span> -->
|
||||
@ -111,7 +111,7 @@
|
||||
<!-- <span>已成功绑定,您可以使用微博直接登录Fly社区,当然,您也可以</span>
|
||||
<a href="javascript:;" class="acc-unbind" type="weibo_id">解除绑定</a> -->
|
||||
<a href="" class="acc-weibo" type="weibo_id" onclick="layer.msg('正在绑定微博', {icon:16, shade: 0.1, time:0})" >立即绑定</a>
|
||||
<span>,即可使用微博帐号登录Fly社区</span>
|
||||
<span>,即可使用微博帐号登录</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user