新增接口小版本更新支持

This commit is contained in:
mzeros 2024-11-02 15:48:19 +08:00
parent 51ce1314c9
commit 68dc4af69d
8 changed files with 18 additions and 5027 deletions

View File

@ -56,7 +56,7 @@ class Plugs extends Controller
} }
} }
$this->field = $this->app->request->get('field', 'icon'); $this->field = $this->app->request->get('field', 'icon');
$this->fetch(realpath(__DIR__ . '/../../view/api/icon.html')); $this->fetch(dirname(__DIR__, 2) . '/view/api/icon.html');
} }
/** /**

View File

@ -52,10 +52,9 @@ class Upload extends Controller
$allows = str2arr(sysconf('storage.allow_exts|raw')); $allows = str2arr(sysconf('storage.allow_exts|raw'));
if (empty($uuid) && $unid > 0) $allows = array_intersect($exts, $allows); if (empty($uuid) && $unid > 0) $allows = array_intersect($exts, $allows);
foreach ($allows as $ext) $data['exts'][$ext] = Storage::mime($ext); foreach ($allows as $ext) $data['exts'][$ext] = Storage::mime($ext);
$template = realpath(__DIR__ . '/../../view/api/upload.js');
$data['exts'] = json_encode($data['exts'], JSON_UNESCAPED_UNICODE); $data['exts'] = json_encode($data['exts'], JSON_UNESCAPED_UNICODE);
$data['nameType'] = sysconf('storage.name_type|raw') ?: 'xmd5'; $data['nameType'] = sysconf('storage.name_type|raw') ?: 'xmd5';
return view($template, $data)->contentType('application/x-javascript'); return view(dirname(__DIR__, 2) . '/view/api/upload.js', $data)->contentType('application/x-javascript');
} }
/** /**

View File

@ -73,6 +73,7 @@ class Core extends Controller
-801 => 'ip: 请求错误,不在白名单', -801 => 'ip: 请求错误,不在白名单',
-802 => '方法不存在', -802 => '方法不存在',
-803 => '版本号不正确',
-1000 => '系统维护中', -1000 => '系统维护中',
@ -98,7 +99,6 @@ class Core extends Controller
# 获取输入的信息 # 获取输入的信息
public function input(): void public function input(): void
{ {
// var_dump(8888);exit;
$this->input = input(); $this->input = input();
if (!$this->input) { if (!$this->input) {
$this->no(-100); $this->no(-100);

View File

@ -1,18 +1,5 @@
<?php <?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use think\exception\HttpResponseException; use think\exception\HttpResponseException;
@ -28,6 +15,8 @@ if(!$version){
//默认跳转到v1版本 //默认跳转到v1版本
if ($version == null) $version = "api";#api.notify,url if ($version == null) $version = "api";#api.notify,url
$pathInfo = request()->pathinfo(); $pathInfo = request()->pathinfo();
if ($pathInfo == null) { if ($pathInfo == null) {
$json = [ $json = [
@ -35,7 +24,6 @@ if ($pathInfo == null) {
'data'=>'', 'data'=>'',
'msg' =>'请求错误' 'msg' =>'请求错误'
]; ];
// var_dump($json);
throw new HttpResponseException(json($json)); throw new HttpResponseException(json($json));
} }
@ -44,7 +32,14 @@ if ($pathInfo == null) {
if($version!='api'){ if($version!='api'){
if(!str_contains($pathInfo, 'api.')){ if(!str_contains($pathInfo, 'api.')){
app()->route->rule(':controller/:function', $version . '.:controller/:function'); if(str_contains($version, '.')){
$versions = str_replace(".", "", $version);
#支持小版本的更新
app()->route->rule(':controller/:function', $versions . '.:controller/:function');
}else{
app()->route->rule(':controller/:function', $version . '.:controller/:function');
}
} }

View File

@ -30,10 +30,10 @@ define(function () {
this.patterns = { this.patterns = {
qq: '^[1-9][0-9]{4,11}$', qq: '^[1-9][0-9]{4,11}$',
ip: '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$', ip: '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$',
url: '^https?://([a-zA-Z0-9]+\\.)+[a-zA-Z0-9]+', url: '^https?://([a-zA-Z0-9-]+\\.)+[-_a-zA-Z0-9-]+',
phone: '^1[3-9][0-9]{9}$', phone: '^1[3-9][0-9]{9}$',
mobile: '^1[3-9][0-9]{9}$', mobile: '^1[3-9][0-9]{9}$',
email: '^([a-zA-Z0-9_\\.\\-])+@(([a-zA-Z0-9\-])+\\.)+([a-zA-Z0-9]{2,4})+$', email: '^([a-zA-Z0-9_\\.-])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$',
wechat: '^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$', wechat: '^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$',
cardid: '^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$', cardid: '^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$',
userame: '^[a-zA-Z0-9_-]{4,16}$', userame: '^[a-zA-Z0-9_-]{4,16}$',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long