mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	opt: 取消强制手机号验证,更新配置
This commit is contained in:
		@@ -1,12 +1,18 @@
 | 
			
		||||
Listen = "0.0.0.0:5678"
 | 
			
		||||
ProxyURL = "YOUR_PROXY_URL"
 | 
			
		||||
MysqlDns = "mysql_user:mysql_pass@tcp(localhost:3306)/chatgpt_plus?charset=utf8&parseTime=True&loc=Local"
 | 
			
		||||
ProxyURL = "http://172.22.11.200:7777"
 | 
			
		||||
MysqlDns = "root:mysql_pass@tcp(localhost:3306)/chatgpt_plus?charset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=True&loc=Local"
 | 
			
		||||
StaticDir = "./static"
 | 
			
		||||
StaticUrl = "http://localhost:5678/static"
 | 
			
		||||
AesEncryptKey = "YOUR_AES_KEY"
 | 
			
		||||
FunApiToken = "YOUR_FUN_API_TOKEN"
 | 
			
		||||
StartWechatBot = false
 | 
			
		||||
 | 
			
		||||
[Session]
 | 
			
		||||
  SecretKey = "azyehq3ivunjhbntz78isj00i4hz2mt9xtddysfucxakadq4qbfrt0b7q3lnvg80"
 | 
			
		||||
  Driver = "cookie"
 | 
			
		||||
  SecretKey = "m0cjm3gsuw9jk73np1ni7r42koilybjcndlycjdmq7za3pbqn7w12fyok5pqh6q5"
 | 
			
		||||
  Name = "CHAT_SESSION_ID"
 | 
			
		||||
  Path = "/"
 | 
			
		||||
  Domain = ""
 | 
			
		||||
  Domain = "localhost"
 | 
			
		||||
  MaxAge = 86400
 | 
			
		||||
  Secure = false
 | 
			
		||||
  HttpOnly = false
 | 
			
		||||
@@ -14,4 +20,17 @@ MysqlDns = "mysql_user:mysql_pass@tcp(localhost:3306)/chatgpt_plus?charset=utf8&
 | 
			
		||||
 | 
			
		||||
[Manager]
 | 
			
		||||
  Username = "admin"
 | 
			
		||||
  Password = "admin123"
 | 
			
		||||
  Password = "admin123"
 | 
			
		||||
 | 
			
		||||
[Redis]
 | 
			
		||||
  Host = "localhost"
 | 
			
		||||
  Port = 6379
 | 
			
		||||
  Password = ""
 | 
			
		||||
 | 
			
		||||
