mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-06 22:55:38 +08:00
feat: Adjust license (#8056)
Some checks failed
SonarCloud Scan / SonarCloud (push) Failing after -12s
Some checks failed
SonarCloud Scan / SonarCloud (push) Failing after -12s
This commit is contained in:
parent
33d4ade1d4
commit
db307732c6
14 changed files with 43 additions and 3 deletions
|
@ -71,6 +71,7 @@ type SettingInfo struct {
|
||||||
ApiKey string `json:"apiKey"`
|
ApiKey string `json:"apiKey"`
|
||||||
IpWhiteList string `json:"ipWhiteList"`
|
IpWhiteList string `json:"ipWhiteList"`
|
||||||
ApiKeyValidityTime string `json:"apiKeyValidityTime"`
|
ApiKeyValidityTime string `json:"apiKeyValidityTime"`
|
||||||
|
LicenseVerify string `json:"licenseVerify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SettingUpdate struct {
|
type SettingUpdate struct {
|
||||||
|
|
|
@ -23,6 +23,7 @@ type System struct {
|
||||||
Language string `mapstructure:"language"`
|
Language string `mapstructure:"language"`
|
||||||
IsDemo bool `mapstructure:"is_demo"`
|
IsDemo bool `mapstructure:"is_demo"`
|
||||||
IsIntl bool `mapstructure:"is_intl"`
|
IsIntl bool `mapstructure:"is_intl"`
|
||||||
|
LicenseVerify string `mapstructure:"license_verify"`
|
||||||
AppRepo string `mapstructure:"app_repo"`
|
AppRepo string `mapstructure:"app_repo"`
|
||||||
ChangeUserInfo string `mapstructure:"change_user_info"`
|
ChangeUserInfo string `mapstructure:"change_user_info"`
|
||||||
OneDriveID string `mapstructure:"one_drive_id"`
|
OneDriveID string `mapstructure:"one_drive_id"`
|
||||||
|
|
|
@ -84,6 +84,15 @@ func Init() {
|
||||||
global.CONF.System.ApiKeyValidityTime = apiKeyValidityTimeSetting.Value
|
global.CONF.System.ApiKeyValidityTime = apiKeyValidityTimeSetting.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if global.CONF.System.LicenseVerify == "" {
|
||||||
|
licenseVerify, err := settingRepo.Get(settingRepo.WithByKey("LicenseVerify"))
|
||||||
|
if err != nil {
|
||||||
|
global.LOG.Errorf("load service license verify from setting failed, err: %v", err)
|
||||||
|
}
|
||||||
|
global.CONF.System.LicenseVerify = licenseVerify.Value
|
||||||
|
}
|
||||||
|
handleLicenseVerify(global.CONF.System.LicenseVerify, settingRepo)
|
||||||
|
|
||||||
handleUserInfo(global.CONF.System.ChangeUserInfo, settingRepo)
|
handleUserInfo(global.CONF.System.ChangeUserInfo, settingRepo)
|
||||||
|
|
||||||
handleCronjobStatus()
|
handleCronjobStatus()
|
||||||
|
@ -207,6 +216,12 @@ func loadLocalDir() {
|
||||||
global.LOG.Errorf("error type dir: %T", varMap["dir"])
|
global.LOG.Errorf("error type dir: %T", varMap["dir"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleLicenseVerify(licenseVerify string, settingRepo repo.ISettingRepo) {
|
||||||
|
if err := settingRepo.Update("LicenseVerify", licenseVerify); err != nil {
|
||||||
|
global.LOG.Fatalf("init license verify before start failed, err: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func handleUserInfo(tags string, settingRepo repo.ISettingRepo) {
|
func handleUserInfo(tags string, settingRepo repo.ISettingRepo) {
|
||||||
if len(tags) == 0 {
|
if len(tags) == 0 {
|
||||||
return
|
return
|
||||||
|
|
|
@ -105,6 +105,7 @@ func Init() {
|
||||||
migrations.AddOllamaModel,
|
migrations.AddOllamaModel,
|
||||||
migrations.AddAppMenu,
|
migrations.AddAppMenu,
|
||||||
migrations.AddAppPanelName,
|
migrations.AddAppPanelName,
|
||||||
|
migrations.AddLicenseVerify,
|
||||||
})
|
})
|
||||||
if err := m.Migrate(); err != nil {
|
if err := m.Migrate(); err != nil {
|
||||||
global.LOG.Error(err)
|
global.LOG.Error(err)
|
||||||
|
|
|
@ -448,3 +448,14 @@ var AddAppPanelName = &gormigrate.Migration{
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var AddLicenseVerify = &gormigrate.Migration{
|
||||||
|
ID: "20250226-add-license-verify",
|
||||||
|
Migrate: func(tx *gorm.DB) error {
|
||||||
|
|
||||||
|
if err := tx.Create(&model.Setting{Key: "LicenseVerify", Value: "LX"}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package viper
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@ func Init() {
|
||||||
global.CONF.System.Entrance = entrance
|
global.CONF.System.Entrance = entrance
|
||||||
global.CONF.System.Language = language
|
global.CONF.System.Language = language
|
||||||
global.CONF.System.ChangeUserInfo = loadChangeInfo()
|
global.CONF.System.ChangeUserInfo = loadChangeInfo()
|
||||||
|
global.CONF.System.LicenseVerify = os.Getenv("LXWARE_LICENSE_VERIFY")
|
||||||
global.Viper = v
|
global.Viper = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ func Start() {
|
||||||
session.Init()
|
session.Init()
|
||||||
gin.SetMode(gin.DebugMode)
|
gin.SetMode(gin.DebugMode)
|
||||||
cron.Run()
|
cron.Run()
|
||||||
|
hook.Init()
|
||||||
InitOthers()
|
InitOthers()
|
||||||
business.Init()
|
business.Init()
|
||||||
hook.Init()
|
|
||||||
|
|
||||||
rootRouter := router.Routers()
|
rootRouter := router.Routers()
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ export namespace Setting {
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
ipWhiteList: string;
|
ipWhiteList: string;
|
||||||
apiKeyValidityTime: number;
|
apiKeyValidityTime: number;
|
||||||
|
licenseVerify: string;
|
||||||
}
|
}
|
||||||
export interface SettingUpdate {
|
export interface SettingUpdate {
|
||||||
key: string;
|
key: string;
|
||||||
|
|
|
@ -37,6 +37,7 @@ export interface GlobalState {
|
||||||
isIntl: boolean;
|
isIntl: boolean;
|
||||||
isTrial: boolean;
|
isTrial: boolean;
|
||||||
productProExpires: number;
|
productProExpires: number;
|
||||||
|
licenseVerify: string;
|
||||||
|
|
||||||
errStatus: string;
|
errStatus: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ const GlobalStore = defineStore({
|
||||||
isIntl: false,
|
isIntl: false,
|
||||||
isTrial: false,
|
isTrial: false,
|
||||||
productProExpires: 0,
|
productProExpires: 0,
|
||||||
|
licenseVerify: '',
|
||||||
|
|
||||||
errStatus: '',
|
errStatus: '',
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -412,6 +412,7 @@ const loadDataFromDB = async () => {
|
||||||
i18n.locale.value = res.data.language;
|
i18n.locale.value = res.data.language;
|
||||||
i18n.warnHtmlMessage = false;
|
i18n.warnHtmlMessage = false;
|
||||||
globalStore.entrance = res.data.securityEntrance;
|
globalStore.entrance = res.data.securityEntrance;
|
||||||
|
globalStore.licenseVerify = res.data.licenseVerify;
|
||||||
globalStore.setDefaultNetwork(res.data.defaultNetwork);
|
globalStore.setDefaultNetwork(res.data.defaultNetwork);
|
||||||
globalStore.setOpenMenuTabs(res.data.menuTabs === 'enable');
|
globalStore.setOpenMenuTabs(res.data.menuTabs === 'enable');
|
||||||
globalStore.updateLanguage(res.data.language);
|
globalStore.updateLanguage(res.data.language);
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<el-col :xs="24" :sm="24" :md="9" :lg="9" :xl="9">
|
<el-col :xs="24" :sm="24" :md="9" :lg="9" :xl="9">
|
||||||
<CardWithHeader :header="$t('license.quickUpdate')" height="160px">
|
<CardWithHeader :header="$t('license.quickUpdate')" height="160px">
|
||||||
<template #body>
|
<template #body>
|
||||||
<div class="h-app-card">
|
<div class="h-app-card" v-if="globalStore.licenseVerify != 'TC' || !hasLicense">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="15">
|
<el-col :span="15">
|
||||||
<div class="h-app-content">{{ $t('license.importLicense') }}</div>
|
<div class="h-app-content">{{ $t('license.importLicense') }}</div>
|
||||||
|
|
3
go.mod
3
go.mod
|
@ -218,7 +218,8 @@ require (
|
||||||
github.com/spf13/cast v1.6.0 // indirect
|
github.com/spf13/cast v1.6.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/stretchr/testify v1.10.0 // indirect
|
github.com/stretchr/testify v1.10.0 // indirect
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1065 // indirect
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudapp v1.0.1105 // indirect
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1105 // indirect
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1065 // indirect
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1065 // indirect
|
||||||
github.com/therootcompany/xz v1.0.1 // indirect
|
github.com/therootcompany/xz v1.0.1 // indirect
|
||||||
github.com/theupdateframework/notary v0.7.0 // indirect
|
github.com/theupdateframework/notary v0.7.0 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -960,9 +960,13 @@ github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+z
|
||||||
github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo=
|
github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo=
|
||||||
github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg=
|
github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg=
|
||||||
github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk=
|
github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudapp v1.0.1105 h1:ikgsQkFcKDzOJFbxIcSCdu7oj8GQBfwJohBpYHWeSco=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudapp v1.0.1105/go.mod h1:/GMcTQRH1+iDTX8RSl+G79doAWcabhpt+xmv3V9P3p0=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1065 h1:krcqtAmexnHHBm/4ge4tr2b1cn/a7JGBESVGoZYXQAE=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1065 h1:krcqtAmexnHHBm/4ge4tr2b1cn/a7JGBESVGoZYXQAE=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1065/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1065/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1105 h1:lCs0dmezU6/8JcfNwEaam1Pm1RS/5MhXvNhf/X2y65s=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1105/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1065 h1:aEFtLD1ceyeljQXB1S2BjN0zjTkf0X3XmpuxFIiC29w=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1065 h1:aEFtLD1ceyeljQXB1S2BjN0zjTkf0X3XmpuxFIiC29w=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1065/go.mod h1:HWvwy09hFSMXrj9SMvVRWV4U7rZO3l+WuogyNuxiT3M=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1065/go.mod h1:HWvwy09hFSMXrj9SMvVRWV4U7rZO3l+WuogyNuxiT3M=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
||||||
|
|
Loading…
Add table
Reference in a new issue