Skip to content

Commit

Permalink
fix: 解决计划任务列表不显示备份账号的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu committed Jan 14, 2025
1 parent c708e31 commit e86090c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 47 deletions.
4 changes: 2 additions & 2 deletions core/app/dto/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type SettingUpdate struct {
type SSLUpdate struct {
SSLType string `json:"sslType" validate:"required,oneof=self select import import-paste import-local"`
Domain string `json:"domain"`
SSL string `json:"ssl" validate:"required,oneof=enable disable"`
SSL string `json:"ssl" validate:"required,oneof=Enable Disable"`
Cert string `json:"cert"`
Key string `json:"key"`
SSLID uint `json:"sslID"`
Expand Down Expand Up @@ -143,7 +143,7 @@ type SyncTime struct {
}

type BindInfo struct {
Ipv6 string `json:"ipv6" validate:"required,oneof=enable disable"`
Ipv6 string `json:"ipv6" validate:"required,oneof=Enable Disable"`
BindAddress string `json:"bindAddress" validate:"required"`
}

Expand Down
2 changes: 1 addition & 1 deletion core/middleware/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func newDB(pathItem string) (*gorm.DB, error) {
case strings.HasPrefix(pathItem, "/core"):
dbFile = path.Join(global.CONF.System.BaseDir, "1panel/db/core.db")
case strings.HasPrefix(pathItem, "/xpack"):
dbFile = path.Join(global.CONF.System.BaseDir, "1panel/db/xpack/xpack.db")
dbFile = path.Join(global.CONF.System.BaseDir, "1panel/db/xpack.db")
default:
dbFile = path.Join(global.CONF.System.BaseDir, "1panel/db/agent.db")
}
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/api/interface/cronjob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export namespace Cronjob {
files: Array<Item>;
sourceDir: string;

sourceAccountIDs: string;
downloadAccountID: number;
sourceAccounts: Array<number>;
sourceAccounts: Array<string>;
downloadAccount: string;
retainCopies: number;
status: string;
secret: string;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/interface/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ export namespace Setting {
export interface SnapshotInfo {
id: number;
name: string;
from: string;
defaultDownload: string;
sourceAccounts: Array<string>;
downloadAccount: string;
description: string;
status: string;
message: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/layout/components/Sidebar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const loadNodes = async () => {
nodes.value = [];
return;
}
nodes.value = res.data;
nodes.value = res.data || [];
if (nodes.value.length === 0) {
globalStore.currentNode = 'local';
}
Expand Down
50 changes: 22 additions & 28 deletions frontend/src/views/cronjob/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,34 @@
{{ row.lastRecordTime }}
</template>
</el-table-column>
<el-table-column :min-width="80" :label="$t('setting.backupAccount')" prop="defaultDownload">
<el-table-column :min-width="80" :label="$t('setting.backupAccount')">
<template #default="{ row }">
<span v-if="!hasBackup(row.type)">-</span>
<div v-else>
<div v-for="(item, index) of row.backupAccounts?.split(',')" :key="index">
<div v-for="(item, index) of row.sourceAccounts" :key="index">
<div v-if="row.accountExpand || (!row.accountExpand && index < 3)">
<span v-if="row.backupAccounts">
<span>
{{ $t('setting.' + item) }}
<div v-if="row.expand || (!row.expand && index < 3)">
<span type="info">
<span>
{{ loadName(item) }}
</span>
<el-icon
v-if="item === row.downloadAccount"
size="12"
class="relative top-px left-1"
>
<Star />
</el-icon>
</span>
<el-icon
size="12"
v-if="item === row.defaultDownload"
class="relative top-px left-1"
>
<Star />
</el-icon>
</span>
<span v-else>-</span>
</div>
</div>
</div>
<div v-if="!row.accountExpand && row.backupAccounts?.split(',').length > 3">
<div v-if="!row.accountExpand && row.sourceAccounts?.length > 3">
<el-button type="primary" link @click="row.accountExpand = true">
{{ $t('commons.button.expand') }}...
</el-button>
</div>
<div v-if="row.accountExpand && row.backupAccounts?.split(',').length > 3">
<div v-if="row.accountExpand && row.sourceAccounts?.length > 3">
<el-button type="primary" link @click="row.accountExpand = false">
{{ $t('commons.button.collapse') }}
</el-button>
Expand Down Expand Up @@ -209,18 +210,6 @@ const search = async (column?: any) => {
.then((res) => {
loading.value = false;
data.value = res.data.items || [];
for (const item of data.value) {
let itemAccounts = item.backupAccounts.split(',') || [];
let accounts = [];
for (const account of itemAccounts) {
if (account == item.defaultDownload) {
accounts.unshift(account);
} else {
accounts.push(account);
}
}
item.itemAccounts = accounts.join(',');
}
paginationConfig.total = res.data.total;
})
.catch(() => {
Expand Down Expand Up @@ -364,6 +353,11 @@ const loadDetail = (row: any) => {
dialogRecordRef.value!.acceptParams(params);
};
const loadName = (from: any) => {
let items = from.split(' - ');
return i18n.global.t('setting.' + items[0]) + ' ' + items[1];
};
const buttons = [
{
label: i18n.global.t('commons.button.handle'),
Expand Down
17 changes: 7 additions & 10 deletions frontend/src/views/setting/snapshot/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,29 @@
<el-table-column prop="version" :label="$t('app.version')" />
<el-table-column :label="$t('setting.backupAccount')" min-width="80" prop="from">
<template #default="{ row }">
<div v-if="row.hasLoad">
<div v-for="(item, index) of row.from.split(',')" :key="index" class="mt-1">
<div>
<div v-for="(item, index) of row.sourceAccounts" :key="index" class="mt-1">
<div v-if="row.expand || (!row.expand && index < 3)">
<span v-if="row.from" type="info">
<span type="info">
<span>
{{ loadName(item) }}
</span>
<el-icon
v-if="item === row.defaultDownload"
v-if="item === row.downloadAccount"
size="12"
class="relative top-px left-1"
>
<Star />
</el-icon>
</span>
<span v-else>-</span>
</div>
</div>
<div v-if="!row.expand && row.from.split(',').length > 3">
<div v-if="!row.expand && row.sourceAccounts.length > 3">
<el-button type="primary" link @click="row.expand = true">
{{ $t('commons.button.expand') }}...
</el-button>
</div>
<div v-if="row.expand && row.from.split(',').length > 3">
<div v-if="row.expand && row.sourceAccounts.length > 3">
<el-button type="primary" link @click="row.expand = false">
{{ $t('commons.button.collapse') }}
</el-button>
Expand Down Expand Up @@ -296,7 +295,7 @@ const onChange = async (info: any) => {
};
const onRecover = async (row: any) => {
if (row.defaultDownload.indexOf('ALIYUN') !== -1 && row.size > 100 * 1024 * 1024) {
if (row.downloadAccount.indexOf('ALIYUN') !== -1 && row.size > 100 * 1024 * 1024) {
MsgError(i18n.global.t('setting.ALIYUNRecover'));
return;
}
Expand Down Expand Up @@ -422,8 +421,6 @@ const loadSize = async () => {
for (const item of stats) {
if (snap.id === item.id) {
snap.hasLoad = true;
snap.from = item.from;
snap.defaultDownload = item.defaultDownload;
snap.size = item.size;
break;
}
Expand Down

0 comments on commit e86090c

Please sign in to comment.