@ajaxjs/ui 1.3.0 → 1.3.2
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.
- package/.browserslistrc +3 -0
- package/.eslintrc.js +26 -0
- package/babel.config.js +5 -0
- package/deprecated/api-helper.zip +0 -0
- package/deprecated/api-helper2.zip +0 -0
- package/deprecated/api-selector.zip +0 -0
- package/deprecated/common-ui.zip +0 -0
- package/deprecated/data-source.zip +0 -0
- package/deprecated/table-selector.zip +0 -0
- package/deprecated/utils.js +220 -0
- package/dist/@ajaxjs/widgets.common.js +4084 -0
- package/dist/@ajaxjs/widgets.common.js.map +1 -0
- package/dist/@ajaxjs/widgets.css +1 -0
- package/dist/@ajaxjs/widgets.umd.js +4095 -0
- package/dist/@ajaxjs/widgets.umd.js.map +1 -0
- package/dist/@ajaxjs/widgets.umd.min.js +2 -0
- package/dist/@ajaxjs/widgets.umd.min.js.map +1 -0
- package/dist/demo.html +1 -0
- package/examples/App.vue +137 -0
- package/package.json +50 -41
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/{dist → src}/data-source/data-source.ts +16 -14
- package/{dist → src}/iam/iam.ts +2 -4
- package/{dist → src}/iam/user.vue +19 -16
- package/src/index.js +48 -0
- package/src/iview-ext/fast-iview-table.ts +131 -0
- package/src/iview-ext/fast-iview-table.vue +67 -0
- package/{dist/iView-ext/fast-iview-table → src/iview-ext}/list.ts +11 -12
- package/{dist/table-selector → src/iview-ext}/table-selector.vue +17 -12
- package/{dist/iView-ext → src/iview-ext}/tips.vue +5 -2
- package/src/main.ts +7 -0
- package/src/shims-tsx.d.ts +11 -0
- package/{dist → src}/shims-vue.d.ts +4 -4
- package/src/style/common-functions.less +286 -0
- package/src/style/reset.less +19 -0
- package/src/style/reset2.less +49 -0
- package/tsconfig.json +40 -0
- package/vue.config.js +14 -0
- package/LICENSE +0 -201
- package/dist/api-helper/common/arg.vue +0 -46
- package/dist/api-helper/common/http-method.vue +0 -53
- package/dist/api-helper/common/input-table.vue +0 -128
- package/dist/api-helper/document/document-render.d.ts +0 -10
- package/dist/api-helper/document/document-render.js +0 -38
- package/dist/api-helper/document/document-render.js.map +0 -1
- package/dist/api-helper/document/document-render.ts +0 -35
- package/dist/api-helper/document/document-render.vue +0 -155
- package/dist/api-helper/document/document.d.ts +0 -31
- package/dist/api-helper/document/document.js +0 -55
- package/dist/api-helper/document/document.js.map +0 -1
- package/dist/api-helper/document/document.ts +0 -55
- package/dist/api-helper/document/document.vue +0 -78
- package/dist/api-helper/document/perview.vue +0 -0
- package/dist/api-helper/index.js +0 -142
- package/dist/api-helper/index.vue +0 -108
- package/dist/api-helper/request-body.vue +0 -66
- package/dist/api-helper/table.d.ts +0 -7
- package/dist/api-helper/table.js +0 -13
- package/dist/api-helper/table.js.map +0 -1
- package/dist/api-helper/table.ts +0 -10
- package/dist/api-helper/table.vue +0 -103
- package/dist/api-helper/xhr.js +0 -100
- package/dist/api-helper2/api-helper.d.ts +0 -194
- package/dist/api-helper2/api-helper.vue +0 -144
- package/dist/api-helper2/bookmark.vue +0 -168
- package/dist/api-helper2/common/arg.vue +0 -46
- package/dist/api-helper2/common/http-method.vue +0 -53
- package/dist/api-helper2/document/document-render.vue +0 -189
- package/dist/api-helper2/document/document.vue +0 -130
- package/dist/api-helper2/document/perview.vue +0 -0
- package/dist/api-helper2/env.vue +0 -140
- package/dist/api-helper2/history.vue +0 -116
- package/dist/api-helper2/main.vue +0 -70
- package/dist/api-helper2/request-body.vue +0 -68
- package/dist/api-helper2/table.vue +0 -116
- package/dist/api-selector/api-list-dataservice.d.ts +0 -18
- package/dist/api-selector/api-list-dataservice.js +0 -209
- package/dist/api-selector/api-list-dataservice.js.map +0 -1
- package/dist/api-selector/api-list-dataservice.ts +0 -232
- package/dist/api-selector/api-list-swagger.d.ts +0 -28
- package/dist/api-selector/api-list-swagger.js +0 -179
- package/dist/api-selector/api-list-swagger.js.map +0 -1
- package/dist/api-selector/api-list-swagger.ts +0 -206
- package/dist/api-selector/api-list.d.ts +0 -80
- package/dist/api-selector/api-list.js +0 -129
- package/dist/api-selector/api-list.js.map +0 -1
- package/dist/api-selector/api-list.ts +0 -135
- package/dist/api-selector/index.vue +0 -125
- package/dist/api-selector/test-dataservice.d.ts +0 -23
- package/dist/api-selector/test-dataservice.js +0 -74
- package/dist/api-selector/test-dataservice.js.map +0 -1
- package/dist/api-selector/test-swagger.d.ts +0 -901
- package/dist/api-selector/test-swagger.js +0 -656
- package/dist/api-selector/test-swagger.js.map +0 -1
- package/dist/data-source/data-source.css +0 -44
- package/dist/data-source/data-source.d.ts +0 -14
- package/dist/data-source/data-source.html +0 -59
- package/dist/data-source/data-source.js +0 -97
- package/dist/data-source/data-source.js.map +0 -1
- package/dist/iView-ext/fast-iview-table/fast-iview-table.d.ts +0 -37
- package/dist/iView-ext/fast-iview-table/fast-iview-table.js +0 -72
- package/dist/iView-ext/fast-iview-table/fast-iview-table.js.map +0 -1
- package/dist/iView-ext/fast-iview-table/fast-iview-table.ts +0 -75
- package/dist/iView-ext/fast-iview-table/fast-iview-table.vue +0 -52
- package/dist/iView-ext/fast-iview-table/list.d.ts +0 -44
- package/dist/iView-ext/fast-iview-table/list.js +0 -97
- package/dist/iView-ext/fast-iview-table/list.js.map +0 -1
- package/dist/iam/iam.d.ts +0 -16
- package/dist/iam/iam.js +0 -54
- package/dist/iam/iam.js.map +0 -1
- package/dist/index.d.ts +0 -57
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/index.ts +0 -18
- package/dist/libs/entity.d.ts +0 -26
- package/dist/libs/entity.js +0 -1
- package/dist/libs/entity.js.map +0 -1
- package/dist/libs/iview-widgets.d.ts +0 -59
- package/dist/libs/iview-widgets.js +0 -2
- package/dist/libs/iview-widgets.js.map +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -24
- package/dist/main.js.map +0 -1
- package/dist/main.ts +0 -22
- package/dist/table-selector/table-selector.htm +0 -28
- package/dist/table-selector/table-selector.js +0 -149
- /package/{dist → src}/data-source/data-source.less +0 -0
- /package/{dist → src}/data-source/data-source.vue +0 -0
- /package/{dist → src}/libs/api-helper.d.ts +0 -0
- /package/{dist → src}/libs/api-list.d.ts +0 -0
- /package/{dist → src}/libs/common.d.ts +0 -0
- /package/{dist → src}/libs/entity.ts +0 -0
- /package/{dist → src}/libs/iview-widgets.ts +0 -0
|
@@ -1,78 +0,0 @@
|
|
|
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" src="./document.ts"></script>
|
|
66
|
-
|
|
67
|
-
<style lang="less" scoped>
|
|
68
|
-
.demo-drawer-footer {
|
|
69
|
-
width: 100%;
|
|
70
|
-
position: absolute;
|
|
71
|
-
bottom: 0;
|
|
72
|
-
left: 0;
|
|
73
|
-
border-top: 1px solid #e8e8e8;
|
|
74
|
-
padding: 10px 16px;
|
|
75
|
-
text-align: right;
|
|
76
|
-
background: #fff;
|
|
77
|
-
}
|
|
78
|
-
</style>
|
|
File without changes
|
package/dist/api-helper/index.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import RequestBody from "./request-body.vue";
|
|
2
|
-
import Document from "./document/document.vue";
|
|
3
|
-
import InputTable from "./common/input-table.vue";
|
|
4
|
-
|
|
5
|
-
import { codemirror } from "vue-codemirror";
|
|
6
|
-
import "codemirror/addon/selection/active-line.js";
|
|
7
|
-
import "codemirror/addon/edit/closebrackets.js";
|
|
8
|
-
import "codemirror/mode/javascript/javascript";
|
|
9
|
-
import "codemirror/addon/lint/json-lint";
|
|
10
|
-
import "codemirror/lib/codemirror.css";
|
|
11
|
-
import "codemirror/addon/hint/show-hint.css";
|
|
12
|
-
import "codemirror/theme/base16-light.css";
|
|
13
|
-
|
|
14
|
-
import xhr from "./xhr";
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
components: { RequestBody, Document, InputTable, codemirror },
|
|
18
|
-
mixins: [xhr],
|
|
19
|
-
data() {
|
|
20
|
-
return {
|
|
21
|
-
mainTab: 'form',
|
|
22
|
-
url: {
|
|
23
|
-
prefix: "https://dd.com",
|
|
24
|
-
// main: "https://jsonplaceholder.typicode.com/posts",
|
|
25
|
-
main: "https://httpbin.org/post",
|
|
26
|
-
},
|
|
27
|
-
httpMethod: "POST",
|
|
28
|
-
|
|
29
|
-
cmOption: {
|
|
30
|
-
tabSize: 4,
|
|
31
|
-
styleActiveLine: true,
|
|
32
|
-
lineNumbers: true,
|
|
33
|
-
mode: "application/json",
|
|
34
|
-
// theme: "monokai"
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
requestParams: {
|
|
38
|
-
form: {
|
|
39
|
-
contentType: 'application/x-www-form-urlencoded',
|
|
40
|
-
data: [
|
|
41
|
-
{
|
|
42
|
-
enable: true,
|
|
43
|
-
key: "param1",
|
|
44
|
-
value: "bar",
|
|
45
|
-
desc: "",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
enable: true,
|
|
49
|
-
key: "param2",
|
|
50
|
-
value: "foo",
|
|
51
|
-
desc: "",
|
|
52
|
-
},
|
|
53
|
-
// {
|
|
54
|
-
// enable: true,
|
|
55
|
-
// key: "",
|
|
56
|
-
// value: "",
|
|
57
|
-
// desc: "",
|
|
58
|
-
// },
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
head: [
|
|
62
|
-
{
|
|
63
|
-
enable: true,
|
|
64
|
-
key: "",
|
|
65
|
-
value: "",
|
|
66
|
-
desc: "",
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
raw: {
|
|
70
|
-
contentType: 'application/json',
|
|
71
|
-
json: '{ "title": "My post title", "body": "This is the body of my post." }',
|
|
72
|
-
},
|
|
73
|
-
queryString: [
|
|
74
|
-
{
|
|
75
|
-
enable: true,
|
|
76
|
-
key: "",
|
|
77
|
-
value: "",
|
|
78
|
-
desc: "",
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
requestAll: "",
|
|
84
|
-
responseHead: "",
|
|
85
|
-
responseBody: "",
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
mounted() {
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
methods: {
|
|
92
|
-
load() {
|
|
93
|
-
let params, contentType;
|
|
94
|
-
|
|
95
|
-
if ('form' === this.mainTab) {
|
|
96
|
-
contentType = this.requestParams.form.contentType;
|
|
97
|
-
params = json2fromParams(this.requestParams.form.data);
|
|
98
|
-
} else if ('raw' === this.mainTab) {
|
|
99
|
-
contentType = this.requestParams.raw.contentType;
|
|
100
|
-
params = this.requestParams.raw.json;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.doRequest(this.httpMethod, this.url.main, params, {
|
|
104
|
-
header: {
|
|
105
|
-
'content-type': contentType
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
authToken() {
|
|
110
|
-
// 读取粘贴板
|
|
111
|
-
try {
|
|
112
|
-
navigator.clipboard.readText().then((v) => {
|
|
113
|
-
console.log("获取剪贴板成功:", v);
|
|
114
|
-
this.requestParams.head.unshift({
|
|
115
|
-
enable: true,
|
|
116
|
-
key: "Authorization",
|
|
117
|
-
value: "Bearer " + v,
|
|
118
|
-
desc: "认证用的 token",
|
|
119
|
-
});
|
|
120
|
-
}).catch((v) => {
|
|
121
|
-
console.log("获取剪贴板失败: ", v);
|
|
122
|
-
});
|
|
123
|
-
} catch (e) {
|
|
124
|
-
console.log(e);
|
|
125
|
-
this.$Message.error('不支持读取粘贴板');
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
formatJs() {
|
|
130
|
-
let json = this.requestParams.raw.json;
|
|
131
|
-
json = JSON.stringify(JSON.parse(json), null, 4);
|
|
132
|
-
this.requestParams.raw.json = json;
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
function json2fromParams(arr) {
|
|
138
|
-
let _arr = [];
|
|
139
|
-
arr.forEach(({ key, value }) => _arr.push(key + '=' + encodeURIComponent(value)));
|
|
140
|
-
|
|
141
|
-
return _arr.join('&');
|
|
142
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div style="clear: both;margin: 30px; border:1px solid lightgray;padding:10px 5px">
|
|
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" />
|
|
16
|
-
{{ url.prefix }} -->
|
|
17
|
-
</span>
|
|
18
|
-
</Input>
|
|
19
|
-
<Button style="width: 8%" type="primary" @click="load" :disabled="loading">发送</Button>
|
|
20
|
-
<!-- <Button style="width: 8%">保存</Button> -->
|
|
21
|
-
</section>
|
|
22
|
-
|
|
23
|
-
<!-- <Document /> -->
|
|
24
|
-
|
|
25
|
-
<Tabs name="request" class="request" v-model="mainTab" :animated="false">
|
|
26
|
-
<TabPane label="请求体 Form" name="form" tab="request">
|
|
27
|
-
<div style="margin:10px 0;">
|
|
28
|
-
content-type
|
|
29
|
-
<Select
|
|
30
|
-
style="width:260px;"
|
|
31
|
-
size="small"
|
|
32
|
-
transfer
|
|
33
|
-
v-model="requestParams.form.contentType"
|
|
34
|
-
>
|
|
35
|
-
<Option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</Option>
|
|
36
|
-
<Option value="multipart/form-data">multipart/form-data</Option>
|
|
37
|
-
</Select>
|
|
38
|
-
</div>
|
|
39
|
-
<InputTable :data="requestParams.form.data" />
|
|
40
|
-
</TabPane>
|
|
41
|
-
<TabPane label="请求体 Raw" name="raw" tab="request">
|
|
42
|
-
<div style="margin:10px 0;">
|
|
43
|
-
<a style="float:right;" @click="formatJs">格式化</a>
|
|
44
|
-
content-type
|
|
45
|
-
<Select
|
|
46
|
-
style="width:260px;"
|
|
47
|
-
size="small"
|
|
48
|
-
transfer
|
|
49
|
-
v-model="requestParams.raw.contentType"
|
|
50
|
-
>
|
|
51
|
-
<Option value="application/json">application/json</Option>
|
|
52
|
-
<Option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</Option>
|
|
53
|
-
<Option value="multipart/form-data">multipart/form-data</Option>
|
|
54
|
-
<Option value="text/plain">text/plain</Option>
|
|
55
|
-
<Option value="text/plain">text/xml</Option>
|
|
56
|
-
</Select>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<!-- JSON 源码编辑器-->
|
|
60
|
-
<codemirror
|
|
61
|
-
class="code-editor"
|
|
62
|
-
ref="cm"
|
|
63
|
-
v-model="requestParams.raw.json"
|
|
64
|
-
:options="cmOption"
|
|
65
|
-
style="height:200px;"
|
|
66
|
-
></codemirror>
|
|
67
|
-
</TabPane>
|
|
68
|
-
<TabPane tab="request" label="查询参数 Query" name="name3">
|
|
69
|
-
<InputTable :data="requestParams.queryString" />
|
|
70
|
-
</TabPane>
|
|
71
|
-
<TabPane label="头部参数" name="head" tab="request">
|
|
72
|
-
<InputTable :data="requestParams.head" />
|
|
73
|
-
<div style="float:right;margin-top:10px;">
|
|
74
|
-
<a @click="authToken">一键生成 Bear Token</a>
|
|
75
|
-
</div>
|
|
76
|
-
</TabPane>
|
|
77
|
-
</Tabs>
|
|
78
|
-
|
|
79
|
-
<Tabs class="response" name="response" value="responseContent" :animated="false">
|
|
80
|
-
<TabPane tab="response" label="返回内容" name="responseContent">
|
|
81
|
-
<div style="clear:both;height:30px;font-size:8pt;">
|
|
82
|
-
<div style="float:right;height:30px;">Elapsed: {{this.response.elapsed}}ms HTTP status code: <span v-html="formatStatusCode()"></span></div>
|
|
83
|
-
</div>
|
|
84
|
-
<!-- JSON 源码编辑器-->
|
|
85
|
-
<codemirror class="code-editor" v-model="responseBody" :options="cmOption" style="height:300px;"></codemirror>
|
|
86
|
-
</TabPane>
|
|
87
|
-
<TabPane tab="response" label="返回头部" name="responseHead">
|
|
88
|
-
<Input type="textarea" :rows="8" :readonly="true" v-model="responseHead" />
|
|
89
|
-
</TabPane>
|
|
90
|
-
<TabPane tab="response" label="请求信息" name="requestHead">
|
|
91
|
-
<Input type="textarea" :rows="8" :readonly="true" v-model="requestAll" />
|
|
92
|
-
</TabPane>
|
|
93
|
-
</Tabs>
|
|
94
|
-
</div>
|
|
95
|
-
</template>
|
|
96
|
-
|
|
97
|
-
<script src="./index.js"></script>
|
|
98
|
-
|
|
99
|
-
<style lang="less" scoped>
|
|
100
|
-
.request {
|
|
101
|
-
clear: both;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.url-bar > * {
|
|
105
|
-
float: left;
|
|
106
|
-
margin-right: 10px;
|
|
107
|
-
}
|
|
108
|
-
</style>
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<RadioGroup v-model="requestType" type="button" size="small">
|
|
4
|
-
<Radio label="Form"></Radio>
|
|
5
|
-
|
|
6
|
-
<Radio label="Raw"></Radio>
|
|
7
|
-
</RadioGroup>
|
|
8
|
-
<!--
|
|
9
|
-
<span v-if="requestType == 'JSON'" class="jsonRootType">JSON 根类型
|
|
10
|
-
<RadioGroup v-model="json.rootType" size="small">
|
|
11
|
-
<Radio label="Object" size="small"></Radio>
|
|
12
|
-
<Radio label="Array"></Radio>
|
|
13
|
-
</RadioGroup>
|
|
14
|
-
</span>-->
|
|
15
|
-
|
|
16
|
-
<div style="margin-top: 20px">
|
|
17
|
-
<section v-if="requestType == 'Form'">
|
|
18
|
-
<Table mode="SIMPLE" />
|
|
19
|
-
</section>
|
|
20
|
-
|
|
21
|
-
<section v-if="requestType == 'JSON'">
|
|
22
|
-
<Table mode="SCHEME" />
|
|
23
|
-
</section>
|
|
24
|
-
|
|
25
|
-
<section v-if="requestType == 'Raw'">
|
|
26
|
-
<div style="width:500px;margin:10px 0;">
|
|
27
|
-
ContentType
|
|
28
|
-
<Select v-model="raw.contentType" style="width:200px;" size="small" transfer>
|
|
29
|
-
<Option value="application/json">application/json</Option>
|
|
30
|
-
<Option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</Option>
|
|
31
|
-
<Option value="multipart/form-data">multipart/form-data</Option>
|
|
32
|
-
<Option value="text/plain">text/plain</Option>
|
|
33
|
-
<Option value="text/plain">text/xml</Option>
|
|
34
|
-
</Select>
|
|
35
|
-
</div>
|
|
36
|
-
<Input type="textarea" :rows="4" />
|
|
37
|
-
</section>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
|
|
42
|
-
<script lang="ts">
|
|
43
|
-
import Table from "./table.vue";
|
|
44
|
-
|
|
45
|
-
export default {
|
|
46
|
-
components: { Table },
|
|
47
|
-
data() {
|
|
48
|
-
return {
|
|
49
|
-
requestType: "Form",
|
|
50
|
-
json: {
|
|
51
|
-
rootType: "Object",
|
|
52
|
-
},
|
|
53
|
-
raw: {
|
|
54
|
-
contentType: "application/json",
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
</script>
|
|
60
|
-
|
|
61
|
-
<style lang="less" scoped>
|
|
62
|
-
.jsonRootType {
|
|
63
|
-
font-size: 9pt;
|
|
64
|
-
padding-left: 20px;
|
|
65
|
-
}
|
|
66
|
-
</style>
|
package/dist/api-helper/table.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/api-helper/table.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;IACD,IAAI;QACF,OAAO;QACL,oBAAoB;SACD,CAAC;IACxB,CAAC;CACF,CAAC"}
|
package/dist/api-helper/table.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="table" :class="mode">
|
|
3
|
-
<header>
|
|
4
|
-
<ul>
|
|
5
|
-
<li class="check"><input type="checkbox" /></li>
|
|
6
|
-
<li class="name">参数变量名</li>
|
|
7
|
-
<li class="type">类型</li>
|
|
8
|
-
<li class="value">参数值</li>
|
|
9
|
-
<li class="default">值示例</li>
|
|
10
|
-
<li class="required">必填</li>
|
|
11
|
-
<li class="comment">说明</li>
|
|
12
|
-
<li class="action">操作</li>
|
|
13
|
-
</ul>
|
|
14
|
-
</header>
|
|
15
|
-
|
|
16
|
-
<ul class="tableBody">
|
|
17
|
-
<li>
|
|
18
|
-
<div class="row check">
|
|
19
|
-
<input type="checkbox" />
|
|
20
|
-
</div>
|
|
21
|
-
<div class="row name">
|
|
22
|
-
<Input value="dfgg" size="small" />
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row type">
|
|
25
|
-
<Select size="small" transfer>
|
|
26
|
-
<Option value="string">string</Option>
|
|
27
|
-
<Option value="number">number</Option>
|
|
28
|
-
<Option value="boolean">boolean</Option>
|
|
29
|
-
<Option value="object">object</Option>
|
|
30
|
-
<Option value="array">array</Option>
|
|
31
|
-
<Option value="null">null</Option>
|
|
32
|
-
</Select>
|
|
33
|
-
</div>
|
|
34
|
-
<div class="row value">
|
|
35
|
-
<Input value="dfgg" size="small" />
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<div class="row comment">
|
|
39
|
-
<Input value="dfgg" size="small" />
|
|
40
|
-
</div>
|
|
41
|
-
<div class="row action"></div>
|
|
42
|
-
</li>
|
|
43
|
-
</ul>
|
|
44
|
-
</div>
|
|
45
|
-
</template>
|
|
46
|
-
|
|
47
|
-
<script lang="ts" src="./table.ts"></script>
|
|
48
|
-
|
|
49
|
-
<style lang="less" scoped>
|
|
50
|
-
.table {
|
|
51
|
-
width: 100%;
|
|
52
|
-
|
|
53
|
-
.check {
|
|
54
|
-
width: 50px;
|
|
55
|
-
}
|
|
56
|
-
.name {
|
|
57
|
-
width: 200px;
|
|
58
|
-
}
|
|
59
|
-
.type {
|
|
60
|
-
width: 100px;
|
|
61
|
-
}
|
|
62
|
-
.value {
|
|
63
|
-
width: 200px;
|
|
64
|
-
}
|
|
65
|
-
.comment {
|
|
66
|
-
width: 300px;
|
|
67
|
-
}
|
|
68
|
-
.action {
|
|
69
|
-
width: 100px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.row {
|
|
73
|
-
display: inline-block;
|
|
74
|
-
padding: 0 4px;
|
|
75
|
-
box-sizing: border-box;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.SCHEME {
|
|
80
|
-
.default,
|
|
81
|
-
.required {
|
|
82
|
-
display: none;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
header {
|
|
87
|
-
background-color: #f8f8f9;
|
|
88
|
-
li {
|
|
89
|
-
// text-align: center;
|
|
90
|
-
padding: 6px 14px;
|
|
91
|
-
display: inline-block;
|
|
92
|
-
font-weight: bold;
|
|
93
|
-
box-sizing: border-box;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.tableBody {
|
|
98
|
-
li {
|
|
99
|
-
padding: 10px;
|
|
100
|
-
box-sizing: border-box;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
</style>
|
package/dist/api-helper/xhr.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// XHR 发送组件
|
|
2
|
-
export default {
|
|
3
|
-
data() {
|
|
4
|
-
return {
|
|
5
|
-
loading: false,
|
|
6
|
-
response: {
|
|
7
|
-
readyState: 0,
|
|
8
|
-
status: 0,
|
|
9
|
-
elapsed: 0,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
methods: {
|
|
15
|
-
doRequest(method, url, params, cfg) {
|
|
16
|
-
let el = new Date();
|
|
17
|
-
let xhr = new XMLHttpRequest();
|
|
18
|
-
xhr.open(method, url);
|
|
19
|
-
xhr.timeout = 5000; // 设置超时时间为5秒
|
|
20
|
-
xhr.ontimeout = () => this.loading = false;// 请求超时后的处理
|
|
21
|
-
xhr.onreadystatechange = () => {
|
|
22
|
-
this.loading = true;
|
|
23
|
-
this.response.readyState = xhr.readyState;
|
|
24
|
-
this.response.status = xhr.status;
|
|
25
|
-
|
|
26
|
-
if (xhr.readyState === 4) {
|
|
27
|
-
try {
|
|
28
|
-
if (!xhr.responseText) {
|
|
29
|
-
this.$Message.error('服务端返回空的字符串');
|
|
30
|
-
this.loading = false;
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 跨域可能不能获取完整的响应头 https://qzy.im/blog/2020/09/can-not-get-response-header-using-javascript-in-cors-request/
|
|
36
|
-
let heads = xhr.getAllResponseHeaders();
|
|
37
|
-
heads = heads.split(';').join('\n');
|
|
38
|
-
this.responseHead = heads;
|
|
39
|
-
|
|
40
|
-
let parseContentType = cfg && cfg.parseContentType;
|
|
41
|
-
switch (parseContentType) {
|
|
42
|
-
case "text":
|
|
43
|
-
data = responseText;
|
|
44
|
-
break;
|
|
45
|
-
case "xml":
|
|
46
|
-
data = xhr.responseXML;
|
|
47
|
-
break;
|
|
48
|
-
case "json":
|
|
49
|
-
default:
|
|
50
|
-
this.responseBody = JSON.stringify(JSON.parse(xhr.responseText), null, 2);
|
|
51
|
-
}
|
|
52
|
-
} catch (e) {
|
|
53
|
-
alert("HTTP 请求错误:\n" + e + "\nURL: " + url); // 提示用户 异常
|
|
54
|
-
} finally {
|
|
55
|
-
this.loading = false;
|
|
56
|
-
this.response.elapsed = new Date() - el;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
let requestAll = 'HEAD \n' + method.toUpperCase() + ' ' + url + '\n';
|
|
62
|
-
|
|
63
|
-
if (cfg && cfg.header) {
|
|
64
|
-
for (let i in cfg.header) {
|
|
65
|
-
requestAll += i + " : " + cfg.header[i] + '\n';
|
|
66
|
-
xhr.setRequestHeader(i, cfg.header[i]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (params)
|
|
71
|
-
requestAll += 'BODY:\n' + params;
|
|
72
|
-
|
|
73
|
-
this.requestAll = requestAll;
|
|
74
|
-
xhr.send(params || null);
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
formatStatusCode() {
|
|
78
|
-
let code = this.response.status;
|
|
79
|
-
let str = code + '';
|
|
80
|
-
|
|
81
|
-
if (str[0] === '2')
|
|
82
|
-
return `<span style="color:green">${code}</span>`;
|
|
83
|
-
else if (str[0] === '4' || str[0] === '5')
|
|
84
|
-
return `<span style="color:red">${code}</span>`;
|
|
85
|
-
else
|
|
86
|
-
return str;
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
function json2fromParams(param) {
|
|
92
|
-
let result = "";
|
|
93
|
-
|
|
94
|
-
for (let name in param) {
|
|
95
|
-
if (typeof param[name] != "function")
|
|
96
|
-
result += "&" + name + "=" + encodeURIComponent(param[name]);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return result.substring(1);
|
|
100
|
-
}
|