@ajaxjs/ui 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,189 @@
1
+ <template>
2
+ <div class="document-rendered">
3
+ <h3>{{documnetObj.name}}</h3>
4
+ <p>{{documnetObj.description}}</p>
5
+
6
+ <div>
7
+ <h3 style="margin-top:0;">对应 UI:</h3>
8
+ <img class="ui small" @click="enlagrn($event)" src="https://tcs-devops.aliyuncs.com/storage/112h785d5d59567281da7b2b5f67ee7ec6b5?Signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcHBJRCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9hcHBJZCI6IjVlNzQ4MmQ2MjE1MjJiZDVjN2Y5YjMzNSIsIl9vcmdhbml6YXRpb25JZCI6IiIsImV4cCI6MTY1NjI0MTAzNywiaWF0IjoxNjU1NjM2MjM3LCJyZXNvdXJjZSI6Ii9zdG9yYWdlLzExMmg3ODVkNWQ1OTU2NzI4MWRhN2IyYjVmNjdlZTdlYzZiNSJ9.zKVBc_WpZmoNV2XdzQOpKRSe4Etm5w2o2HH2afZrHOg" />
9
+ </div>
10
+
11
+ <p style="padding-top:3px">请求 <span class=" code-font">{{documnetObj.httpMethod}}</span> <span class="code code-font">{{documnetObj.url}}</span></p>
12
+
13
+ <h3>请求参数:</h3>
14
+ <table class="request-arg aj-table">
15
+ <thead>
16
+ <th>参数说明</th>
17
+ <th>变量</th>
18
+ <th>类型</th>
19
+ <th>参数位置</th>
20
+ <th>必填</th>
21
+ <th>描述</th>
22
+ </thead>
23
+ <tbody>
24
+ <tr v-for="arg in args" :key="arg.name">
25
+ <td>{{arg.desc}}</td>
26
+ <td>{{arg.name}}</td>
27
+ <td>{{arg.dataType}}</td>
28
+ <td>{{arg.type}}</td>
29
+ <td>{{arg.isRequired?'Yes': 'No'}}</td>
30
+ <td>{{arg.comment}}
31
+
32
+ <ul v-if="arg.values && arg.values.length">
33
+ <li v-for="enu in arg.values" :key="enu.value">
34
+ {{enu.value}} : {{enu.comment}}
35
+ </li>
36
+ </ul>
37
+ </td>
38
+ </tr>
39
+ </tbody>
40
+ </table>
41
+
42
+ <h3>请求示例:</h3>
43
+ <div class="note">
44
+ <a :href="documnetObj.demoUrl" target="_blank">{{documnetObj.demoUrl}}</a>
45
+ </div>
46
+ <h3>返回结果:</h3>
47
+
48
+ <pre class="note">
49
+ {
50
+ "status": int, // 调用接口是否成功,0:失败,1:成功
51
+ "errorCode": string, // 错误码,当 status=0 时,必须返回错误码
52
+ "message": string, // 错误具体信息
53
+ "data": { // 飞机状态信息
54
+ "airSpeed": 52.0,
55
+ "altitude": 55.5,
56
+ "ammeterState": "OK",
57
+ "compassState": "OK",
58
+ "flightState": "UNLOCKED",
59
+ "gpsState": "OK",
60
+ "gpsTime": "2022-06-07 14:36:14",
61
+ "groundSpeed": 5.0,
62
+ "heading": 55.0,
63
+ "ip": "192.168.0.22",
64
+ "latitude": 39.9352,
65
+ "longitude": 116.354,
66
+ "netSignal": 98.0,
67
+ "netState": "OK",
68
+ "power": 8.0,
69
+ "satelliteMod": "98",
70
+ "satelliteNum": 98,
71
+ "satellitePrecision": 98.0,
72
+ "uavId": "10001",
73
+ "voltage": 5.0
74
+ }
75
+ }</pre>
76
+ </div>
77
+ </template>
78
+
79
+ <script lang="ts">
80
+ export default {
81
+ data() {
82
+ return {
83
+ documnetObj: {
84
+ name: "解锁任务中所有的飞机",
85
+ description: "把 空闲、解锁失败的进行解锁",
86
+ httpMethod: "GET",
87
+ url: "/uav/{uav_id}/check_status",
88
+ demoUrl: "http://test.ajaxjs.com:8081/drone/uav/10001/check_status",
89
+ isShow: true
90
+ } as API_HELPER_DOCUMENT,
91
+ args: [
92
+ {
93
+ desc: "任务 id",
94
+ name: "task_id",
95
+ type: "FORM",
96
+ dataType: "string",
97
+ comment: "执行任务 execute | 立即返航 return | 结束任务 close 任选一",
98
+ isRequired: true,
99
+ values: [
100
+ { value: "execute", comment: "执行任务" },
101
+ { value: "return", comment: "立即返航" },
102
+ { value: "close", comment: "结束任务" },
103
+ ],
104
+ },
105
+ ] as API_HELPER_ARGUMENT[],
106
+ };
107
+ },
108
+ methods: {
109
+ enlagrn(e: Event): void {
110
+ let img: HTMLElement = <HTMLElement>e.target;
111
+ img.classList.toggle("small");
112
+ },
113
+ },
114
+ };
115
+ </script>
116
+
117
+ <style lang="less" scoped>
118
+ .document-rendered {
119
+ h3 {
120
+ font-weight: bold;
121
+ font-size: 1.2rem;
122
+ margin: 8px 0;
123
+ }
124
+
125
+ img.ui {
126
+ cursor: pointer;
127
+ max-width: 360px;
128
+ &.small {
129
+ max-width: 260px;
130
+ }
131
+ }
132
+ }
133
+
134
+ .code {
135
+ padding: 3px 4px;
136
+ // border: 1px solid rgb(250, 167, 59);
137
+ background-color: rgb(253, 222, 222);
138
+ color: rgb(255, 35, 35);
139
+ }
140
+
141
+ .code-font {
142
+ font-family: "Courier New";
143
+ }
144
+
145
+ .note {
146
+ padding-left: 10px;
147
+ border-left: 4px solid lightgray;
148
+ }
149
+
150
+ .request-arg {
151
+ width: 98%;
152
+ td {
153
+ text-align: center;
154
+ }
155
+ }
156
+
157
+ // 快速制作1px 表格边框,为需要设置的 table 元素加上 border 的class即可
158
+ .aj-table {
159
+ border: 1px lightgray solid;
160
+ border-collapse: collapse;
161
+ border-spacing: 0;
162
+
163
+ th {
164
+ // background-color: #efefef;
165
+ letter-spacing: 3px;
166
+ }
167
+
168
+ td,
169
+ th {
170
+ border: 1px lightgray solid;
171
+ line-height: 160%;
172
+ height: 120%;
173
+ padding: 6px;
174
+ }
175
+
176
+ tr {
177
+ // .transition (background-color 400ms ease-out);
178
+
179
+ &:nth-child(odd) {
180
+ // background: #f5f5f5;
181
+ box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
182
+ }
183
+
184
+ &:hover {
185
+ background-color: #fbf8e9;
186
+ }
187
+ }
188
+ }
189
+ </style>
@@ -0,0 +1,130 @@
1
+ <template>
2
+ <!-- 渲染文档内容 -->
3
+ <div>
4
+ <Button @click="value3 = true" type="primary">编辑文档</Button>
5
+ <Drawer title="编辑文档" v-model="value3" width="1090" :mask-closable="false" :styles="styles">
6
+ <Form :model="documnetObj">
7
+ <Row :gutter="32">
8
+ <Col span="16">
9
+ <FormItem label="接口名称" label-position="top">
10
+ <Input v-model="documnetObj.name" placeholder="请输入接口名称" />
11
+ </FormItem>
12
+ </Col>
13
+ <Col span="8">
14
+ <FormItem label="分类" label-position="top">
15
+ <Select v-model="documnetObj.catalogId" placeholder="接口分类">
16
+ <Option value="private">Private</Option>
17
+ <Option value="public">Public</Option>
18
+ </Select>
19
+ </FormItem>
20
+ </Col>
21
+ </Row>
22
+
23
+ <FormItem label="接口说明" label-position="top">
24
+ <Input type="textarea" v-model="documnetObj.description" :rows="4" placeholder="接口说明" />
25
+ </FormItem>
26
+
27
+ <Row :gutter="32">
28
+ <Col span="15">
29
+ <FormItem label="对应 UI" label-position="top">
30
+ <!-- <FileUploader :is-img-upload="true" :is-show-btn="false" ref="imgUploader" /> -->
31
+ </FormItem>
32
+
33
+ </Col>
34
+ <Col span="6">
35
+
36
+ <FormItem label="接口编码状态" label-position="top">
37
+ <Select v-model="documnetObj.codeState" placeholder="请选择接口状态">
38
+ <Option value="INITED">初始化</Option>
39
+ <Option value="DEFINED">已定义</Option>
40
+ <Option value="DONE">已完成</Option>
41
+ </Select>
42
+ </FormItem>
43
+
44
+ <FormItem label="是否在文档汇总中展示" label-position="right">
45
+ <i-Switch v-model="documnetObj.isShow" />
46
+ </FormItem>
47
+ </Col>
48
+ </Row>
49
+ </Form>
50
+ <div class="demo-drawer-footer">
51
+ <Button type="success" style="margin-right: 8px" @click="perview = true" icon="ios-eye">预览文档</Button>
52
+ <Button type="primary" style="margin-right: 8px" @click="save" icon="md-create">保存</Button>
53
+ <Button @click="value3 = false">关闭</Button>
54
+ </div>
55
+ </Drawer>
56
+
57
+ <Modal v-model="perview" title="预览文档" width="1200" ok-text="关闭" cancel-text="">
58
+ <div style="max-height: 600px;overflow-y:scroll;">
59
+ <Render />
60
+ </div>
61
+ </Modal>
62
+ </div>
63
+ </template>
64
+
65
+ <script lang="ts">
66
+ import Render from "./document-render.vue";
67
+ import { xhr_post_upload } from "../../../util/xhr";
68
+ //@ts-ignore
69
+ // import FileUploader from "./../../../widget/FileUploader/FileUploader.vue";
70
+
71
+ export default {
72
+ // components: { Render, FileUploader },
73
+ components: { Render },
74
+ data() {
75
+ return {
76
+ perview: false,
77
+ value3: true,
78
+
79
+ documnetObj: {
80
+ name: "解锁任务中所有的飞机",
81
+ description: "把 空闲、解锁失败的进行解锁",
82
+ httpMethod: "GET",
83
+ url: "/uav/{uav_id}/check_status",
84
+ demoUrl: "http://test.ajaxjs.com:8081/drone/uav/10001/check_status",
85
+ codeState: "DEFINED",
86
+ isShow: true,
87
+ } as API_HELPER_DOCUMENT,
88
+
89
+ styles: {
90
+ height: "calc(100% - 55px)",
91
+ overflow: "auto",
92
+ paddingBottom: "53px",
93
+ position: "static",
94
+ },
95
+ formData: {
96
+ name: "",
97
+ url: "",
98
+ owner: "",
99
+ type: "",
100
+ approver: "",
101
+ date: "",
102
+ desc: "",
103
+ },
104
+ };
105
+ },
106
+ methods: {
107
+ enlagrn(e: Event): void {
108
+ let img: HTMLElement = <HTMLElement>e.target;
109
+ img.classList.toggle("small");
110
+ },
111
+
112
+ save(): void {
113
+ // xhr_post_upload("", (j) => {}, {}, { contentType: null });
114
+ },
115
+ },
116
+ };
117
+ </script>
118
+
119
+ <style lang="less" scoped>
120
+ .demo-drawer-footer {
121
+ width: 100%;
122
+ position: absolute;
123
+ bottom: 0;
124
+ left: 0;
125
+ border-top: 1px solid #e8e8e8;
126
+ padding: 10px 16px;
127
+ text-align: right;
128
+ background: #fff;
129
+ }
130
+ </style>
File without changes
@@ -0,0 +1,140 @@
1
+ <template>
2
+ <div style="overflow: hidden">
3
+ <div class="left">
4
+ <ul>
5
+ <li v-for="env in envs" :key="env.id" @click="active(env.id)" :class="{ actived: env.actived }">
6
+ <Icon type="md-trash" style="float: right; margin-top: 3px" @click="del(env.id, $event)" />
7
+ {{env.name}}
8
+ </li>
9
+ </ul>
10
+ <a class="add" @click="add">+ 新建……</a>
11
+ </div>
12
+ <div class="right">
13
+ <Input v-model="editing.name" ref="inputName">
14
+ <span slot="prepend">环境名称</span>
15
+ </Input>
16
+ <br />
17
+ <Input v-model="editing.urlPrefix">
18
+ <span slot="prepend">URL前缀</span>
19
+ </Input>
20
+
21
+ <br />
22
+ <br />
23
+ <p>
24
+ 环境变量:在接口文档或测试的过程中,使用 ${变量名} 即可引用该环境变量
25
+ </p>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script lang="ts">
31
+ import { xhr_get } from "../../util/xhr";
32
+
33
+ export default {
34
+ props: {},
35
+ data() {
36
+ return {
37
+ envs: [
38
+ {
39
+ id: 1,
40
+ name: "本地测试",
41
+ urlPrefix: "https://dd.com",
42
+ actived: true,
43
+ } as API_HELPER_ENV,
44
+ {
45
+ id: 2,
46
+ name: "生产环境",
47
+ urlPrefix: "http://foo.com",
48
+ actived: false,
49
+ } as API_HELPER_ENV,
50
+ ],
51
+ editing: {} as API_HELPER_ENV,
52
+ isCreate: false,
53
+ };
54
+ },
55
+ mounted() {
56
+ xhr_get("http://127.0.0.1:8080/cms/api/ApiHelper/env/list", (j: RepsonseResult) => {
57
+ if (j.status)
58
+ this.envs = j.data;
59
+ else this.$Message.warning(j.message);
60
+ }
61
+ );
62
+ },
63
+ methods: {
64
+ add(): void {
65
+ this.isCreate = true;
66
+ this.editing = {};
67
+ this.$refs.inputName.focus();
68
+ },
69
+ /**
70
+ * 点击某个环境,激活之
71
+ */
72
+ active(id: number): void {
73
+ for (let i = 0; i < this.envs.length; i++) {
74
+ let env: API_HELPER_ENV = this.envs[i];
75
+
76
+ if (env.id == id) {
77
+ this.editing = env;
78
+ env.actived = true;
79
+ } else env.actived = false;
80
+ }
81
+ },
82
+
83
+ /**
84
+ * 删除某个环境
85
+ */
86
+ del(id: number, e: Event): void {
87
+ e.stopPropagation();
88
+ let index: number;
89
+
90
+ for (let i = 0; i < this.envs.length; i++) {
91
+ let env: API_HELPER_ENV = this.envs[i];
92
+
93
+ if (env.id == id) {
94
+ index = i;
95
+ break;
96
+ }
97
+ }
98
+
99
+ if (index == 0 || index) {
100
+ this.envs.splice(index, 1);
101
+ this.editing = {};
102
+ }
103
+ },
104
+ },
105
+ };
106
+ </script>
107
+
108
+ <style lang="less" scoped>
109
+ .left {
110
+ float: left;
111
+ width: 28%;
112
+ height: 300px;
113
+ border-right: 1px solid #f5f5f5;
114
+ }
115
+
116
+ .right {
117
+ float: right;
118
+ width: 70%;
119
+ padding-left: 10px;
120
+ }
121
+
122
+ ul {
123
+ margin: 0 2%;
124
+ }
125
+
126
+ li {
127
+ border-bottom: 1px solid #f5f5f5;
128
+ padding: 5px 8px;
129
+ cursor: pointer;
130
+ &.actived {
131
+ font-weight: bold;
132
+ }
133
+ }
134
+
135
+ .add {
136
+ // color: #2d8cf0;
137
+ display: block;
138
+ padding: 5px 10px;
139
+ }
140
+ </style>
@@ -0,0 +1,116 @@
1
+ <template>
2
+ <div>
3
+ <div class="toolbar">
4
+ <Button size="small" type="error" style="float:right;" :disabled="!historyList.length" @click="historyList=[];">清空历史记录</Button>
5
+ <span v-if="historyList.length">共 {{historyList.length}} 笔记录</span>
6
+ </div>
7
+
8
+ <ul style="max-height:500px">
9
+ <li v-for="history in historyList" :key="history.id" @click="select(history)">
10
+ <span v-if="history.name">{{history.name}}
11
+ <br /></span>
12
+ <span style="font-family:Courier New">
13
+ <HttpMethod :type="history.httpMethod" />{{history.url}}
14
+ </span>
15
+ <br />
16
+ <div style="font-family:Arial;font-size:3px;color:gray;float:right;margin-top:4px;">{{history.time}}ms</div>
17
+ <span style="font-family:Courier New;font-size:5px;color:lightgray">{{history.date}}</span>
18
+ </li>
19
+ </ul>
20
+ </div>
21
+ </template>
22
+
23
+ <script lang="ts">
24
+ import HttpMethod from "./common/http-method.vue";
25
+
26
+ export default {
27
+ components: { HttpMethod },
28
+ data() {
29
+ return {
30
+ historyList: [
31
+ {
32
+ id: 1,
33
+ httpMethod: "GET",
34
+ name: "fgfgf",
35
+ url: "http://qq.com",
36
+ time: 203,
37
+ date: "2022-3-3 3:23",
38
+ stateCode: 200,
39
+ },
40
+ {
41
+ id: 2,
42
+ httpMethod: "POST",
43
+ url: "http://qq.com/gggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
44
+ time: 203,
45
+ date: "2022-3-3 3:23",
46
+ stateCode: 200,
47
+ },
48
+ {
49
+ id: 3,
50
+ httpMethod: "PUT",
51
+ name: "fgfgf",
52
+ url: "http://qq.com",
53
+ time: 203,
54
+ date: "2022-3-3 3:23",
55
+ stateCode: 200,
56
+ },
57
+ {
58
+ id: 4,
59
+ httpMethod: "DELETE",
60
+ name: "获取新闻详情",
61
+ url: "http://qq.com",
62
+ time: 203,
63
+ date: "2022-3-3 3:23",
64
+ stateCode: 200,
65
+ },
66
+ ] as API_HELPER_HISTORY[],
67
+ };
68
+ },
69
+
70
+ methods: {
71
+ select(h: any): void {
72
+ alert(h);
73
+ },
74
+ },
75
+ };
76
+ </script>
77
+
78
+ <style lang="less" scoped>
79
+ .toolbar {
80
+ padding: 0 6px 5px 6px;
81
+ border-bottom: 1px solid #f0f0f0;
82
+ box-sizing: content-box;
83
+ overflow: hidden;
84
+ margin: 0 8px;
85
+ }
86
+ ul {
87
+ overflow-y: auto;
88
+ &::-webkit-scrollbar {
89
+ width: 6px;
90
+ }
91
+ &::-webkit-scrollbar-thumb {
92
+ border-radius: 8px;
93
+ background: rgba(23, 35, 61, 0.15);
94
+ }
95
+ &::-webkit-scrollbar-track {
96
+ background-color: transparent;
97
+ border-radius: 8px;
98
+ }
99
+ }
100
+
101
+ li {
102
+ padding: 10px 5px;
103
+ margin: 10px 5px;
104
+ border: 1px solid #f0f0f0;
105
+ border-radius: 5px;
106
+ overflow: hidden;
107
+ max-width: 290px;
108
+ text-overflow: ellipsis; //溢出用省略号显示
109
+ white-space: nowrap; //溢出不换行
110
+ transition: border-color ease-in 400ms;
111
+ cursor: pointer;
112
+ &:hover {
113
+ border-color: lightgray;
114
+ }
115
+ }
116
+ </style>
@@ -0,0 +1,70 @@
1
+ <template>
2
+ <div style="clear: both">
3
+ <section class="url-bar">
4
+ <Input v-model="url.main" style="width: 70%">
5
+ <span slot="prepend">
6
+ <Select v-model="httpMethod" style="width: 80px">
7
+ <Option value="GET">GET</Option>
8
+ <Option value="POST">POST</Option>
9
+ <Option value="PUT">PUT</Option>
10
+ <Option value="DELETE">DELETE</Option>
11
+ <Option value="PATCH">PATCH</Option>
12
+ <Option value="HEAD">HEAD</Option>
13
+ <Option value="OPTION">OPTION</Option>
14
+ </Select>
15
+ <Divider type="vertical" />{{ url.prefix }}
16
+ </span>
17
+ </Input>
18
+ <Button style="width: 8%" type="primary">发送</Button>
19
+ <Button style="width: 8%">保存</Button>
20
+ </section>
21
+
22
+ <Document />
23
+
24
+ <Tabs name="request" class="request" value="name2" :animated="false">
25
+ <TabPane label="头部参数" name="name1" tab="request">标签一的内容</TabPane>
26
+ <TabPane label="请求体" name="name2" tab="request">
27
+ <RequestBody />
28
+ </TabPane>
29
+ <TabPane tab="request" label="查询参数" name="name3">标签三的内容</TabPane>
30
+ <TabPane tab="request" label="路径参数" name="name4">标签三的内容</TabPane>
31
+ </Tabs>
32
+
33
+ <Tabs class="response" name="response" value="requestHead" :animated="false">
34
+ <TabPane tab="response" label="请求头部" name="requestHead">标签一的内容</TabPane>
35
+ <TabPane tab="response" label="请求内容" name="requestBody">标签二的内容</TabPane>
36
+ <TabPane tab="response" label="返回头部" name="responseHead">标签三的内容</TabPane>
37
+ <TabPane tab="response" label="返回内容" name="responseContent">标签三的内容</TabPane>
38
+ </Tabs>
39
+ </div>
40
+ </template>
41
+
42
+ <script>
43
+ import RequestBody from "./request-body.vue";
44
+ import Document from "./document/document.vue";
45
+
46
+ export default {
47
+ components: { RequestBody, Document },
48
+ data() {
49
+ return {
50
+ url: {
51
+ prefix: "https://dd.com",
52
+ main: "/dfdf",
53
+ },
54
+ httpMethod: "GET",
55
+ };
56
+ },
57
+ };
58
+ </script>
59
+
60
+
61
+ <style lang="less" scoped>
62
+ .request {
63
+ clear: both;
64
+ }
65
+
66
+ .url-bar > * {
67
+ float: left;
68
+ margin-right: 10px;
69
+ }
70
+ </style>