fix(app): fix issue with reinstall openresty failed (#8265)

This commit is contained in:
zhengkunwang 2025-03-27 16:55:36 +08:00 committed by GitHub
parent d09a3d82b9
commit 1908a59174
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 78 additions and 98 deletions

View file

@ -112,6 +112,7 @@ type Resource struct {
type Database struct {
Name string `json:"name"`
DatabaseName string `json:"databaseName"`
Type string `json:"type"`
From string `json:"from"`
ID uint `json:"id"`

View file

@ -192,16 +192,18 @@ func (a AppService) GetApp(ctx *gin.Context, key string) (*response.AppDTO, erro
}
var versionsRaw []string
hasLatest := false
latestVersion := ""
for _, detail := range details {
if strings.Contains(detail.Version, "latest") {
hasLatest = true
latestVersion = detail.Version
continue
}
versionsRaw = append(versionsRaw, detail.Version)
}
appDTO.Versions = common.GetSortedVersions(versionsRaw)
if hasLatest {
appDTO.Versions = append([]string{"latest"}, appDTO.Versions...)
appDTO.Versions = append([]string{latestVersion}, appDTO.Versions...)
}
tags, err := getAppTags(app.ID, strings.ToLower(common.GetLang(ctx)))
if err != nil {

View file

@ -1834,9 +1834,7 @@ func handleOpenrestyFile(appInstall *model.AppInstall) error {
break
}
}
if !hasDefaultWebsite {
return nil
}
if hasDefaultWebsite {
installDir := appInstall.GetPath()
defaultConfigPath := path.Join(installDir, "conf", "default", "00.default.conf")
fileOp := files.NewFileOp()
@ -1848,5 +1846,6 @@ func handleOpenrestyFile(appInstall *model.AppInstall) error {
if err := fileOp.WriteFile(defaultConfigPath, strings.NewReader(newContent), constant.FilePerm); err != nil {
return err
}
return createAllWebsitesWAFConfig()
}
return createAllWebsitesWAFConfig(websites)
}

View file

@ -3214,6 +3214,7 @@ func (w WebsiteService) ListDatabases() ([]response.Database, error) {
Name: db.Name,
Type: database.Type,
From: database.From,
DatabaseName: database.Name,
})
}
}
@ -3226,6 +3227,7 @@ func (w WebsiteService) ListDatabases() ([]response.Database, error) {
Name: db.Name,
Type: database.Type,
From: database.From,
DatabaseName: database.Name,
})
}
}

View file

@ -297,11 +297,7 @@ func moveDefaultWafConfig(websiteDir string, defaultConfigContent []byte, defaul
return nil
}
func createAllWebsitesWAFConfig() error {
websites, _ := websiteRepo.List()
if len(websites) == 0 {
return nil
}
func createAllWebsitesWAFConfig(websites []model.Website) error {
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
if err != nil {
return err

View file

@ -196,7 +196,6 @@ func (c Client) PullImageWithProcessAndOptions(task *task.Task, imageName string
}
return err
}
timeStr := time.Now().Format("2006/01/02 15:04:05")
status, _ := progress["status"].(string)
if status == "Downloading" || status == "Extracting" {
id, _ := progress["id"].(string)
@ -204,16 +203,17 @@ func (c Client) PullImageWithProcessAndOptions(task *task.Task, imageName string
current, _ := progressDetail["current"].(float64)
progressStr := ""
total, ok := progressDetail["total"].(float64)
timeStr := time.Now().Format("2006/01/02 15:04:05")
if ok {
progressStr = fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, (current/total)*100)
} else {
progressStr = fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, current)
}
_ = setLog(id, progressStr, task)
}
if status == "Pull complete" || status == "Download complete" {
id, _ := progress["id"].(string)
timeStr := time.Now().Format("2006/01/02 15:04:05")
progressStr := fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, 100.0)
_ = setLog(id, progressStr, task)
}
@ -312,7 +312,6 @@ func (c Client) BuildImageWithProcessAndOptions(task *task.Task, tar io.ReadClos
} else {
progressStr = fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, current)
}
_ = setLog(id, progressStr, task)
case "Pull complete", "Download complete", "Verifying Checksum":
id, _ := progress["id"].(string)

View file

