mirror of https://github.com/1099438829/apeblog
修正别名问题导致的bug
This commit is contained in:
parent
2ce83a9294
commit
19c801c92d
|
|
@ -68,6 +68,7 @@ class Article extends AuthController
|
|||
['id', ''],
|
||||
['author', ''],
|
||||
['title', ''],
|
||||
['alias', ''],
|
||||
['category_id', ''],
|
||||
['type', 'article'],
|
||||
['abstract', ''],
|
||||
|
|
@ -97,6 +98,8 @@ class Article extends AuthController
|
|||
}
|
||||
//判断摘要是否为空,为空则从内容摘取
|
||||
$data['abstract'] = $data['abstract'] ?: mb_substr(strip_tags($content), 0, 100);
|
||||
//判断是否写了别名,没写则需要生成
|
||||
if ($data['alias'] == "") $data['alias'] = get_rand_str(6);
|
||||
unset($data['content']);
|
||||
if ($data['is_recommend']) $data['is_recommend'] = 1;
|
||||
if ($data['is_hot']) $data['is_hot'] = 1;
|
||||
|
|
|
|||
|
|
@ -72,9 +72,11 @@ class Category extends AuthController
|
|||
]);
|
||||
if ($data['title'] == "") return app("json")->fail("分类名称不能为空");
|
||||
if ($data['type'] == "") return app("json")->fail("类型不能为空");
|
||||
$content = $data['content'];
|
||||
unset($data['content']);
|
||||
//判断是否写了别名,没写则需要生成
|
||||
if ($data['alias'] == "") $data['alias'] = get_rand_str(8);
|
||||
if ($id == "") {
|
||||
$content = $data['content'];
|
||||
unset($data['content']);
|
||||
$model = new aModel();
|
||||
$id = $model->insert($data, true);
|
||||
$data = [
|
||||
|
|
@ -84,8 +86,6 @@ class Category extends AuthController
|
|||
$model = new DocumentCategoryContent();
|
||||
$res = $model->save($data);
|
||||
} else {
|
||||
$content = $data['content'];
|
||||
unset($data['content']);
|
||||
$res = aModel::update($data, ['id' => $id]);
|
||||
if ($res) {
|
||||
$res = DocumentCategoryContent::update(['content' => $content], ['id' => $id]);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@
|
|||
<input type="text" class="form-control" id="title" name="title" value=""
|
||||
placeholder="文章名称"/>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>别名</label>
|
||||
<input type="text" class="form-control" id="alias" name="alias" value=""
|
||||
placeholder="别名索引"/>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="category_id">栏目分类</label>
|
||||
<div class="form-controls">
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@
|
|||
<input type="hidden" name="id" value="{$info.id}">
|
||||
<input type="text" class="form-control" id="title" name="title" placeholder="文章名称" value="{$info.title}"/>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>别名</label>
|
||||
<input type="text" class="form-control" id="alias" name="alias" value="{$info.alias}"
|
||||
placeholder="别名索引"/>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="category_id">栏目分类</label>
|
||||
<div class="form-controls">
|
||||
|
|
|
|||
|
|
@ -163,3 +163,22 @@ if (!function_exists('file_cdn')) {
|
|||
return (config("app.cdn_url")?:$server_url = server_url()) . $path;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_rand_str')) {
|
||||
/**
|
||||
* 生成随机字符串
|
||||
* @param $length
|
||||
* @return string
|
||||
* @author 李玉坤
|
||||
* @date 2022-04-11 18:26
|
||||
*/
|
||||
function get_rand_str($length){
|
||||
//字符组合
|
||||
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
|
||||
$randStr = str_shuffle($str);//打乱字符串
|
||||
$randstr= substr($randStr,0,$length);//substr(string,start,length);返回字符串的一部分
|
||||
$randstr = md5($randstr.time());
|
||||
$randstr = substr($randstr,5,$length);
|
||||
return $randstr;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ class Data
|
|||
//缓存数据key
|
||||
const DATA_FRIEND_LINK = 'data_friend_link'; //友链
|
||||
const DATA_DOCUMENT_CATEGORY_LIST = 'data_document_category_list'; //文章分类
|
||||
const CURR_CATEGORY_PATENT_ID = 'curr_category_patent_id'; //当前分类腹肌id
|
||||
const CURR_CATEGORY_PATENT_ID = 'curr_category_patent_id'; //当前分类父级id
|
||||
const DATA_SYSTEM_CONFIG = 'data_system_config'; //系统配置
|
||||
const DATA_ADVERT = 'data_advert'; //广告
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue