diff --git a/mayfly_go_web/src/views/login/component/Account.vue b/mayfly_go_web/src/views/login/component/Account.vue index 15fed505..3588703b 100644 --- a/mayfly_go_web/src/views/login/component/Account.vue +++ b/mayfly_go_web/src/views/login/component/Account.vue @@ -71,8 +71,8 @@ export default defineComponent({ const state = reactive({ captchaImage: '', loginForm: { - username: 'test', - password: '123456', + username: '', + password: '', captcha: '', cid: '', }, diff --git a/mayfly_go_web/src/views/ops/db/SqlExec.vue b/mayfly_go_web/src/views/ops/db/SqlExec.vue index 8cdc3852..7278ed0f 100644 --- a/mayfly_go_web/src/views/ops/db/SqlExec.vue +++ b/mayfly_go_web/src/views/ops/db/SqlExec.vue @@ -31,6 +31,24 @@ 保存 + +
+ + sql脚本执行 + +
@@ -95,6 +113,8 @@ import sqlFormatter from 'sql-formatter'; import { notNull, notEmpty } from '@/common/assert'; import { ElMessage } from 'element-plus'; import ProjectEnvSelect from '../component/ProjectEnvSelect.vue'; +import config from '@/common/config'; +import { getSession } from '@/common/utils/storage'; export default defineComponent({ name: 'SqlExec', @@ -104,7 +124,10 @@ export default defineComponent({ }, setup() { const cmEditor: any = ref(null); + const token = getSession('token'); + const state = reactive({ + token: token, dbs: [], tables: [], dbId: null, @@ -201,6 +224,26 @@ export default defineComponent({ state.execRes.data = res.res; }; + const beforeUpload = (file: File) => { + if (!state.dbId) { + ElMessage.error('请先选择数据库'); + return false; + } + ElMessage.success(`'${file.name}' 正在上传执行, 请关注结果通知`); + }; + + // 执行sql成功 + const execSqlFileSuccess = (res: any) => { + if (res.code !== 200) { + ElMessage.error(res.msg); + } + }; + + // 获取sql文件上传执行url + const getUploadSqlFileUrl = () => { + return `${config.baseApiUrl}/dbs/${state.dbId}/exec-sql-file`; + }; + const flexColumnWidth = (str: any, tableData: any, flag = 'equal') => { // str为该列的字段名(传字符串);tableData为该表格的数据源(传变量); // flag为可选值,可不传该参数,传参时可选'max'或'equal',默认为'max' @@ -244,10 +287,10 @@ export default defineComponent({ flexWidth += 8; } else if (char >= '\u4e00' && char <= '\u9fa5') { // 如果是中文字符,为字符分配15个单位宽度 - flexWidth += 15; + flexWidth += 16; } else { - // 其他种类字符,为字符分配8个单位宽度 - flexWidth += 8; + // 其他种类字符,为字符分配10个单位宽度 + flexWidth += 10; } } if (flexWidth < 80) { @@ -367,6 +410,9 @@ export default defineComponent({ inputRead, changeTable, runSql, + beforeUpload, + getUploadSqlFileUrl, + execSqlFileSuccess, flexColumnWidth, saveSql, changeDb, diff --git a/mayfly_go_web/src/views/ops/machine/ServiceManage.vue b/mayfly_go_web/src/views/ops/machine/ServiceManage.vue index 242f276c..dac95a50 100644 --- a/mayfly_go_web/src/views/ops/machine/ServiceManage.vue +++ b/mayfly_go_web/src/views/ops/machine/ServiceManage.vue @@ -219,13 +219,31 @@ export default defineComponent({ } if (script.type == enums.scriptTypeEnum['REAL_TIME'].value) { - state.terminalDialog.cmd = script.script; + script = script.script + if (state.scriptParamsDialog.params) { + script = templateResolve(script, state.scriptParamsDialog.params) + } + state.terminalDialog.cmd = script; state.terminalDialog.visible = true; state.terminalDialog.machineId = props.machineId; return; } }; + /** + * 解析 {{.param}} 形式模板字符串 + */ + function templateResolve(template: string, param: any) { + return template.replace(/\{{.\w+\}}/g, (word) => { + const key = word.substring(3, word.length - 2); + const value = param[key]; + if (value != null || value != undefined) { + return value; + } + return ''; + }); + } + const closeTermnial = () => { state.terminalDialog.visible = false; state.terminalDialog.machineId = 0; diff --git a/mayfly_go_web/src/views/personal/index.vue b/mayfly_go_web/src/views/personal/index.vue index ca6b365b..dc8997be 100644 --- a/mayfly_go_web/src/views/personal/index.vue +++ b/mayfly_go_web/src/views/personal/index.vue @@ -50,11 +50,11 @@
@@ -62,6 +62,31 @@ + + + + + + + + + + + + +