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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
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};
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -286,26 +286,38 @@
|
||||
render-to-body
|
||||
@cancel="handlePreviewCancel"
|
||||
>
|
||||
<a-scrollbar style="height: 700px; overflow: auto">
|
||||
<a-tabs type="card" size="large">
|
||||
<a-tab-pane
|
||||
v-for="item in generatePreviewList"
|
||||
:key="item.fileName"
|
||||
:title="item.fileName"
|
||||
<div>
|
||||
<a-scrollbar style="height: 700px; overflow: auto">
|
||||
<a-link
|
||||
style="position: absolute; right: 20px; top: 50px; z-index: 999"
|
||||
@click="handleCopy"
|
||||
>
|
||||
<codemirror
|
||||
v-model="item.content"
|
||||
:autofocus="true"
|
||||
:extensions="extensions"
|
||||
/>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-scrollbar>
|
||||
<template #icon>
|
||||
<icon-copy size="large" />
|
||||
</template>
|
||||
复制
|
||||
</a-link>
|
||||
<a-tabs size="large" @tab-click="handleTabClick">
|
||||
<a-tab-pane
|
||||
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>
|
||||
</template>
|
||||
|
||||
<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 { java } from '@codemirror/lang-java';
|
||||
import { javascript } from '@codemirror/lang-javascript';
|
||||
@ -331,6 +343,7 @@
|
||||
'query_type_enum',
|
||||
);
|
||||
|
||||
const { copy, copied } = useClipboard();
|
||||
const extensions = [java(), javascript()];
|
||||
const tableList = ref<TableRecord[]>([]);
|
||||
const fieldConfigList = ref<FieldConfigRecord[]>([]);
|
||||
@ -340,6 +353,7 @@
|
||||
const loading = ref(false);
|
||||
const visible = ref(false);
|
||||
const fieldConfigLoading = ref(false);
|
||||
const copyCodeContent = ref();
|
||||
const generatePreviewList = ref<GeneratePreviewRecord[]>([]);
|
||||
const previewVisible = ref(false);
|
||||
|
||||
@ -463,6 +477,7 @@
|
||||
const handlePreview = (tableName: string) => {
|
||||
preview(tableName).then((res) => {
|
||||
generatePreviewList.value = res.data;
|
||||
copyCodeContent.value = generatePreviewList.value[0].content;
|
||||
previewVisible.value = true;
|
||||
});
|
||||
};
|
||||
@ -472,9 +487,34 @@
|
||||
*/
|
||||
const handlePreviewCancel = () => {
|
||||
generatePreviewList.value = [];
|
||||
copyCodeContent.value = '';
|
||||
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