diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..ecbb1cd4 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,16 @@ +version = 1 + +[[analyzers]] +name = "javascript" +enabled = true + + [analyzers.meta] + plugins = ["vue"] + +[[analyzers]] +name = "go" +enabled = true + + [analyzers.meta] + import_root = "github.com/flipped-aurora/gin-vue-admin" + dependencies_vendored = true diff --git a/server/Dockerfile b/server/Dockerfile index b7f4b3a4..0e03cd50 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -5,6 +5,7 @@ COPY . . RUN go env -w GO111MODULE=on RUN go env -w GOPROXY=https://goproxy.cn,direct +RUN go env -w CGO_ENABLED=0 RUN go env RUN go mod tidy RUN go build -o server . diff --git a/server/core/server.go b/server/core/server.go index 6f30d54d..e11b3419 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -6,6 +6,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/initialize" + "github.com/flipped-aurora/gin-vue-admin/server/service/system" "go.uber.org/zap" ) @@ -18,6 +19,12 @@ func RunWindowsServer() { // 初始化redis服务 initialize.Redis() } + + // 从db加载jwt数据 + if global.GVA_DB != nil { + system.LoadAll() + } + Router := initialize.Routers() Router.Static("/form-generator", "./resource/page") diff --git a/server/core/viper.go b/server/core/viper.go index bbcfd364..60ce695a 100644 --- a/server/core/viper.go +++ b/server/core/viper.go @@ -7,8 +7,6 @@ import ( "path/filepath" "time" - "github.com/flipped-aurora/gin-vue-admin/server/service/system" - "github.com/songzhibin97/gkit/cache/local_cache" "github.com/flipped-aurora/gin-vue-admin/server/global" @@ -60,10 +58,7 @@ func Viper(path ...string) *viper.Viper { } global.GVA_CONFIG.AutoCode.Root, _ = filepath.Abs("..") global.BlackCache = local_cache.NewCache( - local_cache.SetDefaultExpire(time.Duration(global.GVA_CONFIG.JWT.ExpiresTime))) - // 从db加载jwt数据 - if global.GVA_DB != nil { - system.LoadAll() - } + local_cache.SetDefaultExpire(time.Second * time.Duration(global.GVA_CONFIG.JWT.ExpiresTime)) + ) return v } diff --git a/server/model/system/request/sys_user.go b/server/model/system/request/sys_user.go index 84ab1ef4..c03807e1 100644 --- a/server/model/system/request/sys_user.go +++ b/server/model/system/request/sys_user.go @@ -5,7 +5,7 @@ type Register struct { Username string `json:"userName"` Password string `json:"passWord"` NickName string `json:"nickName" gorm:"default:'QMPlusUser'"` - HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"` + HeaderImg string `json:"headerImg" gorm:"default:'https://qmplusimg.henrongyi.top/gva_header.jpg'"` AuthorityId string `json:"authorityId" gorm:"default:888"` AuthorityIds []string `json:"authorityIds"` } diff --git a/server/model/system/sys_user.go b/server/model/system/sys_user.go index c7fbf90e..40678cd4 100644 --- a/server/model/system/sys_user.go +++ b/server/model/system/sys_user.go @@ -7,15 +7,15 @@ import ( type SysUser struct { global.GVA_MODEL - UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID - Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 - Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码 - NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 - SideMode string `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"` // 用户侧边主题 - HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像 - BaseColor string `json:"baseColor" gorm:"default:#fff;comment:基础颜色"` // 基础颜色 - ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"` // 活跃颜色 - AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID + UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID + Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 + Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码 + NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 + SideMode string `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"` // 用户侧边主题 + HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像 + BaseColor string `json:"baseColor" gorm:"default:#fff;comment:基础颜色"` // 基础颜色 + ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"` // 活跃颜色 + AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` } diff --git a/server/resource/template/web/table.vue.tpl b/server/resource/template/web/table.vue.tpl index 6fd337c0..878830c3 100644 --- a/server/resource/template/web/table.vue.tpl +++ b/server/resource/template/web/table.vue.tpl @@ -21,21 +21,21 @@ {{ end }}{{ end }}{{ end }} - - 查询 - 新增 - -

确定要删除吗?

-
- 取消 - 确定 -
- -
-
+
+ 查询 + 新增 + +

确定要删除吗?

