framework6.1

This commit is contained in:
taoser 2023-02-11 21:24:02 +08:00
parent 108083fca2
commit a056a37573
50 changed files with 649 additions and 614 deletions

View File

@ -296,7 +296,7 @@ abstract class BaseController
* 通过百度分词接口获取关键词或者标签
* flag 1.为word时获取分词2.为tag时获取标签
*
* @return void
* @return array
*/
public function setKeywords($data)
{
@ -385,7 +385,7 @@ abstract class BaseController
}
}
}
return json(['code'=>0,'data'=>$keywords]);
return $keywords;
}
// api_post接口

View File

@ -14,6 +14,7 @@ use think\response\Json;
use Symfony\Component\VarExporter\VarExporter;
use taoler\com\Files;
use app\common\lib\facade\HttpHelper;
use app\common\lib\FileHelper;
class Addons extends AdminController
{
@ -212,8 +213,6 @@ class Addons extends AdminController
public function install(array $data = [], bool $type = true)
{
$data = Request::only(['name','version','uid','token']) ?? $data;
// $data = ['name' => $name, 'version' => $version, 'uid' => $uid, 'token' => $token];
// 接口
$response = HttpHelper::withHost()->post('/v1/getaddons',$data)->toJson();
if($response->code < 0) return json($response);
@ -238,19 +237,19 @@ class Addons extends AdminController
//把远程文件放入本地
//拼接路径
$addons_dir = Files::getDirPath('../runtime/addons/');
Files::mkdirs($addons_dir);
$addons_dir = FileHelper::getDirPath(root_path() . 'runtime' . DS . 'addons');
if(!is_dir($addons_dir)) Files::mkdirs($addons_dir);
$package_file = $addons_dir . $data['name'] .'.zip'; //升级的压缩包文件
$cpfile = copy($file_url,$package_file);
$package_file = $addons_dir . $data['name'] . '.zip'; //升级的压缩包文件路径
$cpfile = copy($file_url, $package_file);
if(!$cpfile) return json(['code'=>-1,'msg'=>'下载升级文件失败']);
$uzip = new Zip();
$zipDir = strstr($package_file, '.zip',true); //返回文件名后缀前的字符串
$zipPath = Files::getDirPath($zipDir); //转换为带/的路径 压缩文件解压到的路径
$unzip_res = $uzip->unzip($package_file,$zipPath,true);
$zipPath = FileHelper::getDirPath($zipDir); //转换为带/的路径 压缩文件解压到的路径
$unzip_res = $uzip->unzip($package_file, $zipPath, true);
if(!$unzip_res) return json(['code'=>-1,'msg'=>'解压失败']);
unlink($package_file);
//升级插件
//升级前的写入文件权限检查
@ -268,19 +267,19 @@ class Addons extends AdminController
if (!is_writable($dirPath)) $checkString .= $dirPath . '&nbsp;[<span class="text-red">' . '无写入权限' . '</span>]<br>';
}
}
if (!empty($checkString)) return json(['code' => -1, 'msg' => $checkString]);
$addonsPath = '../';
$cpRes = Files::copyDirs($zipPath,$addonsPath);
$cpData = $cpRes->getData();
//更新失败
if($cpData['code'] == -1) return json(['code'=>-1,'msg'=>$cpData['msg']]);
try {
FileHelper::copyDir(root_path() . 'runtime' . DS . 'addons' . DS . $data['name'] . DS, root_path());
} catch (\Exception $e) {
return json(['code'=> -1, 'msg'=> $e->getMessage()]);
}
$class = get_addons_instance($data['name']);
try {
if($type) {
// 执行数据库
$sqlInstallFile = root_path().'addons/'.$data['name'].'/install.sql';
$sqlInstallFile = root_path(). 'addons' . DS . $data['name'] . DS . 'install.sql';
if(file_exists($sqlInstallFile)) {
SqlFile::dbExecute($sqlInstallFile);
}
@ -305,16 +304,20 @@ class Addons extends AdminController
}
Files::delDirAndFile('../runtime/addons/'.$data['name'] . DS);
return json(['code'=>0,'msg'=>'插件安装成功!']);
$msg = $type ? '插件安装成功!' : '插件升级成功!';
return json(['code' => 0, 'msg' => $msg]);
}
/**
* 卸载插件
* @param string $name
* @return Json
* @throws \Exception
*/
public function uninstall()
public function uninstall(string $name = '')
{
$name = input('name');
$name = input('name') ?? $name;
// 执行插件卸载
$class = get_addons_instance($name);
$class->uninstall();
@ -369,6 +372,8 @@ class Addons extends AdminController
// 卸载插件
$class = get_addons_instance($data['name']);
$class->uninstall();
$this->uninstall($data['name']);
// 卸载菜单
$menu = get_addons_menu($data['name']);
if(!empty($menu)){
@ -378,19 +383,20 @@ class Addons extends AdminController
try {
// 升级安装第二个参数为false
$this->install($data,false);
$res = $this->install($data,false);
// 升级sql
$sqlUpdateFile = root_path().'addons/'.$data['name'].'/update.sql';
if(file_exists($sqlUpdateFile)) {
SqlFile::dbExecute($sqlUpdateFile);
}
// 恢复配置
set_addons_config($data['name'],$config);
if(!empty($config)) {
set_addons_config($data['name'], $config);
}
} catch (\Exception $e) {
return json(['code' => -1, 'msg' => $e->getMessage()]);
}
return json(['code' => 0, 'msg' => '升级成功']);
return $res;
}
/**

View File

@ -479,8 +479,8 @@ class Forum extends AdminController
public function getKeywords()
{
$data = Request::only(['flag','keywords','content']);
return $this->setKeywords($data);
$keywords = $this->setKeywords($data);
return json(['code'=>0, 'msg' => 'ok', 'data'=> $keywords]);
}
/**

View File

@ -95,7 +95,6 @@ class Index extends AdminController
//版本检测
public function getVersion(){
$verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]);
if($verCheck->code !== -1){
return $verCheck->code ? "<span style='color:red'>有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}</span>" : $verCheck->msg;

View File

@ -48,7 +48,7 @@
{include file="public/user_login" /}
{/block}
{block name="js"}
<script src="/static/notify.js"></script>
<script>
var addonList = "{:url('Addons/index')}";
layui.config({

View File

@ -42,7 +42,7 @@
<div class="layui-inline">
<label class="layui-form-label">{:lang('enclosure')}</label>
<div class="layui-input-inline" style="width: 190px;">
<input type="text" class="layui-input" name="upzip" value="{$article.upzip}" placeholder="zip,jpg格式" title="上传附件"/>
<input type="text" class="layui-input" name="upzip" value="{$article.upzip ?? ''}" placeholder="zip,jpg格式" title="上传附件"/>
</div>
<button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button>
</div>

View File

@ -182,7 +182,7 @@ overflow: visible;
,othis.find('input[name="sort"]').val(data.sort)
,othis.find('input[name="catename"]').val(data.catename)
,othis.find('input[name="ename"]').val(data.ename)
,othis.find('input[name="icon"]').val(data.icon)
,othis.find('input[name="icon"]').val(data.icon)
,othis.find('input[name="desc"]').val(data.desc);
}
});

View File

@ -114,10 +114,11 @@
base: '/static/admin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'useradmin', 'table'], function(){
}).use(['index', 'useradmin', 'table', 'notify'], function(){
var $ = layui.$
,form = layui.form
,table = layui.table;
var notify = layui.notify;
//监听搜索
form.on('submit(LAY-user-front-search)', function(data){

View File

@ -3,6 +3,7 @@
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use taoser\SetArr;
use think\facade\Request;
use think\facade\Db;
use think\facade\Session;
@ -291,7 +292,7 @@ function getOnepic($str)
//判断蜘蛛函数
function find_spider(){
$useragent = strtolower(empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : '');
$useragent = strtolower(empty($useragent) ? Request::header('USER_AGENT') : '');
$spider_arr=array(
'bot',
'spider',
@ -329,4 +330,112 @@ if (!function_exists('__')) {
}
}
if (!function_exists('setKeywords')) {
/**
* 关键词
* 通过百度分词接口获取关键词或者标签
* flag 1.为word时获取分词2.为tag时获取标签
*
* @return string
*/
function setKeywords($flag, $title, $content)
{
$keywords = [];
// 百度分词自动生成关键词
if(!empty(config('taoler.baidu.client_id')) == true) {
//headers数组内的格式
$headers = array();
$headers[] = "Content-Type:application/json";
switch($flag) {
//分词
case 'word':
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
$body = ["text" => $title];
break;
//标签
case 'tag':
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/keyword?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
$body = ['title' => $title, 'content'=> $content];
break;
default:
$url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?charset=UTF-8&access_token='.config('taoler.baidu.access_token');
$body = ["text" => $title];
}
$postBody = json_encode($body);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);//设置请求头
curl_setopt($curl, CURLOPT_POSTFIELDS, $postBody);//设置请求体
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');//使用一个自定义的请求信息来代替"GET"或"HEAD"作为HTTP请求。(这个加不加没啥影响)
$datas = curl_exec($curl);
if($datas == false) {
echo '接口无法链接';
} else {
$res = stripos($datas,'error_code');
// 接收返回的数据
$dataItem = json_decode($datas);
if($res == false) {
// 数据正常
$items = $dataItem->items;
foreach($items as $item) {
switch($flag) {
case 'word':
if($item->pos == 'n' && !in_array($item->item,$keywords)){
$keywords[] = $item->item;
}
break;
case 'tag':
if(!in_array($item->tag,$keywords)){
$keywords[] = $item->tag;
}
break;
default:
if($item->pos == 'n' && !in_array($item->item,$keywords)){
$keywords[] = $item->item;
}
}
}
} else {
// 接口正常但获取数据失败可能参数错误重新获取token
$url = 'https://aip.baidubce.com/oauth/2.0/token';
$post_data['grant_type'] = config('taoler.baidu.grant_type');;
$post_data['client_id'] = config('taoler.baidu.client_id');
$post_data['client_secret'] = config('taoler.baidu.client_secret');
$o = "";
foreach ( $post_data as $k => $v )
{
$o.= "$k=" . urlencode( $v ). "&" ;
}
$postData = substr($o,0,-1);
$curl = curl_init();//初始化curl
curl_setopt($curl, CURLOPT_URL,$url);//抓取指定网页
curl_setopt($curl, CURLOPT_HEADER, 0);//设置header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($curl, CURLOPT_POST, 1);//post提交方式
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
$data = curl_exec($curl);//运行curl
curl_close($curl);
// 写入token
SetArr::name('taoler')->edit([
'baidu'=> [
'access_token' => json_decode($data)->access_token,
]
]);
//echo 'api接口数据错误 - ';
//echo $dataItem->error_msg;
}
}
}
return implode(",", $keywords);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace app\common\lib;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
class FileHelper
{
/**
* 检测目录并循环创建目录
* @param $dir
* @return bool
*/
public static function mkdirs($dir)
{
if (!file_exists($dir)) {
self::mkdirs(dirname($dir));
mkdir($dir, 0755);
}
return true;
}
/**
* 转换为/结尾的路径
* @param $path string 文件夹路径
* @return string
*/
public static function getDirPath($path)
{
//去掉path最右侧的/号,再重新组装带/路径
return rtrim(str_replace('\\','/',$path),'/') . '/';
}
/**
* 复制文件夹文件和子文目录文件,可排除目录复制 升级+备份代码
* @param $source
* @param $dest
* @param array $exdir
* @param $delete
* @return bool
*/
public static function copyDir($source, $dest, array $exdir = ['app'], $delete = false)
{
if (!is_dir($dest)) self::mkdirs($dest);
foreach (
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
) as $item) {
if ($item->isDir()) {
$sontDir = $dest . $iterator->getSubPathName();
if(in_array($sontDir,$exdir)){
continue;
}
if (!is_dir($sontDir)) {
self::mkdirs($sontDir);
}
} else {
try {
copy((string)$item, $dest . $iterator->getSubPathName());
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
if($delete) unlink($item);
}
}
return true;
}
}

View File

@ -53,7 +53,12 @@ class HttpHelper
*/
public function get(string $url, array $data = []): HttpHelper
{
$this->response = $this->http->get($url, $data);
try {
$this->response = $this->http->get($url, $data);
} catch (\Exception $e) {
//echo $e->getMessage();
}
// $this->response = $this->http->get($url, $data);
return $this;
}
@ -65,7 +70,12 @@ class HttpHelper
*/
public function post(string $url, array $data = [])
{
$this->response = $this->http->post($url, $data);
try {
$this->response = $this->http->post($url, $data);
} catch (\Exception $e) {
//echo $e->getMessage();
}
// $this->response = $this->http->post($url, $data);
return $this;
}
@ -101,7 +111,14 @@ class HttpHelper
*/
public function ok() : bool
{
return $this->response->status() === 200;
// return $this->response->status() === 200;
//halt($this->response);
if($this->response !== null) {
return $this->response->status() === 200;
}
return false;
}
}

