refactor: 优化生成预览功能,增加复制按钮
1.增加复制按钮 2.移除模板内协议头信息
This commit is contained in:
parent
401702972f
commit
505ba49a53
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import top.charles7c.continew.starter.extension.crud.enums.Api;
|
import top.charles7c.continew.starter.extension.crud.enums.Api;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
import top.charles7c.continew.starter.extension.crud.base.BaseMapper;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import top.charles7c.continew.starter.extension.crud.base.BaseService;
|
import top.charles7c.continew.starter.extension.crud.base.BaseService;
|
||||||
|
@ -1,19 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ${packageName}.${subPackageName};
|
package ${packageName}.${subPackageName};
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
@ -286,26 +286,38 @@
|
|||||||
render-to-body
|
render-to-body
|
||||||
@cancel="handlePreviewCancel"
|
@cancel="handlePreviewCancel"
|
||||||
>
|
>
|
||||||
<a-scrollbar style="height: 700px; overflow: auto">
|
<div>
|
||||||
<a-tabs type="card" size="large">
|
<a-scrollbar style="height: 700px; overflow: auto">
|
||||||
<a-tab-pane
|
<a-link
|
||||||
v-for="item in generatePreviewList"
|
style="position: absolute; right: 20px; top: 50px; z-index: 999"
|
||||||
:key="item.fileName"
|
@click="handleCopy"
|
||||||
:title="item.fileName"
|
|
||||||
>
|
>
|
||||||
<codemirror
|
<template #icon>
|
||||||
v-model="item.content"
|
<icon-copy size="large" />
|
||||||
:autofocus="true"
|
</template>
|
||||||
:extensions="extensions"
|
复制
|
||||||
/>
|
</a-link>
|
||||||
</a-tab-pane>
|
<a-tabs size="large" @tab-click="handleTabClick">
|
||||||
</a-tabs>
|
<a-tab-pane
|
||||||
</a-scrollbar>
|
v-for="item in generatePreviewList"
|
||||||
|
:key="item.fileName"
|
||||||
|
:title="item.fileName"
|
||||||
|
>
|
||||||
|
<codemirror
|
||||||
|
v-model="item.content"
|
||||||
|
:autofocus="true"
|
||||||
|
:extensions="extensions"
|
||||||
|
/>
|
||||||
|
</a-tab-pane>
|
||||||
|
</a-tabs>
|
||||||
|
</a-scrollbar>
|
||||||
|
</div>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive, watch } from 'vue';
|
||||||
|
import { useClipboard } from '@vueuse/core';
|
||||||
import { Codemirror } from 'vue-codemirror';
|
import { Codemirror } from 'vue-codemirror';
|
||||||
import { java } from '@codemirror/lang-java';
|
import { java } from '@codemirror/lang-java';
|
||||||
import { javascript } from '@codemirror/lang-javascript';
|
import { javascript } from '@codemirror/lang-javascript';
|
||||||
@ -331,6 +343,7 @@
|
|||||||
'query_type_enum',
|
'query_type_enum',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { copy, copied } = useClipboard();
|
||||||
const extensions = [java(), javascript()];
|
const extensions = [java(), javascript()];
|
||||||
const tableList = ref<TableRecord[]>([]);
|
const tableList = ref<TableRecord[]>([]);
|
||||||
const fieldConfigList = ref<FieldConfigRecord[]>([]);
|
const fieldConfigList = ref<FieldConfigRecord[]>([]);
|
||||||
@ -340,6 +353,7 @@
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const fieldConfigLoading = ref(false);
|
const fieldConfigLoading = ref(false);
|
||||||
|
const copyCodeContent = ref();
|
||||||
const generatePreviewList = ref<GeneratePreviewRecord[]>([]);
|
const generatePreviewList = ref<GeneratePreviewRecord[]>([]);
|
||||||
const previewVisible = ref(false);
|
const previewVisible = ref(false);
|
||||||
|
|
||||||
@ -463,6 +477,7 @@
|
|||||||
const handlePreview = (tableName: string) => {
|
const handlePreview = (tableName: string) => {
|
||||||
preview(tableName).then((res) => {
|
preview(tableName).then((res) => {
|
||||||
generatePreviewList.value = res.data;
|
generatePreviewList.value = res.data;
|
||||||
|
copyCodeContent.value = generatePreviewList.value[0].content;
|
||||||
previewVisible.value = true;
|
previewVisible.value = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -472,9 +487,34 @@
|
|||||||
*/
|
*/
|
||||||
const handlePreviewCancel = () => {
|
const handlePreviewCancel = () => {
|
||||||
generatePreviewList.value = [];
|
generatePreviewList.value = [];
|
||||||
|
copyCodeContent.value = '';
|
||||||
previewVisible.value = false;
|
previewVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击 Tab
|
||||||
|
*
|
||||||
|
* @param key Tab 键
|
||||||
|
*/
|
||||||
|
const handleTabClick = (key: any) => {
|
||||||
|
copyCodeContent.value = generatePreviewList.value.filter(
|
||||||
|
(p) => p.fileName === key,
|
||||||
|
)[0].content;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制代码
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const handleCopy = () => {
|
||||||
|
copy(copyCodeContent.value);
|
||||||
|
};
|
||||||
|
watch(copied, () => {
|
||||||
|
if (copied.value) {
|
||||||
|
proxy.$message.success('复制成功');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码
|
* 生成代码
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user