1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-13 17:24:44 +08:00

fix: 修改数据库配置文件不存在提示信息 (#2226)

This commit is contained in:
ssongliu 2023-09-08 23:10:17 +08:00 committed by GitHub
parent 6b908d2553
commit 9e5a452245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 11 deletions

View File

@ -115,7 +115,6 @@ func (d *DatabaseRepo) WithTypeList(dbType string) DBOption {
values = append(values, ty)
}
}
fmt.Println(strings.Join(rules, " OR "))
return g.Where(strings.Join(rules, " OR "), values...)
}
}

View File

@ -31,7 +31,7 @@ func NewLocal(command []string, containerName, password, database string) *Local
func (r *Local) Create(info CreateInfo) error {
createSql := fmt.Sprintf("create database `%s` default character set %s collate %s", info.Name, info.Format, formatMap[info.Format])
if err := r.ExecSQL(createSql, info.Timeout); err != nil {
if strings.Contains(err.Error(), "ERROR 1007") {
if strings.Contains(strings.ToLower(err.Error()), "error 1007") {
return buserr.New(constant.ErrDatabaseIsExist)
}
return err
@ -60,7 +60,7 @@ func (r *Local) CreateUser(info CreateInfo, withDeleteDB bool) error {
for _, user := range userlist {
if err := r.ExecSQL(fmt.Sprintf("create user %s identified by '%s';", user, info.Password), info.Timeout); err != nil {
if strings.Contains(err.Error(), "ERROR 1396") {
if strings.Contains(strings.ToLower(err.Error()), "error 1396") {
return buserr.New(constant.ErrUserIsExist)
}
_ = r.Delete(DeleteInfo{

View File

@ -32,7 +32,7 @@ func NewRemote(db Remote) *Remote {
func (r *Remote) Create(info CreateInfo) error {
createSql := fmt.Sprintf("create database `%s` default character set %s collate %s", info.Name, info.Format, formatMap[info.Format])
if err := r.ExecSQL(createSql, info.Timeout); err != nil {
if strings.Contains(strings.ToLower(err.Error()), "ERROR 1007") {
if strings.Contains(strings.ToLower(err.Error()), "error 1007") {
return buserr.New(constant.ErrDatabaseIsExist)
}
return err

View File

@ -67,13 +67,13 @@ export const loadBaseDir = () => {
// backup
export const handleBackup = (params: Backup.Backup) => {
return http.post(`/settings/backup/backup`, params, 600000);
return http.post(`/settings/backup/backup`, params, 3600000);
};
export const handleRecover = (params: Backup.Recover) => {
return http.post(`/settings/backup/recover`, params, 600000);
return http.post(`/settings/backup/recover`, params, 86400000);
};
export const handleRecoverByUpload = (params: Backup.Recover) => {
return http.post(`/settings/backup/recover/byupload`, params, 600000);
return http.post(`/settings/backup/recover/byupload`, params, 86400000);
};
export const downloadBackupRecord = (params: Backup.RecordDownload) => {
return http.post<string>(`/settings/backup/record/download`, params, 600000);

View File

@ -338,6 +338,8 @@ const message = {
'The database has been associated with an application. Changing the password will change the database password of the application at the same time. The change takes effect after the application restarts.',
confChange: 'Configuration change',
confNotFound:
'The configuration file could not be found. Please upgrade the application to the latest version in the app store and try again!',
portHelper:
'This port is the exposed port of the container. You need to save the modification separately and restart the container!',

View File

@ -334,6 +334,7 @@ const message = {
portHelper: '該端口為容器對外暴露端口修改需要單獨保存並且重啟容器',
confChange: '配置修改',
confNotFound: '未能找到該應用配置文件請在應用商店升級該應用至最新版本後重試',
loadFromRemote: '從服務器獲取',
loadFromRemoteHelper: '此操作將同步服務器上數據庫信息到 1Panel是否繼續',

View File

@ -334,6 +334,7 @@ const message = {
portHelper: '该端口为容器对外暴露端口修改需要单独保存并且重启容器',
confChange: '配置修改',
confNotFound: '未能找到该应用配置文件请在应用商店升级该应用至最新版本后重试',
loadFromRemote: '从服务器获取',
loadFromRemoteHelper: '此操作将同步服务器上数据库信息到 1Panel是否继续',

View File

@ -136,7 +136,7 @@ import { loadDatabaseFile, loadMysqlBaseInfo, loadMysqlVariables, updateMysqlCon
import { ChangePort, CheckAppInstalled, GetAppDefaultConfig } from '@/api/modules/app';
import { Rules } from '@/global/form-rules';
import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message';
import { MsgError, MsgSuccess } from '@/utils/message';
const loading = ref(false);
@ -306,9 +306,15 @@ const loadSlowLogs = async () => {
const loadMysqlConf = async () => {
useOld.value = false;
const res = await loadDatabaseFile(props.type + '-conf', props.database);
loading.value = false;
mysqlConf.value = res.data;
await loadDatabaseFile(props.type + '-conf', props.database)
.then((res) => {
loading.value = false;
mysqlConf.value = res.data;
})
.catch(() => {
MsgError(i18n.global.t('database.confNotFound'));
loading.value = false;
});
};
const onLoadInfo = async () => {