From ec746c021a82a902cab32b80bbafa49d5584f592 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:16:10 +0800 Subject: [PATCH] feat: merge ai from dev (#7986) --- agent/app/dto/ai.go | 11 +- agent/app/service/ai.go | 24 +-- frontend/src/api/interface/ai.ts | 1 + frontend/src/components/app-status/index.vue | 11 +- frontend/src/views/ai/model/domain/index.vue | 176 +++++++++---------- 5 files changed, 105 insertions(+), 118 deletions(-) diff --git a/agent/app/dto/ai.go b/agent/app/dto/ai.go index 6c2065cae..193af5eeb 100644 --- a/agent/app/dto/ai.go +++ b/agent/app/dto/ai.go @@ -36,9 +36,10 @@ type OllamaBindDomainReq struct { } type OllamaBindDomainRes struct { - Domain string `json:"domain"` - SSLID uint `json:"sslID"` - AllowIPs []string `json:"allowIPs"` - WebsiteID uint `json:"websiteID"` - ConnUrl string `json:"connUrl"` + Domain string `json:"domain"` + SSLID uint `json:"sslID"` + AllowIPs []string `json:"allowIPs"` + WebsiteID uint `json:"websiteID"` + ConnUrl string `json:"connUrl"` + AcmeAccountID uint `json:"acmeAccountID"` } diff --git a/agent/app/service/ai.go b/agent/app/service/ai.go index f00b1d151..9bc576334 100644 --- a/agent/app/service/ai.go +++ b/agent/app/service/ai.go @@ -61,7 +61,7 @@ func (u *AIToolService) Search(req dto.SearchWithPage) (int64, []dto.OllamaModel } dtoLists = append(dtoLists, item) } - return int64(total), dtoLists, err + return total, dtoLists, err } func (u *AIToolService) LoadDetail(name string) (string, error) { @@ -244,14 +244,18 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error { } } createWebsiteReq := request.WebsiteCreate{ - Domains: []request.WebsiteDomain{{Domain: req.Domain}}, + Domains: []request.WebsiteDomain{{Domain: req.Domain, Port: 80}}, Alias: strings.ToLower(req.Domain), Type: constant.Deployment, AppType: constant.InstalledApp, AppInstallID: req.AppInstallID, } + if req.SSLID > 0 { + createWebsiteReq.WebsiteSSLID = req.SSLID + createWebsiteReq.EnableSSL = true + } websiteService := NewIWebsiteService() - if err := websiteService.CreateWebsite(createWebsiteReq); err != nil { + if err = websiteService.CreateWebsite(createWebsiteReq); err != nil { return err } website, err := websiteRepo.GetFirst(websiteRepo.WithAlias(strings.ToLower(req.Domain))) @@ -263,18 +267,6 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error { return err } } - if req.SSLID > 0 { - sslReq := request.WebsiteHTTPSOp{ - WebsiteID: website.ID, - Enable: true, - Type: "existed", - WebsiteSSLID: req.SSLID, - HttpConfig: "HTTPSOnly", - } - if _, err = websiteService.OpWebsiteHTTPS(context.Background(), sslReq); err != nil { - return err - } - } if err = ConfigAIProxy(website); err != nil { return err } @@ -295,6 +287,8 @@ func (u *AIToolService) GetBindDomain(req dto.OllamaBindDomainReq) (*dto.OllamaB res.Domain = website.PrimaryDomain if website.WebsiteSSLID > 0 { res.SSLID = website.WebsiteSSLID + ssl, _ := websiteSSLRepo.GetFirst(repo.WithByID(website.WebsiteSSLID)) + res.AcmeAccountID = ssl.AcmeAccountID } res.ConnUrl = fmt.Sprintf("%s://%s", strings.ToLower(website.Protocol), website.PrimaryDomain) res.AllowIPs = GetAllowIps(website) diff --git a/frontend/src/api/interface/ai.ts b/frontend/src/api/interface/ai.ts index a120bea66..c1ebbdb4e 100644 --- a/frontend/src/api/interface/ai.ts +++ b/frontend/src/api/interface/ai.ts @@ -107,5 +107,6 @@ export namespace AI { allowIPs: string[]; websiteID?: number; connUrl: string; + acmeAccountID: number; } } diff --git a/frontend/src/components/app-status/index.vue b/frontend/src/components/app-status/index.vue index b563982ba..6cf8032db 100644 --- a/frontend/src/components/app-status/index.vue +++ b/frontend/src/components/app-status/index.vue @@ -116,7 +116,15 @@ let refresh = ref(1); const httpPort = ref(0); const httpsPort = ref(0); -const em = defineEmits(['setting', 'isExist', 'before', 'after', 'update:loading', 'update:maskShow']); +const em = defineEmits([ + 'setting', + 'isExist', + 'before', + 'after', + 'update:loading', + 'update:maskShow', + 'update:appInstallID', +]); const setting = () => { em('setting', false); }; @@ -128,6 +136,7 @@ const onCheck = async (key: any, name: any) => { em('isExist', res.data); em('update:maskShow', res.data.status !== 'Running'); operateReq.installId = res.data.appInstallId; + em('update:appInstallID', res.data.appInstallId); httpPort.value = res.data.httpPort; httpsPort.value = res.data.httpsPort; refresh.value++; diff --git a/frontend/src/views/ai/model/domain/index.vue b/frontend/src/views/ai/model/domain/index.vue index 6e0f76c33..d0525f4a6 100644 --- a/frontend/src/views/ai/model/domain/index.vue +++ b/frontend/src/views/ai/model/domain/index.vue @@ -1,98 +1,81 @@