View File

@ -32,7 +32,7 @@ class Zip
foreach($folderPaths as $folderPath) {
if(self::getDirSize($folderPath) == 0) {
continue;
};
}
// 被压缩文件绝对路径
$rootPath = realpath($folderPath);
// Create recursive directory iterator

View File

@ -278,7 +278,8 @@ class Article extends Model
])->withCount(['comments'])
->where('status',1)
->where($where)
->order(['is_top'=>'desc','create_time'=>'desc'])
->limit(15)
->order(['create_time'=>'desc'])
->paginate([
'list_rows' => 15,
'page' => $page

View File

@ -484,14 +484,14 @@ class Article extends BaseController
}
/**
* 关键词
*
* @return void
*/
* 关键词
* @return \think\response\Json
*/
public function keywords()
{
$data = Request::only(['flag','keywords','content']);
return $this->setKeywords($data);
$keywords = $this->setKeywords($data);
return json(['code'=>0, 'msg' => 'ok', 'data'=> $keywords]);
}
// 文章置顶、加精、评论状态

145
composer.lock generated
View File

@ -304,16 +304,16 @@
},
{
"name": "endroid/qr-code",
"version": "4.6.0",
"version": "4.6.1",
"source": {
"type": "git",
"url": "https://github.com/endroid/qr-code.git",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c"
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/b60873b14e2ca7bf3c3746f5e032023095a7e05c",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"shasum": ""
},
"require": {
@ -364,7 +364,7 @@
],
"support": {
"issues": "https://github.com/endroid/qr-code/issues",
"source": "https://github.com/endroid/qr-code/tree/4.6.0"
"source": "https://github.com/endroid/qr-code/tree/4.6.1"
},
"funding": [
{
@ -372,7 +372,7 @@
"type": "github"
}
],
"time": "2022-10-04T17:13:41+00:00"
"time": "2022-10-26T08:48:17+00:00"
},
{
"name": "firebase/php-jwt",
@ -1012,57 +1012,6 @@
],
"time": "2022-10-04T09:16:37+00:00"
},
{
"name": "league/flysystem-cached-adapter",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-cached-adapter.git",
"reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/d1925efb2207ac4be3ad0c40b8277175f99ffaff",
"reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff",
"shasum": ""
},
"require": {
"league/flysystem": "~1.0",
"psr/cache": "^1.0.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7",
"predis/predis": "~1.0",
"tedivm/stash": "~0.12"
},
"suggest": {
"ext-phpredis": "Pure C implemented extension for PHP"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\Flysystem\\Cached\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "frankdejonge",
"email": "info@frenky.net"
}
],
"description": "An adapter decorator to enable meta-data caching.",
"support": {
"issues": "https://github.com/thephpleague/flysystem-cached-adapter/issues",
"source": "https://github.com/thephpleague/flysystem-cached-adapter/tree/master"
},
"time": "2020-07-25T15:56:04+00:00"
},
{
"name": "league/mime-type-detection",
"version": "1.11.0",
@ -2496,23 +2445,21 @@
},
{
"name": "topthink/framework",
"version": "v6.0.13",
"version": "v6.1.1",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6"
"reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6",
"url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"league/flysystem": "^1.1.4",
"league/flysystem-cached-adapter": "^1.0",
"php": ">=7.2.5",
"psr/container": "~1.0",
"psr/http-message": "^1.0",
@ -2557,26 +2504,26 @@
],
"support": {
"issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v6.0.13"
"source": "https://github.com/top-think/framework/tree/v6.1.1"
},
"time": "2022-07-15T02:52:08+00:00"
"time": "2022-10-26T03:48:53+00:00"
},
{
"name": "topthink/think-captcha",
"version": "v3.0.7",
"version": "v3.0.8",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-captcha.git",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331"
"reference": "52fba122c953995bec3013c635025172491ae299"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/a450602932a5d9ba183e288b79921ba3b9a92331",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/52fba122c953995bec3013c635025172491ae299",
"reference": "52fba122c953995bec3013c635025172491ae299",
"shasum": ""
},
"require": {
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"type": "library",
"extra": {
@ -2610,9 +2557,9 @@
"description": "captcha package for thinkphp",
"support": {
"issues": "https://github.com/top-think/think-captcha/issues",
"source": "https://github.com/top-think/think-captcha/tree/v3.0.7"
"source": "https://github.com/top-think/think-captcha/tree/v3.0.8"
},
"time": "2022-04-23T02:38:14+00:00"
"time": "2022-10-26T07:59:42+00:00"
},
{
"name": "topthink/think-helper",
@ -2707,20 +2654,20 @@
},
{
"name": "topthink/think-migration",
"version": "v3.0.3",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-migration.git",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79"
"reference": "c5880669b277762d5ff935e551bc0d5c71de6811"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/c5880669b277762d5ff935e551bc0d5c71de6811",
"reference": "c5880669b277762d5ff935e551bc0d5c71de6811",
"shasum": ""
},
"require": {
"topthink/framework": "^6.0.0",
"topthink/framework": "^6.0",
"topthink/think-helper": "^3.0.3"
},
"require-dev": {
@ -2755,27 +2702,27 @@
],
"support": {
"issues": "https://github.com/top-think/think-migration/issues",
"source": "https://github.com/top-think/think-migration/tree/v3.0.3"
"source": "https://github.com/top-think/think-migration/tree/v3.0.4"
},
"time": "2020-12-07T05:54:22+00:00"
"time": "2022-10-26T07:57:54+00:00"
},
{
"name": "topthink/think-multi-app",
"version": "v1.0.14",
"version": "v1.0.15",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-multi-app.git",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3"
"reference": "387e0dac059c20f92cac5da41a871e10829c1c97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/387e0dac059c20f92cac5da41a871e10829c1c97",
"reference": "387e0dac059c20f92cac5da41a871e10829c1c97",
"shasum": ""
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"type": "library",
"extra": {
@ -2803,22 +2750,22 @@
"description": "thinkphp6 multi app support",
"support": {
"issues": "https://github.com/top-think/think-multi-app/issues",
"source": "https://github.com/top-think/think-multi-app/tree/master"
"source": "https://github.com/top-think/think-multi-app/tree/v1.0.15"
},
"time": "2020-07-12T13:50:37+00:00"
"time": "2022-10-26T08:03:06+00:00"
},
{
"name": "topthink/think-orm",
"version": "v2.0.54",
"version": "v2.0.55",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-orm.git",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e"
"reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/97b061b47616301ff29fbd4c35ed9184e1162e4e",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"shasum": ""
},
"require": {
@ -2858,9 +2805,9 @@
],
"support": {
"issues": "https://github.com/top-think/think-orm/issues",
"source": "https://github.com/top-think/think-orm/tree/v2.0.54"
"source": "https://github.com/top-think/think-orm/tree/v2.0.55"
},
"time": "2022-07-05T05:25:51+00:00"
"time": "2022-09-27T14:18:43+00:00"
},
{
"name": "topthink/think-template",
@ -3328,21 +3275,21 @@
"packages-dev": [
{
"name": "topthink/think-trace",
"version": "v1.4",
"version": "v1.5",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-trace.git",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444"
"reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-trace/zipball/9a9fa8f767b6c66c5a133ad21ca1bc96ad329444",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444",
"url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"shasum": ""
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"type": "library",
"extra": {
@ -3373,9 +3320,9 @@
"description": "thinkphp debug trace",
"support": {
"issues": "https://github.com/top-think/think-trace/issues",
"source": "https://github.com/top-think/think-trace/tree/v1.4"
"source": "https://github.com/top-think/think-trace/tree/v1.5"
},
"time": "2020-06-29T05:27:28+00:00"
"time": "2022-10-26T07:56:45+00:00"
}
],
"aliases": [],

View File

@ -16,7 +16,7 @@ return [
// 应用名,此项不可更改
'appname' => 'TaoLer',
// 版本配置
'version' => '2.0.6',
'version' => '2.0.8',
// 加盐
'salt' => 'taoler',
// 数据库备份目录

View File

@ -8,10 +8,11 @@
*/
layui.define(['table', 'form'], function(exports){
layui.define(['table', 'form', 'notify'], function(exports){
var $ = layui.$
,table = layui.table
,form = layui.form;
var notify = layui.notify;
//用户管理
table.render({
@ -97,10 +98,11 @@ layui.define(['table', 'form'], function(exports){
data:{"id":field.id,"name":field.username,"phone":field.phone,"email":field.email,"user_img":field.avatar,"sex":field.sex},
daType:"json",
success:function (res){
if(data.code == 0){
if(res.code === 0){
notify.success(res.msg);
layer.msg(data.msg,{icon:6,time:2000});
} else {
layer.open({title:'修改失败',content:data.msg,icon:5,adim:6})
notify.error(res.msg);
}
}
});

View File

@ -14,7 +14,7 @@ return array(
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/framework/src/think'),
'taoser\\think\\' => array($vendorDir . '/taoser/think-auth/src'),
'taoser\\' => array($vendorDir . '/taoser/think-addons/src', $vendorDir . '/taoser/think-setarr/src'),
'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'),
@ -42,7 +42,6 @@ return array(
'PHPSocketIO\\' => array($vendorDir . '/workerman/phpsocket.io/src'),
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
'League\\MimeTypeDetection\\' => array($vendorDir . '/league/mime-type-detection/src'),
'League\\Flysystem\\Cached\\' => array($vendorDir . '/league/flysystem-cached-adapter/src'),
'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
'Laravel\\SerializableClosure\\' => array($vendorDir . '/laravel/serializable-closure/src'),
'Jaeger\\' => array($vendorDir . '/jaeger/g-http/src'),

View File

@ -102,7 +102,6 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2
'L' =>
array (
'League\\MimeTypeDetection\\' => 25,
'League\\Flysystem\\Cached\\' => 24,
'League\\Flysystem\\' => 17,
'Laravel\\SerializableClosure\\' => 28,
),
@ -181,10 +180,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2
),
'think\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/framework/src/think',
1 => __DIR__ . '/..' . '/topthink/think-helper/src',
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
1 => __DIR__ . '/..' . '/topthink/think-template/src',
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
3 => __DIR__ . '/..' . '/topthink/think-template/src',
3 => __DIR__ . '/..' . '/topthink/framework/src/think',
),
'taoser\\think\\' =>
array (
@ -295,10 +294,6 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2
array (
0 => __DIR__ . '/..' . '/league/mime-type-detection/src',
),
'League\\Flysystem\\Cached\\' =>
array (
0 => __DIR__ . '/..' . '/league/flysystem-cached-adapter/src',
),
'League\\Flysystem\\' =>
array (
0 => __DIR__ . '/..' . '/league/flysystem/src',

View File

@ -313,17 +313,17 @@
},
{
"name": "endroid/qr-code",
"version": "4.6.0",
"version_normalized": "4.6.0.0",
"version": "4.6.1",
"version_normalized": "4.6.1.0",
"source": {
"type": "git",
"url": "https://github.com/endroid/qr-code.git",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c"
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/b60873b14e2ca7bf3c3746f5e032023095a7e05c",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"shasum": ""
},
"require": {
@ -342,7 +342,7 @@
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
"setasign/fpdf": "Enables you to use the PDF writer"
},
"time": "2022-10-04T17:13:41+00:00",
"time": "2022-10-26T08:48:17+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -376,7 +376,7 @@
],
"support": {
"issues": "https://github.com/endroid/qr-code/issues",
"source": "https://github.com/endroid/qr-code/tree/4.6.0"
"source": "https://github.com/endroid/qr-code/tree/4.6.1"
},
"funding": [
{
@ -1057,62 +1057,6 @@
],
"install-path": "../league/flysystem"
},
{
"name": "league/flysystem-cached-adapter",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-cached-adapter.git",
"reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/d1925efb2207ac4be3ad0c40b8277175f99ffaff",
"reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"league/flysystem": "~1.0",
"psr/cache": "^1.0.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7",
"predis/predis": "~1.0",
"tedivm/stash": "~0.12"
},
"suggest": {
"ext-phpredis": "Pure C implemented extension for PHP"
},
"time": "2020-07-25T15:56:04+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"League\\Flysystem\\Cached\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "frankdejonge",
"email": "info@frenky.net"
}
],
"description": "An adapter decorator to enable meta-data caching.",
"install-path": "../league/flysystem-cached-adapter"
},
{
"name": "league/mime-type-detection",
"version": "1.11.0",
@ -2650,24 +2594,22 @@
},
{
"name": "topthink/framework",
"version": "v6.0.13",
"version_normalized": "6.0.13.0",
"version": "v6.1.1",
"version_normalized": "6.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6"
"reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6",
"url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"league/flysystem": "^1.1.4",
"league/flysystem-cached-adapter": "^1.0",
"php": ">=7.2.5",
"psr/container": "~1.0",
"psr/http-message": "^1.0",
@ -2682,7 +2624,7 @@
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.0"
},
"time": "2022-07-15T02:52:08+00:00",
"time": "2022-10-26T03:48:53+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2714,35 +2656,29 @@
],
"support": {
"issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v6.0.13"
"source": "https://github.com/top-think/framework/tree/v6.1.1"
},
"install-path": "../topthink/framework"
},
{
"name": "topthink/think-captcha",
"version": "v3.0.7",
"version_normalized": "3.0.7.0",
"version": "v3.0.8",
"version_normalized": "3.0.8.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-captcha.git",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331"
"reference": "52fba122c953995bec3013c635025172491ae299"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/a450602932a5d9ba183e288b79921ba3b9a92331",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/52fba122c953995bec3013c635025172491ae299",
"reference": "52fba122c953995bec3013c635025172491ae299",
"shasum": ""
},
"require": {
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"time": "2022-04-23T02:38:14+00:00",
"time": "2022-10-26T07:59:42+00:00",
"type": "library",
"extra": {
"think": {
@ -2776,7 +2712,7 @@
"description": "captcha package for thinkphp",
"support": {
"issues": "https://github.com/top-think/think-captcha/issues",
"source": "https://github.com/top-think/think-captcha/tree/v3.0.7"
"source": "https://github.com/top-think/think-captcha/tree/v3.0.8"
},
"install-path": "../topthink/think-captcha"
},
@ -2891,21 +2827,21 @@
},
{
"name": "topthink/think-migration",
"version": "v3.0.3",
"version_normalized": "3.0.3.0",
"version": "v3.0.4",
"version_normalized": "3.0.4.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-migration.git",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79"
"reference": "c5880669b277762d5ff935e551bc0d5c71de6811"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/c5880669b277762d5ff935e551bc0d5c71de6811",
"reference": "c5880669b277762d5ff935e551bc0d5c71de6811",
"shasum": ""
},
"require": {
"topthink/framework": "^6.0.0",
"topthink/framework": "^6.0",
"topthink/think-helper": "^3.0.3"
},
"require-dev": {
@ -2914,7 +2850,7 @@
"suggest": {
"fzaninotto/faker": "Required to use the factory builder (^1.8)."
},
"time": "2020-12-07T05:54:22+00:00",
"time": "2022-10-26T07:57:54+00:00",
"type": "library",
"extra": {
"think": {
@ -2942,36 +2878,30 @@
],
"support": {
"issues": "https://github.com/top-think/think-migration/issues",
"source": "https://github.com/top-think/think-migration/tree/v3.0.3"
"source": "https://github.com/top-think/think-migration/tree/v3.0.4"
},
"install-path": "../topthink/think-migration"
},
{
"name": "topthink/think-multi-app",
"version": "v1.0.14",
"version_normalized": "1.0.14.0",
"version": "v1.0.15",
"version_normalized": "1.0.15.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-multi-app.git",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3"
"reference": "387e0dac059c20f92cac5da41a871e10829c1c97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/387e0dac059c20f92cac5da41a871e10829c1c97",
"reference": "387e0dac059c20f92cac5da41a871e10829c1c97",
"shasum": ""
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"time": "2020-07-12T13:50:37+00:00",
"time": "2022-10-26T08:03:06+00:00",
"type": "library",
"extra": {
"think": {
@ -2997,21 +2927,25 @@
}
],
"description": "thinkphp6 multi app support",
"support": {
"issues": "https://github.com/top-think/think-multi-app/issues",
"source": "https://github.com/top-think/think-multi-app/tree/v1.0.15"
},
"install-path": "../topthink/think-multi-app"
},
{
"name": "topthink/think-orm",
"version": "v2.0.54",
"version_normalized": "2.0.54.0",
"version": "v2.0.55",
"version_normalized": "2.0.55.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-orm.git",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e"
"reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/97b061b47616301ff29fbd4c35ed9184e1162e4e",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"shasum": ""
},
"require": {
@ -3025,7 +2959,7 @@
"require-dev": {
"phpunit/phpunit": "^7|^8|^9.5"
},
"time": "2022-07-05T05:25:51+00:00",
"time": "2022-09-27T14:18:43+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -3053,7 +2987,7 @@
],
"support": {
"issues": "https://github.com/top-think/think-orm/issues",
"source": "https://github.com/top-think/think-orm/tree/v2.0.54"
"source": "https://github.com/top-think/think-orm/tree/v2.0.55"
},
"install-path": "../topthink/think-orm"
},
@ -3109,30 +3043,24 @@
},
{
"name": "topthink/think-trace",
"version": "v1.4",
"version_normalized": "1.4.0.0",
"version": "v1.5",
"version_normalized": "1.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-trace.git",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444"
"reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-trace/zipball/9a9fa8f767b6c66c5a133ad21ca1bc96ad329444",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"shasum": ""
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"time": "2020-06-29T05:27:28+00:00",
"time": "2022-10-26T07:56:45+00:00",
"type": "library",
"extra": {
"think": {
@ -3161,6 +3089,10 @@
}
],
"description": "thinkphp debug trace",
"support": {
"issues": "https://github.com/top-think/think-trace/issues",
"source": "https://github.com/top-think/think-trace/tree/v1.5"
},
"install-path": "../topthink/think-trace"
},
{

View File

@ -3,7 +3,7 @@
'name' => 'taoser/taoler',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'db01522b1bc5e463fdc10fc88dcc01a3eee4f23a',
'reference' => 'd0f1021f8dc728187d75d1722deac92d73a25d82',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -56,9 +56,9 @@
'dev_requirement' => false,
),
'endroid/qr-code' => array(
'pretty_version' => '4.6.0',
'version' => '4.6.0.0',
'reference' => 'b60873b14e2ca7bf3c3746f5e032023095a7e05c',
'pretty_version' => '4.6.1',
'version' => '4.6.1.0',
'reference' => 'a75c913b0e4d6ad275e49a2c1de1cacffc6c2184',
'type' => 'library',
'install_path' => __DIR__ . '/../endroid/qr-code',
'aliases' => array(),
@ -145,15 +145,6 @@
'aliases' => array(),
'dev_requirement' => false,
),
'league/flysystem-cached-adapter' => array(
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'reference' => 'd1925efb2207ac4be3ad0c40b8277175f99ffaff',
'type' => 'library',
'install_path' => __DIR__ . '/../league/flysystem-cached-adapter',
'aliases' => array(),
'dev_requirement' => false,
),
'league/mime-type-detection' => array(
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
@ -367,7 +358,7 @@
'taoser/taoler' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'db01522b1bc5e463fdc10fc88dcc01a3eee4f23a',
'reference' => 'd0f1021f8dc728187d75d1722deac92d73a25d82',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -410,18 +401,18 @@
'dev_requirement' => false,
),
'topthink/framework' => array(
'pretty_version' => 'v6.0.13',
'version' => '6.0.13.0',
'reference' => '126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6',
'pretty_version' => 'v6.1.1',
'version' => '6.1.1.0',
'reference' => '2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/framework',
'aliases' => array(),
'dev_requirement' => false,
),
'topthink/think-captcha' => array(
'pretty_version' => 'v3.0.7',
'version' => '3.0.7.0',
'reference' => 'a450602932a5d9ba183e288b79921ba3b9a92331',
'pretty_version' => 'v3.0.8',
'version' => '3.0.8.0',
'reference' => '52fba122c953995bec3013c635025172491ae299',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-captcha',
'aliases' => array(),
@ -446,27 +437,27 @@
'dev_requirement' => false,
),
'topthink/think-migration' => array(
'pretty_version' => 'v3.0.3',
'version' => '3.0.3.0',
'reference' => '5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79',
'pretty_version' => 'v3.0.4',
'version' => '3.0.4.0',
'reference' => 'c5880669b277762d5ff935e551bc0d5c71de6811',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-migration',
'aliases' => array(),
'dev_requirement' => false,
),
'topthink/think-multi-app' => array(
'pretty_version' => 'v1.0.14',
'version' => '1.0.14.0',
'reference' => 'ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3',
'pretty_version' => 'v1.0.15',
'version' => '1.0.15.0',
'reference' => '387e0dac059c20f92cac5da41a871e10829c1c97',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-multi-app',
'aliases' => array(),
'dev_requirement' => false,
),
'topthink/think-orm' => array(
'pretty_version' => 'v2.0.54',
'version' => '2.0.54.0',
'reference' => '97b061b47616301ff29fbd4c35ed9184e1162e4e',
'pretty_version' => 'v2.0.55',
'version' => '2.0.55.0',
'reference' => 'e1974a4c3b1b4c5b808fcc0863fc254e711dee13',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-orm',
'aliases' => array(),
@ -482,9 +473,9 @@
'dev_requirement' => false,
),
'topthink/think-trace' => array(
'pretty_version' => 'v1.4',
'version' => '1.4.0.0',
'reference' => '9a9fa8f767b6c66c5a133ad21ca1bc96ad329444',
'pretty_version' => 'v1.5',
'version' => '1.5.0.0',
'reference' => '55027fd79abb744f32a3be8d9e1ccf873a3ca9b7',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-trace',
'aliases' => array(),

View File

@ -133,27 +133,17 @@ final class PngWriter implements WriterInterface, ValidatingWriterInterface
}
$targetImage = $result->getImage();
$matrix = $result->getMatrix();
if ($logoImageData->getPunchoutBackground()) {
/** @var int $transparent */
$transparent = imagecolorallocatealpha($targetImage, 255, 255, 255, 127);
imagealphablending($targetImage, false);
for (
$x_offset = intval(imagesx($targetImage) / 2 - $logoImageData->getWidth() / 2);
$x_offset < intval(imagesx($targetImage) / 2 - $logoImageData->getWidth() / 2) + $logoImageData->getWidth();
++$x_offset
) {
for (
$y_offset = intval(imagesy($targetImage) / 2 - $logoImageData->getHeight() / 2);
$y_offset < intval(imagesy($targetImage) / 2 - $logoImageData->getHeight() / 2) + $logoImageData->getHeight();
++$y_offset
) {
imagesetpixel(
$targetImage,
$x_offset,
$y_offset,
$transparent
);
$xOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2);
$yOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2);
for ($xOffset = $xOffsetStart; $xOffset < $xOffsetStart + $logoImageData->getWidth(); ++$xOffset) {
for ($yOffset = $yOffsetStart; $yOffset < $yOffsetStart + $logoImageData->getHeight(); ++$yOffset) {
imagesetpixel($targetImage, $xOffset, $yOffset, $transparent);
}
}
}
@ -161,8 +151,8 @@ final class PngWriter implements WriterInterface, ValidatingWriterInterface
imagecopyresampled(
$targetImage,
$logoImageData->getImage(),
intval(imagesx($targetImage) / 2 - $logoImageData->getWidth() / 2),
intval(imagesx($targetImage) / 2 - $logoImageData->getHeight() / 2),
intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2),
intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2),
0,
0,
$logoImageData->getWidth(),
@ -175,7 +165,7 @@ final class PngWriter implements WriterInterface, ValidatingWriterInterface
imagedestroy($logoImageData->getImage());
}
return new PngResult($result->getMatrix(), $targetImage);
return new PngResult($matrix, $targetImage);
}
private function addLabel(LabelInterface $label, PngResult $result): PngResult

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2022-10-17 08:21:26
// This file is automatically generated at:2022-10-30 14:42:32
declare (strict_types = 1);
return array (
0 => 'taoser\\addons\\Service',

View File

@ -15,15 +15,37 @@ class Controller extends BaseController
{
// app 容器
protected $app;
// 当前插件操作
protected $addon = null;
// 请求对象
protected $request;
// 当前插件标识
protected $name;
// 插件路径
protected $addon_path;
protected $controller = null;
protected $action = null;
// 视图模型
protected $view;
/**
* 无需登录的方法,同时也就不需要鉴权了
* @var array
*/
protected $noNeedLogin = ['*'];
/**
* 无需鉴权的方法,但需要登录
* @var array
*/
protected $noNeedRight = ['*'];
/**
* 权限Auth
* @var Auth
*/
protected $auth = null;
/**
* 插件构造函数
@ -35,6 +57,8 @@ class Controller extends BaseController
$this->app = $app;
$this->request = $app->request;
$this->name = $this->getName();
$this->controller = $this->request->controller();
$this->action = $this->request->action();
$this->addon_path = $app->addons->getAddonsPath() . $this->name . DIRECTORY_SEPARATOR;
$this->addon_config = "addon_{$this->name}_config";
$this->addon_info = "addon_{$this->name}_info";
@ -44,12 +68,17 @@ class Controller extends BaseController
]);
// 控制器初始化
$this->initialize();
$this->_initialize();
parent::__construct($app);
}
// 初始化
protected function initialize()
{}
protected function _initialize()
{
$controller = $this->controller;
$action = $this->action;
}
/**
* 获取插件标识

View File

@ -1,6 +1,6 @@
![](https://box.kancloud.cn/5a0aaa69a5ff42657b5c4715f3d49221)
ThinkPHP 6.0
ThinkPHP 6.1
===============
[![Build Status](https://travis-ci.org/top-think/framework.svg?branch=6.0)](https://travis-ci.org/top-think/framework)
@ -11,9 +11,8 @@ ThinkPHP 6.0
[![PHP Version](https://img.shields.io/badge/php-%3E%3D7.1-8892BF.svg)](http://www.php.net/)
[![License](https://poser.pugx.org/topthink/framework/license)](https://packagist.org/packages/topthink/framework)
ThinkPHP6.0底层架构采用PHP7.1改写和进一步优化。
[官方应用服务市场](https://market.topthink.com) | [`ThinkAPI`——官方统一API服务](https://docs.topthink.com/think-api/)
[官方服务](https://www.topthink.com) | [`ThinkAPI`——官方统一API](https://doc.topthink.com/think-api)
## 主要新特性
@ -35,7 +34,7 @@ ThinkPHP6.0底层架构采用PHP7.1改写和进一步优化。
* 统一和精简大量用法
> ThinkPHP6.0的运行环境要求PHP7.2+兼容PHP8.1
> ThinkPHP6.1的运行环境要求PHP7.2.5+兼容PHP8.1
## 安装

View File

@ -22,8 +22,6 @@
"php": ">=7.2.5",
"ext-json": "*",
"ext-mbstring": "*",
"league/flysystem": "^1.1.4",
"league/flysystem-cached-adapter": "^1.0",
"psr/log": "~1.0",
"psr/container": "~1.0",
"psr/simple-cache": "^1.0",

View File

@ -39,7 +39,7 @@ use think\initializer\RegisterService;
*/
class App extends Container
{
const VERSION = '6.0.13LTS';
const VERSION = '6.1.0';
/**
* 应用调试模式
@ -152,7 +152,6 @@ class App extends Container
'session' => Session::class,
'validate' => Validate::class,
'view' => View::class,
'filesystem' => Filesystem::class,
'think\DbManager' => Db::class,
'think\LogManager' => Log::class,
'think\CacheManager' => Cache::class,

View File

@ -117,9 +117,9 @@ class Console
*/
protected function makeRequest()
{
$uri = $this->app->config->get('app.url', 'http://localhost');
$url = $this->app->config->get('app.url', 'http://localhost');
$components = parse_url($uri);
$components = parse_url($url);
$server = $_SERVER;
@ -127,6 +127,7 @@ class Console
$server = array_merge($server, [
'SCRIPT_FILENAME' => $components['path'],
'SCRIPT_NAME' => $components['path'],
'REQUEST_URI' => $components['path'],
]);
}
@ -150,8 +151,6 @@ class Console
$server['HTTP_HOST'] .= ':' . $components['port'];
}
$server['REQUEST_URI'] = $uri;
/** @var Request $request */
$request = $this->app->make('request');

View File

@ -287,58 +287,4 @@ class Lang
return $value;
}
/**
* 自动侦测设置获取语言选择
* @deprecated
* @access public
* @param Request $request
* @return string
*/
public function detect(Request $request): string
{
// 自动侦测设置获取语言选择
$langSet = '';
if ($request->get($this->config['detect_var'])) {
// url中设置了语言变量
$langSet = strtolower($request->get($this->config['detect_var']));
} elseif ($request->header($this->config['header_var'])) {
// Header中设置了语言变量
$langSet = strtolower($request->header($this->config['header_var']));
} elseif ($request->cookie($this->config['cookie_var'])) {
// Cookie中设置了语言变量
$langSet = strtolower($request->cookie($this->config['cookie_var']));
} elseif ($request->server('HTTP_ACCEPT_LANGUAGE')) {
// 自动侦测浏览器语言
$match = preg_match('/^([a-z\d\-]+)/i', $request->server('HTTP_ACCEPT_LANGUAGE'), $matches);
if ($match) {
$langSet = strtolower($matches[1]);
if (isset($this->config['accept_language'][$langSet])) {
$langSet = $this->config['accept_language'][$langSet];
}
}
}
if (empty($this->config['allow_lang_list']) || in_array($langSet, $this->config['allow_lang_list'])) {
// 合法的语言
$this->range = $langSet;
}
return $this->range;
}
/**
* 保存当前语言到Cookie
* @deprecated
* @access public
* @param Cookie $cookie Cookie对象
* @return void
*/
public function saveToCookie(Cookie $cookie)
{
if ($this->config['use_cookie']) {
$cookie->set($this->config['cookie_var'], $this->range);
}
}
}

View File

@ -70,33 +70,35 @@ class LoadLangPack
if ($request->get($this->config['detect_var'])) {
// url中设置了语言变量
$langSet = strtolower($request->get($this->config['detect_var']));
$langSet = $request->get($this->config['detect_var']);
} elseif ($request->header($this->config['header_var'])) {
// Header中设置了语言变量
$langSet = strtolower($request->header($this->config['header_var']));
$langSet = $request->header($this->config['header_var']);
} elseif ($request->cookie($this->config['cookie_var'])) {
// Cookie中设置了语言变量
$langSet = strtolower($request->cookie($this->config['cookie_var']));
$langSet = $request->cookie($this->config['cookie_var']);
} elseif ($request->server('HTTP_ACCEPT_LANGUAGE')) {
// 自动侦测浏览器语言
$match = preg_match('/^([a-z\d\-]+)/i', $request->server('HTTP_ACCEPT_LANGUAGE'), $matches);
if ($match) {
$langSet = strtolower($matches[1]);
if (isset($this->config['accept_language'][$langSet])) {
$langSet = $this->config['accept_language'][$langSet];
}
$langSet = $request->server('HTTP_ACCEPT_LANGUAGE');
}
if (preg_match('/^([a-z\d\-]+)/i', $langSet, $matches)) {
$langSet = strtolower($matches[1]);
if (isset($this->config['accept_language'][$langSet])) {
$langSet = $this->config['accept_language'][$langSet];
}
} else {
$langSet = $this->lang->getLangSet();
}
if (empty($this->config['allow_lang_list']) || in_array($langSet, $this->config['allow_lang_list'])) {
// 合法的语言
$range = $langSet;
$this->lang->setLangSet($range);
$this->lang->setLangSet($langSet);
} else {
$range = $this->lang->getLangSet();
$langSet = $this->lang->getLangSet();
}
return $range;
return $langSet;
}
/**

View File

@ -9,7 +9,7 @@
],
"license": "Apache-2.0",
"require": {
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"autoload": {
"psr-4": {

View File

@ -177,6 +177,10 @@ class Captcha
$this->imageW || $this->imageW = $this->length * $this->fontSize * 1.5 + $this->length * $this->fontSize / 2;
// 图片高(px)
$this->imageH || $this->imageH = $this->fontSize * 2.5;
$this->imageW = intval($this->imageW);
$this->imageH = intval($this->imageH);
// 建立一幅 $this->imageW x $this->imageH 的图像
$this->im = imagecreate((int) $this->imageW, (int) $this->imageH);
// 设置背景
@ -224,7 +228,7 @@ class Captcha
$y = $this->fontSize + mt_rand(10, 20);
$angle = $this->math ? 0 : mt_rand(-40, 40);
imagettftext($this->im, $this->fontSize, $angle, (int) $x, (int) $y, $this->color, $fontttf, $char);
imagettftext($this->im, intval($this->fontSize), intval($this->fontSize), intval($x), intval($y), $this->color, $fontttf, $char);
}
ob_start();
@ -253,10 +257,10 @@ class Captcha
$px = $py = 0;
// 曲线前部分
$A = mt_rand(1, (int) ($this->imageH / 2)); // 振幅
$b = mt_rand(-intval($this->imageH / 4), intval($this->imageH / 4)); // Y轴方向偏移量
$f = mt_rand(-intval($this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量
$T = mt_rand((int)$this->imageH, intval($this->imageW * 2)); // 周期
$A = mt_rand(1, intval($this->imageH / 2)); // 振幅
$b = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // Y轴方向偏移量
$f = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量
$T = mt_rand($this->imageH, $this->imageW * 2); // 周期
$w = (2 * M_PI) / $T;
$px1 = 0; // 曲线横坐标起始位置
@ -267,16 +271,16 @@ class Captcha
$py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b
$i = (int) ($this->fontSize / 5);
while ($i > 0) {
imagesetpixel($this->im, (int) $px + $i, (int) $py + $i, $this->color); // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出不用这while循环性能要好很多
imagesetpixel($this->im, intval($px + $i), intval($py + $i), $this->color); // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出不用这while循环性能要好很多
$i--;
}
}
}
// 曲线后部分
$A = mt_rand(1, (int) ($this->imageH / 2)); // 振幅
$f = mt_rand(-(int) ($this->imageH / 4), (int) ($this->imageH / 4)); // X轴方向偏移量
$T = mt_rand((int) $this->imageH, (int) ($this->imageW * 2)); // 周期
$A = mt_rand(1, intval($this->imageH / 2)); // 振幅
$f = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量
$T = mt_rand($this->imageH, $this->imageW * 2); // 周期
$w = (2 * M_PI) / $T;
$b = $py - $A * sin($w * $px + $f) - $this->imageH / 2;
$px1 = $px2;
@ -287,7 +291,7 @@ class Captcha
$py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b
$i = (int) ($this->fontSize / 5);
while ($i > 0) {
imagesetpixel($this->im, (int) ($px + $i), (int) ($py + $i), $this->color);
imagesetpixel($this->im, intval($px + $i), intval($py + $i), $this->color);
$i--;
}
}
@ -306,7 +310,7 @@ class Captcha
$noiseColor = imagecolorallocate($this->im, mt_rand(150, 225), mt_rand(150, 225), mt_rand(150, 225));
for ($j = 0; $j < 5; $j++) {
// 绘杂点
imagestring($this->im, 5, mt_rand(-10, (int) $this->imageW), mt_rand(-10, (int) $this->imageH), $codeSet[mt_rand(0, 29)], $noiseColor);
imagestring($this->im, 5, mt_rand(-10, $this->imageW), mt_rand(-10, $this->imageH), $codeSet[mt_rand(0, 29)], $noiseColor);
}
}
}
@ -336,5 +340,4 @@ class Captcha
@imagecopyresampled($this->im, $bgImage, 0, 0, 0, 0, $this->imageW, $this->imageH, $width, $height);
@imagedestroy($bgImage);
}
}

View File

@ -21,7 +21,7 @@
}
},
"require": {
"topthink/framework": "^6.0.0",
"topthink/framework": "^6.0",
"topthink/think-helper": "^3.0.3"
},
"minimum-stability": "dev",

View File

@ -85,11 +85,11 @@ class FactoryBuilder
*
* @param string $class
* @param string $name
* @param array $definitions
* @param array $states
* @param array $afterMaking
* @param array $afterCreating
* @param Faker $faker
* @param array $definitions
* @param array $states
* @param array $afterMaking
* @param array $afterCreating
* @param Faker $faker
* @return void
*/
public function __construct($class, $name, array $definitions, array $states,
@ -283,9 +283,12 @@ class FactoryBuilder
*/
protected function makeInstance(array $attributes = [])
{
return new $this->class(
$this->getRawAttributes($attributes)
);
/** @var Model $model */
$model = new $this->class;
$model->setAttrs($this->getRawAttributes($attributes));
return $model;
}
/**
@ -319,7 +322,7 @@ class FactoryBuilder
* Get the state attributes.
*
* @param string $state
* @param array $attributes
* @param array $attributes
* @return array
*/
protected function stateAttributes($state, array $attributes)
@ -386,7 +389,7 @@ class FactoryBuilder
/**
* Call after callbacks for each model and state.
*
* @param array $afterCallbacks
* @param array $afterCallbacks
* @param Collection $models
* @return void
*/
@ -404,8 +407,8 @@ class FactoryBuilder
/**
* Call after callbacks for each model and state.
*
* @param array $afterCallbacks
* @param Model $model
* @param array $afterCallbacks
* @param Model $model
* @param string $state
* @return void
*/

View File

@ -14,5 +14,11 @@ use Phinx\Seed\AbstractSeed;
class Seeder extends AbstractSeed
{
/**
* @return Factory
*/
public function factory()
{
return app(Factory::class);
}
}

View File

@ -26,7 +26,7 @@ class Create extends Command
->addArgument('name', InputArgument::REQUIRED, 'What is the name of the model?');
}
protected function handle()
public function handle()
{
$path = $this->getPath();

View File

@ -74,6 +74,8 @@ EOT
$status = ' <info>up</info> ';
} else {
$status = ' <error>down</error> ';
$version = [];
$version['start_time'] = $version['end_time'] = $version['breakpoint'] = '';
}
$maxNameLength = max($maxNameLength, strlen($migration->getName()));

View File

@ -10,7 +10,7 @@
],
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"autoload": {
"psr-4": {

View File

@ -42,15 +42,17 @@ class Url extends UrlBuild
// 解析到控制器
$url = substr($url, 1);
} elseif ('' === $url) {
$url = $this->getAppName() . '/' . $request->controller() . '/' . $request->action();
$url = $request->controller() . '/' . $request->action();
if (!$this->app->http->isBind()) {
$url = $this->getAppName() . '/' . $url;
}
} else {
// 解析到 应用/控制器/操作
$controller = $request->controller();
$app = $this->getAppName();
$path = explode('/', $url);
$action = array_pop($path);
$controller = empty($path) ? $controller : array_pop($path);
$app = empty($path) ? $app : array_pop($path);
$app = empty($path) ? $this->getAppName() : array_pop($path);
$url = $controller . '/' . $action;
$bind = $this->app->config->get('app.domain_bind', []);
@ -58,7 +60,7 @@ class Url extends UrlBuild
isset($bind[$_SERVER['SERVER_NAME']]) && $domain = $_SERVER['SERVER_NAME'];
$domain = is_bool($domain) ? $key : $domain;
} else {
} elseif (!$this->app->http->isBind()) {
$url = $app . '/' . $url;
}
}

View File

@ -559,23 +559,4 @@ trait ModelRelationQuery
$result->refreshOrigin();
}
/**
* 查询软删除数据
* @access public
* @return Query
*/
public function withTrashed()
{
return $this->model ? $this->model->queryWithTrashed() : $this;
}
/**
* 只查询软删除数据
* @access public
* @return Query
*/
public function onlyTrashed()
{
return $this->model ? $this->model->queryOnlyTrashed() : $this;
}
}

