Skip to content

Commit b99fe53

Browse files
author
pixel
committed
初始化流程整体优化,前端报错锁死的情况提供登出操作
1 parent da0d5d2 commit b99fe53

File tree

3 files changed

+87
-120
lines changed

3 files changed

+87
-120
lines changed

server/config.yaml

Lines changed: 77 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,12 @@
1-
# Gin-Vue-Admin Global Configuration
2-
3-
# jwt configuration
4-
jwt:
5-
signing-key: 'qmPlus'
6-
expires-time: 604800
7-
buffer-time: 86400
8-
9-
# zap logger configuration
10-
zap:
11-
level: 'info'
12-
format: 'console'
13-
prefix: '[GIN-VUE-ADMIN]'
14-
director: 'log'
15-
link-name: 'latest_log'
16-
show-line: true
17-
encode-level: 'LowercaseColorLevelEncoder'
18-
stacktrace-key: 'stacktrace'
19-
log-in-console: true
20-
21-
# redis configuration
22-
redis:
23-
db: 0
24-
addr: '127.0.0.1:6379'
25-
password: ''
26-
27-
# email configuration
28-
email:
29-
30-
port: 465
31-
32-
host: 'smtp.163.com'
33-
is-ssl: true
34-
secret: 'xxx'
35-
nickname: 'test'
36-
37-
# casbin configuration
38-
casbin:
39-
model-path: './resource/rbac_model.conf'
40-
41-
# system configuration
42-
system:
43-
env: 'public' # Change to "develop" to skip authentication for development mode
44-
addr: 8888
45-
db-type: 'mysql'
46-
oss-type: 'local' # 控制oss选择走本期还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置
47-
use-multipoint: false
48-
49-
# captcha configuration
50-
captcha:
51-
key-long: 6
52-
img-width: 240
53-
img-height: 80
54-
55-
# mysql connect configuration
56-
# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://www.gin-vue-admin.com/docs/first)
57-
mysql:
58-
path: ''
59-
config: ''
60-
db-name: ''
61-
username: ''
62-
password: ''
63-
max-idle-conns: 10
64-
max-open-conns: 100
65-
log-mode: false
66-
log-zap: ""
67-
68-
# local configuration
69-
local:
70-
path: 'uploads/file'
71-
72-
# autocode configuration
1+
aliyun-oss:
2+
endpoint: yourEndpoint
3+
access-key-id: yourAccessKeyId
4+
access-key-secret: yourAccessKeySecret
5+
bucket-name: yourBucketName
6+
bucket-url: yourBucketUrl
737
autocode:
748
transfer-restart: true
75-
root: ""
9+
root: G:\QMPlus
7610
server: /server
7711
server-api: /api/v1
7812
server-initialize: /initialize
@@ -82,52 +16,80 @@ autocode:
8216
server-service: /service
8317
web: /web/src
8418
web-api: /api
85-
web-flow: /view
8619
web-form: /view
8720
web-table: /view
88-
89-
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址)
21+
web-flow: /view
22+
captcha:
23+
key-long: 6
24+
img-width: 240
25+
img-height: 80
26+
casbin:
27+
model-path: ./resource/rbac_model.conf
28+
email:
29+
30+
port: 465
31+
32+
host: smtp.163.com
33+
is-ssl: true
34+
secret: xxx
35+
nickname: test
36+
excel:
37+
dir: ./resource/excel/
38+
jwt:
39+
signing-key: qmPlus
40+
expires-time: 604800
41+
buffer-time: 86400
42+
local:
43+
path: uploads/file
44+
mysql:
45+
path: 127.0.0.1:3306
46+
config: charset=utf8mb4&parseTime=True&loc=Local
47+
db-name: gva
48+
username: root
49+
password: Aa@6447985
50+
max-idle-conns: 0
51+
max-open-conns: 0
52+
log-mode: false
53+
log-zap: ""
9054
qiniu:
91-
zone: 'ZoneHuaDong'
92-
bucket: ''
93-
img-path: ''
55+
zone: ZoneHuaDong
56+
bucket: ""
57+
img-path: ""
9458
use-https: false
95-
access-key: ''
96-
secret-key: ''
59+
access-key: ""
60+
secret-key: ""
9761
use-cdn-domains: false
98-
99-
100-
# aliyun oss configuration
101-
aliyun-oss:
102-
endpoint: 'yourEndpoint'
103-
access-key-id: 'yourAccessKeyId'
104-
access-key-secret: 'yourAccessKeySecret'
105-
bucket-name: 'yourBucketName'
106-
bucket-url: 'yourBucketUrl'
107-
108-
# tencent cos configuration
62+
redis:
63+
db: 0
64+
addr: 127.0.0.1:6379
65+
password: ""
66+
system:
67+
env: public
68+
addr: 8888
69+
db-type: mysql
70+
oss-type: local
71+
use-multipoint: false
10972
tencent-cos:
110-
bucket: 'xxxxx-10005608'
111-
region: 'ap-shanghai'
112-
secret-id: 'xxxxxxxx'
113-
secret-key: 'xxxxxxxx'
114-
base-url: 'https://gin.vue.admin'
115-
path-prefix: 'gin-vue-admin'
116-
117-
# excel configuration
118-
excel:
119-
dir: './resource/excel/'
120-
121-
122-
# timer task db clear table
123-
Timer:
73+
bucket: xxxxx-10005608
74+
region: ap-shanghai
75+
secret-id: xxxxxxxx
76+
secret-key: xxxxxxxx
77+
base-url: https://gin.vue.admin
78+
path-prefix: gin-vue-admin
79+
timer:
12480
start: true
125-
spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron/v3
126-
detail: [
127-
# tableName: 需要清理的表名
128-
# compareField: 需要比较时间的字段
129-
# interval: 时间间隔, 具体配置详看 time.ParseDuration() 中字符串表示 且不能为负数
130-
# 2160h = 24 * 30 * 3 -> 三个月
131-
{ tableName: "sys_operation_records" , compareField: "created_at", interval: "2160h" },
132-
#{ tableName: "log2" , compareField: "created_at", interval: "2160h" }
133-
]
81+
spec: '@daily'
82+
detail:
83+
- tableName: sys_operation_records
84+
compareField: created_at
85+
interval: 2160h
86+
zap:
87+
level: info
88+
format: console
89+
prefix: '[GIN-VUE-ADMIN]'
90+
director: log
91+
link-name: latest_log
92+
showLine: true
93+
encode-level: LowercaseColorLevelEncoder
94+
stacktrace-key: stacktrace
95+
log-in-console: true

