mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-15 10:14:44 +08:00
feat: 网站主域名支持域名:端口 (#2410)
Refs https://github.com/1Panel-dev/1Panel/issues/2333
This commit is contained in:
parent
aa588205e9
commit
2624238354
@ -185,10 +185,12 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defaultHttpPort := nginxInstall.HttpPort
|
defaultHttpPort := nginxInstall.HttpPort
|
||||||
|
primaryDomainArray := strings.Split(create.PrimaryDomain, ":")
|
||||||
|
primaryDomain := primaryDomainArray[0]
|
||||||
|
|
||||||
defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
|
defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
|
||||||
website := &model.Website{
|
website := &model.Website{
|
||||||
PrimaryDomain: create.PrimaryDomain,
|
PrimaryDomain: primaryDomain,
|
||||||
Type: create.Type,
|
Type: create.Type,
|
||||||
Alias: create.Alias,
|
Alias: create.Alias,
|
||||||
Remark: create.Remark,
|
Remark: create.Remark,
|
||||||
@ -264,7 +266,6 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
|||||||
if runtime.Resource == constant.ResourceAppstore {
|
if runtime.Resource == constant.ResourceAppstore {
|
||||||
var (
|
var (
|
||||||
req request.AppInstallCreate
|
req request.AppInstallCreate
|
||||||
nginxInstall model.AppInstall
|
|
||||||
install *model.AppInstall
|
install *model.AppInstall
|
||||||
)
|
)
|
||||||
reg, _ := regexp.Compile(`[^a-z0-9_-]+`)
|
reg, _ := regexp.Compile(`[^a-z0-9_-]+`)
|
||||||
@ -273,10 +274,6 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
|||||||
req.Params = create.AppInstall.Params
|
req.Params = create.AppInstall.Params
|
||||||
req.Params["IMAGE_NAME"] = runtime.Image
|
req.Params["IMAGE_NAME"] = runtime.Image
|
||||||
req.AppContainerConfig = create.AppInstall.AppContainerConfig
|
req.AppContainerConfig = create.AppInstall.AppContainerConfig
|
||||||
nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
req.Params["PANEL_WEBSITE_DIR"] = path.Join(nginxInstall.GetPath(), "/www")
|
req.Params["PANEL_WEBSITE_DIR"] = path.Join(nginxInstall.GetPath(), "/www")
|
||||||
tx, installCtx := getTxAndContext()
|
tx, installCtx := getTxAndContext()
|
||||||
install, err = NewIAppService().Install(installCtx, req)
|
install, err = NewIAppService().Install(installCtx, req)
|
||||||
@ -301,9 +298,9 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
var domains []model.WebsiteDomain
|
var domains []model.WebsiteDomain
|
||||||
domains = append(domains, model.WebsiteDomain{Domain: website.PrimaryDomain, Port: defaultHttpPort})
|
domainArray := strings.Split(create.OtherDomains, "\n")
|
||||||
otherDomainArray := strings.Split(create.OtherDomains, "\n")
|
domainArray = append(domainArray, create.PrimaryDomain)
|
||||||
for _, domain := range otherDomainArray {
|
for _, domain := range domainArray {
|
||||||
if domain == "" {
|
if domain == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,20 @@ const checkDomain = (rule: any, value: any, callback: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkDomainWithPort = (rule: any, value: any, callback: any) => {
|
||||||
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.domain')));
|
||||||
|
} else {
|
||||||
|
const reg =
|
||||||
|
/^([\w\u4e00-\u9fa5\-\*]{1,100}\.){1,10}([\w\u4e00-\u9fa5\-]{1,24}|[\w\u4e00-\u9fa5\-]{1,24}\.[\w\u4e00-\u9fa5\-]{1,24})(:\d{1,5})?$/;
|
||||||
|
if (!reg.test(value) && value !== '') {
|
||||||
|
callback(new Error(i18n.global.t('commons.rule.domain')));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const checkIntegerNumber = (rule: any, value: any, callback: any) => {
|
const checkIntegerNumber = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||||
callback(new Error(i18n.global.t('commons.rule.integer')));
|
callback(new Error(i18n.global.t('commons.rule.integer')));
|
||||||
@ -442,6 +456,7 @@ interface CommonRule {
|
|||||||
containerName: FormItemRule;
|
containerName: FormItemRule;
|
||||||
disabledFunctions: FormItemRule;
|
disabledFunctions: FormItemRule;
|
||||||
leechExts: FormItemRule;
|
leechExts: FormItemRule;
|
||||||
|
domainWithPort: FormItemRule;
|
||||||
|
|
||||||
paramCommon: FormItemRule;
|
paramCommon: FormItemRule;
|
||||||
paramComplexity: FormItemRule;
|
paramComplexity: FormItemRule;
|
||||||
@ -626,4 +641,9 @@ export const Rules: CommonRule = {
|
|||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
validator: checkParamSimple,
|
validator: checkParamSimple,
|
||||||
},
|
},
|
||||||
|
domainWithPort: {
|
||||||
|
required: true,
|
||||||
|
validator: checkDomainWithPort,
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -1542,6 +1542,7 @@ const message = {
|
|||||||
runDirHelper2: 'Please ensure that the secondary running directory is under the index directory',
|
runDirHelper2: 'Please ensure that the secondary running directory is under the index directory',
|
||||||
openrestryHelper:
|
openrestryHelper:
|
||||||
'OpenResty default HTTP port: {0} HTTPS port: {1}, which may affect website domain name access and HTTPS forced redirect',
|
'OpenResty default HTTP port: {0} HTTPS port: {1}, which may affect website domain name access and HTTPS forced redirect',
|
||||||
|
primaryDomainHelper: 'Support domain name: port',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: 'Short tag support',
|
short_open_tag: 'Short tag support',
|
||||||
|
@ -1465,6 +1465,7 @@ const message = {
|
|||||||
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
|
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
|
||||||
runDirHelper2: '請確保二級運行目錄位於 index 目錄下',
|
runDirHelper2: '請確保二級運行目錄位於 index 目錄下',
|
||||||
openrestryHelper: 'OpenResty 默認 HTTP 端口:{0} HTTPS 端口:{1},可能影響網站域名訪問和 HTTPS 強制跳轉',
|
openrestryHelper: 'OpenResty 默認 HTTP 端口:{0} HTTPS 端口:{1},可能影響網站域名訪問和 HTTPS 強制跳轉',
|
||||||
|
primaryDomainHelper: '支援網域:port',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: '短標簽支持',
|
short_open_tag: '短標簽支持',
|
||||||
|
@ -1465,6 +1465,7 @@ const message = {
|
|||||||
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
|
retainConfig: '是否保留 php-fpm.conf 和 php.ini 文件',
|
||||||
runDirHelper2: '请确保二级运行目录位于 index 目录下',
|
runDirHelper2: '请确保二级运行目录位于 index 目录下',
|
||||||
openrestryHelper: 'OpenResty 默认 HTTP 端口:{0} HTTPS 端口 :{1},可能影响网站域名访问和 HTTPS 强制跳转',
|
openrestryHelper: 'OpenResty 默认 HTTP 端口:{0} HTTPS 端口 :{1},可能影响网站域名访问和 HTTPS 强制跳转',
|
||||||
|
primaryDomainHelper: '支持域名:端口',
|
||||||
},
|
},
|
||||||
php: {
|
php: {
|
||||||
short_open_tag: '短标签支持',
|
short_open_tag: '短标签支持',
|
||||||
|
@ -246,6 +246,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model.trim="website.primaryDomain"
|
v-model.trim="website.primaryDomain"
|
||||||
@input="changeAlias(website.primaryDomain)"
|
@input="changeAlias(website.primaryDomain)"
|
||||||
|
:placeholder="$t('website.primaryDomainHelper')"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('website.otherDomains')" prop="otherDomains">
|
<el-form-item :label="$t('website.otherDomains')" prop="otherDomains">
|
||||||
@ -364,7 +365,7 @@ const website = ref({
|
|||||||
proxyAddress: '',
|
proxyAddress: '',
|
||||||
});
|
});
|
||||||
const rules = ref<any>({
|
const rules = ref<any>({
|
||||||
primaryDomain: [Rules.domain],
|
primaryDomain: [Rules.domainWithPort],
|
||||||
alias: [Rules.linuxName],
|
alias: [Rules.linuxName],
|
||||||
type: [Rules.requiredInput],
|
type: [Rules.requiredInput],
|
||||||
webSiteGroupId: [Rules.requiredSelectBusiness],
|
webSiteGroupId: [Rules.requiredSelectBusiness],
|
||||||
@ -504,7 +505,7 @@ const changeRuntime = (runID: number) => {
|
|||||||
if (item.id === runID) {
|
if (item.id === runID) {
|
||||||
runtimeResource.value = item.resource;
|
runtimeResource.value = item.resource;
|
||||||
if (item.resource === 'appstore') {
|
if (item.resource === 'appstore') {
|
||||||
getAppDetailByID(item.appDetailId);
|
getAppDetailByID(item.appDetailID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -519,7 +520,7 @@ const getRuntimes = async () => {
|
|||||||
website.value.runtimeID = first.id;
|
website.value.runtimeID = first.id;
|
||||||
runtimeResource.value = first.resource;
|
runtimeResource.value = first.resource;
|
||||||
if (first.resource === 'appstore') {
|
if (first.resource === 'appstore') {
|
||||||
getAppDetailByID(first.appDetailId);
|
getAppDetailByID(first.appDetailID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@ -583,7 +584,8 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const changeAlias = (value: string) => {
|
const changeAlias = (value: string) => {
|
||||||
website.value.alias = value;
|
const domain = value.split(':')[0];
|
||||||
|
website.value.alias = domain;
|
||||||
};
|
};
|
||||||
|
|
||||||
function compareVersions(version1: string, version2: string): boolean {
|
function compareVersions(version1: string, version2: string): boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user