View File

@ -383,7 +383,7 @@ trait Attribute
} elseif (isset($this->type[$name])) {
// 类型转换
$value = $this->writeTransform($value, $this->type[$name]);
} elseif (array_key_exists($name, $this->origin) && is_object($value) && method_exists($value, '__toString')) {
} elseif ((array_key_exists($name, $this->origin) || empty($this->origin)) && is_object($value) && method_exists($value, '__toString')) {
// 对象类型
$value = $value->__toString();
}

View File

@ -18,14 +18,18 @@ use think\Model;
/**
* 数据软删除
* @mixin Model
* @method $this withTrashed()
* @method $this onlyTrashed()
*/
trait SoftDelete
{
/**
* 是否包含软删除数据
* @var bool
*/
protected $withTrashed = false;
public function db($scope = []): Query
{
$query = parent::db($scope);
$this->withNoTrashed($query);
return $query;
}
/**
* 判断当前实例是否被软删除
@ -43,74 +47,18 @@ trait SoftDelete
return false;
}
/**
* 查询软删除数据
* @access public
* @return Query
*/
public static function withTrashed(): Query
public function scopeWithTrashed(Query $query)
{
$model = new static();
return $model->withTrashedData(true)->db();
$query->removeOption('soft_delete');
}
/**
* 查询软删除数据
* @access public
* @return Query
*/
public function queryWithTrashed(): Query
{
return $this->withTrashedData(true)->db();
}
/**
* 是否包含软删除数据
* @access protected
* @param bool $withTrashed 是否包含软删除数据
* @return $this
*/
protected function withTrashedData(bool $withTrashed)
{
$this->withTrashed = $withTrashed;
return $this;
}
/**
* 只查询软删除数据
* @access public
* @return Query
*/
public static function onlyTrashed(): Query
{
$model = new static();
$field = $model->getDeleteTimeField(true);
if ($field) {
return $model
->db()
->useSoftDelete($field, $model->getWithTrashedExp());
}
return $model->db();
}
/**
* 只查询软删除数据
* @access public
* @return Query
*/
public function queryOnlyTrashed(): Query
public function scopeOnlyTrashed(Query $query)
{
$field = $this->getDeleteTimeField(true);
if ($field) {
return $this->db()
->useSoftDelete($field, $this->getWithTrashedExp());
$query->useSoftDelete($field, $this->getWithTrashedExp());
}
return $this->db();
}
/**
@ -139,9 +87,9 @@ trait SoftDelete
if ($name && !$force) {
// 软删除
$this->set($name, $this->autoWriteTimestamp($name));
$this->set($name, $this->autoWriteTimestamp());
$result = $this->exists()->withEvent(false)->save();
$this->exists()->withEvent(false)->save();
$this->withEvent(true);
} else {
@ -149,7 +97,7 @@ trait SoftDelete
$where = $this->getWhere();
// 删除当前模型数据
$result = $this->db()
$this->db()
->where($where)
->removeOption('soft_delete')
->delete();
@ -172,8 +120,8 @@ trait SoftDelete
/**
* 删除记录
* @access public
* @param mixed $data 主键列表 支持闭包查询条件
* @param bool $force 是否强制删除
* @param mixed $data 主键列表 支持闭包查询条件
* @param bool $force 是否强制删除
* @return bool
*/
public static function destroy($data, bool $force = false): bool
@ -182,18 +130,20 @@ trait SoftDelete
if (empty($data) && 0 !== $data) {
return false;
}
// 仅当强制删除时包含软删除数据
$model = (new static());
if ($force) {
$model->withTrashedData(true);
}
$query = $model->db(false);
// 仅当强制删除时包含软删除数据
if ($force) {
$query->removeOption('soft_delete');
}
if (is_array($data) && key($data) !== 0) {
$query->where($data);
$data = null;
} elseif ($data instanceof \Closure) {
call_user_func_array($data, [ & $query]);
call_user_func_array($data, [&$query]);
$data = null;
} elseif (is_null($data)) {
return false;
@ -202,6 +152,7 @@ trait SoftDelete
$resultSet = $query->select($data);
foreach ($resultSet as $result) {
/** @var Model $result */
$result->force($force)->delete();
}
@ -211,7 +162,7 @@ trait SoftDelete
/**
* 恢复被软删除的记录
* @access public
* @param array $where 更新条件
* @param array $where 更新条件
* @return bool
*/
public function restore($where = []): bool
@ -243,7 +194,7 @@ trait SoftDelete
/**
* 获取软删除字段
* @access protected
* @param bool $read 是否查询操作 写操作的时候会自动去掉表别名
* @param bool $read 是否查询操作 写操作的时候会自动去掉表别名
* @return string|false
*/
protected function getDeleteTimeField(bool $read = false)
@ -269,7 +220,7 @@ trait SoftDelete
/**
* 查询的时候默认排除软删除数据
* @access protected
* @param Query $query
* @param Query $query
* @return void
*/
protected function withNoTrashed(Query $query): void

View File

@ -241,7 +241,7 @@ class BelongsTo extends OneToOne
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
$result->hidden([$relation]);
$result->hidden([$relation], true);
}
}
}
@ -283,7 +283,7 @@ class BelongsTo extends OneToOne
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
$result->hidden([$relation]);
$result->hidden([$relation], true);
}
}

