Compare commits

...

3 Commits

Author SHA1 Message Date
yumo 16cfdb89b6 添加文档信息和修复主页的bug 2023-12-14 18:30:24 +08:00
yumo e25404ee2f 完善逻辑条正 2023-12-14 16:32:56 +08:00
yumo 1ba8bfcc4f 修复修改轮播广告的bug 2023-12-08 09:43:10 +08:00
18 changed files with 385 additions and 28 deletions

View File

@ -225,7 +225,8 @@ class Admin extends AuthController
*/
public function profile(): string
{
$this->assign("info", aModel::find($this->adminId));
$this->assign("info", (new \app\admin\model\Admin)->find($this->adminId));
// dd((new \app\admin\model\Admin)->find($this->adminId));
return $this->fetch();
}

View File

@ -4,6 +4,7 @@ namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\admin\model\AdminLog as lModel;
use app\common\model\AdvertInfo;
use app\Request;
use Exception;
use think\db\exception\DataNotFoundException;

View File

@ -25,7 +25,7 @@ class AdminNotify extends AuthController
['start_time', ''],
['end_time', ''],
['is_read', ''],
['aid', $this->adminId],
['uid', $this->adminId],
]);
$this->assign("where", $where);
$this->assign("list", nModel::systemPage($where));

View File

@ -254,6 +254,9 @@ class Advert extends AuthController
* 保存修改
* @param string $id
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function saveAdvert($id = "")
{
@ -283,4 +286,18 @@ class Advert extends AuthController
cache(Data::DATA_ADVERT . '_' . $info['alias'], null);//清除缓存
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
}
/**
* 删除广告
* @param Request $request
* @return mixed
*/
public function delAdvert(Request $request)
{
$where = Util::postMore([
['id', ''],
],$request);
if (empty($where['id'])) return app("json")->fail("参数错误,请刷新后重试");
return (new \app\common\model\AdvertInfo)->where('id',$where['id'])->delete() ? app("json")->success("删除成功") : app("json")->fail("删除失败");
}
}

View File

@ -88,7 +88,7 @@ class Article extends AuthController
['is_recommend', 0],
['is_top', 0],
['is_hot', 0],
['theme', 'detail.html'],
['template', 'detail.html'],
['link_str', ''],
['is_jump', 0],
['cover_path', ''],

View File

@ -40,7 +40,7 @@ class Image extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function category(): array
public function category()
{
return app("json")->success(AttachmentCategory::buildNodes($this->type, 0, $this->request->param("title", "")));
}

View File

@ -19,7 +19,7 @@ class Index extends AuthController
{
$this->assign("adminInfo", $this->adminInfo);
$this->assign("menu", AdminAuth::getAuthList($this->adminId,$this->auth));
$this->assign("message", AdminNotify::pageList(5));
$this->assign("message", AdminNotify::pageList($this->adminId,5));
return $this->fetch();
}

View File

