From 63012b31ac63e0dd9e465cc6700782a73458b6c2 Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Sun, 11 Oct 2020 16:18:56 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/package.json b/web/package.json index e5c49d7c..2120187b 100644 --- a/web/package.json +++ b/web/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "serve": "start https://www.gin-vue-admin.com && vue-cli-service serve", + "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, From 51b6c1086ec6ff56a08c663b300ba10d882991ee Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Mon, 12 Oct 2020 12:06:00 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E5=B1=80=E9=83=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=92=8C=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/openDocument.js | 23 +++++++++++++++++++++++ web/package.json | 2 +- web/src/main.js | 2 +- web/src/utils/request.js | 9 ++++----- web/src/view/layout/index.vue | 11 +++++++++-- web/src/view/system/state.vue | 7 ++++++- 6 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 web/openDocument.js diff --git a/web/openDocument.js b/web/openDocument.js new file mode 100644 index 00000000..0999755f --- /dev/null +++ b/web/openDocument.js @@ -0,0 +1,23 @@ +/* + 商用代码公司自用产品无需授权 + 若作为代码出售的产品(任何涉及代码交付第三方作为后续开发)必须保留此脚本 + 或标注原作者信息 + 否则将依法维权 +*/ + +var child_process = require("child_process"); + +var url = "https://www.gin-vue-admin.com", + cmd = ''; +console.log(process.platform) +switch (process.platform) { + case 'win32': + cmd = 'start'; + child_process.exec(cmd + ' ' + url); + break; + + case 'darwin': + cmd = 'open'; + child_process.exec(cmd + ' ' + url); + break; +} \ No newline at end of file diff --git a/web/package.json b/web/package.json index 2120187b..aa0ad1d9 100644 --- a/web/package.json +++ b/web/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "serve": "vue-cli-service serve", + "serve": "node openDocument.js && vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, diff --git a/web/src/main.js b/web/src/main.js index 085b2493..fd5b1f81 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -54,7 +54,7 @@ auth(Vue) import uploader from 'vue-simple-uploader' Vue.use(uploader) -new Vue({ +export default new Vue({ render: h => h(App), router, store diff --git a/web/src/utils/request.js b/web/src/utils/request.js index 8821cd61..b97abfbb 100644 --- a/web/src/utils/request.js +++ b/web/src/utils/request.js @@ -1,12 +1,12 @@ import axios from 'axios'; // 引入axios -import { Message, Loading } from 'element-ui'; +import { Message } from 'element-ui'; import { store } from '@/store/index' +import context from '@/main.js' const service = axios.create({ baseURL: process.env.VUE_APP_BASE_API, timeout: 99999 }) let acitveAxios = 0 -let loadingInstance let timer const showLoading = () => { acitveAxios++ @@ -15,7 +15,7 @@ const showLoading = () => { } timer = setTimeout(() => { if (acitveAxios > 0) { - loadingInstance = Loading.service({ fullscreen: true }) + context.$bus.emit("showLoading") } }, 400); } @@ -24,13 +24,12 @@ const closeLoading = () => { acitveAxios-- if (acitveAxios <= 0) { clearTimeout(timer) - loadingInstance && loadingInstance.close() + context.$bus.emit("closeLoading") } } //http request 拦截器 service.interceptors.request.use( config => { - console.log(config) if (!config.donNotShowLoading) { showLoading() } diff --git a/web/src/view/layout/index.vue b/web/src/view/layout/index.vue index bc9d9ba7..1e5fcf58 100644 --- a/web/src/view/layout/index.vue +++ b/web/src/view/layout/index.vue @@ -58,11 +58,11 @@ - + - + @@ -106,6 +106,7 @@ export default { isMobile: false, isShadowBg: false, showPassword: false, + loadingFlag:false, pwdModify: {}, rules: { password: [ @@ -209,6 +210,12 @@ export default { } this.$bus.emit('collapse', this.isCollapse) this.$bus.emit('mobile', this.isMobile) + this.$bus.on("showLoading",()=>{ + this.loadingFlag = true + }) + this.$bus.on("closeLoading",()=>{ + this.loadingFlag = false + }) window.onresize = () => { return (() => { let screenWidth = document.body.clientWidth diff --git a/web/src/view/system/state.vue b/web/src/view/system/state.vue index db920ef5..1cdba1b7 100644 --- a/web/src/view/system/state.vue +++ b/web/src/view/system/state.vue @@ -138,6 +138,7 @@ export default { name: "State", data() { return { + timer:null, state: {}, colors: [ { color: "#5cb87a", percentage: 20 }, @@ -148,10 +149,14 @@ export default { }, created() { this.reload(); - setInterval(() => { + this.timer = setInterval(() => { this.reload(); }, 1000*10); }, + beforeDestroy(){ + clearInterval(this.timer) + this.timer = null + }, methods: { async reload() { const { data } = await getSystemState(); From 3c9d81756b043a1244a9a1e4c2fcee221d4ea6e6 Mon Sep 17 00:00:00 2001 From: SliverHorn <503551462@qq.com> Date: Mon, 12 Oct 2020 13:23:45 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9body=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=B8=BAlongtext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/model/sys_operation_record.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/sys_operation_record.go b/server/model/sys_operation_record.go index 015b9306..e94bfaaa 100644 --- a/server/model/sys_operation_record.go +++ b/server/model/sys_operation_record.go @@ -16,7 +16,7 @@ type SysOperationRecord struct { Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟"` Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"` ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"` - Body string `json:"body" form:"body" gorm:"column:body;comment:请求Body"` + Body string `json:"body" form:"body" gorm:"type:longtext;column:body;comment:请求Body"` Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"` UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` User SysUser `json:"user"` From 5b1eb546fdb9153c72a35a7946702a495dffd2f3 Mon Sep 17 00:00:00 2001 From: SliverHorn <503551462@qq.com> Date: Tue, 13 Oct 2020 15:29:08 +0800 Subject: [PATCH 04/16] add ss.Dbname --- server/initialize/gorm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/initialize/gorm.go b/server/initialize/gorm.go index 35b60f7f..61088dc0 100644 --- a/server/initialize/gorm.go +++ b/server/initialize/gorm.go @@ -119,7 +119,7 @@ func GormPostgreSql() { // GormSqlServer 初始化SqlServer数据库 func GormSqlServer() { ss := global.GVA_CONFIG.Sqlserver - dsn := "sqlserver://" + ss.Username + ":" + ss.Password + "@" + ss.Path + "?database=gorm" + dsn := "sqlserver://" + ss.Username + ":" + ss.Password + "@" + ss.Path + "?database=" + ss.Dbname if global.GVA_DB, err = gorm.Open(sqlserver.Open(dsn), &gorm.Config{}); err != nil { global.GVA_LOG.Error("SqlServer启动异常", zap.Any("err", err)) os.Exit(0) From 6cc9a420bf62a5e749cc807822697b240e6004ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E6=B7=BC=EF=BC=88piexlmax?= <303176530@qq.com> Date: Tue, 13 Oct 2020 17:37:16 +0800 Subject: [PATCH 05/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b66509a9..9c17d519 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm ``` - node版本 > v8.6.0 -- golang版本 >= v1.11 +- golang版本 >= v1.14 - IDE推荐:Goland - gormv2版本初始化数据库可以利用批量创建功能,这里已经写好初始化代码,需要在main.go内打开 initialize.Data() 的注释即可 - 替换掉项目中的七牛云公钥,私钥,仓名和默认url地址,以免发生测试文件数据错乱 From f1de3e6b84c5a7ca82cb7185fa7ee19cea008721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E6=B7=BC=EF=BC=88piexlmax?= <303176530@qq.com> Date: Tue, 13 Oct 2020 17:37:59 +0800 Subject: [PATCH 06/16] Update README-en.md --- README-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 2aed4fce..fdc1bd81 100644 --- a/README-en.md +++ b/README-en.md @@ -70,7 +70,7 @@ We are excited that you are interested in contributing to gin-vue-admin. Before ``` - node version > v8.6.0 -- golang version >= v1.11 +- golang version >= v1.14 - IDE recommendation: Goland - We recommend you to apply for your own cloud service in QINIU. Replace the public key, private key, warehouse name and default url address with your own, so as not to mess up the test database. ``` From 6c4b217b1b71a7b9381ede080443b4447590ff4a Mon Sep 17 00:00:00 2001 From: SliverHorn <503551462@qq.com> Date: Thu, 15 Oct 2020 11:55:55 +0800 Subject: [PATCH 07/16] repair config env error --- server/config.yaml | 1 - server/config/system.go | 1 - server/core/config.go | 9 ++++----- server/utils/constant.go | 6 ++++++ 4 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 server/utils/constant.go diff --git a/server/config.yaml b/server/config.yaml index 0e478e1e..c7f8fdb6 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -42,7 +42,6 @@ system: addr: 8888 db-type: 'mysql' oss-type: 'local' - config-env: 'GVA_CONFIG' need-init-data: false use-multipoint: false diff --git a/server/config/system.go b/server/config/system.go index 53f52ad0..67e5406f 100644 --- a/server/config/system.go +++ b/server/config/system.go @@ -5,7 +5,6 @@ type System struct { Addr int `mapstructure:"addr" json:"addr" yaml:"addr"` DbType string `mapstructure:"db-type" json:"dbType" yaml:"db-type"` OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"` - ConfigEnv string `mapstructure:"config-env" json:"configEnv" yaml:"config-env"` NeedInitData bool `mapstructure:"need-init-data" json:"needInitData" yaml:"need-init-data"` UseMultipoint bool `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"` } diff --git a/server/core/config.go b/server/core/config.go index e3ac9094..317fce67 100644 --- a/server/core/config.go +++ b/server/core/config.go @@ -5,6 +5,7 @@ import ( "fmt" "gin-vue-admin/global" _ "gin-vue-admin/packfile" + "gin-vue-admin/utils" "github.com/fsnotify/fsnotify" "github.com/spf13/viper" "os" @@ -12,15 +13,13 @@ import ( var config string -const defaultConfigFile = "config.yaml" - func init() { flag.StringVar(&config, "c", "", "choose config file.") flag.Parse() if config == "" { // 优先级: 命令行 > 环境变量 > 默认值 - if configEnv := os.Getenv(global.GVA_CONFIG.System.ConfigEnv); configEnv == "" { - config = defaultConfigFile - fmt.Printf("您正在使用config的默认值,config的路径为%v\n", defaultConfigFile) + if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" { + config = utils.ConfigFile + fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile) } else { config = configEnv fmt.Printf("您正在使用GVA_CONFIG环境变量,config的路径为%v\n", config) diff --git a/server/utils/constant.go b/server/utils/constant.go new file mode 100644 index 00000000..bb50e80c --- /dev/null +++ b/server/utils/constant.go @@ -0,0 +1,6 @@ +package utils + +const ( + ConfigEnv = "GVA_CONFIG" + ConfigFile = "config.yaml" +) From bea9ede941cf6b5a131bf79ad3d626d6e97efbbb Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Thu, 15 Oct 2020 15:20:53 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E4=B8=BA=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E5=A2=9E=E5=8A=A0=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/view/example/rte/rte.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/view/example/rte/rte.vue b/web/src/view/example/rte/rte.vue index 85d101b2..57f9ad29 100644 --- a/web/src/view/example/rte/rte.vue +++ b/web/src/view/example/rte/rte.vue @@ -1,5 +1,6 @@