View File

@ -240,7 +240,7 @@ class HasOne extends OneToOne
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
$result->hidden([$relation]);
$result->hidden([$relation], true);
}
}
}
@ -282,7 +282,7 @@ class HasOne extends OneToOne
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
$result->hidden([$relation]);
$result->hidden([$relation], true);
}
}

View File

@ -13,6 +13,7 @@ namespace think\model\relation;
use Closure;
use think\db\exception\DbException as Exception;
use think\db\Query;
use think\helper\Str;
use think\Model;
use think\model\Relation;
@ -46,14 +47,16 @@ class MorphTo extends Relation
*/
protected $relation;
protected $queryCaller = [];
/**
* 架构函数
* @access public
* @param Model $parent 上级模型对象
* @param string $morphType 多态字段名
* @param string $morphKey 外键名
* @param array $alias 多态别名定义
* @param string $relation 关联名
* @param Model $parent 上级模型对象
* @param string $morphType 多态字段名
* @param string $morphKey 外键名
* @param array $alias 多态别名定义
* @param ?string $relation 关联名
*/
public function __construct(Model $parent, string $morphType, string $morphKey, array $alias = [], string $relation = null)
{
@ -80,8 +83,8 @@ class MorphTo extends Relation
/**
* 延迟获取关联数据
* @access public
* @param array $subRelation 子关联名
* @param Closure $closure 闭包查询条件
* @param array $subRelation 子关联名
* @param ?Closure $closure 闭包查询条件
* @return Model
*/
public function getRelation(array $subRelation = [], Closure $closure = null)
@ -95,7 +98,7 @@ class MorphTo extends Relation
// 主键数据
$pk = $this->parent->$morphKey;
$relationModel = (new $model)->relation($subRelation)->find($pk);
$relationModel = $this->buildQuery((new $model)->relation($subRelation))->find($pk);
if ($relationModel) {
$relationModel->setParent(clone $this->parent);
@ -107,11 +110,11 @@ class MorphTo extends Relation
/**
* 根据关联条件查询当前模型
* @access public
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @param Query $query Query对象
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @param Query $query Query对象
* @return Query
*/
public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null)
@ -122,22 +125,45 @@ class MorphTo extends Relation
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @param mixed $fields 字段
* @param string $joinType JOIN类型
* @param Query $query Query对象
* @param mixed $where 查询条件(数组或者闭包)
* @param mixed $fields 字段
* @param string $joinType JOIN类型
* @param ?Query $query Query对象
* @return Query
*/
public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null)
{
throw new Exception('relation not support: hasWhere');
$alias = class_basename($this->parent);
$types = $this->parent->distinct()->column($this->morphType);
$query = $query ?: $this->parent->db();
return $query->alias($alias)
->where(function (Query $query) use ($types, $where, $alias) {
foreach ($types as $type) {
if ($type) {
$query->whereExists(function (Query $query) use ($type, $where, $alias) {
/** @var Model $model */
$model = new ($this->parseModel($type));
$table = $model->getTable();
$query
->table($table)
->where($alias . '.' . $this->morphType, $type)
->whereRaw("`{$alias}`.`{$this->morphKey}`=`{$table}`.`{$model->getPk()}`")
->where($where);
}, 'OR');
}
}
});
}
/**
* 解析模型的完整命名空间
* @access protected
* @param string $model 模型名(或者完整类名)
* @return string
* @param string $model 模型名(或者完整类名)
* @return Model
*/
protected function parseModel(string $model): string
{
@ -158,7 +184,7 @@ class MorphTo extends Relation
/**
* 设置多态别名
* @access public
* @param array $alias 别名定义
* @param array $alias 别名定义
* @return $this
*/
public function setAlias(array $alias)
@ -173,7 +199,7 @@ class MorphTo extends Relation
* @access public
* @return $this
*/
public function removeOption()
public function removeOption(string $option = '')
{
return $this;
}
@ -181,11 +207,11 @@ class MorphTo extends Relation
/**
* 预载入关联查询
* @access public
* @param array $resultSet 数据集
* @param string $relation 当前关联名
* @param array $subRelation 子关联名
* @param Closure $closure 闭包
* @param array $cache 关联缓存
* @param array $resultSet 数据集
* @param string $relation 当前关联名
* @param array $subRelation 子关联名
* @param ?Closure $closure 闭包
* @param array $cache 关联缓存
* @return void
* @throws Exception
*/
@ -211,8 +237,8 @@ class MorphTo extends Relation
if (!\is_null($closure)) {
$obj = $closure($obj);
}
$pk = $obj->getPk();
$list = $obj->with($subRelation)
$pk = $obj->getPk();
$list = $obj->with($subRelation)
->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null)
->select($val);
$data = [];
@ -242,11 +268,11 @@ class MorphTo extends Relation
/**
* 预载入关联查询
* @access public
* @param Model $result 数据对象
* @param string $relation 当前关联名
* @param array $subRelation 子关联名
* @param Closure $closure 闭包
* @param array $cache 关联缓存
* @param Model $result 数据对象
* @param string $relation 当前关联名
* @param array $subRelation 子关联名
* @param ?Closure $closure 闭包
* @param array $cache 关联缓存
* @return void
*/
public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void
@ -260,36 +286,42 @@ class MorphTo extends Relation
/**
* 关联统计
* @access public
* @param Model $result 数据对象
* @param Closure $closure 闭包
* @param string $aggregate 聚合查询方法
* @param string $field 字段
* @param Model $result 数据对象
* @param ?Closure $closure 闭包
* @param string $aggregate 聚合查询方法
* @param string $field 字段
* @return integer
*/
public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*')
{}
{
}
/**
* 多态MorphTo 关联模型预查询
* @access protected
* @param string $model 关联模型对象
* @param string $relation 关联名
* @param Model $result
* @param array $subRelation 子关联
* @param array $cache 关联缓存
* @param string $model 关联模型对象
* @param string $relation 关联名
* @param Model $result
* @param array $subRelation 子关联
* @param array $cache 关联缓存
* @return void
*/
protected function eagerlyMorphToOne(string $model, string $relation, Model $result, array $subRelation = [], array $cache = []): void
{
// 预载入关联查询 支持嵌套预载入
$pk = $this->parent->{$this->morphKey};
$data = (new $model)->with($subRelation)
->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null)
->find($pk);
if ($data) {
$data->setParent(clone $result);
$data->exists(true);
$data = null;
if(\class_exists($model)){
$data = (new $model)->with($subRelation)
->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null)
->find($pk);
if ($data) {
$data->setParent(clone $result);
$data->exists(true);
}
}
$result->setRelation($relation, $data ?: null);
@ -298,8 +330,8 @@ class MorphTo extends Relation
/**
* 添加关联数据
* @access public
* @param Model $model 关联模型对象
* @param string $type 多态类型
* @param Model $model 关联模型对象
* @param string $type 多态类型
* @return Model
*/
public function associate(Model $model, string $type = ''): Model
@ -332,4 +364,18 @@ class MorphTo extends Relation
return $this->parent->setRelation($this->relation, null);
}
protected function buildQuery(Query $query)
{
foreach ($this->queryCaller as $caller) {
call_user_func_array([$query, $caller[0]], $caller[1]);
}
return $query;
}
public function __call($method, $args)
{
$this->queryCaller[] = [$method, $args];
return $this;
}
}