+
+ 取消 + 确定 +
+ +
+
0 +} + // CreateAutoCodeHistory RouterPath : RouterPath@RouterString;RouterPath2@RouterString2 func (autoCodeHistoryService *AutoCodeHistoryService) CreateAutoCodeHistory(meta, structName, structCNName, autoCodePath string, injectionMeta string, tableName string, apiIds string) error { return global.GVA_DB.Create(&system.SysAutoCodeHistory{ diff --git a/server/service/system/sys_initdb.go b/server/service/system/sys_initdb.go index a0a768e5..45d3b747 100644 --- a/server/service/system/sys_initdb.go +++ b/server/service/system/sys_initdb.go @@ -5,6 +5,8 @@ import ( "fmt" "path/filepath" + uuid "github.com/satori/go.uuid" + "github.com/flipped-aurora/gin-vue-admin/server/config" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/example" @@ -33,6 +35,7 @@ func (initDBService *InitDBService) writeConfig(viper *viper.Viper, mysql config for k, v := range cs { viper.Set(k, v) } + viper.Set("jwt.signing-key", uuid.NewV4()) return viper.WriteConfig() } @@ -159,6 +162,7 @@ func (initDBService *InitDBService) InitDB(conf request.InitDB) error { global.GVA_DB = nil return err } + if err = initDBService.writeConfig(global.GVA_VP, MysqlConfig); err != nil { return err } diff --git a/server/source/admin.go b/server/source/admin.go index 3128acb0..713035a1 100644 --- a/server/source/admin.go +++ b/server/source/admin.go @@ -16,8 +16,8 @@ var Admin = new(admin) type admin struct{} var admins = []system.SysUser{ - {GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"}, - {GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "http://qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"}, + {GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "https:///qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"}, + {GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "https:///qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"}, } //@author: [SliverHorn](https://github.com/SliverHorn) diff --git a/server/source/file.go b/server/source/file.go index 59b2db14..964383c6 100644 --- a/server/source/file.go +++ b/server/source/file.go @@ -14,8 +14,8 @@ var File = new(file) type file struct{} var files = []example.ExaFileUploadAndDownload{ - {global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "10.png", "http://qmplusimg.henrongyi.top/gvalogo.png", "png", "158787308910.png"}, - {global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "http://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"}, + {global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "10.png", "https://qmplusimg.henrongyi.top/gvalogo.png", "png", "158787308910.png"}, + {global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "https://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"}, } //@author: [SliverHorn](https://github.com/SliverHorn) diff --git a/server/source/user_authority.go.go b/server/source/user_authority.go similarity index 100% rename from server/source/user_authority.go.go rename to server/source/user_authority.go diff --git a/web/package.json b/web/package.json index b47b01e3..b32113d5 100644 --- a/web/package.json +++ b/web/package.json @@ -21,7 +21,7 @@ "screenfull": "^5.0.2", "script-ext-html-webpack-plugin": "^2.1.4", "spark-md5": "^3.0.1", - "vue": "^3.0.0", + "vue": "^3.2.0", "vue-particle-line": "^0.1.4", "vue-router": "^4.0.0-0", "vuex": "^4.0.0-0", diff --git a/web/src/components/upload/image.vue b/web/src/components/upload/image.vue index fc9f6870..2283e632 100644 --- a/web/src/components/upload/image.vue +++ b/web/src/components/upload/image.vue @@ -2,7 +2,6 @@ @@ -53,6 +51,13 @@ export default { }, methods: { beforeImageUpload(file) { + const isJPG = file.type === 'image/jpeg' + const isPng = file.type === 'image/png' + if (!isJPG && !isPng) { + this.$message.error('上传头像图片只能是 jpg或png 格式!') + return false + } + const isRightSize = file.size / 1024 < this.fileSize if (!isRightSize) { // 压缩 diff --git a/web/src/style/main.scss b/web/src/style/main.scss index f5da1cb4..e3418976 100644 --- a/web/src/style/main.scss +++ b/web/src/style/main.scss @@ -653,7 +653,7 @@ li { color: #fff; } .el-menu--inline { - border-left: 5px solid #2c3b41; + // border-left: 5px solid #2c3b41; } } .hideside { @@ -810,9 +810,6 @@ li { padding: 0 15px; border-left: 1px solid #ebeef5; border-right: 1px solid #ebeef5; - .demo-form-inline { - margin-bottom: 10px; - } } // table @@ -892,6 +889,14 @@ li { // upload-demo .upload-demo, .upload { + .upload-box{ + margin-bottom: 12px; + display: flex; + justify-content: flex-end; + .upload-btn{ + margin-left: 12px; + } + } background-color: $white-bg; padding: 15px; .el-upload-list__item-status-label { @@ -1019,6 +1024,7 @@ li { .main-cont.el-main { background-color: $bg-main; .menu-total { + cursor: pointer; font-size: 22px; color: #838383; margin-top: 16px; @@ -1042,7 +1048,12 @@ li { height: $height-nav-scroll; border: none; border-left: 1px solid $border-color; + border-right: 1px solid $border-color; + +.el-tabs__item{ + border-left: 0px solid $border-color; + } } + .el-tabs__item.is-active { background-color: rgba(64, 158, 255, .08); } @@ -1145,10 +1156,6 @@ $mainHight: 100vh; } } -.el-scrollbar__wrap { - padding-bottom: 17px; -} - .layout-cont { .right-box { height: $height-header; @@ -1174,10 +1181,6 @@ $mainHight: 100vh; background-color: #fff; padding: 0; } - .fl-right { - // height: $height-header; - // line-height: $height-header; - } &.el-main { overflow: auto; background: #fff; @@ -1186,6 +1189,8 @@ $mainHight: 100vh; overflow: visible; position: relative; .menu-total { + margin-left:6px; + cursor: pointer; float: left; margin-top: 10px; width: 30px; @@ -1201,7 +1206,7 @@ $mainHight: 100vh; } } .el-menu-vertical { - height: calc(100vh - 64px) !important; + height: calc(100vh - 60px) !important; visibility: auto; &:not(.el-menu--collapse) { width: 220px; @@ -1397,6 +1402,15 @@ $mainHight: 100vh; } } +.gva-btn-list{ + margin-bottom: 12px; + display: flex; + justify-content: flex-end; + .el-button+.el-button{ + margin-left: 12px; + } +} + ::-webkit-scrollbar-track-piece { background-color: #f8f8f8; } diff --git a/web/src/view/example/customer/customer.vue b/web/src/view/example/customer/customer.vue index c1043d89..942e59eb 100644 --- a/web/src/view/example/customer/customer.vue +++ b/web/src/view/example/customer/customer.vue @@ -1,11 +1,9 @@