pull/27/merge
watchingfun 2 years ago committed by GitHub
commit 45bc403fc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -11,10 +11,12 @@
"@ant-design/icons-vue": "^6.1.0", "@ant-design/icons-vue": "^6.1.0",
"ant-design-vue": "^3.2.3", "ant-design-vue": "^3.2.3",
"monaco-editor": "^0.33.0", "monaco-editor": "^0.33.0",
"splitpanes": "^3.1.5",
"sql-formatter": "^4.0.2", "sql-formatter": "^4.0.2",
"vue": "^3.2.25" "vue": "^3.2.25"
}, },
"devDependencies": { "devDependencies": {
"@types/splitpanes": "^2.2.6",
"@typescript-eslint/eslint-plugin": "^5.23.0", "@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0", "@typescript-eslint/parser": "^5.23.0",
"@vitejs/plugin-vue": "^2.3.1", "@vitejs/plugin-vue": "^2.3.1",

@ -5,6 +5,8 @@ import { onMounted, ref, toRaw } from "vue";
import * as monaco from "monaco-editor"; import * as monaco from "monaco-editor";
import { format } from "sql-formatter"; import { format } from "sql-formatter";
import { GithubOutlined } from "@ant-design/icons-vue"; import { GithubOutlined } from "@ant-design/icons-vue";
import { Splitpanes, Pane } from "splitpanes";
import "splitpanes/dist/splitpanes.css";
import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker"; import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
import JsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker"; import JsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker";
@ -137,22 +139,22 @@ onMounted(() => {
</a-space> </a-space>
</a-row> </a-row>
<div style="margin-top: 16px" /> <div style="margin-top: 16px" />
<a-row :gutter="[16, 16]"> <splitpanes class="default-theme">
<a-col :sm="24" :md="12"> <pane>
<div <div
id="inputContainer" id="inputContainer"
ref="inputContainer" ref="inputContainer"
style="height: 80vh; max-width: 100%" style="height: 80vh; max-width: 100%"
/> />
</a-col> </pane>
<a-col :sm="24" :md="12"> <pane>
<div <div
id="outputContainer" id="outputContainer"
ref="outputContainer" ref="outputContainer"
style="height: 80vh; max-width: 100%" style="height: 80vh; max-width: 100%"
/> />
</a-col> </pane>
</a-row> </splitpanes>
<br /> <br />
<div style="margin-bottom: 16px"> <div style="margin-bottom: 16px">
yupi你能体会手写一句 3000 行的 SQL牵一发而动全身的恐惧么 yupi你能体会手写一句 3000 行的 SQL牵一发而动全身的恐惧么

@ -14,9 +14,15 @@
@expand="onExpand" @expand="onExpand"
> >
<template #title="{ title, sql, params, resultSQL }"> <template #title="{ title, sql, params, resultSQL }">
<a-popover title="详情" placement="top"> <a-popover title="详情" placement="top" trigger="click">
<template #content> <template #content>
<div style="max-width: 600px"> <div
style="
max-width: 600px;
max-height: calc(100vh - 70px);
overflow: auto;
"
>
<p> <p>
<b>替换前语句</b> <b>替换前语句</b>
<a-typography-paragraph copyable> <a-typography-paragraph copyable>
@ -51,12 +57,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from "vue"; import { ref, watch } from "vue";
const props = defineProps<{ tree?: InvokeTree }>(); const props = withDefaults(defineProps<{ tree?: InvokeTree }>(), {
tree: () => [],
const tree = ref(props.tree); });
if (!tree.value) {
tree.value = [];
}
const expandedKeys = ref<string[]>([]); const expandedKeys = ref<string[]>([]);
const searchValue = ref<string>(""); const searchValue = ref<string>("");
@ -98,16 +101,16 @@ const generateList = (data: InvokeTreeNode[], preKey: string) => {
} }
} }
}; };
generateList(tree.value, ""); generateList(props.tree, "");
watch(searchValue, (value) => { watch(searchValue, (value) => {
if (!tree?.value) { if (!props.tree.length) {
return; return;
} }
expandedKeys.value = dataList expandedKeys.value = dataList
.map((item: InvokeTreeNode) => { .map((item: InvokeTreeNode) => {
if (item.title.indexOf(value) > -1) { if (item.title.indexOf(value) > -1) {
return getParentKey(item.key, tree.value as InvokeTree); return getParentKey(item.key, props.tree as InvokeTree);
} }
return null; return null;
}) })

@ -11,7 +11,7 @@ export function doGenerateSQL(json: InputJSON) {
if (!sql) { if (!sql) {
return null; return null;
} }
const initTreeNode = { const initTreeNode: InvokeTreeNode = {
title: "main", title: "main",
sql, sql,
children: [], children: [],
@ -26,7 +26,7 @@ export function doGenerateSQL(json: InputJSON) {
); );
return { return {
resultSQL, resultSQL,
invokeTree: rootInvokeTreeNode.children[0], // 取第一个作为根节点 invokeTree: rootInvokeTreeNode.children![0], // 取第一个作为根节点
}; };
} }
@ -156,7 +156,7 @@ function replaceSubSql(
const params: Record<string, string> = {}; const params: Record<string, string> = {};
for (const singleParamsStr of singleParamsStrArray) { for (const singleParamsStr of singleParamsStrArray) {
// 必须分成 2 段 // 必须分成 2 段
const keyValueArray = singleParamsStr.split("=", 2); const keyValueArray = singleParamsStr.split(/=(.+)/, 2);
if (keyValueArray.length < 2) { if (keyValueArray.length < 2) {
continue; continue;
} }

Loading…
Cancel
Save