Explorar o código

Merge pull request #541 from flipped-aurora/gva_gormv2_dev

Gva gormv2 dev
奇淼(piexlmax %!s(int64=3) %!d(string=hai) anos
pai
achega
0d857349d6

+ 2 - 0
server/api/v1/sys_authority.go

@@ -7,6 +7,7 @@ import (
 	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"gin-vue-admin/utils"
+
 	"github.com/gin-gonic/gin"
 	"go.uber.org/zap"
 )
@@ -30,6 +31,7 @@ func CreateAuthority(c *gin.Context) {
 		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
 		response.FailWithMessage("创建失败"+err.Error(), c)
 	} else {
+		_ = service.UpdateCasbin(authority.AuthorityId, request.DefaultCasbin())
 		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "创建成功", c)
 	}
 }

+ 3 - 0
server/api/v1/sys_menu.go

@@ -24,6 +24,9 @@ func GetMenu(c *gin.Context) {
 		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
 		response.FailWithMessage("获取失败", c)
 	} else {
+		if menus == nil {
+			menus = []model.SysMenu{}
+		}
 		response.OkWithDetailed(response.SysMenusResponse{Menus: menus}, "获取成功", c)
 	}
 }

+ 4 - 0
server/model/request/sys_casbin.go

@@ -11,3 +11,7 @@ type CasbinInReceive struct {
 	AuthorityId string       `json:"authorityId"` // 权限id
 	CasbinInfos []CasbinInfo `json:"casbinInfos"`
 }
+
+func DefaultCasbin() []CasbinInfo {
+	return []CasbinInfo{{Path: "/menu/getMenu", Method: "POST"}, {Path: "/jwt/jsonInBlacklist", Method: "POST"}}
+}

+ 19 - 1
server/model/request/sys_menu.go

@@ -1,9 +1,27 @@
 package request
 
-import "gin-vue-admin/model"
+import (
+	"gin-vue-admin/global"
+	"gin-vue-admin/model"
+)
 
 // Add menu authority info structure
 type AddMenuAuthorityInfo struct {
 	Menus       []model.SysBaseMenu
 	AuthorityId string // 角色ID
 }
+
+func DefaultMenu() []model.SysBaseMenu {
+	return []model.SysBaseMenu{{
+		GVA_MODEL: global.GVA_MODEL{ID: 1},
+		ParentId:  "0",
+		Path:      "dashboard",
+		Name:      "dashboard",
+		Component: "view/dashboard/index.vue",
+		Sort:      1,
+		Meta: model.Meta{
+			Title: "仪表盘",
+			Icon:  "setting",
+		},
+	}}
+}

+ 2 - 2
server/utils/directory.go

@@ -37,9 +37,9 @@ func CreateDir(dirs ...string) (err error) {
 		}
 		if !exist {
 			global.GVA_LOG.Debug("create directory" + v)
-			err = os.MkdirAll(v, os.ModePerm)
-			if err != nil {
+			if err := os.MkdirAll(v, os.ModePerm); err != nil {
 				global.GVA_LOG.Error("create directory"+v, zap.Any(" error:", err))
+				return err
 			}
 		}
 	}

+ 1 - 1
web/build.config.js

@@ -7,7 +7,7 @@ module.exports = {
     /**
      * 如果设置path属性, { name: 'vue', scope: 'Vue', path: '/vue/2.6.9/vue.min.js' } 即编译出来以[baseCdnUrl][path]
      * 否则自动拼写 [baseCdnUrl]/[name]/[version]/[name].min.js
-     * */
+     */
     { name: 'vue', scope: 'Vue' },
     { name: 'vue-router', scope: 'VueRouter' },
     { name: 'vuex', scope: 'Vuex' },

+ 7 - 12
web/src/core/config.js

@@ -1,15 +1,10 @@
-/*
-* 网站配置文件
-* */
-
-
-
-const config ={
-
-    appName : 'Gin-Vue-Admin',
-
-    appLogo : 'https://www.gin-vue-admin.com/img/logo.png'
+/**
+ * 网站配置文件
+ */
 
+const config = {
+  appName: 'Gin-Vue-Admin',
+  appLogo: 'https://www.gin-vue-admin.com/img/logo.png'
 }
 
-export default config
+export default config

+ 1 - 2
web/src/core/gin-vue-admin.js

@@ -10,10 +10,9 @@ import APlayer from '@moefe/vue-aplayer'
 import '../../node_modules/timeline-vuejs/dist/timeline-vuejs.css'
 // 路由守卫
 import Bus from '@/utils/bus'
-//加载网站配置文件夹
+// 加载网站配置文件夹
 import config from './config'
 Vue.prototype.$GIN_VUE_ADMIN = config
-console.log(config)
 Vue.use(Bus)
 Vue.use(APlayer, {
   defaultCover: 'https://github.com/u3u.png',

+ 6 - 1
web/src/utils/request.js

@@ -80,7 +80,12 @@ service.interceptors.response.use(
   },
   error => {
     closeLoading()
-    MessageBox.confirm(`检测到接口错误${error},此类错误内容常见于后台panic,如果影响您正常使用可强制登出清理缓存`, '接口报错', {
+    MessageBox.confirm(`
+    <p>检测到接口错误${error}</p>
+    <p>错误码500:此类错误内容常见于后台panic,如果影响您正常使用可强制登出清理缓存</p>
+    <p>错误码404:此类错误多为接口未注册(或未重启)或者请求路径(方法)与api路径(方法)不符</p>
+    `, '接口报错', {
+      dangerouslyUseHTMLString: true,
       distinguishCancelAndClose: true,
       confirmButtonText: '清理缓存',
       cancelButtonText: '取消'

+ 1 - 0
web/src/view/init/index.vue

@@ -8,6 +8,7 @@
           <p class="init_p">1.您需有用一定的VUE和golang基础</p>
           <p class="init_p">2.请您确认是否已经阅读过官方文档</p>
           <p class="init_p">3.请您确认是否了解后续的配置流程</p>
+          <p class="init_p">注:开发组不为文档中书写过的内容提供无偿服务</p>
           <p class="init_btn">
             <el-button type="primary" @click="goDoc">
               阅读文档

+ 16 - 6
web/src/view/person/person.vue

@@ -18,15 +18,20 @@
                 <li>
                   <i class="el-icon-user" />{{ userInfo.nickName }}
                 </li>
-                <li>
-                  <i class="el-icon-data-analysis" />北京反转极光科技有限公司-技术部-前端事业群
-                </li>
+                <el-tooltip class="item" effect="light" content="北京反转极光科技有限公司-技术部-前端事业群" placement="top">
+                  <li>
+                    <i class="el-icon-data-analysis" />北京反转极光科技有限公司-技术部-前端事业群
+                  </li>
+                </el-tooltip>
                 <li>
                   <i class="el-icon-video-camera-solid" />中国·北京市·朝阳区
                 </li>
-                <li>
-                  <i class="el-icon-medal-1" />goLang/JavaScript/Vue/Gorm
-                </li>
+                <el-tooltip class="item" effect="light" content="goLang/JavaScript/Vue/Gorm" placement="top">
+                  <li>
+                    <i class="el-icon-medal-1" />goLang/JavaScript/Vue/Gorm
+                  </li>
+                </el-tooltip>
+
               </ul>
             </div>
           </div>
@@ -245,7 +250,12 @@ export default {
       ul {
         display: inline-block;
         height: 100%;
+        width: 100%;
         li {
+          width: 100%;
+          white-space:nowrap;
+          overflow: hidden;
+          text-overflow: ellipsis;
           i {
             margin-right: 8px;
           }