1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-02-28 19:14:13 +08:00

feat: merge ai from dev (#7986)

This commit is contained in:
zhengkunwang 2025-02-25 14:16:10 +08:00 committed by GitHub
parent 90eca45347
commit ec746c021a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 105 additions and 118 deletions

View File

@ -41,4 +41,5 @@ type OllamaBindDomainRes struct {
AllowIPs []string `json:"allowIPs"`
WebsiteID uint `json:"websiteID"`
ConnUrl string `json:"connUrl"`
AcmeAccountID uint `json:"acmeAccountID"`
}

View File

@ -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)

View File

@ -107,5 +107,6 @@ export namespace AI {
allowIPs: string[];
websiteID?: number;
connUrl: string;
acmeAccountID: number;
}
}

View File

@ -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++;

View File

@ -1,9 +1,7 @@
<template>
<DrawerPro v-model="open" :title="$t('aiTools.proxy.proxy')" :back="handleClose" size="large">
<DrawerPro v-model="open" :header="$t('aiTools.proxy.proxy')" :back="handleClose" size="large">
<div v-loading="loading">
<el-form ref="formRef" label-position="top" @submit.prevent :model="req" :rules="rules">
<el-row type="flex" justify="center">
<el-col :span="22">
<el-alert class="common-prompt" :closable="false" type="warning">
<template #default>
<ul>
@ -20,12 +18,7 @@
</span>
<span class="input-help">
{{ $t('aiTools.proxy.proxyHelper6') }}
<el-link
class="pageRoute"
icon="Position"
@click="toWebsite(req.websiteID)"
type="primary"
>
<el-link class="pageRoute" icon="Position" @click="toWebsite(req.websiteID)" type="primary">
{{ $t('firewall.quickJump') }}
</el-link>
</span>
@ -47,16 +40,8 @@
{{ $t('website.enable') + ' ' + 'HTTPS' }}
</el-checkbox>
</el-form-item>
<el-form-item
:label="$t('website.acmeAccountManage')"
prop="acmeAccountID"
v-if="req.enableSSL"
>
<el-select
v-model="req.acmeAccountID"
:placeholder="$t('website.selectAcme')"
@change="listSSL"
>
<el-form-item :label="$t('website.acmeAccountManage')" prop="acmeAccountID" v-if="req.enableSSL">
<el-select v-model="req.acmeAccountID" :placeholder="$t('website.selectAcme')" @change="loadSSL">
<el-option :key="0" :label="$t('website.imported')" :value="0"></el-option>
<el-option
v-for="(acme, index) in acmeAccounts"
@ -91,8 +76,6 @@
{{ $t('firewall.quickJump') }}
</el-link>
</el-alert>
</el-col>
</el-row>
</el-form>
</div>
<template #footer>
@ -134,6 +117,9 @@ const req = ref({
appInstallID: 0,
websiteID: 0,
});
const sslReq = reactive({
acmeAccountID: '',
});
const rules = reactive<FormRules>({
domain: [Rules.domainWithPort],
sslID: [Rules.requiredSelectBusiness],
@ -167,9 +153,7 @@ const changeSSL = () => {
};
const loadSSL = () => {
const sslReq = {
acmeAccountID: String(req.value.acmeAccountID),
};
sslReq.acmeAccountID = String(req.value.acmeAccountID);
listSSL(sslReq).then((res) => {
ssls.value = res.data || [];
if (ssls.value.length > 0) {
@ -193,9 +177,6 @@ const loadSSL = () => {
const listAcmeAccount = () => {
searchAcmeAccount({ page: 1, pageSize: 100 }).then((res) => {
acmeAccounts.value = res.data.items || [];
if (acmeAccounts.value.length > 0) {
req.value.acmeAccountID = acmeAccounts.value[0].id;
}
loadSSL();
});
};
@ -229,6 +210,7 @@ const search = async (appInstallID: number) => {
if (res.data.sslID > 0) {
req.value.enableSSL = true;
req.value.sslID = res.data.sslID;
req.value.acmeAccountID = res.data.acmeAccountID;
listAcmeAccount();
}
}