server/service/jwt_black_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ func JsonInBlacklist(jwtList model.JwtBlacklist) (err error) {
2626
//@return: bool
2727

2828
func IsBlacklist(jwt string) bool {
29-
isNotFound := errors.Is(global.GVA_DB.Where("jwt = ?", jwt).First(&model.JwtBlacklist{}).Error, gorm.ErrRecordNotFound)
29+
err := global.GVA_DB.Where("jwt = ?", jwt).First(&model.JwtBlacklist{}).Error
30+
isNotFound := errors.Is(err, gorm.ErrRecordNotFound)
3031
return !isNotFound
3132
}
3233

web/src/utils/request.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import axios from 'axios' // 引入axios
22
import { Message } from 'element-ui'
33
import { store } from '@/store'
44
import context from '@/main'
5+
import { MessageBox } from 'element-ui'
56

67
const service = axios.create({
78
baseURL: process.env.VUE_APP_BASE_API,
@@ -79,11 +80,14 @@ service.interceptors.response.use(
7980
},
8081
error => {
8182
closeLoading()
82-
Message({
83-
showClose: true,
84-
message: error,
85-
type: 'error'
83+
MessageBox.confirm(`检测到接口错误${error},此类错误内容常见于后台panic,如果影响您正常使用可强制登出清理缓存`, '接口报错', {
84+
distinguishCancelAndClose: true,
85+
confirmButtonText: '清理缓存',
86+
cancelButtonText: '取消'
8687
})
88+
.then(() => {
89+
store.commit('user/LoginOut')
90+
})
8791
return error
8892
}
8993
)

0 commit comments

Comments
 (0)