Skip to content

Commit 18e57b1

Browse files
author
pixel
committed
Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
2 parents 4a0a54e + deb6ea5 commit 18e57b1

File tree

18 files changed

+83
-47
lines changed

18 files changed

+83
-47
lines changed

server/cmd/datas/authorities.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
)
1111

1212
var Authorities = []model.SysAuthority{
13-
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0"},
14-
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888"},
15-
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
13+
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0", DefaultRouter: "dashboard"},
14+
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888", DefaultRouter: "dashboard"},
15+
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0", DefaultRouter: "dashboard"},
1616
}
1717

1818
func InitSysAuthority(db *gorm.DB) {

server/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ system:
4343
env: 'public' # Change to "develop" to skip authentication for development mode
4444
addr: 8888
4545
db-type: 'mysql'
46-
oss-type: 'local'
46+
oss-type: 'local' # 控制oss选择走本期还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置
4747
use-multipoint: false
4848

4949
# captcha configuration

server/model/sys_authority.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ type SysAuthority struct {
1414
DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"`
1515
Children []SysAuthority `json:"children" gorm:"-"`
1616
SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"`
17+
DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"`
1718
}

server/resource/template/server/router.go.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func Init{{.StructName}}Router(Router *gin.RouterGroup) {
10-
{{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()).Use(middleware.OperationRecord())
10+
{{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.OperationRecord())
1111
{
1212
{{.StructName}}Router.POST("create{{.StructName}}", v1.Create{{.StructName}}) // 新建{{.StructName}}
1313
{{.StructName}}Router.DELETE("delete{{.StructName}}", v1.Delete{{.StructName}}) // 删除{{.StructName}}

server/resource/template/web/table.vue.tpl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,7 @@
6868
<el-table-column label="按钮组">
6969
<template slot-scope="scope">
7070
<el-button class="table-button" @click="update{{.StructName}}(scope.row)" size="small" type="primary" icon="el-icon-edit">变更</el-button>
71-
<el-popover placement="top" width="160" v-model="scope.row.visible">
72-
<p>确定要删除吗?</p>
73-
<div style="text-align: right; margin: 0">
74-
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
75-
<el-button type="primary" size="mini" @click="delete{{.StructName}}(scope.row)">确定</el-button>
76-
</div>
77-
<el-button type="danger" icon="el-icon-delete" size="mini" slot="reference">删除</el-button>
78-
</el-popover>
71+
<el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteRow(scope.row)">删除</el-button>
7972
</template>
8073
</el-table-column>
8174
</el-table>
@@ -145,7 +138,6 @@ export default {
145138
return {
146139
listApi: get{{ .StructName }}List,
147140
dialogFormVisible: false,
148-
visible: false,
149141
type: "",
150142
deleteVisible: false,
151143
multipleSelection: [],
@@ -208,6 +200,15 @@ export default {
208200
handleSelectionChange(val) {
209201
this.multipleSelection = val
210202
},
203+
deleteRow(row){
204+
this.$confirm('确定要删除吗?', '提示', {
205+
confirmButtonText: '确定',
206+
cancelButtonText: '取消',
207+
type: 'warning'
208+
}).then(() => {
209+
this.delete{{.StructName}}(row);
210+
});
211+
},
211212
async onDelete() {
212213
const ids = []
213214
if(this.multipleSelection.length == 0){
@@ -265,7 +266,6 @@ export default {
265266
};
266267
},
267268
async delete{{.StructName}}(row) {
268-
this.visible = false;
269269
const res = await delete{{.StructName}}({ ID: row.ID });
270270
if (res.code == 0) {
271271
this.$message({
@@ -317,4 +317,4 @@ export default {
317317
</script>
318318

319319
<style>
320-
</style>
320+
</style>

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "qm-plus-vue-page",
2+
"name": "gin-vue-admin",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
@@ -72,4 +72,4 @@
7272
"> 1%",
7373
"last 2 versions"
7474
]
75-
}
75+
}

web/src/components/chooseImg/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div style="display:flex;justify-content:space-around;flex-wrap:wrap;padding-top:40px">
44
<el-image
55
class="header-img-box-list"
6-
:src="item.url"
6+
:src="(item.url && item.url.slice(0, 4) !== 'http')?path+item.url:item.url"
77
v-for="(item,key) in picList"
88
:key="key"
99
@click.native="chooseImg(item.url,target,targetKey)"
@@ -17,6 +17,7 @@
1717
</template>
1818

1919
<script>
20+
const path = process.env.VUE_APP_BASE_API
2021
import { getFileList } from "@/api/fileUploadAndDownload";
2122
export default {
2223
props: {
@@ -26,7 +27,8 @@ export default {
2627
data() {
2728
return {
2829
drawer: false,
29-
picList: []
30+
picList: [],
31+
path:path
3032
};
3133
},
3234
methods: {

web/src/permission.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ router.beforeEach(async(to, from, next) => {
1313
document.title = getPageTitle(to.meta.title)
1414
if (whiteList.indexOf(to.name) > -1) {
1515
if (token) {
16-
next({ path: '/layout/dashboard' })
16+
next({ name: store.getters["user/userInfo"].authority.defaultRouter })
1717
} else {
1818
next()
1919
}
2020
} else {
2121
// 不在白名单中并且已经登陆的时候
2222
if (token) {
2323
// 添加flag防止多次获取动态路由和栈溢出
24-
if (!asyncRouterFlag) {
24+
if (!asyncRouterFlag && store.getters['router/asyncRouters'].length == 0) {
2525
asyncRouterFlag++
2626
await store.dispatch('router/SetAsyncRouter')
2727
const asyncRouters = store.getters['router/asyncRouters']

web/src/store/module/router.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const router = {
2828
// 设置动态路由
2929
setAsyncRouter(state, asyncRouters) {
3030
state.asyncRouters = asyncRouters
31-
}
31+
},
3232
},
3333
actions: {
3434
// 从后台获取动态路由
@@ -73,6 +73,9 @@ export const router = {
7373
},
7474
routerList(state) {
7575
return state.routerList
76+
},
77+
defaultRouter(state) {
78+
return state.defaultRouter
7679
}
7780
}
7881
}

web/src/store/module/user.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ export const user = {
3535
}
3636
},
3737
actions: {
38-
async LoginIn({ commit }, loginInfo) {
38+
async LoginIn({ commit, dispatch, rootGetters, getters }, loginInfo) {
3939
const res = await login(loginInfo)
4040
if (res.code == 0) {
4141
commit('setUserInfo', res.data.user)
4242
commit('setToken', res.data.token)
43+
await dispatch('router/SetAsyncRouter', {}, { root: true })
44+
const asyncRouters = rootGetters['router/asyncRouters']
45+
router.addRoutes(asyncRouters)
4346
const redirect = router.history.current.query.redirect
4447
if (redirect) {
4548
router.push({ path: redirect })
4649
} else {
47-
router.push({ path: '/layout/dashboard' })
50+
router.push({ name: getters["userInfo"].authority.defaultRouter })
4851
}
4952
return true
5053
}

0 commit comments

Comments
 (0)