@ -31,7 +31,7 @@ class AdminNotify extends BaseModel
}
if ($where['title'] != '') $model = $model->where("title|content", "like", "%$where[title]%");
if ($where['is_read'] != '') $model = $model->where("is_read", $where['is_read']);
if ($where['aid'] != '') $model = $model->where("aid", $where['aid']);
if ($where['uid'] != '') $model = $model->where("uid", $where['uid']);
$model = $model->order("is_read");
$model = $model->order("create_time desc");
return $model->paginate(10)->appends($where);
@ -53,16 +53,17 @@ class AdminNotify extends BaseModel
/**
* 后台首页获取通知信息
* @param $uid
* @param int $num
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function pageList(int $num): array
public static function pageList($uid,int $num): array
{
$model = new self;
$model = $model->where("is_read", 0);
$model = $model->where("is_read", 0)->where("uid",$uid);
$count = self::count();
$model = $model->order("create_time desc");
$model = $model->page(1, $num);

View File

@ -97,7 +97,7 @@
<div class="card">
<div class="card-body">
<div class="edit-avatar">
<img src="{$info.avatar}" alt="{$info.name}" class="img-avatar">
<img src="{$info.avatar}" alt="{$info.nickname}" class="img-avatar">
<div class="avatar-divider"></div>
<div class="edit-avatar-content">
<button class="btn btn-default trigger-btn">修改头像</button>
@ -109,7 +109,7 @@
<input type="hidden" class="form-control" name="avatar" id="avatar" value="{$info.avatar}"/>
<div class="form-group">
<label for="name">用户名</label>
<input type="text" class="form-control" name="name" id="name" value="{$info.name}"
<input type="text" class="form-control" name="username" id="username" value="{$info.username}"
disabled="disabled"/>
</div>
<div class="form-group">

View File

@ -87,11 +87,9 @@ class Document extends BaseModel
/**
* 更新文件信息
* @param $date
* @param $data
* @param string $type
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @return bool
*/
public function updateInfo($data, string $type = Data::DOCUMENT_TYPE_ARTICLE)
{

View File

@ -0,0 +1,72 @@
<?php
namespace app\common\model;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Paginator;
/**
* 消息通知
* Class AdminNotify
* @package app\admin\model\admin
*/
class Message extends BaseModel
{
/**
* 系统分页
* @param array $where
* @return Paginator
* @throws DbException
*/
public static function systemPage(array $where)
{
$model = new self;
if ($where['start_time'] != "" && $where['end_time'] != "") {
$model = $model->where("create_time", "between", [strtotime($where['start_time'] . " 00:00:00"), strtotime($where['end_time'] . " 23:59:59")]);
}
if ($where['title'] != '') $model = $model->where("title|content", "like", "%$where[title]%");
if ($where['is_read'] != '') $model = $model->where("is_read", $where['is_read']);
if ($where['uid'] != '') $model = $model->where("aid", $where['aid']);
$model = $model->order("is_read");
$model = $model->order("create_time desc");
return $model->paginate(10)->appends($where);
}
/**
* 添加记录
* @param array $data
* @return int|string
*/
public static function addLog(array $data): bool
{
if (self::create($data)){
return true;
}else{
return false;
}
}
/**
* 后台首页获取通知信息
* @param int $num
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function pageList(int $num): array
{
$model = new self;
$model = $model->where("is_read", 0);
$count = self::count();
$model = $model->order("create_time desc");
$model = $model->page(1, $num);
$data = $model->select();
if ($data) $data = $data->toArray();
return compact("data", "count");
}
}

View File

@ -126,7 +126,7 @@ class Article extends Base
//更新浏览次数
$documentModel->where('id', $article['id'])->inc('view')->update();
//读取模板文件
$template = Data::DOCUMENT_TYPE_ARTICLE . '/' . ($article['theme'] ?: 'detail.html');
$template = Data::DOCUMENT_TYPE_ARTICLE . '/' . ($article['template'] ?: 'detail.html');
$templateFile = config('view.view_path') . $template;
if (!is_file($templateFile)) {
//配置的模版文件不存在则走默认模版

View File

@ -34,8 +34,8 @@ return [
// 异常页面的模板文件
'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
// 默认跳转页面对应的模板文件
'dispatch_success_tmpl' => root_path(). 'app/common/tpl/dispatch_jump.tpl',
'dispatch_error_tmpl' => root_path(). 'app/common/tpl/dispatch_jump.tpl',
'dispatch_success_tmpl' => public_path() . '/tpl/dispatch_jump.tpl',
'dispatch_error_tmpl' => public_path() . '/tpl/dispatch_jump.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',

120
public/doc/安装教程.md Normal file
View File

@ -0,0 +1,120 @@
# 安装教程
#### 一、ape博客推荐你使用阿里云和腾讯云服务器
阿里云服务器官方长期折扣优惠地址:
点击访问,([https://www.aliyun.com/daily-act/ecs/activity_selection?userCode=dery8ymr](https://www.aliyun.com/daily-act/ecs/activity_selection?userCode=dery8ymr))
腾讯云服务器官方长期折扣优惠地址:
点击访问,([https://curl.qcloud.com/G8kYi1YB](https://curl.qcloud.com/G8kYi1YB))
服务器最低配置:
```auto
1核CPU (建议2核+)
2G内存 (建议4G+)
2M带宽 (建议5M+)
```
#### 二、服务器运行环境要求
```auto
PHP >= 7.1
Mysql >= 5.5.0 (需支持innodb引擎)
Apache 或 Nginx
PDO PHP Extension
MBstring PHP Extension
CURL PHP Extension
Composer (用于管理第三方扩展包)
```
#### 三、系统安装
**方式一:完整包安装**
第一步:前往官网博客下载页面 ([https://gitee.com/muziys/apeblog/releases](https://gitee.com/muziys/apeblog/releases)) 下载完整包解压到你的项目目录
第二步添加虚拟主机并绑定到项目的public目录
第三步:访问 [http://www.yoursite.com/install/index](http://www.yoursite.com/install/index) 进行安装
**方式二:命令行安装(推荐)**
推荐使用命令行安装因为采用命令行安装的方式可以和勾股blog随时保持更新同步。使用命令行安装请提前准备好`Git`、`Composer`。
**Linux下勾股blog的安装请使用以下命令进行安装**
第一步克隆ape博客到你本地
```shell
git clone https://gitee.com/gougucms/blog.git
```
复制
第二步:进入目录
```shell
cd blog
```
复制
第三步下载PHP依赖包
composer install
第四步添加虚拟主机并绑定到项目的public目录
实际部署中确保绑定域名访问到的是public目录。
第五步:访问 [http://www.yoursite.com/install/index](http://www.yoursite.com/install/index) 进行安装
⚠️ 注意:安装过程中,系统会自动创建数据库,请确保填写的数据库用户的权限可创建数据库,如果权限不足,请先手动创建空的数据库,然后填写刚创建的数据库名称和用户名也可完成安装。
🔺 提醒:安装过程中,如果进度条卡住,一般都是数据库写入权限或者安装环境配置问题,请注意检查。
遇到解决不了的问题请到QQ群反馈24641076群一满46924914群二满,295256660群三
✅ PS如需要重新安装请删除目录里面 config/install.lock 的文件,即可重新安装。
#### 四、伪静态配置
**Nginx**
修改nginx.conf 配置文件 加入下面的语句。
```shell
location /admin/ {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/admin/(.*)$ /admin.php?s=$1;
}
}
location /api/ {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/api/(.*)$ /api.php?s=$1;
}
}
location / {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=$1 last;
}
}
```
**Apache**
把下面的内容保存为.htaccess文件放到应用入 public 文件的同级目录下。
```shell
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/(.*)$ admin.php?s=$1;
RewriteRule ^api/(.*)$ api.php?s=$1;
RewriteRule ^(.*)$ index.php?s=$1 [L]
</IfModule>
```

View File

@ -0,0 +1,72 @@
# 常见问题
1、安装失败可能存在php配置文件禁止了`putenv`和`proc_open`函数。解决方法,查找`php.ini`文件位置,打开`php.ini`,搜索`disable_functions`项,看是否禁用了`putenv` 和`proc_open`函数。如果在禁用列表里,移除`putenv` `proc_open`然后退出重启php即可。
2、如果安装后打开页面提示`404`错误,请检查服务器伪静态配置,如果是宝塔面板,网站伪静态请配置使用`thinkphp规则`。
**伪静态配置如下:**
**Nginx**
修改nginx.conf 配置文件 加入下面的语句。
```shell
location /admin/ {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/admin/(.*)$ /admin.php?s=$1;
}
}
location /api/ {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/api/(.*)$ /api.php?s=$1;
}
}
location / {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=$1 last;
}
}
```
**Apache**
把下面的内容保存为.htaccess文件放到应用入 public 文件的同级目录下。
```shell
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/(.*)$ admin.php?s=$1;
RewriteRule ^api/(.*)$ api.php?s=$1;
RewriteRule ^(.*)$ index.php?s=$1 [L]
</IfModule>
```
3、如果提示当前权限不足无法写入配置文件`config/database.php`,请检查`database.php`是否可读还有可能是当前安装程序无法访问父目录请检查PHP的`open_basedir`配置。
4、如果`composer install`失败,请尝试在命令行进行切换配置到国内源,命令如下:
```shell
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
```
复制
5、如果`composer install`失败请尝试composer降级
```shell
composer self-update
```
复制
6、如果`composer install`失败,请尝试删除项目文件,重新拉取。
7、访问 [http://www.yoursite.com/install/index](http://www.yoursite.com/install/index) ,请注意查看伪静态请配置是否设置了`thinkphp规则`。
8、遇到问题请到QQ**1099438829** 反馈,或者到**Issue**里面反馈,谢谢!

View File

@ -0,0 +1,51 @@
**初始的目录结构如下:**
```auto
www 系统部署目录(或者子目录)
├── app 应用目录
│ ├── admin 后台模块目录
│ │ ├── config 后台配置文件目录
│ │ ├── controller 控制器目录
│ │ ├── extend 拓展目录
│ │ ├── lang 语言文件目录
│ │ ├── model 模型目录
│ │ ├── subscribes 事件目录
│ │ └── view 视图模板目录
│ ├── api
│ │ └── controller 控制器目录
│ ├── common 公共目录
│ │ ├── constant 全局变量目录
│ │ ├── extend 拓展目录
│ │ ├── model 模型目录
│ │ ├── paginator 分页组件
│ │ ├── taglib 模板拓展标签
│ │ └── validate 校验器目录
│ └── index
│ ├── config 配置目录
│ ├── controller 控制器目录
│ ├── route 路由目录
│ └── validate 校验器目录
├── config 配置文件目录
├── public 公共目录
│ ├── doc 文档目录
│ ├── install 安装模块目录(系统安装完后,建议删除)
│ │ ├── css 安装器css
│ │ ├── images 图片资源
│ │ ├── js js资源
│ │ └── templates 模板
│ ├── static 系统静态资源
│ │ ├── admin 后台静态资源
│ │ └── banner banner静态文件
│ ├── storage 文件存储目录
│ │ └── image 图片目录
│ ├── template 主题目录
│ │ └── default 默认主题
│ └── tpl 系统跳转等模板目录
├───route 路由目录
├───vendor 第三方类库目录(Composer依赖库目录)
├───runtime 应用的运行时目录(可写,可定制)
├───composer.json composer 定义文件
├───LICENSE.txt 授权说明文件
├───README.md README 文件
├───think 命令行入口文件
```

View File

@ -143,17 +143,17 @@ COMMIT;
-- ----------------------------
DROP TABLE IF EXISTS `ape_admin_notify`;
CREATE TABLE `ape_admin_notify` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '消息ID',
`aid` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`content` mediumtext NOT NULL COMMENT '内容',
`from` varchar(10) NOT NULL DEFAULT '' COMMENT '消息来源 谁发的',
`type` varchar(10) NOT NULL DEFAULT 'system' COMMENT '消息类型 timer:定时器 system:系统',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '跳转路径 不填写时自动判断',
`is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读',
`create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '消息ID',
`aid` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`content` mediumtext NOT NULL COMMENT '内容',
`from` varchar(10) NOT NULL DEFAULT '' COMMENT '消息来源 谁发的',
`type` varchar(10) NOT NULL DEFAULT 'system' COMMENT '消息类型 timer:定时器 system:系统',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '跳转路径 不填写时自动判断',
`is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读',
`create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='后台信息表';
-- ----------------------------
@ -704,6 +704,30 @@ CREATE TABLE `ape_url_log` (
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for ape_message
-- ----------------------------
DROP TABLE IF EXISTS `ape_message`;
CREATE TABLE `ape_message` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '消息ID',
`uid` int(10) NOT NULL DEFAULT '0' COMMENT '用户id包含管理员',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`content` mediumtext NOT NULL COMMENT '内容',
`from` varchar(10) NOT NULL DEFAULT '' COMMENT '消息来源 谁发的',
`type` varchar(10) NOT NULL DEFAULT 'system' COMMENT '消息类型 公告、通知、私信等',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '跳转路径 不填写时自动判断',
`is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读',
`create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='消息通知表';
-- ----------------------------
-- Records of ape_message
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for ape_user
-- ----------------------------