8000 Merge branch 'master' of https://gitee.com/laravel-admin/laraveladmin… · laraveladmin-cn/laraveladmin@f23f5c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit f23f5c3

Browse files
committed
Merge branch 'master' of https://gitee.com/laravel-admin/laraveladmin into demo
# Conflicts: # app/Console/Kernel.php # docker/php/run.sh
2 parents b43008a + 1dfed0e commit f23f5c3

File tree

23 files changed

+136
-62
lines changed

23 files changed

+136
-62
lines changed

app/Console/Commands/BuildIndexHtml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function checkEnvValue(){
4949
$path = base_path('.env');
5050
$env_str = file_get_contents($path);
5151
collect($_ENV)->each(function ($value,$key)use (&$env_str){
52-
if(Str::contains($value,'=')){
52+
if(is_string($value) && Str::contains($value,'=')){
5353
$value = env($key,'');
5454
$env_str = Str::replaceFirst($key.'='.$value,$key.'="'.$value.'"',$env_str);
5555
}

app/Console/DevelopCommands/CreateView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ protected function readyDatas()
103103
return $data;
104104
});
105105
} else {
106-
$class = get_class($this->bindModel);
107-
$data['tableInfo'] = $class::getTableInfo(); //数据表信息
106+
$class1 = get_class($this->bindModel);
107+
$data['tableInfo'] = $class1::getTableInfo(); //数据表信息
108108
$data['validates'] = collect($data['tableInfo']['table_fields'])->map(function ($item) {
109109

110110
if ($item['validator']) {

app/Console/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ protected function schedule(Schedule $schedule)
3434
->name('db_seed')
3535
->withoutOverlapping()
3636
->hourly();
37-
//->dailyAt('00:01');
3837
if(config('app.env')!='local'){
3938
//数据库备份
4039
$schedule->command("backup:run --only-db")
4140
->name('backup_db')
4241
->withoutOverlapping()
43-
->dailyAt('02:00');
42+
->dailyAt('02:00')
43+
->runInBackground();
4444
}
4545

4646
}

app/Http/Controllers/Traits/ResourceController.php

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,44 @@ public function index()
7474
collect($this->sizer)->keys()->filter(function ($value) {
7575
return Str::endsWith($value, '_id');
7676
})->map(function ($value) use (&$data) {
77-
$val = str_replace('_id', '', $value);
77+
$val = collect(explode('.',$value))->last();
78+
$val = Str::replaceLast('_id', '', $val);
7879
$model = '\App\Models\\' . Str::studly($val);
7980
$item = [];
80-
$relation_id = Request::input('where.' . $value, 0);
81+
$where = Request::input('where');
82+
$relation_id = isset($where[$value])?$where[$value]:0;
8183
if ($relation_id && class_exists($model)) {
82-
$fields = collect(isset($this->mapsWhereFields[$value]) ? $this->mapsWhereFields[$value] : ['id', 'name'])
84+
$fields_and_relation = collect(isset($this->mapsWhereFields[$value]) ? $this->mapsWhereFields[$value] : ['id', 'name'])
8385
->map(function ($field){
8486
if(is_string($field) && Str::contains($field,'`')){
8587
return DB::raw($field);
8688
}
8789
return $field;
88-
})->toArray();
89-
$item = collect($model::select($fields)
90-
->find($relation_id))->toArray();
90+
});
91+
$fields = $fields_and_relation->filter(function ($item){
92+
return !is_array($item);
93+
})->toArray();
94+
$relation = $fields_and_relation->filter(function ($item){
95+
return is_array($item);
96+
})->map(function ($item){
97+
return function ($q)use($item){
98+
if($item){
99+
$q->select($item);
100+
}
101+
return $q;
102+
};
103+
})->toArray();
104+
$modelObj = $model::query();
105+
if($fields){
106+
$modelObj = $modelObj->select($fields);
107+
}
108+
if($relation){
109+
$modelObj = $modelObj->with($relation);
110+
}
111+
$item = collect($modelObj->find($relation_id))->toArray();
91112
}
92-
$data['maps'][$value] = $item ? [$item] : [];
113+
$map = $item ? [$item] : [];
114+
$data['maps'][$value] = $map;
93115
});
94116
//条件筛选及排序返回
95117
$this->addOptions();
@@ -263,7 +285,7 @@ public function list()
263285
$has_primary_key = in_array($primary_key,$fields) || in_array($primary_key1,$fields);
264286
$fields = $has_primary_key ? $fields : array_merge([$primary_key1], $fields);
265287
}
266-
$fields and $this->bindModel->select($fields);
288+
$fields and $this->bindModel = $this->bindModel->select($fields);
267289
//获取带有筛选条件的对象
268290
$obj = $this->getWithOptionModel();
269291
$obj = $this->handleList($obj);
@@ -804,8 +826,13 @@ public function export()
804826
return $value;
805827
});
806828
$fields = $this->selectFields($this->exportFields);
807-
$fields and $this->bindModel = $this->bindModel()->select(in_array($model->getKeyName(), $fields)
808-
? $fields : array_merge([$model->getKeyName()], $fields));
829+
$primary_key = $model->getKeyName();
830+
if($primary_key && $fields && (!isset($this->noPrimaryKey) || !$this->noPrimaryKey)){
831+
$primary_key1 = $model->getTable().'.'.$primary_key;
832+
$has_primary_key = in_array($primary_key,$fields) || in_array($primary_key1,$fields);
833+
$fields = $has_primary_key ? $fields : array_merge([$primary_key1], $fields);
834+
}
835+
$fields and $this->bindModel = $this->bindModel()->select($fields);
809836
//优化导出
810837
$model = $this->newBindModel();
811838
$primary_key = $model->getKeyName();

