提交 8164d5c2 编写于 作者: kanyxmo's avatar kanyxmo

refactor

......@@ -14,7 +14,7 @@
<img src="https://gitee.com/xmo/MineAdmin/badge/star.svg?theme=dark" />
<img src="https://gitee.com/xmo/MineAdmin/badge/fork.svg?theme=dark" />
<img src="https://svg.hamm.cn/badge.svg?key=License&value=Apache-2.0&color=da4a00" />
<img src="https://svg.hamm.cn/badge.svg?key=MineAdmin&value=v1.1.2" />
<img src="https://svg.hamm.cn/badge.svg?key=MineAdmin&value=v1.3.0" />
</p>
PHP有很多优秀的后台管理系统,但基于Swoole的后台管理系统没找到合适我自己的。
所以就开发了一套后台管理系统。系统可以用于网站管理后台、CMS、CRM、OA、ERP等。
......@@ -28,27 +28,14 @@ PHP有很多优秀的后台管理系统,但基于Swoole的后台管理系统
- 腾讯云特惠专场:[点击进入](http://txy.mineadmin.com)
- 阿里云特惠专场:[点击进入](http://aly.mineadmin.com)
## 配置Json来使用Vue完成CRUD操作
在传统的前后端分离架构下,前端必须要配置专业的前端开发人员来完成业务,这对于PHPer习惯前后端一把梭来说比较费事。
在JQuery逐渐没落的大趋势下,使用Vue成为趋势,但从JQ到Vue转变最难的是思想。
MineAdmin强调快速开发,为了适应现代开发模式并且兼顾传统一把梭,特开发出了crud和form两个组件,
只需要像过去配置json的方式即可完成对后端的接口联调,从而快速完成CRUD,大大替开发人员节省了时间。
让刚接触VUE的同学也能上手vue,体验vue的好处。
大神则可以自由发挥是决定使用crud组件,还是使用原生UI库来完成功能。
## 兔小巢
给大家提供一个可以交流的地方:[http://ask.mineadmin.com](http://ask.mineadmin.com)
## 前端仓库地址
移步前端仓库
- [Github MineAdmin-Vue](https://github.com/kanyxmo/MineAdmin-Vue)
- [Gitee MineAdmin-Vue](https://gitee.com/xmo/MineAdmin-vue)
## 官方交流群
> 以下QQ群为 MineAdmin 爱好者建立用于交流学习,请勿相信任何收费事项
## 官方交流群
> QQ群用于交流学习,请勿水群
<img src="https://svg.hamm.cn/badge.svg?key=QQ群&value=150105478" />
......@@ -86,6 +73,7 @@ MineAdmin强调快速开发,为了适应现代开发模式并且兼顾传统
- pcntl
- Mysql >= 5.7
- Redis >= 4.0
- Git >= 2.x
## 下载项目
......@@ -98,7 +86,9 @@ composer config -g repo.packagist composer https://mirrors.tencent.com/composer/
composer install
```
## 后端安装
## 项目安装
> 从 **`1.3.0`** 版本开始在安装后端项目后,会多一个步骤,询问是否在根目录建立 `web` 目录并下载前端项目代码
打开终端,执行安装命令,按照提示,一步步完成`.env`文件的配置
```shell
......@@ -152,11 +142,8 @@ php bin/hyperf.php mine:install
## 演示图片
<img src="https://s1.ax1x.com/2022/07/31/vklKzR.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vklGdO.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vkl8eK.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vkl1L6.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vklwQI.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vkldSA.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vklNJH.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vklJoD.jpg" />
<img src="https://s1.ax1x.com/2022/07/31/vkllsx.jpg" />
......
......@@ -5,5 +5,17 @@
"installed": true,
"enabled": true,
"version": "1.0.0",
"order": 99
"order": 99,
"required": {
},
"required-dev": {
},
"dependencies": {
},
"devDependencies": {
}
}
\ No newline at end of file
......@@ -5,5 +5,17 @@
"installed": true,
"enabled": true,
"version": "1.0.0",
"order": 99
"order": 99,
"required": {
},
"required-dev": {
},
"dependencies": {
},
"devDependencies": {
}
}
\ No newline at end of file
<?php
/**
* MineAdmin is committed to providing solutions for quickly building web applications
* Please view the LICENSE file that was distributed with this source code,
* For the full copyright and license information.
* Thank you very much for using MineAdmin.
*
* @Author X.Mo<root@imoi.cn>
* @Link https://gitee.com/xmo/MineAdmin
*/
/**
* 强制重启服务脚本,并清理缓存代理类
*/
$pid = shell_exec(sprintf('cat %s/../runtime/hyperf.pid', __DIR__));
$rebootCmd = sprintf('rm -rf %s/../runtime/container/* && php %s/hyperf.php start > /dev/null 2>/dev/null &', __DIR__, __DIR__);
if (shell_exec(sprintf('ps -ef | grep -v grep | grep %s', $pid))) {
shell_exec("kill -9 {$pid}");
shell_exec($rebootCmd);
} else {
shell_exec($rebootCmd);
}
此差异已折叠。
......@@ -41,6 +41,7 @@ class InstallProjectCommand extends MineCommand
protected array $redis = [];
public function configure()
{
parent::configure();
......@@ -294,6 +295,20 @@ class InstallProjectCommand extends MineCommand
{
$this->line(PHP_EOL . ' MineAdmin set others items...' . PHP_EOL, 'comment');
$this->call('mine:update');
$this->call('mine:jwt-gen', [ '--jwtSecret' => 'JWT_SECRET' ]);
$this->call('mine:jwt-gen', [ '--jwtSecret' => 'JWT_API_SECRET' ]);
$downloadFrontCode = $this->confirm('Do you downloading the front-end code to "./web" directory?', true);
// 下载前端代码
if ($downloadFrontCode) {
$this->line(PHP_EOL . ' Now about to start downloading the front-end code' . PHP_EOL, 'comment');
if (shell_exec('which git')) {
system('git clone https://gitee.com/mineadmin/mineadmin-vue.git ./web/');
} else {
$this->warn('Your server does not have the `git` command installed and will skip downloading the front-end project');
}
}
}
protected function initUserData()
......
......@@ -5,5 +5,17 @@
"installed": true,
"enabled": true,
"version": "{VERSION}",
"order": 0
"order": 0,
"required": {
},
"required-dev": {
},
"dependencies": {
},
"devDependencies": {
}
}
\ No newline at end of file
<?php
/**
* MineAdmin is committed to providing solutions for quickly building web applications
* Please view the LICENSE file that was distributed with this source code,
* For the full copyright and license information.
* Thank you very much for using MineAdmin.
*
* @Author X.Mo<root@imoi.cn>
* @Link https://gitee.com/xmo/MineAdmin
*/
namespace Mine\Helper;
class SensitiveWordFilter
{
protected array $dict = [];
/**
* 加载词库数据,通过闭包形式,加载词库
* @param \Closure|null $closure
* @return $this
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \RedisException
*/
public function loadDictData(\Closure $closure = null): self
{
$key = config('cache.default.prefix') . ':sensitiveWords';
$redis = redis();
if ($redis->exists($key)) {
$this->dict = $redis->get($key);
} else if ($closure instanceof \Closure){
$this->dict = $closure($this);
$redis->rPush($key, $this->dict);
}
if ($this->dict) foreach ($this->dict as $dict) {
$this->addWords(trim($dict));
}
return $this;
}
/**
* 设置字典词库
* @param array $dict
* @return $this
*/
public function setDict(array $dict): self
{
$this->dict = $dict;
return $this;
}
public function getDict(): array
{
return $this->dict;
}
/**
* 分割文本(注意ascii占1个字节, unicode...)
* @param string $str
* @return string[]
*/
protected function splitStr(string $str): array
{
return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
}
/**
* 添加敏感词
*/
public function addWords(string $words): void
{
$wordArr = $this->splitStr($words);
$curNode = &$this->dict;
foreach ($wordArr as $char) {
if (!isset($curNode)) {
$curNode[$char] = [];
}
$curNode = &$curNode[$char];
}
// 标记到达当前节点完整路径为"敏感词"
$curNode['end']++;
}
/**
* 过滤文本
*
* @param string $str 原始文本
* @param string $replace 敏感字替换字符
* @param int $skipDistance 严格程度: 检测时允许跳过的间隔
*
* @return string 返回过滤后的文本
*/
public function filter(string $str, string $replace = '*', int $skipDistance = 0): string
{
$maxDistance = max($skipDistance, 0) + 1;
$strArr = $this->splitStr($str);
$length = count($strArr);
for ($i = 0; $i < $length; $i++) {
$char = $strArr[$i];
if (!isset($this->dict[$char])) {
continue;
}
$curNode = &$this->dict[$char];
$dist = 0;
$matchIndex = [$i];
for ($j = $i + 1; $j < $length && $dist < $maxDistance; $j++) {
if (!isset($curNode[$strArr[$j]])) {
$dist ++;
continue;
}
$matchIndex[] = $j;
$curNode = &$curNode[$strArr[$j]];
}
// 匹配
if (isset($curNode['end'])) {
foreach ($matchIndex as $index) {
$strArr[$index] = $replace;
}
$i = max($matchIndex);
}
}
return implode('', $strArr);
}
/**
* 检查是否包含敏感词
* @param array|string $strArr
* @return bool
*/
public function checkText(array|string $strArr): bool
{
$strArr = is_array($strArr) ? $strArr : $this->splitStr($strArr);
$curNode = &$this->dict;
foreach ($strArr as $char) {
if (!isset($curNode[$char])) {
return false;
}
}
return $curNode['end'] ?? false;
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ class Mine
/**
* @var string
*/
private static string $version = '1.1.2';
private static string $version = '1.3.0';
/**
* @var string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册