mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: 系统设置部分 bug 解决
This commit is contained in:
parent
0a20aaa3fa
commit
f6cdfdc17b
@ -5,14 +5,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/cloud_storage"
|
"github.com/1Panel-dev/1Panel/backend/utils/cloud_storage"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
|
||||||
"github.com/jinzhu/copier"
|
"github.com/jinzhu/copier"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@ -205,7 +205,7 @@ func (u *BackupService) Update(req dto.BackupOperate) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return constant.ErrRecordNotFound
|
return constant.ErrRecordNotFound
|
||||||
}
|
}
|
||||||
varMap := make(map[string]string)
|
varMap := make(map[string]interface{})
|
||||||
if err := json.Unmarshal([]byte(req.Vars), &varMap); err != nil {
|
if err := json.Unmarshal([]byte(req.Vars), &varMap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -218,13 +218,15 @@ func (u *BackupService) Update(req dto.BackupOperate) error {
|
|||||||
}
|
}
|
||||||
if backup.Type == "LOCAL" {
|
if backup.Type == "LOCAL" {
|
||||||
if dir, ok := varMap["dir"]; ok {
|
if dir, ok := varMap["dir"]; ok {
|
||||||
if err := updateBackupDir(dir); err != nil {
|
if dirStr, isStr := dir.(string); isStr {
|
||||||
|
if err := updateBackupDir(dirStr); err != nil {
|
||||||
upMap["vars"] = backup.Vars
|
upMap["vars"] = backup.Vars
|
||||||
_ = backupRepo.Update(req.ID, upMap)
|
_ = backupRepo.Update(req.ID, upMap)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,20 +297,19 @@ func loadLocalDir() (string, error) {
|
|||||||
|
|
||||||
func updateBackupDir(dir string) error {
|
func updateBackupDir(dir string) error {
|
||||||
oldDir := global.CONF.System.Backup
|
oldDir := global.CONF.System.Backup
|
||||||
fileOp := files.NewFileOp()
|
|
||||||
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
|
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
|
||||||
if err = os.MkdirAll(dir, os.ModePerm); err != nil {
|
if err = os.MkdirAll(dir, os.ModePerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global.Viper.Set("system.backup", path.Join(dir, "backup"))
|
if strings.HasSuffix(oldDir, "/") {
|
||||||
if err := global.Viper.WriteConfig(); err != nil {
|
oldDir = oldDir[:strings.LastIndex(oldDir, "/")]
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
if err := fileOp.CopyDir(oldDir, dir); err != nil {
|
cmd := exec.Command("cp", "-r", oldDir+"/*", dir)
|
||||||
global.Viper.Set("system.backup", oldDir)
|
stdout, err := cmd.CombinedOutput()
|
||||||
_ = global.Viper.WriteConfig()
|
if err != nil {
|
||||||
return err
|
return errors.New(string(stdout))
|
||||||
}
|
}
|
||||||
|
global.CONF.System.Backup = dir
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
<el-tag v-else round style="margin-left: 10px">{{ $t('setting.upgrading') }}</el-tag>
|
<el-tag v-else round style="margin-left: 10px">{{ $t('setting.upgrading') }}</el-tag>
|
||||||
</h3>
|
</h3>
|
||||||
<div style="margin-top: 10px">
|
<div style="margin-top: 10px">
|
||||||
<el-link @click="toGithub">
|
<el-link @click="toDoc">
|
||||||
|
<el-icon><Document /></el-icon>
|
||||||
|
<span>{{ $t('setting.doc') }}</span>
|
||||||
|
</el-link>
|
||||||
|
<el-link @click="toGithub" style="margin-left: 15px">
|
||||||
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-huaban88"></svg-icon>
|
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-huaban88"></svg-icon>
|
||||||
<span style="line-height: 20px">{{ $t('setting.project') }}</span>
|
<span style="line-height: 20px">{{ $t('setting.project') }}</span>
|
||||||
</el-link>
|
</el-link>
|
||||||
@ -23,10 +27,6 @@
|
|||||||
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-bug"></svg-icon>
|
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-bug"></svg-icon>
|
||||||
<span>{{ $t('setting.issue') }}</span>
|
<span>{{ $t('setting.issue') }}</span>
|
||||||
</el-link>
|
</el-link>
|
||||||
<el-link @click="toTalk" style="margin-left: 15px">
|
|
||||||
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-taolun"></svg-icon>
|
|
||||||
<span>{{ $t('setting.chat') }}</span>
|
|
||||||
</el-link>
|
|
||||||
<el-link @click="toGithubStar" style="margin-left: 15px">
|
<el-link @click="toGithubStar" style="margin-left: 15px">
|
||||||
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-star"></svg-icon>
|
<svg-icon style="font-size: 7px; margin-bottom: 3px" iconName="p-star"></svg-icon>
|
||||||
<span>{{ $t('setting.star') }}</span>
|
<span>{{ $t('setting.star') }}</span>
|
||||||
@ -66,7 +66,7 @@ import 'md-editor-v3/lib/style.css';
|
|||||||
import { ElMessageBox } from 'element-plus';
|
import { ElMessageBox } from 'element-plus';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
import { MsgInfo, MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
|
|
||||||
const version = ref();
|
const version = ref();
|
||||||
const upgradeInfo = ref();
|
const upgradeInfo = ref();
|
||||||
@ -79,15 +79,15 @@ const search = async () => {
|
|||||||
version.value = res.data.systemVersion;
|
version.value = res.data.systemVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toDoc = () => {
|
||||||
|
window.open('https://1panel.cn/docs/', '_blank');
|
||||||
|
};
|
||||||
const toGithub = () => {
|
const toGithub = () => {
|
||||||
window.open('https://github.com/1Panel-dev/1Panel', '_blank');
|
window.open('https://github.com/1Panel-dev/1Panel', '_blank');
|
||||||
};
|
};
|
||||||
const toIssue = () => {
|
const toIssue = () => {
|
||||||
window.open('https://github.com/1Panel-dev/1Panel/issues', '_blank');
|
window.open('https://github.com/1Panel-dev/1Panel/issues', '_blank');
|
||||||
};
|
};
|
||||||
const toTalk = () => {
|
|
||||||
window.open('https://github.com/1Panel-dev/1Panel', '_blank');
|
|
||||||
};
|
|
||||||
const toGithubStar = () => {
|
const toGithubStar = () => {
|
||||||
window.open('https://github.com/1Panel-dev/1Panel', '_blank');
|
window.open('https://github.com/1Panel-dev/1Panel', '_blank');
|
||||||
};
|
};
|
||||||
@ -102,7 +102,7 @@ const onLoadUpgradeInfo = async () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (!res.data) {
|
if (!res.data) {
|
||||||
MsgInfo(i18n.global.t('setting.noUpgrade'));
|
MsgSuccess(i18n.global.t('setting.noUpgrade'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
upgradeInfo.value = res.data;
|
upgradeInfo.value = res.data;
|
||||||
|
@ -82,14 +82,10 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-if="dialogData.rowData!.type === 'SFTP'">
|
<div v-if="dialogData.rowData!.type === 'SFTP'">
|
||||||
<el-form-item
|
<el-form-item :label="$t('setting.address')" prop="varsJson.address" :rules="Rules.ip">
|
||||||
:label="$t('setting.address')"
|
|
||||||
prop="varsJson.address"
|
|
||||||
:rules="Rules.requiredInput"
|
|
||||||
>
|
|
||||||
<el-input v-model.trim="dialogData.rowData!.varsJson['address']" />
|
<el-input v-model.trim="dialogData.rowData!.varsJson['address']" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('setting.port')" prop="varsJson.port" :rules="[Rules.number]">
|
<el-form-item :label="$t('setting.port')" prop="varsJson.port" :rules="[Rules.port]">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="65535"
|
:max="65535"
|
||||||
@ -107,7 +103,7 @@
|
|||||||
v-model="dialogData.rowData!.credential"
|
v-model="dialogData.rowData!.credential"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('setting.path')" prop="bucket">
|
<el-form-item :label="$t('setting.path')" prop="bucket" :rules="[Rules.requiredInput]">
|
||||||
<el-input v-model="dialogData.rowData!.bucket" />
|
<el-input v-model="dialogData.rowData!.bucket" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
@ -167,6 +163,9 @@ const acceptParams = (params: DialogProps): void => {
|
|||||||
dialogData.value.rowData!.varsJson['endpoint'].split('://')[1];
|
dialogData.value.rowData!.varsJson['endpoint'].split('://')[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dialogData.value.title === 'create' && dialogData.value.rowData!.type === 'SFTP') {
|
||||||
|
dialogData.value.rowData.varsJson['port'] = 22;
|
||||||
|
}
|
||||||
title.value = i18n.global.t('commons.button.' + dialogData.value.title);
|
title.value = i18n.global.t('commons.button.' + dialogData.value.title);
|
||||||
drawerVisiable.value = true;
|
drawerVisiable.value = true;
|
||||||
};
|
};
|
||||||
@ -186,6 +185,9 @@ const getBuckets = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
let item = deepCopy(dialogData.value.rowData!.varsJson);
|
let item = deepCopy(dialogData.value.rowData!.varsJson);
|
||||||
if (dialogData.value.rowData!.type === 'MINIO') {
|
if (dialogData.value.rowData!.type === 'MINIO') {
|
||||||
|
dialogData.value.rowData!.varsJson['endpointItem'] = dialogData.value
|
||||||
|
.rowData!.varsJson['endpointItem'].replace('https://', '')
|
||||||
|
.replace('http://', '');
|
||||||
item['endpoint'] = endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem'];
|
item['endpoint'] = endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem'];
|
||||||
item['endpointItem'] = undefined;
|
item['endpointItem'] = undefined;
|
||||||
}
|
}
|
||||||
@ -211,6 +213,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
if (!dialogData.value.rowData) return;
|
if (!dialogData.value.rowData) return;
|
||||||
if (dialogData.value.rowData!.type === 'MINIO') {
|
if (dialogData.value.rowData!.type === 'MINIO') {
|
||||||
|
dialogData.value.rowData!.varsJson['endpointItem'].replace('https://', '').replace('http://', '');
|
||||||
dialogData.value.rowData!.varsJson['endpoint'] =
|
dialogData.value.rowData!.varsJson['endpoint'] =
|
||||||
endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem'];
|
endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem'];
|
||||||
dialogData.value.rowData!.varsJson['endpointItem'] = undefined;
|
dialogData.value.rowData!.varsJson['endpointItem'] = undefined;
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
>
|
>
|
||||||
{{ $t('commons.button.sync') }}
|
{{ $t('commons.button.sync') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<span v-show="show">{{ count }} S</span>
|
<span v-show="show">{{ count }} {{ $t('setting.second') }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -129,6 +129,8 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { useTheme } from '@/hooks/use-theme';
|
import { useTheme } from '@/hooks/use-theme';
|
||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
import Password from '@/views/setting/panel/password/index.vue';
|
import Password from '@/views/setting/panel/password/index.vue';
|
||||||
|
import router from '@/routers';
|
||||||
|
import { logOutApi } from '@/api/modules/auth';
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
@ -214,7 +216,15 @@ const onSave = async (formEl: FormInstance | undefined, key: string, val: any) =
|
|||||||
value: val + '',
|
value: val + '',
|
||||||
};
|
};
|
||||||
await updateSetting(param)
|
await updateSetting(param)
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
|
loading.value = false;
|
||||||
|
MsgSuccess(i18n.t('commons.msg.operationSuccess'));
|
||||||
|
if (param.key === 'UserName') {
|
||||||
|
await logOutApi();
|
||||||
|
router.push({ name: 'login', params: { code: '' } });
|
||||||
|
globalStore.setLogStatus(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
MsgSuccess(i18n.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.t('commons.msg.operationSuccess'));
|
||||||
search();
|
search();
|
||||||
|
@ -59,6 +59,7 @@ import { GlobalStore } from '@/store';
|
|||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { updatePassword } from '@/api/modules/setting';
|
import { updatePassword } from '@/api/modules/setting';
|
||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
|
import { logOutApi } from '@/api/modules/auth';
|
||||||
|
|
||||||
const globalStore = GlobalStore();
|
const globalStore = GlobalStore();
|
||||||
const passFormRef = ref<FormInstance>();
|
const passFormRef = ref<FormInstance>();
|
||||||
@ -113,10 +114,11 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => {
|
|||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await updatePassword({ oldPassword: passForm.oldPassword, newPassword: password })
|
await updatePassword({ oldPassword: passForm.oldPassword, newPassword: password })
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
passwordVisiable.value = false;
|
passwordVisiable.value = false;
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
|
await logOutApi();
|
||||||
router.push({ name: 'login', params: { code: '' } });
|
router.push({ name: 'login', params: { code: '' } });
|
||||||
globalStore.setLogStatus(false);
|
globalStore.setLogStatus(false);
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user