update code generator

This commit is contained in:
AceDataCloud committed 2023-01-23 18:10:06 +08:00
1 parent 5401975765
commit 7b8ac91183
6 files changed
+130 -14

No files matched your search

+1
View File
@@ -33,6 +33,7 @@
"element-plus": "^1.3.0-beta.10",
"github-markdown-css": "^5.1.0",
"markdown-it": "^13.0.1",
"programming-languages-logos": "^0.0.3",
"typescript-cookie": "^1.0.3",
"url-join": "^5.0.0",
"uuid": "^8.3.2",
+115
View File
@@ -0,0 +1,115 @@
<template>
<div class="wrapper">
<div class="options">
<div v-for="(option, optionKey) in options" :key="optionKey" class="option">
<el-image :src="option.icon" class="icon" />
<p class="name">{{ option.name }}</p>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import javascript from 'programming-languages-logos/src/javascript/javascript.svg';
import python from 'programming-languages-logos/src/python/python.svg';
import java from 'programming-languages-logos/src/java/java.svg';
import go from 'programming-languages-logos/src/go/go.svg';
import { IApi, IForm } from '@/operators/api/models';
import urlJoin from 'url-join';
interface IOption {
name: string;
icon: string;
}
interface IData {
options: IOption[];
}
export default defineComponent({
name: 'ApiCode',
props: {
api: {
type: Object as () => IApi,
required: true
},
form: {
type: Object as () => IForm,
required: true
}
},
data(): IData {
return {
options: [
{
name: 'Python',
icon: python
},
{
name: 'JavaScript',
icon: javascript
},
{
name: 'Java',
icon: java
},
{
name: 'Go',
icon: go
}
]
};
},
computed: {
url() {
return urlJoin(this.api?.endpoint, this.api?.path);
},
contentType() {
return (this.form?.headers || {})['content-type'];
},
pythonSample() {}
},
watch: {}
});
</script>
<style lang="scss">
.wrapper {
width: 100%;
padding: 15px;
overflow-x: scroll;
.options {
width: fit-content;
overflow: hidden;
.option {
margin: 0 5px;
float: left;
width: 70px;
height: 70px;
text-align: center;
border: 1px solid transparent;
padding: 10px;
border-radius: 10px;
display: inline-flex;
flex-direction: column;
text-align: center;
align-items: center;
&:hover {
border-color: #ccc;
cursor: pointer;
}
.icon {
width: 30px;
height: 30px;
margin-bottom: 10px;
}
.name {
color: #666;
font-size: 11px;
font-weight: bold;
}
}
}
}
</style>
@@ -36,3 +36,9 @@ export default defineComponent({
<style lang="scss">
@import 'github-markdown-css/github-markdown.css';
</style>
<style lang="scss" scoped>
.markdown-body {
background: none;
}
</style>
-14
View File
@@ -1,14 +0,0 @@
<template>
<div class="authentication"></div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'ApiCode',
props: {},
data() {},
watch: {}
});
</script>
+3
View File
@@ -9,6 +9,7 @@
</div>
<div v-if="document?.type === 'API' && document?.api" class="right">
<api-try :form="form" :api="document?.api" />
<api-code :form="form" :api="document?.api" />
</div>
</template>
@@ -16,6 +17,7 @@
import { defineComponent } from 'vue';
import ApiUsage from '@/components/api/Usage.vue';
import ApiTry from '@/components/api/Try.vue';
import ApiCode from '@/components/api/Code.vue';
import { documentOperator, IDocument, IDocumentDetailResponse } from '@/operators';
import { IForm } from '@/operators/api/models';
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
@@ -30,6 +32,7 @@ export default defineComponent({
components: {
ApiUsage,
ApiTry,
ApiCode,
MarkdownRenderer
},
data(): IData {
+5
View File
@@ -2674,6 +2674,11 @@ pretty-hrtime@^1.0.3:
resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"
integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=
programming-languages-logos@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/programming-languages-logos/-/programming-languages-logos-0.0.3.tgz#17e073244d7886a2dc86d20ee6b3332ba765c5f4"
integrity sha512-58WiFkwCoEEwC86WUnRVSBM1vuNqxK4izjwR7uia/uAMw3zdFoVBa+JER1xIuyJxQrxf1T6+eZvoCnsnwXRfRg==
progress@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"