10000 feature 新增单页面外的链接菜单跳转设置 · laraveladmin-cn/laraveladmin@94ceb45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 94ceb45

Browse files
committed
feature 新增单页面外的链接菜单跳转设置
1 parent ac9448c commit 94ceb45

File tree

8 files changed

+70
-7
lines changed

8 files changed

+70
-7
lines changed

app/Http/Controllers/Open/IndexController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function menu(){
198198
$obj = Menu::main()
199199
->select(['id','name','icons','description',
200200
'url','parent_id','resource_id','status','level',
201-
'left_margin','right_margin','method'
201+
'left_margin','right_margin','method','is_out_link'
202202
])
203203
->orderBy('left_margin','asc')
204204
->with(['parent'=>function($q){

app/Models/Menu.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function __construct(array $attributes = [])
5656
'use',
5757
'as',
5858
'middleware',
59-
'item_name'
59+
'item_name',
60+
'is_out_link'
6061
];
6162
//输出隐藏字段
6263
protected $hidden = ['deleted_at'];
@@ -98,6 +99,10 @@ public function __construct(array $attributes = [])
9899
'testing'=>'testing',
99100
'staging'=>'staging',
100101
'production'=>'production'
102+
],
103+
'is_out_link'=>[
104+
'',
105+
''
101106
]
102107
];
103108

@@ -123,7 +128,8 @@ public function __construct(array $attributes = [])
123128
'as'=>'',
124129
'middleware'=>[],
125130
'use'=>[],
126-
'item_name'=>''
131+
'item_name'=>'',
132+
'is_out_link'=>0
127133
];
128134

129135
//字段默认值
@@ -146,6 +152,7 @@ public function __construct(array $attributes = [])
146152
'use'=>'Route usage',
147153
'as'=>'Routing alias',
148154
'middleware'=>'Using middleware alone',
155+
'is_out_link'=>'是否为外部页面',
149156
//'left_margin' => 'Left boundary',
150157
//'right_margin' => 'Right boundary',
151158
//'created_at' => 'Created At',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
class AlertMenusReloadTable extends Migration
7+
{
8+
9+
protected $bindModel='App\Models\Menu';
10+
11+
/**
12+
* Run the migrations.
13+
*
14+
* @return void
15+
*/
16+
public function up()
17+
{
18+
$model = new $this->bindModel();
19+
$prefix = $model->getConnection()->getTablePrefix();
20+
$connection = $model->getConnectionName()?: config('database.default');
21+
DB::connection($connection)->statement("ALTER TABLE `".$prefix.$model->getTable()."`
22+
ADD COLUMN `is_out_link` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否为外部链接:0-否,1-是' AFTER `item_name`;");
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
$model = new $this->bindModel();
33+
$prefix = $model->getConnection()->getTablePrefix();
34+
$connection = $model->getConnectionName()?: config('database.default');
35+
DB::connection($connection)->statement("ALTER TABLE `".$prefix.$model->getTable()."`
36+
DROP COLUMN `is_out_link`;");
37+
}
38+
}

resources/js/components/sidebarItems.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<li class="treeview">
3-
<a class="menu-a" @click="toUrl(menu['url'],$event)" :href="menu['url']?menu['url']:null" :class="{'no-childrens':!(menu['childrens'] && menu['childrens'].length)}">
3+
<a class="menu-a" @click="toUrl(menu['url'],$event,menu['is_out_link'])" :href="menu['url']?menu['url']:null" :class="{'no-childrens':!(menu['childrens'] && menu['childrens'].length)}">
44
<i class="fa" :class="menu['icons']"></i>
55
<span>{{$tp(menu['name'])}}</span>
66
<span class="pull-right-container" v-if="menu['childrens']">

resources/js/pages/admin/layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="navbar-custom-menu pull-left">
1818
<ul class="nav navbar-nav">
1919
<li :class="{active:module['active']}" v-for="module in modules">
20-
<a @click="toUrl(module['url'],$event)" :href="module['url']?module['url']:null">
20+
<a @click="toUrl(module['url'],$event,module['is_out_link'])" :href="module['url']?module['url']:null">
2121
<i class="fa" :class="module['icons']"></i>
2222
{{$tp(module['name'],shared)}}
2323
</a>

resources/js/pages/admin/menus/edit.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@
149149
</div>
150150
</template>
151151
</edit-item>
152+
<edit-item key-name="is_out_link" :options="{name: '是否为外部链接', required: false}" :datas="props">
153+
<template slot="input-item">
154+
<div class="row">
155+
<div v-for="(item,index) in props.maps['is_out_link']"
156+
class="col-lg-3 col-md-3 col-sm-3 col-xs-6">
157+
<icheck v-model="props.data.row['is_out_link']"
158+
type="radio"
159+
:option="index"
160+
:title="item"
161+
:disabled="!props.url || props.data.row['resource_id']>0"> {{item}}
162+
</icheck>
163+
</div>
164+
</div>
165+
</template>
166+
</edit-item>
152167
<edit-item key-name="status" :options="{name: props.transField('State'), required: false}" :datas="props">
153168
<template slot="input-item">
154169
<div class="row">

resources/js/pages/open/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
{{$tp('Home page of official website')}}
44
<router-link to="/admin">{{$tp('Backstage home page')}}</router-link>
55
<router-link to="/home">{{$tp('Front desk home page')}}</router-link>
6+
<a @click="toUrl('/api-doc',$event,true)" href="/api-doc">
7+
接口文档
8+
</a>
69
</div>
710
</template>
811

resources/js/plugin/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default Plugin = {
5454
this.loading = false;
5555
});
5656
};
57-
Vue.prototype.toUrl = function(url,event){
57+
Vue.prototype.toUrl = function(url,event,is_out_page){
5858
event.preventDefault();
5959
if(!url){
6060
return
@@ -71,7 +71,7 @@ export default Plugin = {
7171
window.open(url,'_blank');
7272
return false;
7373
}
74-
if(is_external){
74+
if(is_external || is_out_page){
7575
window.location.href=url;
7676
}else {
7777
this.$router.push({ path: url }).catch(error => {

0 commit comments

Comments
 (0)
0