Skip to content

Commit 8c2c606

Browse files
committed
VueCMF内容管理快速开发框架v2.0.0(完整后端API)
1 parent 7da9ffd commit 8c2c606

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2259
-16
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APP_DEBUG = true[APP]DEFAULT_TIMEZONE = Asia/Shanghai[DATABASE]TYPE = mysqlHOSTNAME = 127.0.0.1DATABASE = vuecmfUSERNAME = rootPASSWORD = 123456HOSTPORT = 3306PREFIX = vuecmf_CHARSET = utf8DEBUG = true[LANG]default_lang = zh-cn

.example.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APP_DEBUG = true[APP]DEFAULT_TIMEZONE = Asia/Shanghai[DATABASE]TYPE = mysqlHOSTNAME = 127.0.0.1DATABASE = testUSERNAME = usernamePASSWORD = passwordHOSTPORT = 3306CHARSET = utf8DEBUG = true[LANG]default_lang = zh-cn

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.idea
2+
/.vscode
3+
*.log
4+
/vendor

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
sudo: false
2+
3+
language: php
4+
5+
branches:
6+
only:
7+
- stable
8+
9+
cache:
10+
directories:
11+
- $HOME/.composer/cache
12+
13+
before_install:
14+
- composer self-update
15+
16+
install:
17+
- composer install --no-dev --no-interaction --ignore-platform-reqs
18+
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
19+
- composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
20+
- composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
21+
- composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
22+
- composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
23+
- composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
24+
- composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
25+
- composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
26+
- composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
27+
- composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
28+
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
29+
30+
script:
31+
- php think unit
32+
33+
deploy:
34+
provider: releases
35+
api_key:
36+
secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
37+
file:
38+
- ThinkPHP_Core.zip
39+
- ThinkPHP_Full.zip
40+
skip_cleanup: true
41+
on:
42+
tags: true

