修复开发模式下未显示错误信息的BUG

修复API部分注释无效的BUG
修复API文档无法替换参数的BUG
pull/56/head
Karson 2018-04-01 15:12:39 +08:00
parent 685fc267c0
commit 2ecae60d86
6 changed files with 110 additions and 88 deletions

View File

@ -322,7 +322,6 @@ class Extractor
if (preg_match_all('/@(?<name>[A-Za-z_-]+)[\s\t]*\((?<args>(?:(?!\)).)*)\)\r?/s', $docblock, $matches))
{
$numMatches = count($matches[0]);
for ($i = 0; $i < $numMatches; ++$i)
{
// annotations has arguments
@ -330,7 +329,12 @@ class Extractor
{
$argsParts = trim($matches['args'][$i]);
$name = $matches['name'][$i];
$argsParts = preg_replace("/\{(\w+)\}/", '#$1#', $argsParts);
$value = self::parseArgs($argsParts);
if(is_string($value))
{
$value = preg_replace("/\#(\w+)\#/", '{$1}', $argsParts);
}
}
else
{

View File

@ -382,27 +382,31 @@
//instead of the initial attribute
var url = $(form).attr('action');
var serializedData = new FormData();
var formData = new FormData();
$(form).find('input').each(function (i, input) {
if ($(input).attr('type') == 'file') {
serializedData.append($(input).attr('name'), $(input)[0].files[0]);
formData.append($(input).attr('name'), $(input)[0].files[0]);
} else {
serializedData.append($(input).attr('name'), $(input).val())
formData.append($(input).attr('name'), $(input).val())
}
});
var index, key, value;
if (matchedParamsInRoute) {
var params = {};
formData.forEach(function(value, key){
params[key] = value;
});
for (index = 0; index < matchedParamsInRoute.length; ++index) {
try {
key = matchedParamsInRoute[index];
value = serializedData[key];
value = params[key];
if (typeof value == "undefined")
value = "";
url = url.replace("{" + key + "}", value);
delete serializedData[key];
url = url.replace("\{" + key + "\}", value);
formData.delete(key);
} catch (err) {
console.log(err);
}
@ -425,7 +429,7 @@
$.ajax({
url: $('#apiUrl').val() + url,
data: $(form).attr('method') == 'get' ? $(form).serialize() : serializedData,
data: $(form).attr('method') == 'get' ? $(form).serialize() : formData,
type: $(form).attr('method') + '',
dataType: 'json',
contentType: false,

View File

@ -1,6 +1,7 @@
<?php
$cdnurl = function_exists('config') ? config('view_replace_str.__CDN__') : '';
$publicurl = function_exists('config') ? config('view_replace_str.__PUBLIC__') : '/';
$debug = function_exists('config') ? config('app_debug') : false;
$lang = [
'An error occurred' => '发生错误',
@ -17,15 +18,16 @@ if (isset($_GET['lang'])) {
} elseif (isset($_COOKIE['think_var'])) {
$langSet = strtolower($_COOKIE['think_var']);
} elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
preg_match('/^([a-z\d\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
preg_match('/^([a-z\d\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
$langSet = strtolower($matches[1]);
}
$langSet = $langSet && in_array($langSet, ['zh-cn', 'en']) ? $langSet : 'zh-cn';
$langSet == 'en' && $lang = array_combine(array_keys($lang), array_keys($lang));
?>
<!DOCTYPE html>
<html>
<head>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title><?=$lang['An error occurred']?></title>
<meta name="robots" content="noindex,nofollow" />
@ -73,14 +75,14 @@ $langSet == 'en' && $lang = array_combine(array_keys($lang), array_keys($lang));
.error-page-wrapper .buttons-container a:nth-child(2) {margin-top:12px;}
}
</style>
</head>
<body class="error-page-wrapper">
<div class="content-container">
</head>
<body class="error-page-wrapper">
<div class="content-container">
<div class="head-line">
<img src="<?=$cdnurl?>/assets/img/error.svg" alt="" width="120"/>
</div>
<div class="subheader">
<?=$lang['The page you are looking for is temporarily unavailable']?>
<?=$debug?$message:$lang['The page you are looking for is temporarily unavailable']?>
</div>
<div class="hr"></div>
<div class="context">
@ -94,6 +96,6 @@ $langSet == 'en' && $lang = array_combine(array_keys($lang), array_keys($lang));
<a href="<?=$publicurl?>"><?=$lang['Home']?></a>
<a href="<?=$publicurl?>"><?=$lang['Feedback']?></a>
</div>
</div>
</body>
</div>
</body>
</html>

View File

@ -62,6 +62,7 @@ class Date
* @param string $output formatting string
* @return string when only a single output is requested
* @return array associative list of all outputs requested
* @from https://github.com/kohana/ohanzee-helpers/blob/master/src/Date.php
*/
public static function span($remote, $local = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds')
{

View File

@ -5,6 +5,7 @@ namespace fast;
use ArrayAccess;
/**
* 表单元素生成
* @class Form
* @package fast
* @method mixed token() static token
@ -45,6 +46,12 @@ class Form
}
/**
*
* 表单元素生成
* @from https://github.com/illuminate/html
* @package fast
*/
class FormBuilder
{

View File

@ -33,7 +33,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.fastadmin.net" target="_blank">FastAdmin</a>
<a class="navbar-brand" href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right">
@ -3351,9 +3351,9 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2018-03-16 14:43:16 </div>
Generated on 2018-04-01 15:11:14 </div>
<div class="col-md-6" align="right">
<a href="http://www.fastadmin.net" target="_blank">FastAdmin</a>
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
</div>
@ -3476,27 +3476,31 @@
//instead of the initial attribute
var url = $(form).attr('action');
var serializedData = new FormData();
var formData = new FormData();
$(form).find('input').each(function (i, input) {
if ($(input).attr('type') == 'file') {
serializedData.append($(input).attr('name'), $(input)[0].files[0]);
formData.append($(input).attr('name'), $(input)[0].files[0]);
} else {
serializedData.append($(input).attr('name'), $(input).val())
formData.append($(input).attr('name'), $(input).val())
}
});
var index, key, value;
if (matchedParamsInRoute) {
var params = {};
formData.forEach(function(value, key){
params[key] = value;
});
for (index = 0; index < matchedParamsInRoute.length; ++index) {
try {
key = matchedParamsInRoute[index];
value = serializedData[key];
value = params[key];
if (typeof value == "undefined")
value = "";
url = url.replace("{" + key + "}", value);
delete serializedData[key];
url = url.replace("\{" + key + "\}", value);
formData.delete(key);
} catch (err) {
console.log(err);
}
@ -3519,7 +3523,7 @@
$.ajax({
url: $('#apiUrl').val() + url,
data: $(form).attr('method') == 'get' ? $(form).serialize() : serializedData,
data: $(form).attr('method') == 'get' ? $(form).serialize() : formData,
type: $(form).attr('method') + '',
dataType: 'json',
contentType: false,