mirror of https://gitee.com/karson/fastadmin.git
Compare commits
15 Commits
b0d295bd67
...
17931decd5
| Author | SHA1 | Date |
|---|---|---|
|
|
17931decd5 | |
|
|
4fd2558a8b | |
|
|
be3c601b72 | |
|
|
426209a5d5 | |
|
|
385a33344c | |
|
|
7763aefd61 | |
|
|
16ae2acb2c | |
|
|
63cdd2ad25 | |
|
|
c12e304aec | |
|
|
0fb49c1a9a | |
|
|
d12f549396 | |
|
|
7c7780bc56 | |
|
|
6ab795e12f | |
|
|
ccf6bd9a98 | |
|
|
fe9029beac |
|
|
@ -920,6 +920,7 @@ class Crud extends Command
|
|||
$replace = '\'{"custom[type]":"' . $table . '"}\'';
|
||||
} elseif ($selectpageController == 'admin') {
|
||||
$attrArr['data-source'] = 'auth/admin/selectpage';
|
||||
$attrArr['data-field'] = 'nickname';
|
||||
} elseif ($selectpageController == 'user') {
|
||||
$attrArr['data-source'] = 'user/user/index';
|
||||
$attrArr['data-field'] = 'nickname';
|
||||
|
|
|
|||
|
|
@ -214,22 +214,27 @@ class Install extends Command
|
|||
$adminFile = ROOT_PATH . 'public' . DS . 'admin.php';
|
||||
|
||||
// 数据库配置文件
|
||||
$dbConfigFile = APP_PATH . 'database.php';
|
||||
$dbConfigText = @file_get_contents($dbConfigFile);
|
||||
$envSampleFile = ROOT_PATH . '.env.sample';
|
||||
$envFile = ROOT_PATH . '.env';
|
||||
if (!file_exists($envFile)) {
|
||||
if (!copy($envSampleFile, $envFile)) {
|
||||
throw new Exception(__('Failed to copy %s to %s', '.env.sample', '.env'));
|
||||
}
|
||||
}
|
||||
|
||||
$envText = @file_get_contents($envFile);
|
||||
|
||||
$callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) {
|
||||
$field = "mysql" . ucfirst($matches[1]);
|
||||
$replace = $$field;
|
||||
if ($matches[1] == 'hostport' && $mysqlHostport == 3306) {
|
||||
$replace = '';
|
||||
}
|
||||
return "'{$matches[1]}'{$matches[2]}=>{$matches[3]}Env::get('database.{$matches[1]}', '{$replace}'),";
|
||||
return "{$matches[1]} = {$replace}";
|
||||
};
|
||||
$dbConfigText = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/", $callback, $dbConfigText);
|
||||
$envText = preg_replace_callback("/(hostname|database|username|password|hostport|prefix)\s*=\s*(.*)/", $callback, $envText);
|
||||
|
||||
// 检测能否成功写入数据库配置
|
||||
$result = @file_put_contents($dbConfigFile, $dbConfigText);
|
||||
$result = @file_put_contents($envFile, $envText);
|
||||
if (!$result) {
|
||||
throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/database.php'));
|
||||
throw new Exception(__('The current permissions are insufficient to write the file %s', '.env'));
|
||||
}
|
||||
|
||||
// 设置新的Token随机密钥key
|
||||
|
|
@ -244,7 +249,7 @@ class Install extends Command
|
|||
throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/config.php'));
|
||||
}
|
||||
|
||||
$avatar = request()->domain() . '/assets/img/avatar.png';
|
||||
$avatar = '/assets/img/avatar.png';
|
||||
// 变更默认管理员密码
|
||||
$adminPassword = $adminPassword ? $adminPassword : Random::alnum(8);
|
||||
$adminEmail = $adminEmail ? $adminEmail : "admin@admin.com";
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ class Http
|
|||
/**
|
||||
* 发送一个POST请求
|
||||
* @param string $url 请求URL
|
||||
* @param array $params 请求参数
|
||||
* @param array $options 扩展参数
|
||||
* @param array $params 请求参数
|
||||
* @param array $options 扩展参数
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function post($url, $params = [], $options = [])
|
||||
public static function post(string $url, array $params = [], array $options = [])
|
||||
{
|
||||
$req = self::sendRequest($url, $params, 'POST', $options);
|
||||
return $req['ret'] ? $req['msg'] : '';
|
||||
|
|
@ -24,11 +24,11 @@ class Http
|
|||
/**
|
||||
* 发送一个GET请求
|
||||
* @param string $url 请求URL
|
||||
* @param array $params 请求参数
|
||||
* @param array $options 扩展参数
|
||||
* @param array $params 请求参数
|
||||
* @param array $options 扩展参数
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function get($url, $params = [], $options = [])
|
||||
public static function get(string $url, array $params = [], array $options = [])
|
||||
{
|
||||
$req = self::sendRequest($url, $params, 'GET', $options);
|
||||
return $req['ret'] ? $req['msg'] : '';
|
||||
|
|
@ -42,7 +42,7 @@ class Http
|
|||
* @param mixed $options CURL的参数
|
||||
* @return array
|
||||
*/
|
||||
public static function sendRequest($url, $params = [], $method = 'POST', $options = [])
|
||||
public static function sendRequest(string $url, $params = [], string $method = 'POST', $options = []): array
|
||||
{
|
||||
$method = strtoupper($method);
|
||||
$protocol = substr($url, 0, 5);
|
||||
|
|
@ -108,7 +108,7 @@ class Http
|
|||
* @param string $method 请求的方法
|
||||
* @return boolean TRUE
|
||||
*/
|
||||
public static function sendAsyncRequest($url, $params = [], $method = 'POST')
|
||||
public static function sendAsyncRequest(string $url, $params = [], string $method = 'POST'): bool
|
||||
{
|
||||
$method = strtoupper($method);
|
||||
$method = $method == 'POST' ? 'POST' : 'GET';
|
||||
|
|
@ -157,10 +157,10 @@ class Http
|
|||
/**
|
||||
* 发送文件到客户端
|
||||
* @param string $file
|
||||
* @param bool $delaftersend
|
||||
* @param bool $exitaftersend
|
||||
* @param bool $deleteAfterSend
|
||||
* @param bool $exitAfterSend
|
||||
*/
|
||||
public static function sendToBrowser($file, $delaftersend = true, $exitaftersend = true)
|
||||
public static function sendToBrowser(string $file, bool $deleteAfterSend = true, bool $exitAfterSend = true)
|
||||
{
|
||||
if (file_exists($file) && is_readable($file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
|
|
@ -174,10 +174,10 @@ class Http
|
|||
ob_clean();
|
||||
flush();
|
||||
readfile($file);
|
||||
if ($delaftersend) {
|
||||
if ($deleteAfterSend) {
|
||||
unlink($file);
|
||||
}
|
||||
if ($exitaftersend) {
|
||||
if ($exitAfterSend) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function alnum($len = 6)
|
||||
public static function alnum(int $len = 6): string
|
||||
{
|
||||
return self::build('alnum', $len);
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function alpha($len = 6)
|
||||
public static function alpha(int $len = 6): string
|
||||
{
|
||||
return self::build('alpha', $len);
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function numeric($len = 4)
|
||||
public static function numeric(int $len = 4): string
|
||||
{
|
||||
return self::build('numeric', $len);
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function nozero($len = 4)
|
||||
public static function nozero(int $len = 4): string
|
||||
{
|
||||
return self::build('nozero', $len);
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function build($type = 'alnum', $len = 8)
|
||||
public static function build(string $type = 'alnum', int $len = 8): string
|
||||
{
|
||||
switch ($type) {
|
||||
case 'alpha':
|
||||
|
|
@ -93,7 +93,7 @@ class Random
|
|||
* 获取全球唯一标识
|
||||
* @return string
|
||||
*/
|
||||
public static function uuid()
|
||||
public static function uuid(): string
|
||||
{
|
||||
return sprintf(
|
||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
|
|
|
|||
|
|
@ -559,7 +559,9 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
}
|
||||
};
|
||||
// @formatter:on
|
||||
var $disabledElements = form.find(':disabled').removeAttr('disabled');
|
||||
var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
|
||||
$disabledElements.attr('disabled', 'disabled');
|
||||
$(dataArr).each(function (i, field) {
|
||||
fieldName = field.name;
|
||||
fieldValue = field.value;
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
display = __(value.charAt(0).toUpperCase() + value.slice(1));
|
||||
}
|
||||
var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
|
||||
if (this.operate != false) {
|
||||
if (typeof this.operate !== 'undefined' && this.operate != false) {
|
||||
html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
|
||||
}
|
||||
return html;
|
||||
|
|
@ -870,6 +870,15 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
value = Fast.api.escape(customValue);
|
||||
field = this.customField;
|
||||
}
|
||||
if (typeof that.searchList === 'object' && typeof that.searchList.then === 'function') {
|
||||
$.when(that.searchList).done(function (ret) {
|
||||
if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
|
||||
that.searchList = ret.data.searchlist;
|
||||
} else if (ret.constructor === Array || ret.constructor === Object) {
|
||||
that.searchList = ret;
|
||||
}
|
||||
})
|
||||
}
|
||||
if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
|
||||
var i = 0;
|
||||
var searchValues = Object.keys(colorArr).map(function (e) {
|
||||
|
|
@ -885,7 +894,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
|
||||
//渲染Flag
|
||||
var html = [];
|
||||
var arr = value !== '' ? value.split(',') : [];
|
||||
var arr = $.isArray(value) ? value : value !== '' ? value.split(',') : [];
|
||||
var color, display, label;
|
||||
$.each(arr, function (i, value) {
|
||||
value = value == null || value.length === 0 ? '' : value.toString();
|
||||
|
|
|
|||
Loading…
Reference in New Issue