@ajaxjs/ui 1.2.2 → 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.
Files changed (156) hide show
  1. package/README.md +8 -11
  2. package/dist/api-helper/common/arg.vue +46 -0
  3. package/dist/api-helper/common/http-method.vue +53 -0
  4. package/dist/api-helper/common/input-table.vue +128 -0
  5. package/dist/api-helper/document/document-render.d.ts +10 -0
  6. package/dist/api-helper/document/document-render.js +38 -0
  7. package/dist/api-helper/document/document-render.js.map +1 -0
  8. package/dist/api-helper/document/document-render.ts +35 -0
  9. package/dist/api-helper/document/document-render.vue +155 -0
  10. package/dist/api-helper/document/document.d.ts +31 -0
  11. package/dist/api-helper/document/document.js +55 -0
  12. package/dist/api-helper/document/document.js.map +1 -0
  13. package/dist/api-helper/document/document.ts +55 -0
  14. package/dist/api-helper/document/document.vue +78 -0
  15. package/dist/api-helper/document/perview.vue +0 -0
  16. package/dist/api-helper/index.js +142 -0
  17. package/dist/api-helper/index.vue +108 -0
  18. package/dist/api-helper/request-body.vue +66 -0
  19. package/dist/api-helper/table.d.ts +7 -0
  20. package/dist/api-helper/table.js +13 -0
  21. package/dist/api-helper/table.js.map +1 -0
  22. package/dist/api-helper/table.ts +10 -0
  23. package/dist/api-helper/table.vue +103 -0
  24. package/dist/api-helper/xhr.js +100 -0
  25. package/dist/api-helper2/api-helper.d.ts +194 -0
  26. package/dist/api-helper2/api-helper.vue +144 -0
  27. package/dist/api-helper2/bookmark.vue +168 -0
  28. package/dist/api-helper2/common/arg.vue +46 -0
  29. package/dist/api-helper2/common/http-method.vue +53 -0
  30. package/dist/api-helper2/document/document-render.vue +189 -0
  31. package/dist/api-helper2/document/document.vue +130 -0
  32. package/dist/api-helper2/document/perview.vue +0 -0
  33. package/dist/api-helper2/env.vue +140 -0
  34. package/dist/api-helper2/history.vue +116 -0
  35. package/dist/api-helper2/main.vue +70 -0
  36. package/dist/api-helper2/request-body.vue +68 -0
  37. package/dist/api-helper2/table.vue +116 -0
  38. package/dist/api-selector/api-list-dataservice.d.ts +18 -0
  39. package/dist/api-selector/api-list-dataservice.js +209 -0
  40. package/dist/api-selector/api-list-dataservice.js.map +1 -0
  41. package/dist/api-selector/api-list-dataservice.ts +232 -0
  42. package/dist/api-selector/api-list-swagger.d.ts +28 -0
  43. package/dist/api-selector/api-list-swagger.js +179 -0
  44. package/dist/api-selector/api-list-swagger.js.map +1 -0
  45. package/dist/api-selector/api-list-swagger.ts +206 -0
  46. package/dist/api-selector/api-list.d.ts +80 -0
  47. package/dist/api-selector/api-list.js +129 -0
  48. package/dist/api-selector/api-list.js.map +1 -0
  49. package/dist/api-selector/api-list.ts +135 -0
  50. package/dist/api-selector/index.vue +125 -0
  51. package/dist/api-selector/test-dataservice.d.ts +23 -0
  52. package/dist/api-selector/test-dataservice.js +74 -0
  53. package/dist/api-selector/test-dataservice.js.map +1 -0
  54. package/dist/api-selector/test-swagger.d.ts +901 -0
  55. package/dist/api-selector/test-swagger.js +656 -0
  56. package/dist/api-selector/test-swagger.js.map +1 -0
  57. package/dist/data-source/data-source.css +44 -0
  58. package/dist/data-source/data-source.d.ts +14 -0
  59. package/dist/data-source/data-source.html +59 -0
  60. package/dist/data-source/data-source.js +97 -0
  61. package/dist/data-source/data-source.js.map +1 -0
  62. package/dist/data-source/data-source.less +46 -0
  63. package/dist/data-source/data-source.ts +95 -0
  64. package/dist/data-source/data-source.vue +59 -0
  65. package/dist/iView-ext/fast-iview-table/fast-iview-table.d.ts +37 -0
  66. package/dist/iView-ext/fast-iview-table/fast-iview-table.js +72 -0
  67. package/dist/iView-ext/fast-iview-table/fast-iview-table.js.map +1 -0
  68. package/dist/iView-ext/fast-iview-table/fast-iview-table.ts +75 -0
  69. package/dist/iView-ext/fast-iview-table/fast-iview-table.vue +52 -0
  70. package/dist/iView-ext/fast-iview-table/list.d.ts +44 -0
  71. package/dist/iView-ext/fast-iview-table/list.js +97 -0
  72. package/dist/iView-ext/fast-iview-table/list.js.map +1 -0
  73. package/dist/iView-ext/fast-iview-table/list.ts +109 -0
  74. package/dist/iView-ext/tips.vue +14 -0
  75. package/dist/index.d.ts +33 -31
  76. package/dist/index.js +8 -60
  77. package/dist/index.js.map +1 -1
  78. package/dist/index.ts +15 -0
  79. package/dist/libs/api-helper.d.ts +194 -0
  80. package/dist/libs/api-list.d.ts +15 -0
  81. package/dist/libs/common.d.ts +201 -0
  82. package/dist/libs/entity.d.ts +26 -0
  83. package/dist/libs/entity.js +1 -0
  84. package/dist/libs/entity.js.map +1 -0
  85. package/dist/libs/entity.ts +31 -0
  86. package/dist/libs/iview-widgets.d.ts +59 -0
  87. package/dist/libs/iview-widgets.js +2 -0
  88. package/dist/libs/iview-widgets.js.map +1 -0
  89. package/dist/libs/iview-widgets.ts +73 -0
  90. package/dist/main.d.ts +1 -1
  91. package/dist/main.js +16 -8
  92. package/dist/main.js.map +1 -1
  93. package/dist/main.ts +22 -0
  94. package/dist/table-selector/table-selector.htm +28 -0
  95. package/dist/table-selector/table-selector.js +149 -0
  96. package/package.json +16 -17
  97. package/dist/router/index.d.ts +0 -3
  98. package/dist/router/index.js +0 -44
  99. package/dist/router/index.js.map +0 -1
  100. package/dist/util/cookies.d.ts +0 -18
  101. package/dist/util/cookies.js +0 -46
  102. package/dist/util/cookies.js.map +0 -1
  103. package/dist/util/dom.d.ts +0 -17
  104. package/dist/util/dom.js +0 -44
  105. package/dist/util/dom.js.map +0 -1
  106. package/dist/util/utils.d.ts +0 -51
  107. package/dist/util/utils.js +0 -174
  108. package/dist/util/utils.js.map +0 -1
  109. package/dist/util/xhr-config.d.ts +0 -22
  110. package/dist/util/xhr-config.js +0 -3
  111. package/dist/util/xhr-config.js.map +0 -1
  112. package/dist/util/xhr.d.ts +0 -71
  113. package/dist/util/xhr.js +0 -262
  114. package/dist/util/xhr.js.map +0 -1
  115. package/dist/widget/AccordionMenu.vue +0 -140
  116. package/dist/widget/AdjustFontSize.vue +0 -65
  117. package/dist/widget/Article.vue +0 -59
  118. package/dist/widget/EmptyContent.d.ts +0 -5
  119. package/dist/widget/EmptyContent.js +0 -7
  120. package/dist/widget/EmptyContent.js.map +0 -1
  121. package/dist/widget/Expander.vue +0 -65
  122. package/dist/widget/FileUploader/FileUploader.d.ts +0 -70
  123. package/dist/widget/FileUploader/FileUploader.js +0 -139
  124. package/dist/widget/FileUploader/FileUploader.js.map +0 -1
  125. package/dist/widget/FileUploader/FileUploader.less +0 -68
  126. package/dist/widget/FileUploader/FileUploader.ts +0 -156
  127. package/dist/widget/FileUploader/FileUploader.vue +0 -43
  128. package/dist/widget/HtmlEditor/HtmlEditor.d.ts +0 -70
  129. package/dist/widget/HtmlEditor/HtmlEditor.js +0 -287
  130. package/dist/widget/HtmlEditor/HtmlEditor.js.map +0 -1
  131. package/dist/widget/HtmlEditor/HtmlEditor.less +0 -345
  132. package/dist/widget/HtmlEditor/HtmlEditor.ts +0 -339
  133. package/dist/widget/HtmlEditor/HtmlEditor.vue +0 -70
  134. package/dist/widget/HtmlEditor/html-editor-HtmlSanitizer.js +0 -103
  135. package/dist/widget/ImageEnlarger.vue +0 -105
  136. package/dist/widget/OpacityBanner.vue +0 -125
  137. package/dist/widget/ProcessLine.vue +0 -133
  138. package/dist/widget/Resize.d.ts +0 -51
  139. package/dist/widget/Resize.js +0 -133
  140. package/dist/widget/Resize.js.map +0 -1
  141. package/dist/widget/Resize.ts +0 -152
  142. package/dist/widget/Resize.vue +0 -104
  143. package/dist/widget/TreeSelector.vue +0 -4
  144. package/dist/widget/calendar/BetweenDate.vue +0 -63
  145. package/dist/widget/calendar/Calendar.d.ts +0 -55
  146. package/dist/widget/calendar/Calendar.js +0 -145
  147. package/dist/widget/calendar/Calendar.js.map +0 -1
  148. package/dist/widget/calendar/Calendar.less +0 -210
  149. package/dist/widget/calendar/Calendar.ts +0 -167
  150. package/dist/widget/calendar/Calendar.vue +0 -52
  151. package/dist/widget/calendar/CalendarInput.vue +0 -71
  152. package/dist/widget/form/validator.d.ts +0 -70
  153. package/dist/widget/form/validator.js +0 -220
  154. package/dist/widget/form/validator.js.map +0 -1
  155. package/dist/widget/form/validator.ts +0 -289
  156. package/dist/widget/play-ground/sku.vue +0 -93
@@ -0,0 +1,78 @@
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
@@ -0,0 +1,142 @@
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
+ }
@@ -0,0 +1,108 @@
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>
@@ -0,0 +1,66 @@
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>
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ props: {
3
+ mode: StringConstructor;
4
+ };
5
+ data(): API_HELPER_TABLE;
6
+ };
7
+ export default _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ props: {
5
+ mode: String,
6
+ },
7
+ data() {
8
+ return {
9
+ // mode: "SCHEME",
10
+ };
11
+ },
12
+ };
13
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,10 @@
1
+ export default {
2
+ props: {
3
+ mode: String,
4
+ },
5
+ data() {
6
+ return {
7
+ // mode: "SCHEME",
8
+ } as API_HELPER_TABLE;
9
+ },
10
+ };
@@ -0,0 +1,103 @@
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>
@@ -0,0 +1,100 @@
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
+ }