mirror of https://github.com/1Panel-dev/1Panel
fix: mysql 数据库连接信息样式调整 (#1857)
parent
07d5c580a6
commit
20a47afb8c
|
@ -20,7 +20,7 @@ type IMysqlRepo interface {
|
||||||
Delete(ctx context.Context, opts ...DBOption) error
|
Delete(ctx context.Context, opts ...DBOption) error
|
||||||
Update(id uint, vars map[string]interface{}) error
|
Update(id uint, vars map[string]interface{}) error
|
||||||
UpdateDatabaseInfo(id uint, vars map[string]interface{}) error
|
UpdateDatabaseInfo(id uint, vars map[string]interface{}) error
|
||||||
DeleteAll(ctx context.Context) error
|
DeleteLocal(ctx context.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIMysqlRepo() IMysqlRepo {
|
func NewIMysqlRepo() IMysqlRepo {
|
||||||
|
@ -67,8 +67,8 @@ func (u *MysqlRepo) Delete(ctx context.Context, opts ...DBOption) error {
|
||||||
return getTx(ctx, opts...).Delete(&model.DatabaseMysql{}).Error
|
return getTx(ctx, opts...).Delete(&model.DatabaseMysql{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *MysqlRepo) DeleteAll(ctx context.Context) error {
|
func (u *MysqlRepo) DeleteLocal(ctx context.Context) error {
|
||||||
return getTx(ctx).Where("1 = 1").Delete(&model.DatabaseMysql{}).Error
|
return getTx(ctx).Where("`from` = ?", "local").Delete(&model.DatabaseMysql{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *MysqlRepo) Update(id uint, vars map[string]interface{}) error {
|
func (u *MysqlRepo) Update(id uint, vars map[string]interface{}) error {
|
||||||
|
|
|
@ -200,7 +200,7 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b
|
||||||
_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name))
|
_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name))
|
||||||
_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(install.App.Key))
|
_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(install.App.Key))
|
||||||
if install.App.Key == constant.AppMysql {
|
if install.App.Key == constant.AppMysql {
|
||||||
_ = mysqlRepo.DeleteAll(ctx)
|
_ = mysqlRepo.DeleteLocal(ctx)
|
||||||
}
|
}
|
||||||
uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/app/%s/%s", install.App.Key, install.Name))
|
uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/app/%s/%s", install.App.Key, install.Name))
|
||||||
if _, err := os.Stat(uploadDir); err == nil {
|
if _, err := os.Stat(uploadDir); err == nil {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</span>
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('database.remoteConn')">
|
<el-form-item :label="$t('database.remoteConn')">
|
||||||
<el-tag>{{ $t('database.localIP') + ':' + form.port }}</el-tag>
|
<el-tag>{{ form.systemIP + ':' + form.port }}</el-tag>
|
||||||
<span class="input-help">{{ $t('database.remoteConnHelper2') }}</span>
|
<span class="input-help">{{ $t('database.remoteConnHelper2') }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ import { GetAppConnInfo } from '@/api/modules/app';
|
||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
import { getRandomStr } from '@/utils/util';
|
import { getRandomStr } from '@/utils/util';
|
||||||
|
import { getSettingInfo } from '@/api/modules/setting';
|
||||||
import useClipboard from 'vue-clipboard3';
|
import useClipboard from 'vue-clipboard3';
|
||||||
const { toClipboard } = useClipboard();
|
const { toClipboard } = useClipboard();
|
||||||
|
|
||||||
|
@ -88,6 +89,7 @@ const loading = ref(false);
|
||||||
|
|
||||||
const dialogVisiable = ref(false);
|
const dialogVisiable = ref(false);
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
|
systemIP: '',
|
||||||
password: '',
|
password: '',
|
||||||
serviceName: '',
|
serviceName: '',
|
||||||
privilege: false,
|
privilege: false,
|
||||||
|
@ -112,11 +114,10 @@ interface DialogProps {
|
||||||
const acceptParams = (param: DialogProps): void => {
|
const acceptParams = (param: DialogProps): void => {
|
||||||
form.password = '';
|
form.password = '';
|
||||||
form.from = param.from;
|
form.from = param.from;
|
||||||
if (form.from !== 'local') {
|
if (form.from === 'local') {
|
||||||
loadRemoteInfo();
|
loadAccess();
|
||||||
}
|
}
|
||||||
loadPassword();
|
loadPassword();
|
||||||
loadAccess();
|
|
||||||
dialogVisiable.value = true;
|
dialogVisiable.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,18 +143,26 @@ const loadAccess = async () => {
|
||||||
form.privilege = res.data;
|
form.privilege = res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadRemoteInfo = async () => {
|
const loadSystemIP = async () => {
|
||||||
const res = await getRemoteDB(form.from);
|
const res = await getSettingInfo();
|
||||||
form.remoteIP = res.data.address;
|
form.systemIP = res.data.systemIP || i18n.global.t('database.localIP');
|
||||||
form.username = res.data.username;
|
|
||||||
form.password = res.data.password;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadPassword = async () => {
|
const loadPassword = async () => {
|
||||||
const res = await GetAppConnInfo('mysql');
|
if (form.from === 'local') {
|
||||||
|
const res = await GetAppConnInfo('mysql');
|
||||||
|
form.password = res.data.password || '';
|
||||||
|
form.port = res.data.port || 3306;
|
||||||
|
form.serviceName = res.data.serviceName || '';
|
||||||
|
loadSystemIP();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const res = await getRemoteDB(form.from);
|
||||||
form.password = res.data.password || '';
|
form.password = res.data.password || '';
|
||||||
form.port = res.data.port || 3306;
|
form.port = res.data.port || 3306;
|
||||||
form.serviceName = res.data.serviceName || '';
|
form.username = res.data.username;
|
||||||
|
form.password = res.data.password;
|
||||||
|
form.remoteIP = res.data.address;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
>
|
>
|
||||||
{{ $t('database.create') }}
|
{{ $t('database.create') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="onChangeConn" type="primary" plain>
|
<el-button :disabled="!mysqlIsExist && isLocal()" @click="onChangeConn" type="primary" plain>
|
||||||
{{ $t('database.databaseConnInfo') }}
|
{{ $t('database.databaseConnInfo') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
|
|
Loading…
Reference in New Issue