LICENSE.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
3+
版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
4+
All rights reserved。
5+
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
6+
7+
Apache Licence是著名的非盈利开源组织Apache采用的协议。
8+
该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
9+
允许代码修改,再作为开源或商业软件发布。需要满足
10+
的条件:
11+
1. 需要给代码的用户一份Apache Licence ;
12+
2. 如果你修改了代码,需要在被修改的文件中说明;
13+
3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
14+
带有原来代码中的协议,商标,专利声明和其他原来作者规
15+
定需要包含的说明;
16+
4. 如果再发布的产品中包含一个Notice文件,则在Notice文
17+
件中需要带有本协议内容。你可以在Notice中增加自己的
18+
许可,但不可以表现为对Apache Licence构成更改。
19+
具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,58 @@
1-
### Hi there 👋
2-
3-
<!--
4-
**vuecmf/vuecmf** is a ✨ _special_ ✨ repository because its `README.md` (this file) appears on your GitHub profile.
5-
6-
Here are some ideas to get you started:
7-
8-
- 🔭 I’m currently working on ...
9-
- 🌱 I’m currently learning ...
10-
- 👯 I’m looking to collaborate on ...
11-
- 🤔 I’m looking for help with ...
12-
- 💬 Ask me about ...
13-
- 📫 How to reach me: ...
14-
- 😄 Pronouns: ...
15-
- ⚡ Fun fact: ...
16-
-->
1+
#欢迎使用VueCMF
2+
3+
VueCMF内容管理快速开发框架v2(后端API)
4+
5+
6+
## VueCMF是什么?
7+
VueCMF是一款完全开源免费的内容管理快速开发框架。采用前后端分离模式搭建,2.0+版本前端使用vue3、Element Plus和TypeScript构建,后端API基于ThinkPHP6开发。可用于快速开发CMS、CRM、WMS、OMS、ERP等管理系统,开发简单、高效易用,极大减少系统的开发周期和研发成本!甚至不用写一行代码使用VueCMF就能设计出功能强大的后台管理系统。
8+
9+
VueCMF开发框架主要有以下功能:
10+
11+
+ 系统授权(管理员、角色、权限)
12+
+ 模型配置(字段、索引、动作、表单)
13+
+ 菜单配置
14+
15+
16+
## 环境要求
17+
* Apache/Nginx
18+
* MySQL >= 5.7
19+
* PHP >= 7.2.5
20+
21+
22+
注意:**以下操作均在命令行中执行**
23+
24+
## 安装
25+
26+
创建新项目
27+
28+
~~~
29+
composer create-project emei8/vuecmf myproject
30+
~~~
31+
32+
若在已有基于thinkphp6的项目中安装, 则需执行下面
33+
~~~
34+
composer require emei8/framework
35+
36+
php think vuecmf:publish
37+
~~~
38+
39+
## 初始化数据
40+
41+
修改.env文件中数据库连接配置(已设置则跳过)
42+
43+
然后执行迁移工具
44+
45+
```
46+
php think migrate:run
47+
```
48+
49+
## 更新框架
50+
~~~
51+
composer update emei8/framework
52+
~~~
53+
54+
55+
## 使用文档
56+
57+
+ [使用手册(http://www.vuecmf.com)](http://www.vuecmf.com/)
58+

app/.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deny from all

app/AppService.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
declare (strict_types = 1);
3+
4+
namespace app;
5+
6+
use think\Service;
7+
8+
/**
9+
* 应用服务类
10+
*/
11+
class AppService extends Service
12+
{
13+
public function register()
14+
{
15+
// 服务注册
16+
}
17+
18+
public function boot()
19+
{
20+
// 服务启动
21+
}
22+
}

app/BaseController.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
declare (strict_types = 1);
3+
4+
namespace app;
5+
6+
use think\App;
7+
use think\exception\ValidateException;
8+
use think\Validate;
9+
10+
/**
11+
* 控制器基础类
12+
*/
13+
abstract class BaseController
14+
{
15+
/**
16+
* Request实例
17+
* @var \think\Request
18+
*/
19+
protected $request;
20+
21+
/**
22+
* 应用实例
23+
* @var \think\App
24+
*/
25+
protected $app;
26+
27+
/**
28+
* 是否批量验证
29+
* @var bool
30+
*/
31+
protected $batchValidate = false;
32+
33+
/**
34+
* 控制器中间件
35+
* @var array
36+
*/
37+
protected $middleware = [];
38+
39+
/**
40+
* 构造方法
41+
* @access public
42+
* @param App $app 应用对象
43+
*/
44+
public function __construct(App $app)
45+
{
46+
$this->app = $app;
47+
$this->request = $this->app->request;
48+
49+
// 控制器初始化
50+
$this->initialize();
51+
}
52+
53+
// 初始化
54+
protected function initialize()
55+
{}
56+
57+
/**
58+
* 验证数据
59+
* @access protected
60+
* @param array $data 数据
61+
* @param string|array $validate 验证器名或者验证规则数组
62+
* @param array $message 提示信息
63+
* @param bool $batch 是否批量验证
64+
* @return array|string|true
65+
* @throws ValidateException
66+
*/
67+
protected function validate(array $data, $validate, array $message = [], bool $batch = false)
68+
{
69+
if (is_array($validate)) {
70+
$v = new Validate();
71+
$v->rule($validate);
72+
} else {
73+
if (strpos($validate, '.')) {
74+
// 支持场景
75+
[$validate, $scene] = explode('.', $validate);
76+
}
77+
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
78+
$v = new $class();
79+
if (!empty($scene)) {
80+
$v->scene($scene);
81+
}
82+
}
83+
84+
$v->message($message);
85+
86+
// 是否批量验证
87+
if ($batch || $this->batchValidate) {
88+
$v->batch(true);
89+
}
90+
91+
return $v->failException(true)->check($data);
92+
}
93+
94+
}

app/ExceptionHandle.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
namespace app;
3+
4+
use think\db\exception\DataNotFoundException;
5+
use think\db\exception\ModelNotFoundException;
6+
use think\exception\Handle;
7+
use think\exception\HttpException;
8+
use think\exception\HttpResponseException;
9+
use think\exception\ValidateException;
10+
use think\Response;
11+
use Throwable;
12+
13+
/**
14+
* 应用异常处理类
15+
*/
16+
class ExceptionHandle extends Handle
17+
{
18+
/**
19+
* 不需要记录信息(日志)的异常类列表
20+
* @var array
21+
*/
22+
protected $ignoreReport = [
23+
HttpException::class,
24+
HttpResponseException::class,
25+
ModelNotFoundException::class,
26+
DataNotFoundException::class,
27+
ValidateException::class,
28+
];
29+
30+
/**
31+
* 记录异常信息(包括日志或者其它方式记录)
32+
*
33+
* @access public
34+
* @param Throwable $exception
35+
* @return void
36+
*/
37+
public function report(Throwable $exception): void
38+
{
39+
// 使用内置的方式记录异常日志
40+
parent::report($exception);
41+
}
42+
43+
/**
44+
* Render an exception into an HTTP response.
45+
*
46+
* @access public
47+
* @param \think\Request $request
48+
* @param Throwable $e
49+
* @return Response
50+
*/
51+
public function render($request, Throwable $e): Response
52+
{
53+
// 添加自定义异常处理机制
54+
55+
// 其他错误交给系统处理
56+
return parent::render($request, $e);
57+
}
58+
}

0 commit comments

Comments
 (0)