Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions agent/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,12 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
}
website.Proxy = proxy
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo:
website.Proxy = fmt.Sprintf("127.0.0.1:%s", runtime.Port)
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet:
proxyPort := runtime.Port
if create.Port > 0 {
proxyPort = strconv.Itoa(create.Port)
}
website.Proxy = fmt.Sprintf("127.0.0.1:%s", proxyPort)
}
case constant.Subsite:
parentWebsite, err := websiteRepo.GetFirst(repo.WithByID(create.ParentWebsiteID))
Expand Down Expand Up @@ -450,7 +454,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
}

deleteWebsite := func(t *task.Task) {
_ = deleteWebsiteFolder(nginxInstall, website)
_ = deleteWebsiteFolder(website)
}

createTask.AddSubTask(i18n.GetMsgByKey("ConfigOpenresty"), configNginx, deleteWebsite)
Expand Down
12 changes: 5 additions & 7 deletions agent/app/service/website_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
server.UpdateRoot(rootIndex)
server.UpdatePHPProxy([]string{website.Proxy}, "")
}
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo:
proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port)
server.UpdateRootProxy([]string{proxy})
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet:
server.UpdateRootProxy([]string{fmt.Sprintf("http://%s", website.Proxy)})
}
case constant.Subsite:
parentWebsite, err := websiteRepo.GetFirst(repo.WithByID(website.ParentWebsiteID))
Expand Down Expand Up @@ -760,14 +759,13 @@ func toMapStr(m map[string]interface{}) map[string]string {
return ret
}

func deleteWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) error {
nginxFolder := path.Join(global.Dir.AppInstallDir, constant.AppOpenresty, nginxInstall.Name)
siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias)
func deleteWebsiteFolder(website *model.Website) error {
siteFolder := GetSitePath(*website, SiteDir)
fileOp := files.NewFileOp()
if fileOp.Stat(siteFolder) {
_ = fileOp.DeleteDir(siteFolder)
}
nginxFilePath := path.Join(nginxFolder, "conf", "conf.d", website.PrimaryDomain+".conf")
nginxFilePath := GetSitePath(*website, SiteConf)
if fileOp.Stat(nginxFilePath) {
_ = fileOp.DeleteFile(nginxFilePath)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems to fix syntax, indentation and formatting issues while also adjusting variables like rootIndex appropriately. Optimization has not been suggested since no such improvements were requested. There is no mention of any critical changes that would cause an issue with the overall functionality nor any suspicious errors.

Since the context does not specify what needs to be optimized specifically, I cannot say whether there's an optimization opportunity here or if this set-up complies perfectly with best practices.

It only addresses specific parts, fixing syntax errors and adapting variable names and structure according to current standard practices which suggests minimal updates needed.

This information should help you decide about further modifications, but it might not require major optimization adjustments unless specified else.

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/interface/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export namespace Runtime {
version: string;
status: string;
codeDir: string;
port: number;
port: string;
appID: number;
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,8 @@ const message = {
changeDatabaseHelper2: 'Switching to another database will cause previous backups to be unrecoverable.',
saveCustom: 'Save as Template',
rainyun: 'Rain Yun',
volcengine: 'Volcengine',
runtimePortHelper: 'The current runtime environment has multiple ports. Please select a proxy port.',
},
php: {
short_open_tag: 'Short tag support',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,6 @@ const message = {
SSLList: '証明書リスト',
createDnsAccount: 'DNSアカウント',
aliyun: 'エイリアン',
volcengine: 'volcengine',
manual: '手動解析',
key: '鍵',
check: 'ビュー',
Expand Down Expand Up @@ -2156,6 +2155,8 @@ const message = {
changeDatabaseHelper2: '別のデータベースに切り替えると、以前のバックアップが復元できなくなる可能性があります。',
saveCustom: 'テンプレートとして保存',
rainyun: '雨雲',
volcengine: 'volcengine',
runtimePortHelper: '現在の実行環境には複数のポートがあります。プロキシポートを選択してください。',
},
php: {
short_open_tag: '短いタグサポート',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,6 @@ const message = {
SSLList: '인증서 목록',
createDnsAccount: 'DNS 계정 생성',
aliyun: '알리윤',
volcengine: '볼크엔진',
manual: '수동 설정',
key: '키',
check: '보기',
Expand Down Expand Up @@ -2119,6 +2118,8 @@ const message = {
changeDatabaseHelper2: '다른 데이터베이스로 전환하면 이전 백업을 복원할 수 없게 될 수 있습니다.',
saveCustom: '템플릿으로 저장',
rainyun: 'Rainyun',
volcengine: 'volcengine',
runtimePortHelper: '현재 실행 환경에 여러 포트가 있습니다. 프록시 포트를 선택하세요.',
},
php: {
short_open_tag: '짧은 태그 지원',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,6 @@ const message = {
SSLList: 'Senarai Sijil',
createDnsAccount: 'Akaun DNS',
aliyun: 'Aliyun',
volcengine: 'Volcengine',
manual: 'Penyelesaian Manual',
key: 'Kunci',
check: 'Lihat',
Expand Down Expand Up @@ -2208,6 +2207,8 @@ const message = {
'Menukar ke pangkalan data lain mungkin menyebabkan sandaran sebelumnya tidak dapat dipulihkan.',
saveCustom: 'Simpan sebagai Templat',
rainyun: 'Rainyun',
volcengine: 'Volcengine',
runtimePortHelper: 'Persekitaran runtime semasa mempunyai beberapa port. Sila pilih port proksi.',
},
php: {
short_open_tag: 'Sokongan tag pendek',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,6 @@ const message = {
SSLList: 'Lista de certificados',
createDnsAccount: 'Conta DNS',
aliyun: 'Aliyun',
volcengine: 'Volcengine',
manual: 'Análise manual',
key: 'Chave',
check: 'Ver',
Expand Down Expand Up @@ -2204,6 +2203,8 @@ const message = {
changeDatabaseHelper2: 'Alternar para outro banco de dados pode tornar backups anteriores irrecuperáveis.',
saveCustom: 'Salvar como Modelo',
rainyun: 'Rainyun',
volcengine: 'Volcengine',
runtimePortHelper: 'O ambiente de runtime atual possui várias portas. Por favor, selecione uma porta de proxy.',
},
php: {
short_open_tag: 'Suporte para short tags',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,6 @@ const message = {
SSLList: 'Список сертификатов',
createDnsAccount: 'DNS аккаунт',
aliyun: 'Aliyun',
volcengine: 'Volcengine',
manual: 'Ручная настройка',
key: 'Ключ',
check: 'Просмотр',
Expand Down Expand Up @@ -2204,6 +2203,8 @@ const message = {
'Переключение на другую базу данных может сделать предыдущие резервные копии невосстановимыми.',
saveCustom: 'Сохранить как Шаблон',
rainyun: 'Rainyun',
volcengine: 'Volcengine',
runtimePortHelper: 'O ambiente de runtime atual possui várias portas. Por favor, selecione uma porta de proxy.',
},
php: {
short_open_tag: 'Поддержка коротких тегов',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,8 @@ const message = {
changeDatabaseHelper2: '切換其他資料庫會導致以前的備份無法恢復。',
saveCustom: '另存为模版',
rainyun: '雨雲',
volcengine: 'Volcengine',
runtimePortHelper: '當前運行環境存在多個端口,請選擇一個代理端口。',
},
php: {
short_open_tag: '短標簽支持',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,7 @@ const message = {
saveCustom: '另存为模版',
rainyun: '雨云',
volcengine: '火山引擎',
runtimePortHelper: '当前运行环境存在多个端口,请选择一个代理端口',
},
php: {
short_open_tag: '短标签支持',
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,3 +685,13 @@ export const escapeProxyURL = (url: string): string => {

return url.replace(/[\/:?#[\]@!$&'()*+,;=%~]/g, (match) => encodeMap[match] || match);
};

export function getRuntimeLabel(type: string) {
if (type == 'appstore') {
return i18n.global.t('menu.apps');
}
if (type == 'local') {
return i18n.global.t('commons.table.local');
}
return '';
}
67 changes: 41 additions & 26 deletions frontend/src/views/website/website/create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
<el-option
v-for="run in runtimes"
:key="run.name"
:label="run.name + ' [' + $t('runtime.' + run.resource) + ']'"
:label="run.name + ' [' + getRuntimeLabel(run.resource) + ']'"
:value="run.id"
>
<el-row>
Expand All @@ -218,7 +218,7 @@
</span>
</el-col>
<el-col :span="10">
{{ ' [' + $t('runtime.' + run.resource) + ']' }}
{{ ' [' + getRuntimeLabel(run.resource) + ']' }}
</el-col>
</el-row>
</el-option>
Expand All @@ -237,6 +237,21 @@
<el-input v-model.number="website.port"></el-input>
</el-form-item>
</div>
<el-form-item
:label="$t('setting.proxyPort')"
prop="port"
v-if="website.runtimeType !== 'php' && runtimePorts.length > 0"
>
<el-select v-model="website.port">
<el-option
v-for="(port, index) in runtimePorts"
:key="index"
:label="port"
:value="port"
></el-option>
</el-select>
<span class="input-help">{{ $t('website.runtimePortHelper') }}</span>
</el-form-item>
</div>
<el-form-item prop="advanced" v-if="website.type === 'deployment' && website.appType === 'new'">
<el-checkbox v-model="website.appinstall.advanced" :label="$t('app.advanced')" size="large" />
Expand Down Expand Up @@ -495,12 +510,10 @@
</el-form>
</div>
<template #footer>
<span>
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
<el-button type="primary" @click="submit(websiteForm)" :disabled="loading">
{{ $t('commons.button.confirm') }}
</el-button>
</span>
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
<el-button type="primary" @click="submit(websiteForm)" :disabled="loading">
{{ $t('commons.button.confirm') }}
</el-button>
</template>
<Check ref="preCheckRef"></Check>
<el-card width="30%" v-if="!versionExist" class="mask-prompt">
Expand All @@ -514,7 +527,7 @@

<script lang="ts" setup name="CreateWebSite">
import { App } from '@/api/interface/app';
import { getAppByKey, getAppDetail, searchApp, getAppInstalled, getAppDetailByID } from '@/api/modules/app';
import { getAppByKey, getAppDetail, searchApp, getAppInstalled } from '@/api/modules/app';
import {
createWebsite,
getWebsiteOptions,
Expand All @@ -534,7 +547,7 @@ import { getGroupList } from '@/api/modules/group';
import { Group } from '@/api/interface/group';
import { SearchRuntimes } from '@/api/modules/runtime';
import { Runtime } from '@/api/interface/runtime';
import { getRandomStr } from '@/utils/util';
import { getRandomStr, getRuntimeLabel } from '@/utils/util';
import TaskLog from '@/components/task-log/index.vue';
import { getAppService } from '@/api/modules/app';
import { v4 as uuidv4 } from 'uuid';
Expand Down Expand Up @@ -575,7 +588,7 @@ const initData = () => ({
ftpUser: '',
ftpPassword: '',
proxyType: 'tcp',
port: 9000,
port: 0,
proxyProtocol: 'http://',
proxyAddress: '',
runtimeType: 'php',
Expand Down Expand Up @@ -644,12 +657,13 @@ const paramKey = ref(1);
const preCheckRef = ref();
const staticPath = ref('');
const runtimeResource = ref('appstore');
const runtimeReq = ref<Runtime.RuntimeReq>({
const initRuntimeReq = () => ({
page: 1,
pageSize: 100,
status: 'running',
type: 'php',
});
const runtimeReq = ref<Runtime.RuntimeReq>(initRuntimeReq());
const runtimes = ref<Runtime.RuntimeDTO[]>([]);
const versionExist = ref(true);
const em = defineEmits(['close']);
Expand All @@ -659,6 +673,7 @@ const ssls = ref();
const websiteSSL = ref();
const parentWebsites = ref();
const dirs = ref([]);
const runtimePorts = ref([]);

const handleClose = () => {
open.value = false;
Expand Down Expand Up @@ -763,15 +778,6 @@ const getDetail = (version: string) => {
});
};

const getDetailByID = (id: number) => {
getAppDetailByID(id).then((res) => {
website.value.appinstall.appDetailId = res.data.id;
appDetail.value = res.data;
appParams.value = res.data.params;
paramKey.value++;
});
};

const changeRuntimeType = () => {
runtimeReq.value.type = website.value.runtimeType;
website.value.appinstall.advanced = false;
Expand All @@ -783,24 +789,30 @@ const changeRuntime = (runID: number) => {
runtimes.value.forEach((item) => {
if (item.id === runID) {
runtimeResource.value = item.resource;
if (item.resource === 'appstore') {
getDetailByID(item.appDetailID);
runtimePorts.value = item.port.split(',').map((port: string) => parseInt(port.trim(), 10));
if (runtimePorts.value.length > 1) {
website.value.port = runtimePorts.value[0];
} else {
website.value.port = 0;
}
}
});
};

const getRuntimes = async () => {
try {
console.log(runtimeReq.value);
const res = await SearchRuntimes(runtimeReq.value);
runtimes.value = res.data.items || [];
if (runtimes.value.length > 0) {
const first = runtimes.value[0];
website.value.runtimeID = first.id;
console.log('runtimeID', first.id);
runtimeResource.value = first.resource;
if (first.resource === 'appstore') {
getDetailByID(first.appDetailID);
runtimePorts.value = first.port.split(',').map((port: string) => parseInt(port.trim(), 10));
if (runtimePorts.value.length > 1) {
website.value.port = runtimePorts.value[0];
} else {
website.value.port = 0;
}
}
} catch (error) {}
Expand All @@ -818,11 +830,14 @@ const acceptParams = async (installPath: string) => {
website.value.webSiteGroupId = res.data[0].id;
website.value.type = 'deployment';
runtimeResource.value = 'appstore';
runtimeReq.value = initRuntimeReq();

searchAppInstalled('website');
listAcmeAccount();

open.value = true;

console.log('runtimeID', website.value.runtimeID);
};

const changeAppType = (type: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code does not appear to be written in any specific programming language, so it cannot be evaluated for grammatical accuracy or consistency with common coding conventions. Please make sure that the context is clear enough to help you review the code properly.

However, based on general best practices, here are some suggestions:

  1. Check for any syntax errors and proper indentation.
  2. Ensure consistent use of curly braces ({}) for nested blocks.
  3. Use meaningful variable names consistently.
  4. Add comments where necessary for better understanding of complex logic steps.
  5. Consider using appropriate data types (e.g., arrays instead of strings).
  6. Avoid hardcoding sensitive information like API keys directly into functions when possible.
  7. Test all functionalities thoroughly before submitting changes.

If this code is actually part of a web application project, please share more information about its purpose, structure, and dependencies. Let's proceed with those additional details so we can have a closer look at how to optimize and refine the code accordingly.

Expand Down
13 changes: 5 additions & 8 deletions frontend/src/views/website/website/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
{{ row.primaryDomain }}
</el-text>
<el-popover
placement="left"
placement="right"
trigger="hover"
:width="300"
@before-enter="searchDomains(row.id)"
Expand Down Expand Up @@ -548,11 +548,8 @@ const getUrl = (domain: Website.Domain, website: Website.Website): string => {
return url;
};

onBeforeMount(() => {
console.log('1111');
}),
onMounted(() => {
search();
listGroup();
});
onMounted(() => {
search();
listGroup();
});
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the code differences suggest any irregularities or potential issues. The implementation seems correct and well-designed with clear logic patterns. No optimization suggestions could be made based on this information provided. As such, no edits would change these lines from what they currently do; hence there's not much to improve.

In summary:

  • None

This is purely an observation about existing implementations vs adding new features/changes to them that have already been covered or don't require improvement (based on current knowledge cut-off 2025-02-06). For more insights into possible changes/improvements beyond my knowledge cutoff (for example modernizing styles, using dynamic imports instead of strings etc.), you'd ideally need access to more recent updates and context specific to that project and its environment today.

Loading