mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-28 10:21:39 +08:00
配置示例文件
This commit is contained in:
2
admin/.env.development
Normal file
2
admin/.env.development
Normal file
@@ -0,0 +1,2 @@
|
||||
# 请求域名
|
||||
VITE_APP_BASE_URL='http://127.0.0.1:8080'
|
||||
2
admin/.gitignore
vendored
2
admin/.gitignore
vendored
@@ -32,6 +32,6 @@ components.d.ts
|
||||
*.sw?
|
||||
|
||||
# .env
|
||||
.env.development
|
||||
# .env.development
|
||||
.env.production
|
||||
test.html
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# 可配置项参考:config\config.go
|
||||
# 具体配置项参考:config\config.go的config结构体
|
||||
|
||||
# APP.GIN_MODE='debug'
|
||||
|
||||
#GIN_MODE='release'
|
||||
# 项目端口
|
||||
SERVER_PORT=8001
|
||||
APP.PORT=8001
|
||||
|
||||
# 数据库
|
||||
DATABASE_URL='root:root@tcp(localhost:3306)/x_admin?charset=utf8mb4&parseTime=True&loc=Local'
|
||||
DB.DSN='root:root@tcp(localhost:3306)/x_admin?charset=utf8mb4&parseTime=True&loc=Local'
|
||||
|
||||
#Redis
|
||||
REDIS_URL='redis://:passwd@localhost:6379'
|
||||
REDIS.URL='redis://localhost:6379'
|
||||
|
||||
# 上传文件目录
|
||||
UPLOAD_DIRECTORY='/www/wwwroot/x_admin_go/public/uploads/'
|
||||
FILE.UPLOAD_DIRECTORY='/www/wwwroot/x_admin_go/public/uploads/'
|
||||
|
||||
20
server/.env.yaml.example
Normal file
20
server/.env.yaml.example
Normal file
@@ -0,0 +1,20 @@
|
||||
# 具体配置项参考:config\config.go的config结构体
|
||||
|
||||
# APP:
|
||||
# GIN_MODE: 'debug'
|
||||
|
||||
# 项目端口
|
||||
APP:
|
||||
PORT: 8080
|
||||
|
||||
# 数据库
|
||||
DB:
|
||||
DSN: 'root:root@tcp(localhost:3306)/x_admin?charset=utf8mb4&parseTime=True&loc=Local'
|
||||
|
||||
#Redis
|
||||
REDIS:
|
||||
URL: 'redis://localhost:6379'
|
||||
|
||||
# 上传文件目录
|
||||
FILE:
|
||||
UPLOAD_DIRECTORY: '/www/wwwroot/x_admin_go/public/uploads/'
|
||||
@@ -29,6 +29,7 @@ func loadConfig(config config) config {
|
||||
if envFilePath == "" {
|
||||
envFilePath = ".env"
|
||||
}
|
||||
viper.SetConfigType("yaml")
|
||||
viper.AddConfigPath(".")
|
||||
viper.SetConfigFile(envFilePath)
|
||||
viper.AutomaticEnv()
|
||||
@@ -45,32 +46,8 @@ func loadConfig(config config) config {
|
||||
}
|
||||
|
||||
func init() {
|
||||
// fmt.Println(Config)
|
||||
fmt.Println("AppConfig:", AppConfig)
|
||||
fmt.Println("DBConfig:", DBConfig)
|
||||
fmt.Println("RedisConfig:", RedisConfig)
|
||||
fmt.Println("FileConfig:", FileConfig)
|
||||
}
|
||||
|
||||
// loadConfig 加载配置
|
||||
// func loadConfig(envPath string) envConfig {
|
||||
// var cfgPath string
|
||||
// flag.StringVar(&cfgPath, "c", "", "config file envPath.")
|
||||
// flag.Parse()
|
||||
// if cfgPath == "" {
|
||||
// viper.AddConfigPath(envPath)
|
||||
// viper.SetConfigFile(".env")
|
||||
// } else {
|
||||
// viper.SetConfigFile(cfgPath)
|
||||
// }
|
||||
// viper.AutomaticEnv()
|
||||
// err := viper.ReadInConfig()
|
||||
// if err != nil {
|
||||
// log.Fatal("loadConfig ReadInConfig err:", err)
|
||||
// }
|
||||
// err = viper.Unmarshal(&config)
|
||||
// if err != nil {
|
||||
// log.Fatal("loadConfig Unmarshal err:", err)
|
||||
// }
|
||||
// return config
|
||||
// }
|
||||
|
||||
@@ -16,7 +16,7 @@ type dbConfig struct {
|
||||
|
||||
var DBConfig = dbConfig{
|
||||
Type: "mysql",
|
||||
Dsn: "root:123456@tcp(127.0.0.1:3306)/x_admin?charset=utf8mb4&parseTime=True&loc=Local",
|
||||
Dsn: "", //root:123456@tcp(127.0.0.1:3306)/x_admin?charset=utf8mb4&parseTime=True&loc=Local
|
||||
MaxOpenConns: 100,
|
||||
MaxIdleConns: 10,
|
||||
ConnMaxLifetimeSeconds: 60 * 60 * 24,
|
||||
|
||||
Reference in New Issue
Block a user