|
@@ -55,7 +55,7 @@
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="API路径" prop="path">
|
|
<el-form-item label="API路径" prop="path">
|
|
<div class="path-input-container">
|
|
<div class="path-input-container">
|
|
- <div class="path-prefix">
|
|
|
|
|
|
+ <div class="path-prefix2">
|
|
{{ originUrl }}
|
|
{{ originUrl }}
|
|
</div>
|
|
</div>
|
|
<el-input v-model="formData.path" placeholder="请输入API路径" class="path-input" />
|
|
<el-input v-model="formData.path" placeholder="请输入API路径" class="path-input" />
|
|
@@ -333,18 +333,18 @@ const editorDidMount = (editor) => {
|
|
if (editor) {
|
|
if (editor) {
|
|
// 设置焦点
|
|
// 设置焦点
|
|
editor.focus();
|
|
editor.focus();
|
|
-
|
|
|
|
|
|
+
|
|
// 添加输入监听,在用户开始输入时触发提示
|
|
// 添加输入监听,在用户开始输入时触发提示
|
|
editor.onDidChangeModelContent(() => {
|
|
editor.onDidChangeModelContent(() => {
|
|
// 触发自动提示
|
|
// 触发自动提示
|
|
editor.trigger('keyboard', 'editor.action.triggerSuggest', {});
|
|
editor.trigger('keyboard', 'editor.action.triggerSuggest', {});
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
// 初始化时就触发一次提示
|
|
// 初始化时就触发一次提示
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
editor.trigger('keyboard', 'editor.action.triggerSuggest', {});
|
|
editor.trigger('keyboard', 'editor.action.triggerSuggest', {});
|
|
}, 100);
|
|
}, 100);
|
|
-
|
|
|
|
|
|
+
|
|
// 添加键盘事件处理,阻止回车键触发表单提交
|
|
// 添加键盘事件处理,阻止回车键触发表单提交
|
|
editor.onKeyDown((e) => {
|
|
editor.onKeyDown((e) => {
|
|
// 当用户在编辑器中按下回车键时
|
|
// 当用户在编辑器中按下回车键时
|
|
@@ -361,16 +361,16 @@ const checkTabWithErrors = () => {
|
|
// 获取所有验证失败的字段
|
|
// 获取所有验证失败的字段
|
|
const fields = formRef.value.fields;
|
|
const fields = formRef.value.fields;
|
|
const errorFields = [];
|
|
const errorFields = [];
|
|
-
|
|
|
|
|
|
+
|
|
// 收集所有错误字段
|
|
// 收集所有错误字段
|
|
for (const field in fields) {
|
|
for (const field in fields) {
|
|
if (fields[field].validateState === 'error') {
|
|
if (fields[field].validateState === 'error') {
|
|
errorFields.push(field);
|
|
errorFields.push(field);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (errorFields.length === 0) return;
|
|
if (errorFields.length === 0) return;
|
|
-
|
|
|
|
|
|
+
|
|
// 基本信息标签页的字段
|
|
// 基本信息标签页的字段
|
|
const basicTabFields = ['name', 'path', 'version', 'description', 'groupKey'];
|
|
const basicTabFields = ['name', 'path', 'version', 'description', 'groupKey'];
|
|
// 执行器标签页的字段
|
|
// 执行器标签页的字段
|
|
@@ -383,10 +383,10 @@ const checkTabWithErrors = () => {
|
|
pluginsTabFields.push(field);
|
|
pluginsTabFields.push(field);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
// 检查每个标签页并切换到有错误的标签页
|
|
// 检查每个标签页并切换到有错误的标签页
|
|
const errorTabs = [];
|
|
const errorTabs = [];
|
|
-
|
|
|
|
|
|
+
|
|
if (errorFields.some(field => basicTabFields.includes(field))) {
|
|
if (errorFields.some(field => basicTabFields.includes(field))) {
|
|
errorTabs.push({ tab: 'basic', name: '基本信息' });
|
|
errorTabs.push({ tab: 'basic', name: '基本信息' });
|
|
}
|
|
}
|
|
@@ -396,17 +396,17 @@ const checkTabWithErrors = () => {
|
|
if (pluginsTabFields.length > 0) {
|
|
if (pluginsTabFields.length > 0) {
|
|
errorTabs.push({ tab: 'plugins', name: '全局插件' });
|
|
errorTabs.push({ tab: 'plugins', name: '全局插件' });
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (errorTabs.length > 0) {
|
|
if (errorTabs.length > 0) {
|
|
// 如果当前标签页不在错误标签页列表中,切换到第一个错误标签页
|
|
// 如果当前标签页不在错误标签页列表中,切换到第一个错误标签页
|
|
const currentTabHasError = errorTabs.some(tab => tab.tab === activeTab.value);
|
|
const currentTabHasError = errorTabs.some(tab => tab.tab === activeTab.value);
|
|
if (!currentTabHasError) {
|
|
if (!currentTabHasError) {
|
|
activeTab.value = errorTabs[0].tab;
|
|
activeTab.value = errorTabs[0].tab;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 显示错误提示
|
|
// 显示错误提示
|
|
showErrorTooltip(errorTabs);
|
|
showErrorTooltip(errorTabs);
|
|
-
|
|
|
|
|
|
+
|
|
// 等待DOM更新后滚动到错误字段
|
|
// 等待DOM更新后滚动到错误字段
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
const errorElement = document.querySelector('.is-error');
|
|
const errorElement = document.querySelector('.is-error');
|
|
@@ -428,7 +428,7 @@ const showErrorTooltip = (errorTabs) => {
|
|
});
|
|
});
|
|
errorMessage += '</ul>';
|
|
errorMessage += '</ul>';
|
|
errorMessage += '</div>';
|
|
errorMessage += '</div>';
|
|
-
|
|
|
|
|
|
+
|
|
// 显示消息提示
|
|
// 显示消息提示
|
|
ElMessage({
|
|
ElMessage({
|
|
dangerouslyUseHTMLString: true,
|
|
dangerouslyUseHTMLString: true,
|
|
@@ -441,7 +441,7 @@ const showErrorTooltip = (errorTabs) => {
|
|
removeErrorTabClickListeners();
|
|
removeErrorTabClickListeners();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
// 等待DOM更新后添加点击事件
|
|
// 等待DOM更新后添加点击事件
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
addErrorTabClickListeners();
|
|
addErrorTabClickListeners();
|
|
@@ -612,10 +612,10 @@ const onSubmit = () => {
|
|
// 验证失败
|
|
// 验证失败
|
|
// 直接显示错误提示
|
|
// 直接显示错误提示
|
|
showValidationErrorMessage(fields);
|
|
showValidationErrorMessage(fields);
|
|
-
|
|
|
|
|
|
+
|
|
// 验证失败时检查是哪个标签页的必填项出错
|
|
// 验证失败时检查是哪个标签页的必填项出错
|
|
checkTabWithErrors();
|
|
checkTabWithErrors();
|
|
-
|
|
|
|
|
|
+
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -626,15 +626,15 @@ const showValidationErrorMessage = (fields) => {
|
|
// 获取所有错误字段
|
|
// 获取所有错误字段
|
|
const errorFields = Object.keys(fields);
|
|
const errorFields = Object.keys(fields);
|
|
if (errorFields.length === 0) return;
|
|
if (errorFields.length === 0) return;
|
|
-
|
|
|
|
|
|
+
|
|
// 基本信息标签页的字段
|
|
// 基本信息标签页的字段
|
|
const basicTabFields = ['name', 'path', 'version', 'description', 'groupKey'];
|
|
const basicTabFields = ['name', 'path', 'version', 'description', 'groupKey'];
|
|
// 执行器标签页的字段
|
|
// 执行器标签页的字段
|
|
const executorTabFields = ['dataSourceKey', 'sqlType', 'sqlContent', 'returnFormat', 'status'];
|
|
const executorTabFields = ['dataSourceKey', 'sqlType', 'sqlContent', 'returnFormat', 'status'];
|
|
-
|
|
|
|
|
|
+
|
|
// 检查每个标签页的错误
|
|
// 检查每个标签页的错误
|
|
const errorTabs = [];
|
|
const errorTabs = [];
|
|
-
|
|
|
|
|
|
+
|
|
if (errorFields.some(field => basicTabFields.includes(field))) {
|
|
if (errorFields.some(field => basicTabFields.includes(field))) {
|
|
errorTabs.push('基本信息');
|
|
errorTabs.push('基本信息');
|
|
}
|
|
}
|
|
@@ -644,7 +644,7 @@ const showValidationErrorMessage = (fields) => {
|
|
if (errorFields.some(field => field.startsWith('plugins['))) {
|
|
if (errorFields.some(field => field.startsWith('plugins['))) {
|
|
errorTabs.push('全局插件');
|
|
errorTabs.push('全局插件');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (errorTabs.length > 0) {
|
|
if (errorTabs.length > 0) {
|
|
// 显示错误消息
|
|
// 显示错误消息
|
|
ElMessage({
|
|
ElMessage({
|
|
@@ -936,8 +936,8 @@ defineExpose({ open });
|
|
width: 100%;
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
|
|
-.path-prefix {
|
|
|
|
- background-color: #f5f7fa;
|
|
|
|
|
|
+.path-prefix2 {
|
|
|
|
+ background-color: #eee;
|
|
padding: 0 10px;
|
|
padding: 0 10px;
|
|
height: 32px;
|
|
height: 32px;
|
|
line-height: 32px;
|
|
line-height: 32px;
|
|
@@ -948,6 +948,13 @@ defineExpose({ open });
|
|
white-space: nowrap;
|
|
white-space: nowrap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* 深色主题下的样式 */
|
|
|
|
+[data-theme='dark'] .path-prefix2 {
|
|
|
|
+ background-color: #333;
|
|
|
|
+ border-color: #424242;
|
|
|
|
+ color: #dadada;
|
|
|
|
+}
|
|
|
|
+
|
|
.path-input {
|
|
.path-input {
|
|
flex: 1;
|
|
flex: 1;
|
|
}
|
|
}
|