[SmsConfig]
 | 
			
		||||
  AccessKey = "YOUR_ACCESS_KEY"
 | 
			
		||||
  AccessSecret = "YOUR_SECRET_KEY"
 | 
			
		||||
  Product = "Dysmsapi"
 | 
			
		||||
  Domain = "dysmsapi.aliyuncs.com"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ func NewDefaultConfig() *types.AppConfig {
 | 
			
		||||
			HttpOnly:  false,
 | 
			
		||||
			SameSite:  http.SameSiteLaxMode,
 | 
			
		||||
		},
 | 
			
		||||
		AlApiToken:     "",
 | 
			
		||||
		FunApiToken:    "",
 | 
			
		||||
		StartWechatBot: false,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,10 +16,11 @@ type AppConfig struct {
 | 
			
		||||
	StaticUrl string      // 静态资源 URL
 | 
			
		||||
	Redis     RedisConfig // redis 连接信息
 | 
			
		||||
 | 
			
		||||
	AesEncryptKey  string
 | 
			
		||||
	SmsConfig      AliYunSmsConfig // 短信发送配置
 | 
			
		||||
	AlApiToken     string          // AL API 服务 token
 | 
			
		||||
	StartWechatBot bool            // 是否启动微信机器人
 | 
			
		||||
	AesEncryptKey     string
 | 
			
		||||
	SmsConfig         AliYunSmsConfig // 短信发送配置
 | 
			
		||||
	FunApiToken       string          // 函数服务 API token
 | 
			
		||||
	StartWechatBot    bool            // 是否启动微信机器人
 | 
			
		||||
	EnabledMsgService bool            // 是否启用短信服务
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type AliYunSmsConfig struct {
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,10 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
 | 
			
		||||
		logger.Error(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	// 设置读写超时时间
 | 
			
		||||
	_ = ws.SetWriteDeadline(time.Now().Add(300 * time.Second))
 | 
			
		||||
	_ = ws.SetReadDeadline(time.Now().Add(300 * time.Second))
 | 
			
		||||
 | 
			
		||||
	sessionId := c.Query("session_id")
 | 
			
		||||
	roleId := h.GetInt(c, "role_id", 0)
 | 
			
		||||
	chatId := c.Query("chat_id")
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,7 @@ type CodeStats struct {
 | 
			
		||||
// Token 生成自验证 token
 | 
			
		||||
func (h *VerifyHandler) Token(c *gin.Context) {
 | 
			
		||||
	// 如果不是通过浏览器访问,则返回错误的 token
 | 
			
		||||
	// TODO: 引入验证码机制防刷机制
 | 
			
		||||
	if c.GetHeader("Sec-Fetch-Mode") != "cors" {
 | 
			
		||||
		token := fmt.Sprintf("%s:%d", utils.RandString(32), time.Now().Unix())
 | 
			
		||||
		encrypt, err := utils.AesEncrypt(h.App.Config.AesEncryptKey, []byte(token))
 | 
			
		||||
@@ -109,7 +110,6 @@ func (h *VerifyHandler) SendMsg(c *gin.Context) {
 | 
			
		||||
	var stat CodeStats
 | 
			
		||||
	err = h.db.Get(MobileStatPrefix+data.Mobile, &stat)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logger.Error(err)
 | 
			
		||||
		stat = CodeStats{
 | 
			
		||||
			Mobile: data.Mobile,
 | 
			
		||||
			Count:  0,
 | 
			
		||||
 
 | 
			
		||||
@@ -114,13 +114,13 @@ func main() {
 | 
			
		||||
 | 
			
		||||
		// 创建函数
 | 
			
		||||
		fx.Provide(func(config *types.AppConfig) (function.FuncZaoBao, error) {
 | 
			
		||||
			return function.NewZaoBao(config.AlApiToken), nil
 | 
			
		||||
			return function.NewZaoBao(config.FunApiToken), nil
 | 
			
		||||
		}),
 | 
			
		||||
		fx.Provide(func(config *types.AppConfig) (function.FuncWeiboHot, error) {
 | 
			
		||||
			return function.NewWeiboHot(config.AlApiToken), nil
 | 
			
		||||
			return function.NewWeiboHot(config.FunApiToken), nil
 | 
			
		||||
		}),
 | 
			
		||||
		fx.Provide(func(config *types.AppConfig) (function.FuncHeadlines, error) {
 | 
			
		||||
			return function.NewHeadLines(config.AlApiToken), nil
 | 
			
		||||
			return function.NewHeadLines(config.FunApiToken), nil
 | 
			
		||||
		}),
 | 
			
		||||
 | 
			
		||||
		// 创建控制器
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,18 @@
 | 
			
		||||
Listen = "0.0.0.0:5678"
 | 
			
		||||
ProxyURL = "http://172.22.11.200:7777"
 | 
			
		||||
MysqlDns = "root:12345678@tcp(172.28.173.76:3307)/chatgpt_plus?charset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=True&loc=Local"
 | 
			
		||||
MysqlDns = "root:mysql_pass@tcp(localhost:3306)/chatgpt_plus?charset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=True&loc=Local"
 | 
			
		||||
StaticDir = "./static"
 | 
			
		||||
StaticUrl = "http://localhost:8080/static"
 | 
			
		||||
StaticUrl = "http://localhost:5678/static"
 | 
			
		||||
AesEncryptKey = "YOUR_AES_KEY"
 | 
			
		||||
FunApiToken = "YOUR_FUN_API_TOKEN"
 | 
			
		||||
StartWechatBot = false
 | 
			
		||||
 | 
			
		||||
[Session]
 | 
			
		||||
  Driver = "cookie"
 | 
			
		||||
  SecretKey = "8k0c67y2or1n7kbmn1w1c86ygqscguoktuf9t524jm64ls585z8uibpdssiy128s"
 | 
			
		||||
  Name = "CHAT_PLUS_SESSION"
 | 
			
		||||
  SecretKey = "m0cjm3gsuw9jk73np1ni7r42koilybjcndlycjdmq7za3pbqn7w12fyok5pqh6q5"
 | 
			
		||||
  Name = "CHAT_SESSION_ID"
 | 
			
		||||
  Path = "/"
 | 
			
		||||
  Domain = ""
 | 
			
		||||
  Domain = "localhost"
 | 
			
		||||
  MaxAge = 86400
 | 
			
		||||
  Secure = false
 | 
			
		||||
  HttpOnly = false
 | 
			
		||||
@@ -23,3 +26,11 @@ StaticUrl = "http://localhost:8080/static"
 | 
			
		||||
  Host = "localhost"
 | 
			
		||||
  Port = 6379
 | 
			
		||||
  Password = ""
 | 
			
		||||
 | 
			
		||||
[SmsConfig]
 | 
			
		||||
  AccessKey = "YOUR_ACCESS_KEY"
 | 
			
		||||
  AccessSecret = "YOUR_SECRET_KEY"
 | 
			
		||||
  Product = "Dysmsapi"
 | 
			
		||||
  Domain = "dysmsapi.aliyuncs.com"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -304,9 +304,6 @@ onMounted(() => {
 | 
			
		||||
  checkSession().then((user) => {
 | 
			
		||||
    loginUser.value = user
 | 
			
		||||
    isLogin.value = true
 | 
			
		||||
    if (user.mobile === '') {
 | 
			
		||||
      showBindMobileDialog.value = true
 | 
			
		||||
    }
 | 
			
		||||
    // 加载角色列表
 | 
			
		||||
    httpGet(`/api/role/list?user_id=${user.id}`).then((res) => {
 | 
			
		||||
      roles.value = res.data;
 | 
			
		||||
 
 | 
			
		||||
@@ -97,9 +97,6 @@ const showBindMobileDialog = ref(false)
 | 
			
		||||
checkSession().then((user) => {
 | 
			
		||||
  loginUser.value = user
 | 
			
		||||
  isLogin.value = true
 | 
			
		||||
  if (user.mobile === '') {
 | 
			
		||||
    showBindMobileDialog.value = true
 | 
			
		||||
  }
 | 
			
		||||
  // 加载角色列表
 | 
			
		||||
  httpGet(`/api/role/list?user_id=${user.id}`).then((res) => {
 | 
			
		||||
    if (res.data) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user