Skip to content

Commit

Permalink
网站检测重复优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyunleo committed Dec 1, 2023
1 parent 3d8f5b1 commit c1aafa2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/main/core/website/NginxWebsite.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ export default class NginxWebsite {
async setBasicInfo(websiteInfo) {
let text = this.confText;
let serverNameStr;
if (websiteInfo.extraServerName) {
if (await Nginx.websiteExists(websiteInfo.extraServerName, websiteInfo.port)) {
throw new Error('第二域名不能重复!')
}
serverNameStr = `server_name ${this.serverName} ${websiteInfo.extraServerName};`;
let extraServerName = websiteInfo.extraServerName
if (extraServerName) {
if (extraServerName !== this.getExtraServerName())
if (await Nginx.websiteExists(extraServerName, websiteInfo.port)) {
throw new Error(`${extraServerName}:${websiteInfo.port}\n已经存在,不能重复!`)
}
serverNameStr = `server_name ${this.serverName} ${extraServerName};`
} else {
serverNameStr = `server_name ${this.serverName};`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/core/website/Website.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class Website {
*/
static async add(websiteInfo) {
if (await Nginx.websiteExists(websiteInfo.serverName, websiteInfo.port)) {
throw new Error('网站已经存在!');
throw new Error(`${websiteInfo.serverName}:${websiteInfo.port}\n已经存在,不能重复!`)
}

if (!FileUtil.Exists(websiteInfo.rootPath)) {
Expand Down

0 comments on commit c1aafa2

Please sign in to comment.