feat: 接口生成页面弹窗改为平铺
parent
d7da0bd5f9
commit
5ccefbd65a
2
.env
2
.env
|
|
@ -6,7 +6,7 @@ VITE_TITLE = 绝弹管理后台
|
||||||
# 网站副标题
|
# 网站副标题
|
||||||
VITE_SUBTITLE = 快速开发web应用的模板工具
|
VITE_SUBTITLE = 快速开发web应用的模板工具
|
||||||
# 接口前缀 说明:参见 axios 的 baseURL
|
# 接口前缀 说明:参见 axios 的 baseURL
|
||||||
VITE_API = http://127.0.0.1:3030/
|
VITE_API = https://nest.dev.juetan.cn/
|
||||||
|
|
||||||
# =====================================================================================
|
# =====================================================================================
|
||||||
# 开发设置
|
# 开发设置
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<bread-page>
|
<bread-page>
|
||||||
<a-input v-model="name" placeholder="中文名称"></a-input>
|
<div class="h-full grid grid-cols-[auto_auto_1fr]">
|
||||||
<a-button @click="editorRef?.open()">打开</a-button>
|
<div class="w-[300px]">
|
||||||
<a-tabs type="capsule" @change="onChange">
|
<a-tabs type="capsule" @change="onChange">
|
||||||
<a-tab-pane v-for="tag in tags" :key="tag.name" :title="tag.description">
|
<a-tab-pane v-for="tag in tags" :key="tag.name" :title="tag.description">
|
||||||
<a-form :model="{}" layout="vertical">
|
<a-form :model="{}" layout="vertical">
|
||||||
|
|
@ -52,15 +52,25 @@
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
<editor-modal ref="editorRef"></editor-modal>
|
</div>
|
||||||
|
<a-divider direction="vertical"></a-divider>
|
||||||
|
<div class="h-full grid grid-rows-[auto_1fr] gap-2">
|
||||||
|
<div>
|
||||||
|
<a-button type="primary" @click="onOpen">确定</a-button>
|
||||||
|
</div>
|
||||||
|
<editor-modal class="bg-gray-100" :content="content"></editor-modal>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</bread-page>
|
</bread-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import doc from "@/dd.json";
|
import doc from "@/dd.json";
|
||||||
import editorModal from "./editor.vue";
|
import editorModal from "./editor.vue";
|
||||||
|
import ejs from "ejs";
|
||||||
|
import template from "./page.ejs?raw";
|
||||||
|
|
||||||
const editorRef = ref<InstanceType<typeof editorModal>>();
|
const content = ref("");
|
||||||
const { tags, routes } = doc;
|
const { tags, routes } = doc;
|
||||||
const type = ref({
|
const type = ref({
|
||||||
create: undefined,
|
create: undefined,
|
||||||
|
|
@ -68,11 +78,37 @@ const type = ref({
|
||||||
modify: undefined,
|
modify: undefined,
|
||||||
delete: undefined,
|
delete: undefined,
|
||||||
});
|
});
|
||||||
const name = ref('')
|
|
||||||
|
|
||||||
const onChange = (value: string | number) => {
|
const onChange = (value: string | number) => {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onOpen = () => {
|
||||||
|
const data = {
|
||||||
|
tag: '',
|
||||||
|
operationId: '',
|
||||||
|
create: {},
|
||||||
|
select: {},
|
||||||
|
modify: {},
|
||||||
|
delete: {},
|
||||||
|
};
|
||||||
|
for (const route of doc.routes) {
|
||||||
|
if (route.operationId === type.value.create) {
|
||||||
|
data.create = route;
|
||||||
|
}
|
||||||
|
if (route.operationId === type.value.select) {
|
||||||
|
data.select = route;
|
||||||
|
}
|
||||||
|
if (route.operationId === type.value.modify) {
|
||||||
|
data.modify = route;
|
||||||
|
}
|
||||||
|
if (route.operationId === type.value.delete) {
|
||||||
|
data.delete = route;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(data);
|
||||||
|
content.value = ejs.render(template, data);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped></style>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<a-modal v-model:visible="visible" :width="1280" title="编辑代码" title-align="start" @close="onClose">
|
<div ref="editorRef" class="w-full h-full border"></div>
|
||||||
<div class="h-[700px]">
|
|
||||||
<div id="editor1" class="w-full h-full"></div>
|
|
||||||
</div>
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import ejs from "ejs";
|
|
||||||
import * as monaco from "monaco-editor";
|
import * as monaco from "monaco-editor";
|
||||||
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
||||||
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
|
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
|
||||||
import htmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker";
|
import htmlWorker from "monaco-editor/esm/vs/language/html/html.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";
|
||||||
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";
|
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";
|
||||||
import pageStr from "./page.ejs?raw";
|
|
||||||
|
|
||||||
self.MonacoEnvironment = {
|
self.MonacoEnvironment = {
|
||||||
getWorker(_, label) {
|
getWorker(_, label) {
|
||||||
|
|
@ -34,26 +28,32 @@ self.MonacoEnvironment = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const visible = ref(false);
|
|
||||||
let editor: monaco.editor.IStandaloneCodeEditor | undefined;
|
let editor: monaco.editor.IStandaloneCodeEditor | undefined;
|
||||||
const onClose = () => {
|
const editorRef = ref<HTMLElement | null>(null);
|
||||||
editor?.dispose();
|
|
||||||
};
|
onMounted(async () => {
|
||||||
defineExpose({
|
|
||||||
async open() {
|
|
||||||
visible.value = true;
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
const box = document.getElementById("editor1")!;
|
if (editorRef.value) {
|
||||||
const code = ejs.render(pageStr, {
|
editor = monaco.editor.create(editorRef.value, {
|
||||||
tag: "user",
|
value: "",
|
||||||
operationId: "addUser",
|
|
||||||
});
|
|
||||||
editor = monaco.editor.create(box, {
|
|
||||||
value: code,
|
|
||||||
language: "html",
|
language: "html",
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
content: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.content,
|
||||||
|
(value) => {
|
||||||
|
editor?.setValue(value);
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped></style>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { createColumn, updateColumn, useAniTable } from "@/components";
|
||||||
|
|
||||||
const [aniTable, aniCtx] = useAniTable({
|
const [aniTable, aniCtx] = useAniTable({
|
||||||
data: async (model, paging) => {
|
data: async (model, paging) => {
|
||||||
return api.<%= tag %>.<%= operationId %>({ ...model, ...paging });
|
return api.<%= select.tag %>.<%= operationId %>({ ...model, ...paging });
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
|
|
@ -65,22 +65,24 @@ const [aniTable, aniCtx] = useAniTable({
|
||||||
class: "!grid grid-cols-2 gap-x-6",
|
class: "!grid grid-cols-2 gap-x-6",
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
|
<%_ for(const item of create.bodyParams) { _%>
|
||||||
{
|
{
|
||||||
field: "username",
|
field: "<%= item.name %>",
|
||||||
label: "登录账号",
|
label: "<%= item.description %>",
|
||||||
type: "input",
|
type: "<%= item.type %>",
|
||||||
required: true,
|
required: <%= item.required %>,
|
||||||
},
|
},
|
||||||
|
<%_ } _%>
|
||||||
],
|
],
|
||||||
submit: ({ model }) => {
|
submit: ({ model }) => {
|
||||||
return api.<%= tag %>.<%= operationId %>(model);
|
return api.<%= create.tag %>.<%= create.operationId %>(model);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modify: {
|
modify: {
|
||||||
extend: true,
|
extend: true,
|
||||||
title: "修改用户",
|
title: "修改用户",
|
||||||
submit: ({ model }) => {
|
submit: ({ model }) => {
|
||||||
return api.<%= tag %>.<%= operationId %>(model.id, model);
|
return api.<%= modify.tag %>.<%= modify.operationId %>(model.id, model);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -70,14 +70,6 @@ const table = useTable({
|
||||||
{
|
{
|
||||||
title: "文件名称",
|
title: "文件名称",
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
// render: ({ record }) => {
|
|
||||||
// return (
|
|
||||||
// <div class="flex items-center">
|
|
||||||
// <i class={`${getIcon(record.mimetype)} text-xl mr-2`}></i>
|
|
||||||
// {record.name}
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
render({ record }) {
|
render({ record }) {
|
||||||
return (
|
return (
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue