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时获取标签 * flag 1.为word时获取分词2.为tag时获取标签
* *
* @return void * @return array
*/ */
public function setKeywords($data) public function setKeywords($data)
{ {
@ -385,7 +385,7 @@ abstract class BaseController
} }
} }
} }
return json(['code'=>0,'data'=>$keywords]); return $keywords;
} }
// api_post接口 // api_post接口

View File

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

View File

@ -479,8 +479,8 @@ class Forum extends AdminController
public function getKeywords() public function getKeywords()
{ {
$data = Request::only(['flag','keywords','content']); $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(){ public function getVersion(){
$verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]); $verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]);
if($verCheck->code !== -1){ if($verCheck->code !== -1){
return $verCheck->code ? "<span style='color:red'>有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}</span>" : $verCheck->msg; 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" /} {include file="public/user_login" /}
{/block} {/block}
{block name="js"} {block name="js"}
<script src="/static/notify.js"></script>
<script> <script>
var addonList = "{:url('Addons/index')}"; var addonList = "{:url('Addons/index')}";
layui.config({ layui.config({

View File

@ -42,7 +42,7 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">{:lang('enclosure')}</label> <label class="layui-form-label">{:lang('enclosure')}</label>
<div class="layui-input-inline" style="width: 190px;"> <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> </div>
<button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button> <button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button>
</div> </div>

View File

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

View File

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

View File

@ -3,6 +3,7 @@
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\Exception;
use taoser\SetArr;
use think\facade\Request; use think\facade\Request;
use think\facade\Db; use think\facade\Db;
use think\facade\Session; use think\facade\Session;
@ -291,7 +292,7 @@ function getOnepic($str)
//判断蜘蛛函数 //判断蜘蛛函数
function find_spider(){ function find_spider(){
$useragent = strtolower(empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : ''); $useragent = strtolower(empty($useragent) ? Request::header('USER_AGENT') : '');
$spider_arr=array( $spider_arr=array(
'bot', 'bot',
'spider', '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 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; return $this;
} }
@ -65,7 +70,12 @@ class HttpHelper
*/ */
public function post(string $url, array $data = []) 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; return $this;
} }
@ -101,7 +111,14 @@ class HttpHelper
*/ */
public function ok() : bool 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) { foreach($folderPaths as $folderPath) {
if(self::getDirSize($folderPath) == 0) { if(self::getDirSize($folderPath) == 0) {
continue; continue;
}; }
// 被压缩文件绝对路径 // 被压缩文件绝对路径
$rootPath = realpath($folderPath); $rootPath = realpath($folderPath);
// Create recursive directory iterator // Create recursive directory iterator

View File

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

View File

@ -484,14 +484,14 @@ class Article extends BaseController
} }
/** /**
* 关键词 * 关键词
* * @return \think\response\Json
* @return void */
*/
public function keywords() public function keywords()
{ {
$data = Request::only(['flag','keywords','content']); $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", "name": "endroid/qr-code",
"version": "4.6.0", "version": "4.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/endroid/qr-code.git", "url": "https://github.com/endroid/qr-code.git",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c" "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/b60873b14e2ca7bf3c3746f5e032023095a7e05c", "url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c", "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -364,7 +364,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/endroid/qr-code/issues", "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": [ "funding": [
{ {
@ -372,7 +372,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-10-04T17:13:41+00:00" "time": "2022-10-26T08:48:17+00:00"
}, },
{ {
"name": "firebase/php-jwt", "name": "firebase/php-jwt",
@ -1012,57 +1012,6 @@
], ],
"time": "2022-10-04T09:16:37+00:00" "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", "name": "league/mime-type-detection",
"version": "1.11.0", "version": "1.11.0",
@ -2496,23 +2445,21 @@
}, },
{ {
"name": "topthink/framework", "name": "topthink/framework",
"version": "v6.0.13", "version": "v6.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/framework.git", "url": "https://github.com/top-think/framework.git",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6" "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6", "url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6", "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"league/flysystem": "^1.1.4",
"league/flysystem-cached-adapter": "^1.0",
"php": ">=7.2.5", "php": ">=7.2.5",
"psr/container": "~1.0", "psr/container": "~1.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.0",
@ -2557,26 +2504,26 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/framework/issues", "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", "name": "topthink/think-captcha",
"version": "v3.0.7", "version": "v3.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-captcha.git", "url": "https://github.com/top-think/think-captcha.git",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331" "reference": "52fba122c953995bec3013c635025172491ae299"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/a450602932a5d9ba183e288b79921ba3b9a92331", "url": "https://api.github.com/repos/top-think/think-captcha/zipball/52fba122c953995bec3013c635025172491ae299",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331", "reference": "52fba122c953995bec3013c635025172491ae299",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"topthink/framework": "^6.0.0" "topthink/framework": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -2610,9 +2557,9 @@
"description": "captcha package for thinkphp", "description": "captcha package for thinkphp",
"support": { "support": {
"issues": "https://github.com/top-think/think-captcha/issues", "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", "name": "topthink/think-helper",
@ -2707,20 +2654,20 @@
}, },
{ {
"name": "topthink/think-migration", "name": "topthink/think-migration",
"version": "v3.0.3", "version": "v3.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-migration.git", "url": "https://github.com/top-think/think-migration.git",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79" "reference": "c5880669b277762d5ff935e551bc0d5c71de6811"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79", "url": "https://api.github.com/repos/top-think/think-migration/zipball/c5880669b277762d5ff935e551bc0d5c71de6811",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79", "reference": "c5880669b277762d5ff935e551bc0d5c71de6811",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"topthink/framework": "^6.0.0", "topthink/framework": "^6.0",
"topthink/think-helper": "^3.0.3" "topthink/think-helper": "^3.0.3"
}, },
"require-dev": { "require-dev": {
@ -2755,27 +2702,27 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/think-migration/issues", "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", "name": "topthink/think-multi-app",
"version": "v1.0.14", "version": "v1.0.15",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-multi-app.git", "url": "https://github.com/top-think/think-multi-app.git",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3" "reference": "387e0dac059c20f92cac5da41a871e10829c1c97"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/387e0dac059c20f92cac5da41a871e10829c1c97",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3", "reference": "387e0dac059c20f92cac5da41a871e10829c1c97",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1.0", "php": ">=7.1.0",
"topthink/framework": "^6.0.0" "topthink/framework": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -2803,22 +2750,22 @@
"description": "thinkphp6 multi app support", "description": "thinkphp6 multi app support",
"support": { "support": {
"issues": "https://github.com/top-think/think-multi-app/issues", "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", "name": "topthink/think-orm",
"version": "v2.0.54", "version": "v2.0.55",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-orm.git", "url": "https://github.com/top-think/think-orm.git",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e" "reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/97b061b47616301ff29fbd4c35ed9184e1162e4e", "url": "https://api.github.com/repos/top-think/think-orm/zipball/e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e", "reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2858,9 +2805,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/think-orm/issues", "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", "name": "topthink/think-template",
@ -3328,21 +3275,21 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "topthink/think-trace", "name": "topthink/think-trace",
"version": "v1.4", "version": "v1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-trace.git", "url": "https://github.com/top-think/think-trace.git",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444" "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-trace/zipball/9a9fa8f767b6c66c5a133ad21ca1bc96ad329444", "url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444", "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1.0", "php": ">=7.1.0",
"topthink/framework": "^6.0.0" "topthink/framework": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -3373,9 +3320,9 @@
"description": "thinkphp debug trace", "description": "thinkphp debug trace",
"support": { "support": {
"issues": "https://github.com/top-think/think-trace/issues", "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": [], "aliases": [],

View File

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

View File

@ -8,10 +8,11 @@
*/ */
layui.define(['table', 'form'], function(exports){ layui.define(['table', 'form', 'notify'], function(exports){
var $ = layui.$ var $ = layui.$
,table = layui.table ,table = layui.table
,form = layui.form; ,form = layui.form;
var notify = layui.notify;
//用户管理 //用户管理
table.render({ 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}, data:{"id":field.id,"name":field.username,"phone":field.phone,"email":field.email,"user_img":field.avatar,"sex":field.sex},
daType:"json", daType:"json",
success:function (res){ success:function (res){
if(data.code == 0){ if(res.code === 0){
notify.success(res.msg);
layer.msg(data.msg,{icon:6,time:2000}); layer.msg(data.msg,{icon:6,time:2000});
} else { } 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\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/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\\think\\' => array($vendorDir . '/taoser/think-auth/src'),
'taoser\\' => array($vendorDir . '/taoser/think-addons/src', $vendorDir . '/taoser/think-setarr/src'), 'taoser\\' => array($vendorDir . '/taoser/think-addons/src', $vendorDir . '/taoser/think-setarr/src'),
'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'), 'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'),
@ -42,7 +42,6 @@ return array(
'PHPSocketIO\\' => array($vendorDir . '/workerman/phpsocket.io/src'), 'PHPSocketIO\\' => array($vendorDir . '/workerman/phpsocket.io/src'),
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
'League\\MimeTypeDetection\\' => array($vendorDir . '/league/mime-type-detection/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'), 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
'Laravel\\SerializableClosure\\' => array($vendorDir . '/laravel/serializable-closure/src'), 'Laravel\\SerializableClosure\\' => array($vendorDir . '/laravel/serializable-closure/src'),
'Jaeger\\' => array($vendorDir . '/jaeger/g-http/src'), 'Jaeger\\' => array($vendorDir . '/jaeger/g-http/src'),

View File

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

View File

@ -313,17 +313,17 @@
}, },
{ {
"name": "endroid/qr-code", "name": "endroid/qr-code",
"version": "4.6.0", "version": "4.6.1",
"version_normalized": "4.6.0.0", "version_normalized": "4.6.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/endroid/qr-code.git", "url": "https://github.com/endroid/qr-code.git",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c" "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/b60873b14e2ca7bf3c3746f5e032023095a7e05c", "url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"reference": "b60873b14e2ca7bf3c3746f5e032023095a7e05c", "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -342,7 +342,7 @@
"roave/security-advisories": "Makes sure package versions with known security issues are not installed", "roave/security-advisories": "Makes sure package versions with known security issues are not installed",
"setasign/fpdf": "Enables you to use the PDF writer" "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", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
@ -376,7 +376,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/endroid/qr-code/issues", "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": [ "funding": [
{ {
@ -1057,62 +1057,6 @@
], ],
"install-path": "../league/flysystem" "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", "name": "league/mime-type-detection",
"version": "1.11.0", "version": "1.11.0",
@ -2650,24 +2594,22 @@
}, },
{ {
"name": "topthink/framework", "name": "topthink/framework",
"version": "v6.0.13", "version": "v6.1.1",
"version_normalized": "6.0.13.0", "version_normalized": "6.1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/framework.git", "url": "https://github.com/top-think/framework.git",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6" "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6", "url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6", "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"league/flysystem": "^1.1.4",
"league/flysystem-cached-adapter": "^1.0",
"php": ">=7.2.5", "php": ">=7.2.5",
"psr/container": "~1.0", "psr/container": "~1.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.0",
@ -2682,7 +2624,7 @@
"mockery/mockery": "^1.2", "mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.0" "phpunit/phpunit": "^7.0"
}, },
"time": "2022-07-15T02:52:08+00:00", "time": "2022-10-26T03:48:53+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@ -2714,35 +2656,29 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/framework/issues", "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" "install-path": "../topthink/framework"
}, },
{ {
"name": "topthink/think-captcha", "name": "topthink/think-captcha",
"version": "v3.0.7", "version": "v3.0.8",
"version_normalized": "3.0.7.0", "version_normalized": "3.0.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-captcha.git", "url": "https://github.com/top-think/think-captcha.git",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331" "reference": "52fba122c953995bec3013c635025172491ae299"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-captcha/zipball/a450602932a5d9ba183e288b79921ba3b9a92331", "url": "https://api.github.com/repos/top-think/think-captcha/zipball/52fba122c953995bec3013c635025172491ae299",
"reference": "a450602932a5d9ba183e288b79921ba3b9a92331", "reference": "52fba122c953995bec3013c635025172491ae299",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "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", "type": "library",
"extra": { "extra": {
"think": { "think": {
@ -2776,7 +2712,7 @@
"description": "captcha package for thinkphp", "description": "captcha package for thinkphp",
"support": { "support": {
"issues": "https://github.com/top-think/think-captcha/issues", "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" "install-path": "../topthink/think-captcha"
}, },
@ -2891,21 +2827,21 @@
}, },
{ {
"name": "topthink/think-migration", "name": "topthink/think-migration",
"version": "v3.0.3", "version": "v3.0.4",
"version_normalized": "3.0.3.0", "version_normalized": "3.0.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-migration.git", "url": "https://github.com/top-think/think-migration.git",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79" "reference": "c5880669b277762d5ff935e551bc0d5c71de6811"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79", "url": "https://api.github.com/repos/top-think/think-migration/zipball/c5880669b277762d5ff935e551bc0d5c71de6811",
"reference": "5717d9e5f3ea745f6dbfd1e30b4402aaadff9a79", "reference": "c5880669b277762d5ff935e551bc0d5c71de6811",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"topthink/framework": "^6.0.0", "topthink/framework": "^6.0",
"topthink/think-helper": "^3.0.3" "topthink/think-helper": "^3.0.3"
}, },
"require-dev": { "require-dev": {
@ -2914,7 +2850,7 @@
"suggest": { "suggest": {
"fzaninotto/faker": "Required to use the factory builder (^1.8)." "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", "type": "library",
"extra": { "extra": {
"think": { "think": {
@ -2942,36 +2878,30 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/think-migration/issues", "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" "install-path": "../topthink/think-migration"
}, },
{ {
"name": "topthink/think-multi-app", "name": "topthink/think-multi-app",
"version": "v1.0.14", "version": "v1.0.15",
"version_normalized": "1.0.14.0", "version_normalized": "1.0.15.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-multi-app.git", "url": "https://github.com/top-think/think-multi-app.git",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3" "reference": "387e0dac059c20f92cac5da41a871e10829c1c97"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/387e0dac059c20f92cac5da41a871e10829c1c97",
"reference": "ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3", "reference": "387e0dac059c20f92cac5da41a871e10829c1c97",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=7.1.0", "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", "type": "library",
"extra": { "extra": {
"think": { "think": {
@ -2997,21 +2927,25 @@
} }
], ],
"description": "thinkphp6 multi app support", "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" "install-path": "../topthink/think-multi-app"
}, },
{ {
"name": "topthink/think-orm", "name": "topthink/think-orm",
"version": "v2.0.54", "version": "v2.0.55",
"version_normalized": "2.0.54.0", "version_normalized": "2.0.55.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-orm.git", "url": "https://github.com/top-think/think-orm.git",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e" "reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/97b061b47616301ff29fbd4c35ed9184e1162e4e", "url": "https://api.github.com/repos/top-think/think-orm/zipball/e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e", "reference": "e1974a4c3b1b4c5b808fcc0863fc254e711dee13",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3025,7 +2959,7 @@
"require-dev": { "require-dev": {
"phpunit/phpunit": "^7|^8|^9.5" "phpunit/phpunit": "^7|^8|^9.5"
}, },
"time": "2022-07-05T05:25:51+00:00", "time": "2022-09-27T14:18:43+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@ -3053,7 +2987,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/think-orm/issues", "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" "install-path": "../topthink/think-orm"
}, },
@ -3109,30 +3043,24 @@
}, },
{ {
"name": "topthink/think-trace", "name": "topthink/think-trace",
"version": "v1.4", "version": "v1.5",
"version_normalized": "1.4.0.0", "version_normalized": "1.5.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-trace.git", "url": "https://github.com/top-think/think-trace.git",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444" "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-trace/zipball/9a9fa8f767b6c66c5a133ad21ca1bc96ad329444", "url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"reference": "9a9fa8f767b6c66c5a133ad21ca1bc96ad329444", "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=7.1.0", "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", "type": "library",
"extra": { "extra": {
"think": { "think": {
@ -3161,6 +3089,10 @@
} }
], ],
"description": "thinkphp debug trace", "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" "install-path": "../topthink/think-trace"
}, },
{ {

View File

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

View File

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

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?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); declare (strict_types = 1);
return array ( return array (
0 => 'taoser\\addons\\Service', 0 => 'taoser\\addons\\Service',

View File

@ -15,15 +15,37 @@ class Controller extends BaseController
{ {
// app 容器 // app 容器
protected $app; protected $app;
// 当前插件操作
protected $addon = null;
// 请求对象 // 请求对象
protected $request; protected $request;
// 当前插件标识 // 当前插件标识
protected $name; protected $name;
// 插件路径 // 插件路径
protected $addon_path; protected $addon_path;
protected $controller = null;
protected $action = null;
// 视图模型 // 视图模型
protected $view; 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->app = $app;
$this->request = $app->request; $this->request = $app->request;
$this->name = $this->getName(); $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_path = $app->addons->getAddonsPath() . $this->name . DIRECTORY_SEPARATOR;
$this->addon_config = "addon_{$this->name}_config"; $this->addon_config = "addon_{$this->name}_config";
$this->addon_info = "addon_{$this->name}_info"; $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) ![](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) [![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/) [![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) [![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", "php": ">=7.2.5",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"league/flysystem": "^1.1.4",
"league/flysystem-cached-adapter": "^1.0",
"psr/log": "~1.0", "psr/log": "~1.0",
"psr/container": "~1.0", "psr/container": "~1.0",
"psr/simple-cache": "^1.0", "psr/simple-cache": "^1.0",

View File

@ -39,7 +39,7 @@ use think\initializer\RegisterService;
*/ */
class App extends Container 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, 'session' => Session::class,
'validate' => Validate::class, 'validate' => Validate::class,
'view' => View::class, 'view' => View::class,
'filesystem' => Filesystem::class,
'think\DbManager' => Db::class, 'think\DbManager' => Db::class,
'think\LogManager' => Log::class, 'think\LogManager' => Log::class,
'think\CacheManager' => Cache::class, 'think\CacheManager' => Cache::class,

View File

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

View File

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

View File

@ -9,7 +9,7 @@
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"require": { "require": {
"topthink/framework": "^6.0.0" "topthink/framework": "^6.0"
}, },
"autoload": { "autoload": {
"psr-4": { "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; $this->imageW || $this->imageW = $this->length * $this->fontSize * 1.5 + $this->length * $this->fontSize / 2;
// 图片高(px) // 图片高(px)
$this->imageH || $this->imageH = $this->fontSize * 2.5; $this->imageH || $this->imageH = $this->fontSize * 2.5;
$this->imageW = intval($this->imageW);
$this->imageH = intval($this->imageH);
// 建立一幅 $this->imageW x $this->imageH 的图像 // 建立一幅 $this->imageW x $this->imageH 的图像
$this->im = imagecreate((int) $this->imageW, (int) $this->imageH); $this->im = imagecreate((int) $this->imageW, (int) $this->imageH);
// 设置背景 // 设置背景
@ -224,7 +228,7 @@ class Captcha
$y = $this->fontSize + mt_rand(10, 20); $y = $this->fontSize + mt_rand(10, 20);
$angle = $this->math ? 0 : mt_rand(-40, 40); $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(); ob_start();
@ -253,10 +257,10 @@ class Captcha
$px = $py = 0; $px = $py = 0;
// 曲线前部分 // 曲线前部分
$A = mt_rand(1, (int) ($this->imageH / 2)); // 振幅 $A = mt_rand(1, intval($this->imageH / 2)); // 振幅
$b = mt_rand(-intval($this->imageH / 4), intval($this->imageH / 4)); // Y轴方向偏移量 $b = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // Y轴方向偏移量
$f = mt_rand(-intval($this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量 $f = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量
$T = mt_rand((int)$this->imageH, intval($this->imageW * 2)); // 周期 $T = mt_rand($this->imageH, $this->imageW * 2); // 周期
$w = (2 * M_PI) / $T; $w = (2 * M_PI) / $T;
$px1 = 0; // 曲线横坐标起始位置 $px1 = 0; // 曲线横坐标起始位置
@ -267,16 +271,16 @@ class Captcha
$py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b $py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b
$i = (int) ($this->fontSize / 5); $i = (int) ($this->fontSize / 5);
while ($i > 0) { 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--; $i--;
} }
} }
} }
// 曲线后部分 // 曲线后部分
$A = mt_rand(1, (int) ($this->imageH / 2)); // 振幅 $A = mt_rand(1, intval($this->imageH / 2)); // 振幅
$f = mt_rand(-(int) ($this->imageH / 4), (int) ($this->imageH / 4)); // X轴方向偏移量 $f = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量
$T = mt_rand((int) $this->imageH, (int) ($this->imageW * 2)); // 周期 $T = mt_rand($this->imageH, $this->imageW * 2); // 周期
$w = (2 * M_PI) / $T; $w = (2 * M_PI) / $T;
$b = $py - $A * sin($w * $px + $f) - $this->imageH / 2; $b = $py - $A * sin($w * $px + $f) - $this->imageH / 2;
$px1 = $px2; $px1 = $px2;
@ -287,7 +291,7 @@ class Captcha
$py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b $py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b
$i = (int) ($this->fontSize / 5); $i = (int) ($this->fontSize / 5);
while ($i > 0) { 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--; $i--;
} }
} }
@ -306,7 +310,7 @@ class Captcha
$noiseColor = imagecolorallocate($this->im, mt_rand(150, 225), mt_rand(150, 225), mt_rand(150, 225)); $noiseColor = imagecolorallocate($this->im, mt_rand(150, 225), mt_rand(150, 225), mt_rand(150, 225));
for ($j = 0; $j < 5; $j++) { 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); @imagecopyresampled($this->im, $bgImage, 0, 0, 0, 0, $this->imageW, $this->imageH, $width, $height);
@imagedestroy($bgImage); @imagedestroy($bgImage);
} }
} }

View File

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

View File

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

View File

@ -14,5 +14,11 @@ use Phinx\Seed\AbstractSeed;
class Seeder extends 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?'); ->addArgument('name', InputArgument::REQUIRED, 'What is the name of the model?');
} }
protected function handle() public function handle()
{ {
$path = $this->getPath(); $path = $this->getPath();

View File

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

View File

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

View File

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

View File

@ -559,23 +559,4 @@ trait ModelRelationQuery
$result->refreshOrigin(); $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])) { } elseif (isset($this->type[$name])) {
// 类型转换 // 类型转换
$value = $this->writeTransform($value, $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(); $value = $value->__toString();
} }

View File

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

View File

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

View File

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

View File

@ -63,7 +63,7 @@
<p>{$sysInfo.state}</p> <p>{$sysInfo.state}</p>
</div> </div>
</div> </div>
{//评论内容} {//评论内容}
<div class="fly-panel detail-box" id="flyReply"> <div class="fly-panel detail-box" id="flyReply">
<span style="font-size: 18px">评论 {$article.comments_count}</span> <span style="font-size: 18px">评论 {$article.comments_count}</span>
@ -188,6 +188,8 @@
{:hook('taonyeditor')} {:hook('taonyeditor')}
{:hook('taoplayer')}
<script> <script>
var collectionFind = "{:url('Collection/find')}", var collectionFind = "{:url('Collection/find')}",
collection = "{:url('collection/')}", collection = "{:url('collection/')}",

View File

@ -90,7 +90,7 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">{:lang('enclosure')}</label> <label class="layui-form-label">{:lang('enclosure')}</label>
<div class="layui-input-inline" style="width: 190px;"> <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> </div>
<button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button> <button type="button" class="layui-btn" id="zip-button"><i class="layui-icon"></i>上传文件</button>
</div> </div>

View File

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

View File

@ -33,13 +33,19 @@
<hr> <hr>
<ul> <ul>
{volist name="cateList" id="cate"} {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"> <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} <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} {if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if}
</a> </a>
</div> </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> </li>
{/volist} {/volist}
</ul> </ul>