diff --git a/api/core/app_server.go b/api/core/app_server.go index ed11ab0c..8ba434fa 100644 --- a/api/core/app_server.go +++ b/api/core/app_server.go @@ -227,7 +227,6 @@ func needLogin(c *gin.Context) bool { c.Request.URL.Path == "/api/sd/client" || c.Request.URL.Path == "/api/dall/imgWall" || c.Request.URL.Path == "/api/dall/client" || - c.Request.URL.Path == "/api/config/get" || c.Request.URL.Path == "/api/product/list" || c.Request.URL.Path == "/api/menu/list" || c.Request.URL.Path == "/api/markMap/client" || @@ -237,6 +236,7 @@ func needLogin(c *gin.Context) bool { c.Request.URL.Path == "/api/payment/doPay" || c.Request.URL.Path == "/api/payment/payWays" || strings.HasPrefix(c.Request.URL.Path, "/api/test") || + strings.HasPrefix(c.Request.URL.Path, "/api/config/") || strings.HasPrefix(c.Request.URL.Path, "/api/function/") || strings.HasPrefix(c.Request.URL.Path, "/api/sms/") || strings.HasPrefix(c.Request.URL.Path, "/api/captcha/") || diff --git a/api/core/types/config.go b/api/core/types/config.go index 8536cd51..c9881999 100644 --- a/api/core/types/config.go +++ b/api/core/types/config.go @@ -126,11 +126,16 @@ type RedisConfig struct { const LicenseKey = "Geek-AI-License" type License struct { - Key string `json:"key"` // 许可证书密钥 - MachineId string `json:"machine_id"` // 机器码 - UserNum int `json:"user_num"` // 用户数量 - ExpiredAt int64 `json:"expired_at"` // 过期时间 - IsActive bool `json:"is_active"` // 是否激活 + Key string `json:"key"` // 许可证书密钥 + MachineId string `json:"machine_id"` // 机器码 + ExpiredAt int64 `json:"expired_at"` // 过期时间 + IsActive bool `json:"is_active"` // 是否激活 + Configs LicenseConfig `json:"configs"` +} + +type LicenseConfig struct { + UserNum int `json:"user_num"` // 用户数量 + DeCopy bool `json:"de_copy"` // 去版权 } func (c RedisConfig) Url() string { @@ -207,4 +212,6 @@ type SystemConfig struct { ContextDeep int `json:"context_deep,omitempty"` SdNegPrompt string `json:"sd_neg_prompt"` // SD 默认反向提示词 + + RandBg bool `json:"rand_bg"` // 前端首页是否启用随机背景 } diff --git a/api/handler/admin/user_handler.go b/api/handler/admin/user_handler.go index bd9b926b..95da105f 100644 --- a/api/handler/admin/user_handler.go +++ b/api/handler/admin/user_handler.go @@ -87,7 +87,7 @@ func (h *UserHandler) Save(c *gin.Context) { // 检测最大注册人数 var totalUser int64 h.DB.Model(&model.User{}).Count(&totalUser) - if h.licenseService.GetLicense().UserNum > 0 && int(totalUser) >= h.licenseService.GetLicense().UserNum { + if h.licenseService.GetLicense().Configs.UserNum > 0 && int(totalUser) >= h.licenseService.GetLicense().Configs.UserNum { resp.ERROR(c, "当前注册用户数已达上限,请请升级 License") return } diff --git a/api/handler/config_handler.go b/api/handler/config_handler.go index 0b8fdb03..30e33b8a 100644 --- a/api/handler/config_handler.go +++ b/api/handler/config_handler.go @@ -9,6 +9,7 @@ package handler import ( "geekai/core" + "geekai/service" "geekai/store/model" "geekai/utils" "geekai/utils/resp" @@ -19,10 +20,11 @@ import ( type ConfigHandler struct { BaseHandler + licenseService *service.LicenseService } -func NewConfigHandler(app *core.AppServer, db *gorm.DB) *ConfigHandler { - return &ConfigHandler{BaseHandler: BaseHandler{App: app, DB: db}} +func NewConfigHandler(app *core.AppServer, db *gorm.DB, licenseService *service.LicenseService) *ConfigHandler { + return &ConfigHandler{BaseHandler: BaseHandler{App: app, DB: db}, licenseService: licenseService} } // Get 获取指定的系统配置 @@ -44,3 +46,9 @@ func (h *ConfigHandler) Get(c *gin.Context) { resp.SUCCESS(c, value) } + +// License 获取 License 配置 +func (h *ConfigHandler) License(c *gin.Context) { + license := h.licenseService.GetLicense() + resp.SUCCESS(c, license.Configs) +} diff --git a/api/handler/user_handler.go b/api/handler/user_handler.go index 263a7139..2718d15e 100644 --- a/api/handler/user_handler.go +++ b/api/handler/user_handler.go @@ -71,7 +71,7 @@ func (h *UserHandler) Register(c *gin.Context) { // 检测最大注册人数 var totalUser int64 h.DB.Model(&model.User{}).Count(&totalUser) - if h.licenseService.GetLicense().UserNum > 0 && int(totalUser) >= h.licenseService.GetLicense().UserNum { + if h.licenseService.GetLicense().Configs.UserNum > 0 && int(totalUser) >= h.licenseService.GetLicense().Configs.UserNum { resp.ERROR(c, "当前注册用户数已达上限,请请升级 License") return } diff --git a/api/main.go b/api/main.go index 9b4458cf..8b585ee6 100644 --- a/api/main.go +++ b/api/main.go @@ -295,6 +295,7 @@ func main() { fx.Invoke(func(s *core.AppServer, h *handler.ConfigHandler) { group := s.Engine.Group("/api/config/") group.GET("get", h.Get) + group.GET("license", h.License) }), // 管理后台控制器 diff --git a/api/service/license_service.go b/api/service/license_service.go index 94e08c0b..4df6f6db 100644 --- a/api/service/license_service.go +++ b/api/service/license_service.go @@ -46,12 +46,13 @@ func NewLicenseService(server *core.AppServer, levelDB *store.LevelDB) *LicenseS } type License struct { - Name string `json:"name"` - License string `json:"license"` - MachineId string `json:"mid"` - ActiveAt int64 `json:"active_at"` - ExpiredAt int64 `json:"expired_at"` - UserNum int `json:"user_num"` + Name string `json:"name"` + License string `json:"license"` + MachineId string `json:"mid"` + ActiveAt int64 `json:"active_at"` + ExpiredAt int64 `json:"expired_at"` + UserNum int `json:"user_num"` + Configs types.LicenseConfig `json:"configs"` } // ActiveLicense 激活 License @@ -80,7 +81,7 @@ func (s *LicenseService) ActiveLicense(license string, machineId string) error { s.license = &types.License{ Key: license, MachineId: machineId, - UserNum: res.Data.UserNum, + Configs: res.Data.Configs, ExpiredAt: res.Data.ExpiredAt, IsActive: true, } @@ -140,7 +141,7 @@ func (s *LicenseService) fetchLicense() (*types.License, error) { return &types.License{ Key: res.Data.License, MachineId: res.Data.MachineId, - UserNum: res.Data.UserNum, + Configs: res.Data.Configs, ExpiredAt: res.Data.ExpiredAt, IsActive: true, }, nil diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index 43cf21f4..87043d42 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -11,8 +11,8 @@
- @@ -77,73 +79,31 @@ if (isMobile()) { const title = ref("Geek-AI 创作系统") const logo = ref("/images/logo.png") const slogan = ref("我辈之人,先干为敬,陪您先把 AI 用起来") +const licenseConfig = ref({}) // const size = Math.max(window.innerWidth * 0.5, window.innerHeight * 0.8) const winHeight = window.innerHeight - 150 +const bgClass = ref('fixed-bg') onMounted(() => { httpGet("/api/config/get?key=system").then(res => { title.value = res.data.title logo.value = res.data.logo + if (res.data.rand_bg) { + bgClass.value = "rand-bg" + } }).catch(e => { ElMessage.error("获取系统配置失败:" + e.message) }) + + httpGet("/api/config/license").then(res => { + licenseConfig.value = res.data + }).catch(e => { + ElMessage.error("获取 License 配置:" + e.message) + }) init() }) const init = () => { - // // 创建场景 - // // 创建场景 - // const scene = new THREE.Scene(); - // - // // 创建相机 - // const camera = new THREE.PerspectiveCamera(30, 1, 0.1, 1000); - // camera.position.z = 3.88; - // - // // 创建渲染器 - // const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); - // renderer.setSize(size, size); - // renderer.setClearColor(0x000000, 0); - // const container = document.getElementById('animation-container'); - // container.appendChild(renderer.domElement); - // - // // 加载地球纹理 - // const loader = new THREE.TextureLoader(); - // loader.load( - // '/images/land_ocean_ice_cloud_2048.jpg', - // function (texture) { - // // 创建地球球体 - // const geometry = new THREE.SphereGeometry(1, 32, 32); - // const material = new THREE.MeshPhongMaterial({ - // map: texture, - // bumpMap: texture, // 使用同一张纹理作为凹凸贴图 - // bumpScale: 0.05, // 调整凹凸贴图的影响程度 - // specularMap: texture, // 高光贴图 - // specular: new THREE.Color('#01193B'), // 高光颜色 - // }); - // const earth = new THREE.Mesh(geometry, material); - // scene.add(earth); - // - // // 添加环境光和点光源 - // const ambientLight = new THREE.AmbientLight(0xffffff, 0.3); - // scene.add(ambientLight); - // const pointLight = new THREE.PointLight(0xffffff, 0.8); - // pointLight.position.set(5, 5, 5); - // scene.add(pointLight); - // - // // 创建动画 - // const animate = function () { - // requestAnimationFrame(animate); - // - // // 使地球自转和公转 - // earth.rotation.y += 0.0006; - // - // renderer.render(scene, camera); - // }; - // - // // 执行动画 - // animate(); - // } - // ); } @@ -158,14 +118,25 @@ const init = () => { align-items baseline padding-top 150px - .bg { + .fixed-bg { position absolute top 0 left 0 width 100vw height 100vh background-image url("~@/assets/img/ai-bg.jpg") - //filter: blur(8px); + background-size: cover; + background-position: center; + } + + .rand-bg { + position absolute + top 0 + left 0 + width 100vw + height 100vh + background-image url("https://api.dujin.org/bing/1920.php") + filter: blur(8px); background-size: cover; background-position: center; } diff --git a/web/src/views/Login.vue b/web/src/views/Login.vue index 21040b19..bb71ed43 100644 --- a/web/src/views/Login.vue +++ b/web/src/views/Login.vue @@ -48,7 +48,7 @@