update code generator
This commit is contained in:
1 parent
5401975765
commit
7b8ac91183
6 files changed
+130
-14
No files matched your search
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user