app/Models/AdminRole.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class AdminRole extends Model
1414
protected $table = 'admin_role'; //数据表名称
1515
protected $itemName='后台用户权限关联';
1616
public $timestamps = false;
17+
public $incrementing = false;
1718
//批量赋值白名单
1819
protected $fillable = ['admin_id','role_id'];
1920
//输出隐藏字段

app/Models/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function setValueAttribute($value){
109109
$type = Arr::get($this->attributes,'type',1);
110110
if(!isset($this->attributes['type'])){
111111
}elseif($type==2){
112-
$value = json_encode($value);
112+
$value = json_encode($value,JSON_UNESCAPED_UNICODE);
113113
}elseif ($type==3){
114114
$value = ($value?:0)-0;
115115
}

app/Models/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function scopeHasPermission ($query,$url,$method='get',$is_bool=true){
466466
public function scopeHasPermissionPath($query,$path,$method='get',$is_bool=true){
467467
$route = app('routes')->match(\Illuminate\Support\Facades\Request::create($path));
468468
if($route){
469-
$url = $route->uri;
469+
$url =Str::startsWith($route->uri,'/')?$route->uri:'/'.$route->uri;
470470
return self::isUrlInMenus($url,self::getMain(),$method,$is_bool);
471471
}else{
472472
return $is_bool?false:collect([]);

app/Models/Table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Table extends Model
1515
protected $table = 'tables'; //数据表名称
1616
//没有主键ID
1717
protected $primaryKey = '';
18+
public $incrementing = false;
1819
//批量赋值白名单
1920
protected $fillable = [];
2021
//字段默认值

app/Models/Traits/BaseModel.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
/**
33
* 通过 PhpStorm 创建.
4-
* 创建人: zhangshiping
54
* 日期: 16-5-20
65
* 时间: 下午6:21
76
*/
@@ -159,8 +158,13 @@ protected function relationWhere(&$query,$key,$exp,$val,$condition='and'){
159158
* @param string $condition
160159
*/
161160
protected function jointWhere(&$query,$key,$exp,$val,$condition='and'){
162-
if(is_string($key) && Str::contains($key,'`')){
163-
$key = DB::raw($key);
161+
if(is_string($key)){
162+
if(Str::contains($key,'->')){
163+
$key = str_replace('->','.',$key);
164+
}
165+
if(Str::contains($key,'`')){
166+
$key = DB::raw($key);
167+
}
164168
}
165169
$whereMap = ['in','not_in','between'];
166170
$exps = [];
@@ -393,6 +397,7 @@ public function scopeGetClassName(){
393397

394398
public function scopeIgnoreUpdateAt($q){
395399
$this->timestamps = false;
400+
return $q;
396401
}
397402

398403
public function scopeGetFillables($q){

docker/docker-compose-prod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ services:
5353
#ports:
5454
# - 1215:1215
5555
restart: always
56+
environment:
57+
- DOCKER_APP_ENV=${APP_ENV}
5658
nginx: #服务器服务
5759
image: nginx:1.15
5860
depends_on:

docker/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ services: #服务
4646
- mysql:db #服务名:别名
4747
- redis:redis
4848
restart: always
49+
environment:
50+
- DOCKER_APP_ENV=${APP_ENV}
4951
nginx: #服务器服务
5052
image: nginx:1.15
5153
depends_on:

docker/php/run.sh

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,27 @@ chmod 600 /var/spool/cron/crontabs/root
1616
/etc/init.d/cron start
1717

1818
projects=`ls ${code_dir}`
19-
##项目消息队列
20-
for project in ${projects}
21-
do
22-
#导入配置
23-
export $(grep -Ev '^$|[#;]' ${code_dir}/${project}/.env | xargs)
24-
#判断是否本地开发环境
25-
if [ "${APP_ENV}" = "" ] || [ "${APP_ENV}" = "local" ];
26-
then
27-
is_local=1
28-
queue_type="work"
29-
else
30-
is_local=0
31-
queue_type="listen"
32-
fi
33-
http_host=${SWOOLE_HTTP_HOST}
34-
unset $(grep -Ev '^$|[#;]' ${code_dir}/${project}/.env | sed -E 's/([^=]*)=.*/\1/')
35-
#队列
36-
echo "[program:${project}]
19+
#本地环境不自动启动队列
20+
if ! [ "${DOCKER_APP_ENV}" = "local" ]
21+
then
22+
##项目消息队列
23+
for project in ${projects}
24+
do
25+
#导入配置
26+
export $(grep -Ev '^$|[#;]' ${code_dir}/${project}/.env | xargs)
27+
#判断是否本地开发环境
28+
if [ "${APP_ENV}" = "" ] || [ "${APP_ENV}" = "local" ];
29+
then
30+
is_local=1
31+
queue_type="listen"
32+
else
33+
is_local=0
34+
queue_type="work"
35+
fi
36+
http_host=${SWOOLE_HTTP_HOST}
37+
unset $(grep -Ev '^$|[#;]' ${code_dir}/${project}/.env | sed -E 's/([^=]*)=.*/\1/')
38+
#队列
39+
echo "[program:${project}]
3740
process_name=%(program_name)s_%(process_num)02d
3841
command=php ${code_dir}/${project}/artisan queue:${queue_type} --sleep=3 --tries=3
3942
autostart=true
@@ -43,20 +46,20 @@ numprocs=1
4346
redirect_stderr=true
4447
stdout_logfile=${code_dir}/${project}/storage/logs/supervisor.log" > /etc/supervisor/conf.d/${project}.conf
4548

46-
#队列监控
47-
echo "[program:${project}_horizon]
49+
#队列监控
50+
echo "[program:${project}_horizon]
4851
process_name=%(program_name)s_%(process_num)02d
4952
command=php ${code_dir}/${project}/artisan horizon
5053
autostart=true
5154
autorestart=true
5255
user=www-data
5356
redirect_stderr=true
5457
stdout_logfile=${code_dir}/${project}/storage/logs/horizon.log" > /etc/supervisor/conf.d/"${project}"_horizon.conf
55-
#phpswoole服务
56-
if [ "${is_local}" = 0 ] && ! [ "${http_host}" = "" ]
57-
then
58-
rm -f ${code_dir}/${project}/storage/logs/swoole_http.pid
59-
echo "[program:${project}_swoole]
58+
#phpswoole服务
59+
if [ "${is_local}" = 0 ] && ! [ "${http_host}" = "" ]
60+
then
61+
rm -f ${code_dir}/${project}/storage/logs/swoole_http.pid
62+
echo "[program:${project}_swoole]
6063
process_name=%(program_name)s_%(process_num)02d
6164
command=php ${code_dir}/${project}/artisan swoole:http start
6265
startsecs=3
@@ -67,9 +70,10 @@ user=www-data
6770
numprocs=1
6871
redirect_stderr=true
6972
stdout_logfile=${code_dir}/${project}/storage/logs/supervisor_swoole.log" > /etc/supervisor/conf.d/"${project}"_swoole.conf
70-
fi
71-
done
72-
supervisord -c /etc/supervisor/supervisord.conf
73+
fi
74+
done
75+
supervisord -c /etc/supervisor/supervisord.conf
76+
fi
7377
#supervisorctl stop all
7478
php-fpm
7579
#php /var/www/laravel/artisan swoole:http start

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"animate.css": "^3.7.2",
3636
"axios": "^0.19.2",
3737
"bootstrap": "^3.4.1",
38-
"bootstrap-colorpicker": "^3.0.0-beta.3",
38+
"bootstrap-colorpicker": "^2.5.3",
3939
"bootstrap-sass": "3.4.1",
4040
"collect.js": "^4.25.0",
4141
"echarts": "^5.2.2",

resources/js/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const app = new Vue({
3838
if(window.AppConfig.env=='production' && window.AppConfig.baidu_statistics_url){
3939
window._hmt = window._hmt || [];
4040
(function() {
41-
var hm = document.createElement("script");
41+
let hm = document.createElement("script");
4242
hm.src = window.AppConfig.baidu_statistics_url;
43-
var s = document.getElementsByTagName("script")[0];
43+
let s = document.getElementsByTagName("script")[0];
4444
s.parentNode.insertBefore(hm, s);
4545
})();
4646
}

resources/js/components/datatable.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
</tr>
322322
</tbody>
323323
<tfoot >
324-
<tr class="loading" v-if="loading">
324+
<tr class="loading" v-if="loading && !hideLoading">
325325
<td colspan="6" class="overlay">
326326
<div class="fa">
327327
<i class="fa fa-refresh fa-spin"></i>
@@ -415,6 +415,7 @@
415415
loading:false, //数据加载中状态
416416
initLoading:true, //初始化加载状态
417417
show_export_fields:false, //导出字段按钮显示状态
418+
hideLoading:false,
418419
data:{
419420
options:{
420421
where:{},
@@ -621,7 +622,7 @@
621622
this.data.options.order = copyObj(options.order || {});
622623
if(url==this.data.configUrl['listUrl']){
623624
//判断是否是每页条数变更
624-
if(response.data.per_page!=this.data.list.per_page){
625+
if(response.data.per_page!=this.data.list.per_page && typeof response.data.last_page =="undefined"){
625626
response.data.last_page = Math.ceil(this.data.list.total/response.data.per_page);
626627
}
627628
for (let i in response.data ) {
@@ -711,7 +712,8 @@
711712
});
712713
},
713714
//刷新
714-
refresh(){
715+
refresh(hideLoading){
716+
this.hideLoading = !!hideLoading;
715717
let options = copyObj(this.affirm_options);
716718
options['page'] = this.data.list['current_page'];
717719
options['get_count'] = 1;

resources/js/components/editItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div :data-id="keyName" class="move-item">
3-
<validation-provider :vid="keyName" :name="options.name" :rules="options.rules || ''" v-slot="{ errors }">
3+
<validation-provider :vid="keyName" :custom-messages="options.messages || null" :name="options.name" :rules="options.rules || ''" v-slot="{ errors }">
44
<div class="form-group edit-item" :class="{'has-error':errors.length>0}">
55
<label><span class="required" v-show="_required">*</span>{{options.name}}</label>
66
<span class="help-block title pull-right" v-show="options.title && !errors.length">

resources/js/components/editorMd.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
return new Promise(resolve => setTimeout(resolve, ms))
218218
},
219219
mouseoutEvent(){
220-
if(this.editorMd && this.editorMd.getValue){
220+
if(this.editorMd && (typeof this.editorMd.getValue!="undefined")){
221221
let val = this.editorMd.getValue();
222222
if((typeof this.value!="undefined") && val!=this.value){
223223
this.$emit('input', val); //修改值

resources/js/components/modal.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@
7272

7373
<style scoped lang="scss">
7474
.modal-dialog {
75-
width: unset;
75+
width: 100%;
76+
}
77+
@media (max-width: 767px) {
78+
.modal-dialog {
79+
width: unset;
80+
}
7681
}
7782
.close {
7883
position: absolute;

resources/js/pages/admin/components/modal.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<span>×</span></button>
1212
<h4 class="modal-title">{{modal['title']}}</h4>
1313
</div>
14-
<div class="modal-body">
14+
<div class="modal-body text-center">
1515
<p v-html="modal['content']"></p>
1616
</div>
1717
<div class="modal-footer">
@@ -100,6 +100,7 @@
100100
top: 0;
101101
right: 0;
102102
margin: auto;
103+
padding:10px;
103104
}
104105
105106
</style>

0 commit comments

Comments
 (0)
0