@ -629,6 +629,7 @@ export namespace Website {
databaseID: number;
websiteID: number;
from: string;
databaseName: number;
}
export interface ChangeDatabase {

View file

@ -1,11 +1,10 @@
<template>
<el-dialog
v-model="open"
:destroy-on-close="true"
:close-on-click-modal="false"
:close-on-press-escape="false"
:show-close="showClose"
:before-close="handleClose"
@close="handleClose"
:width="width"
>
<div>
@ -44,7 +43,6 @@ const config = reactive({
});
const open = ref(false);
const showTail = ref(true);
const emit = defineEmits(['close']);
const openWithTaskID = (id: string, tail: boolean) => {
config.taskID = id;
@ -64,9 +62,10 @@ const openWithResourceID = (taskType: string, taskOperate: string, resourceID: n
open.value = true;
};
const em = defineEmits(['close']);
const handleClose = () => {
em('close', true);
open.value = false;
emit('close', true);
bus.emit('refreshTask', true);
};

View file

@ -273,19 +273,46 @@
<table>
<tbody>
<tr v-if="defaultLink != ''">
<td>
<td v-if="installed.httpPort > 0">
<el-button
type="primary"
link
@click="
toLink(
'http://' +
defaultLink +
':' +
installed.httpPort,
)
"
>
{{ defaultLink + ':' + installed.httpPort }}
{{
'http://' +
defaultLink +
':' +
installed.httpPort
}}
</el-button>
</td>
<td v-if="installed.httpsPort > 0">
<el-button
type="primary"
link
@click="
toLink(
'https://' +
defaultLink +
':' +
installed.httpsPort,
)
"
>
{{
'https://' +
defaultLink +
':' +
installed.httpsPort
}}
</el-button>
</td>
</tr>

View file

@ -2,14 +2,7 @@
<DrawerPro v-model="drawerVisible" :header="$t('app.defaultWebDomain')" @close="handleClose" size="small">
<el-form ref="formRef" label-position="top" :model="form" :rules="rules" @submit.prevent v-loading="loading">
<el-form-item :label="$t('app.defaultWebDomain')" prop="defaultDomain">
<el-input v-model="form.defaultDomain">
<template #prepend>
<el-select v-model="protocol" placeholder="Select" class="p-w-100">
<el-option label="HTTP" value="http://" />
<el-option label="HTTPS" value="https://" />
</el-select>
</template>
</el-input>
<el-input v-model="form.defaultDomain"></el-input>
<span class="input-help">{{ $t('app.defaultWebDomainHepler') }}</span>
</el-form-item>
</el-form>
@ -36,18 +29,15 @@ const form = reactive({
defaultDomain: '',
});
const rules = reactive({
defaultDomain: [Rules.requiredInput],
defaultDomain: [Rules.requiredInput, Rules.ipV4V6OrDomain],
});
const formRef = ref<FormInstance>();
const protocol = ref('http://');
interface DialogProps {
protocol: string;
domain: string;
}
const acceptParams = (config: DialogProps): void => {
form.defaultDomain = config.domain;
protocol.value = config.protocol;
drawerVisible.value = true;
};
@ -64,12 +54,8 @@ const submit = async () => {
}
loading.value = true;
try {
let defaultDomain = '';
if (form.defaultDomain) {
defaultDomain = protocol.value + form.defaultDomain;
}
const req = {
defaultDomain: defaultDomain,
defaultDomain: form.defaultDomain,
};
await updateAppStoreConfig(req);
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));

View file

@ -14,12 +14,6 @@
<el-col :xs="24" :sm="20" :md="15" :lg="12" :xl="12">
<el-form-item :label="$t('app.defaultWebDomain')" prop="defaultDomain">
<el-input v-model="config.defaultDomain" disabled>
<template #prepend>
<el-select v-model="protocol" placeholder="Select" class="p-w-100" disabled>
<el-option label="HTTP" value="http://" />
<el-option label="HTTPS" value="https://" />
</el-select>
</template>
<template #append>
<el-button @click="setDefaultDomain()" icon="Setting">
{{ $t('commons.button.set') }}
@ -54,35 +48,15 @@ const config = ref({
});
const loading = ref(false);
const configForm = ref();
const protocol = ref('http://');
const domainRef = ref();
const useCustomApp = ref(false);
function getUrl(url: string) {
const regex = /^(https?:\/\/)(.*)/;
const match = url.match(regex);
if (match) {
const protocol = match[1];
const remainder = match[2];
return {
protocol: protocol,
remainder: remainder,
};
} else {
return null;
}
}
const search = async () => {
loading.value = true;
try {
const res = await getAppStoreConfig();
if (res.data.defaultDomain != '') {
const url = getUrl(res.data.defaultDomain);
if (url) {
config.value.defaultDomain = url.remainder;
protocol.value = url.protocol;
}
config.value.defaultDomain = res.data.defaultDomain;
}
} catch (error) {
} finally {
@ -93,7 +67,6 @@ const search = async () => {
const setDefaultDomain = () => {
domainRef.value.acceptParams({
domain: config.value.defaultDomain,
protocol: protocol.value,
});
};

View file

@ -24,7 +24,7 @@
<div class="flex justify-between items-center">
<span>{{ item.name }}</span>
<div>
<el-tag>{{ item.type }}</el-tag>
<el-tag>{{ item.databaseName }}</el-tag>
<el-tag class="ml-1">
{{ item.from === 'local' ? $t('commons.table.local') : $t('database.remote') }}
</el-tag>
@ -79,19 +79,14 @@ const listDatabases = async () => {
try {
const res = await getWebsiteDatabase();
databases.value = res.data;
if (databases.value.length > 0) {
if (website.value.dbID > 0) {
if (databases.value.length > 0 && website.value.dbID > 0) {
for (let i = 0; i < databases.value.length; i++) {
if (
databases.value[i].id === website.value.dbID &&
databases.value[i].type === website.value.dbType
) {
if (databases.value[i].id === website.value.dbID && databases.value[i].type === website.value.dbType) {
req.db = databases.value[i].id + databases.value[i].type;
break;
}
}
}
}
} catch (error) {}
};