View File

@ -10,7 +10,7 @@
],
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0"
"topthink/framework": "^6.0"
},
"autoload": {
"psr-4": {

View File

@ -188,6 +188,8 @@
{:hook('taonyeditor')}
{:hook('taoplayer')}
<script>
var collectionFind = "{:url('Collection/find')}",
collection = "{:url('collection/')}",

View File

@ -90,7 +90,7 @@
<div class="layui-inline">
<label class="layui-form-label">{:lang('enclosure')}</label>
<div class="layui-input-inline" style="width: 190px;">
<input type="text" class="layui-input" name="upzip" value="{$article.upzip}" placeholder="zip,jpg格式" title="上传附件"/>
<input type="text" class="layui-input" name="upzip" value="{$article.upzip ?? ''}" placeholder="zip,jpg格式" title="上传附件"/>
</div>
<button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button>
</div>

View File

@ -2,7 +2,7 @@
<a href="{$Request.domain}{:url('user/home',['id'=>$art.user_id])}" class="fly-avatar">
<img src="{$Request.domain}{$art.user.user_img}" alt="{$art.user.name}">
</a>
<h2><a href="{$Request.domain}{$art.url}" style="color:{$art.title_color};">{$art.title}</a></h2>
<h2><a href="{$Request.domain}{$art.url}" style="color:{$art.title_color ?? ''};">{$art.title}</a></h2>
<div class="fly-list-info">
{if config('taoler.config.cate_show') == 1}
<a class="layui-badge">{:cookie('think_lang') == 'en-us' ? $art.cate.ename : $art.cate.catename}</a>

View File

@ -33,13 +33,19 @@
<hr>
<ul>
{volist name="cateList" id="cate"}
<li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if}>
<li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if} class="layui-menu-item-group layui-menu-item-down" lay-options="{type: 'group'}">
<div class="layui-menu-body-title">
<a href="{$Request.domain}{:url('cate',['ename' => $cate.ename])}"><i class="layui-icon {$cate.icon}"></i> {:cookie('think_lang') == 'en-us' ? $cate.ename : $cate.catename}
<span class="layui-font-12 layui-font-gray">>> {$cate.ename}</span>
{if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if}
</a>
</div>
{notempty name="cate.children"}
<ul>
{volist name="cate.children" id="vo2"}
<li><a href="{$Request.domain}{:url('cate',['ename' => $vo2.ename])}">{$vo2.catename}</a></li>
{/volist}
</ul>
{/notempty}
</li>
{/volist}
</ul>