mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
优化url,多应用之间不能互相根据路由生成url,没有研究透
This commit is contained in:
@@ -9,6 +9,7 @@ use app\model\Post as ModelPost;
|
|||||||
use app\model\PostCategory;
|
use app\model\PostCategory;
|
||||||
use app\model\PostTag;
|
use app\model\PostTag;
|
||||||
use app\model\Tag;
|
use app\model\Tag;
|
||||||
|
use think\facade\Route;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
@@ -56,6 +57,8 @@ class Post extends Common
|
|||||||
//
|
//
|
||||||
$post_data = $request->post();
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
$post_data['uid'] = uniqid();
|
||||||
|
|
||||||
$categorys = [];
|
$categorys = [];
|
||||||
$tags = [];
|
$tags = [];
|
||||||
if (isset($post_data['categorys'])) {
|
if (isset($post_data['categorys'])) {
|
||||||
|
|||||||
2
app/admin/route/index.php
Normal file
2
app/admin/route/index.php
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
use think\facade\Route;
|
||||||
@@ -6,6 +6,7 @@ use app\model\Category;
|
|||||||
use app\model\Nav;
|
use app\model\Nav;
|
||||||
use app\model\Post;
|
use app\model\Post;
|
||||||
use app\model\PostCategory;
|
use app\model\PostCategory;
|
||||||
|
use think\facade\Route;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
@@ -19,8 +20,6 @@ class Index extends Common
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
$sub_category = [];
|
$sub_category = [];
|
||||||
|
|
||||||
if(!empty($this->request->param('category_id'))){
|
if(!empty($this->request->param('category_id'))){
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ class Post extends Common
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \think\Response
|
* @return \think\Response
|
||||||
*/
|
*/
|
||||||
public function read($id)
|
public function read($uid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
$model_post = ModelPost::find($id);
|
$model_post = ModelPost::where('uid',$uid)->find();
|
||||||
|
|
||||||
$model_post->hits = $model_post->hits + 1;
|
$model_post->hits = $model_post->hits + 1;
|
||||||
|
|
||||||
|
|||||||
7
app/index/route/index.php
Normal file
7
app/index/route/index.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\facade\Route;
|
||||||
|
|
||||||
|
Route::rule('a:uid', 'Post/read');
|
||||||
|
Route::rule('i[:category_id]/s[:sub_category_id]/p[:page]', 'Index/index');
|
||||||
|
|
||||||
@@ -136,4 +136,11 @@ class Post extends Model
|
|||||||
|
|
||||||
return get_source_link($value);
|
return get_source_link($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getReadUrlAttr()
|
||||||
|
{
|
||||||
|
$url_info = parse_url((string)url('index/Index/index')->domain('www'));
|
||||||
|
|
||||||
|
return $url_info['scheme'].'://'.$url_info['host'].'/a'.$this->getData('uid').'.html';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,3 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
use think\facade\Route;
|
use think\facade\Route;
|
||||||
|
|
||||||
Route::get('think', function () {
|
|
||||||
return 'hello,ThinkPHP6!';
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('hello/:name', 'index/hello');
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="layui-btn-container">
|
<div class="layui-btn-container">
|
||||||
<a class="layui-btn layui-btn-sm" target="_blank" href="{:url('index/Post/read',['id'=>$vo.id])}">查看</a>
|
<a class="layui-btn layui-btn-sm" target="_blank" href="{$vo.read_url}">查看</a>
|
||||||
<a class="layui-btn layui-btn-sm" href="{:url('edit',['id'=>$vo.id,'type'=>$Request.param.type])}">编辑</a>
|
<a class="layui-btn layui-btn-sm" href="{:url('edit',['id'=>$vo.id,'type'=>$Request.param.type])}">编辑</a>
|
||||||
<div class="layui-btn layui-btn-sm delete">删除</div>
|
<div class="layui-btn layui-btn-sm delete">删除</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
<div class="post-list">
|
<div class="post-list">
|
||||||
{volist name='list_post' id='post'}
|
{volist name='list_post' id='post'}
|
||||||
|
|
||||||
<a href="{:url('Post/read',['id'=>$post.id])}" class="post-item"
|
<a href="{:url('Post/read',['uid'=>$post.uid])}" class="post-item"
|
||||||
onmouseover="$(this).find('.poster').addClass('layui-anim-scale')"
|
onmouseover="$(this).find('.poster').addClass('layui-anim-scale')"
|
||||||
onmouseout="$(this).find('.poster').removeClass('layui-anim-scale')">
|
onmouseout="$(this).find('.poster').removeClass('layui-anim-scale')">
|
||||||
{notempty name='$post->getData("poster")'}
|
{notempty name='$post->getData("poster")'}
|
||||||
|
|||||||
Reference in New Issue
Block a user