@ajaxjs/ui 1.2.3 → 1.2.5

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/README.md CHANGED
@@ -1,7 +1,23 @@
1
+ [![NPM](https://img.shields.io/npm/v/@ajaxjs/ui.svg?sanitize=true)](https://www.npmjs.com/package/@ajaxjs/ui)
2
+ [![Vue.js](https://img.shields.io/badge/Vue.js-2.6.14-brightgreen.svg?style=flat&logo=vuedotjs&logoColor=white)](https://vuejs.org)
3
+ [![TypeScript](https://img.shields.io/badge/TypeScript-4.9.4-blue.svg?style=flat&logo=Typescript&logoColor=white)](https://www.typescriptlang.org/)
4
+ [![License](https://img.shields.io/badge/license-Apache--2.0-green.svg?longCache=true&style=flat)](http://www.apache.org/licenses/LICENSE-2.0.txt)
5
+ [![Email](https://img.shields.io/badge/Contact--me-Email-orange.svg)](mailto:frank@ajaxjs.com)
6
+ [![QQ群](https://framework.ajaxjs.com/static/qq.svg)](https://shang.qq.com/wpa/qunwpa?idkey=3877893a4ed3a5f0be01e809e7ac120e346102bd550deb6692239bb42de38e22)
7
+
1
8
  # Widgets based on iView.js
2
9
 
3
10
  for Vue2 & iView.js v2
4
11
 
12
+ NPM: https://www.npmjs.com/package/@ajaxjs/ui.
13
+
14
+ ```shell
15
+ npm i @ajaxjs/ui # install
16
+ npm run dev # do coding
17
+ npm run build # output js
18
+ npm run release # deploy to NPM
19
+ ```
20
+
5
21
  ## API Selector API 选择器
6
22
 
7
23
  ## API Helper 可视化 HTTP 请求工具
@@ -0,0 +1,194 @@
1
+ /**
2
+ * 表格定义
3
+ */
4
+ declare type API_HELPER_TABLE = {
5
+ mode: 'SIMPLE' | 'SCHEME';
6
+ };
7
+
8
+ /**
9
+ * 环境
10
+ */
11
+ declare type API_HELPER_ENV = {
12
+ id: number;
13
+ name: string;
14
+
15
+ /**
16
+ * URL 前缀
17
+ */
18
+ urlPrefix: string;
19
+
20
+ /**
21
+ *
22
+ */
23
+ actived: boolean;
24
+ };
25
+
26
+ /**
27
+ * HTTP 方法
28
+ */
29
+ declare type API_HELPER_HTTP_METHOD = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTION';
30
+
31
+ /**
32
+ * 历史记录
33
+ */
34
+ declare type API_HELPER_HISTORY = {
35
+ id: number;
36
+
37
+ /**
38
+ * 任务名称,可选
39
+ */
40
+ name?: string;
41
+
42
+ /**
43
+ * 任务 id,可选
44
+ */
45
+ nameId: number;
46
+
47
+ httpMethod: API_HELPER_HTTP_METHOD;
48
+
49
+ url: string;
50
+
51
+ /**
52
+ * 请求日期
53
+ */
54
+ date: string;
55
+
56
+ /**
57
+ * 耗时
58
+ */
59
+ time: number;
60
+
61
+ stateCode: number;
62
+ };
63
+
64
+ /**
65
+ * 参数的枚举值
66
+ */
67
+ declare type API_HELPER_ARGUMENT_ENU = {
68
+ /**
69
+ * 是否默认
70
+ */
71
+ isDefault?: boolean;
72
+
73
+ /**
74
+ * 值
75
+ */
76
+ value: any;
77
+
78
+ /**
79
+ * 值是什么含义
80
+ */
81
+ comment: string;
82
+ };
83
+
84
+ /**
85
+ * 参数
86
+ */
87
+ declare type API_HELPER_ARGUMENT = {
88
+ /**
89
+ * 是否使用
90
+ */
91
+ isEnable: boolean;
92
+
93
+ /**
94
+ * 变量
95
+ */
96
+ name: string;
97
+
98
+ /**
99
+ * 参数说明
100
+ */
101
+ desc: string;
102
+
103
+ /**
104
+ * 参数位置
105
+ */
106
+ type: 'HEADER' | 'PATH' | 'QUERY' | 'BODY' | 'FORM';
107
+
108
+ /**
109
+ * 数据类型
110
+ */
111
+ dataType: any;
112
+
113
+ /**
114
+ * 对应后端语言的类型或者枚举
115
+ */
116
+ mappingType?: any;
117
+
118
+ /**
119
+ * 值,枚举值
120
+ */
121
+ values?: API_HELPER_ARGUMENT_ENU[];
122
+
123
+ /**
124
+ * 是否必填
125
+ */
126
+ isRequired: boolean;
127
+
128
+ /**
129
+ * 说明,描述
130
+ */
131
+ comment: string;
132
+ };
133
+
134
+ /**
135
+ * JSON 类型参数
136
+ */
137
+ declare type API_HELPER_JSON_ARGUMENT = API_HELPER_ARGUMENT & {
138
+ /**
139
+ * 类型
140
+ */
141
+ dataType: number | string | boolean | null | array | object;
142
+ };
143
+
144
+ /**
145
+ * 文档
146
+ */
147
+ declare type API_HELPER_DOCUMENT = {
148
+ /**
149
+ * ID
150
+ */
151
+ id: any;
152
+
153
+ /**
154
+ * 名称
155
+ */
156
+ name: string;
157
+
158
+ /**
159
+ * 分组
160
+ */
161
+ catalogId: any;
162
+
163
+ /**
164
+ * 说明
165
+ */
166
+ description: string;
167
+
168
+ /**
169
+ * HTTP 请求方法
170
+ */
171
+ httpMethod: API_HELPER_HTTP_METHOD;
172
+
173
+ url: string;
174
+
175
+ /**
176
+ * 对应 UI,图片地址
177
+ */
178
+ ui: string;
179
+
180
+ /**
181
+ * 请求示例
182
+ */
183
+ demoUrl: string;
184
+
185
+ /**
186
+ * 接口编码状态
187
+ */
188
+ codeState: 'INITED' | 'DEFINED' | 'DONE';
189
+
190
+ /**
191
+ * 是否在文档汇总中展示
192
+ */
193
+ isShow: boolean;
194
+ };
@@ -0,0 +1,144 @@
1
+ <template>
2
+ <div class="container">
3
+ <div class="left">
4
+ <Tabs value="history" :animated="false">
5
+ <TabPane label="收藏" name="bookmark">
6
+ <Bookmark />
7
+ </TabPane>
8
+ <TabPane label="历史" name="history">
9
+ <History />
10
+ </TabPane>
11
+ </Tabs>
12
+ </div>
13
+
14
+ <div class="right">
15
+ <nav>
16
+ MyAPI
17
+ <Icon type="md-help-circle" style="margin: 10px 10px 0 10px; float: right; cursor: pointer" size="19" @click="isShowAbout = true" />
18
+ <Dropdown style="margin-left: 10px; float: right" @on-click="onSelectEnvClk" on-click="onSelectEnvClk">
19
+ <Button size="small" style="width: 150px">
20
+ 选择环境...
21
+ <Icon type="ios-arrow-down"></Icon>
22
+ </Button>
23
+ <DropdownMenu slot="list" style="width: 150px">
24
+ <DropdownItem>驴打滚</DropdownItem>
25
+ <DropdownItem>炸酱面</DropdownItem>
26
+ <DropdownItem disabled>豆汁儿</DropdownItem>
27
+ <DropdownItem>冰糖葫芦</DropdownItem>
28
+ <DropdownItem name="config" divided style="color: #2d8cf0">配置环境...</DropdownItem>
29
+ </DropdownMenu>
30
+ </Dropdown>
31
+ </nav>
32
+ <Tabs class="mainTab" name="mainTab" :value="activeTab" :animated="false" type="card" @on-click="ifAdd">
33
+ <TabPane v-for="tab in mainTabs" :key="tab.label" :label="tab.label" :name="tab.name" :index="tab.index" :closable="tab.closable" tab="mainTab" style="padding: 0 10px">
34
+ <Main />
35
+ </TabPane>
36
+ </Tabs>
37
+ </div>
38
+ <Modal title="配置环境" v-model="isShowEnv" ok-text="保存" cancel-text="" width="900">
39
+ <Env />
40
+ </Modal>
41
+
42
+ <Modal v-model="isShowAbout" title="关于" cancel-text="">
43
+ ajaxjs.com 倾情奉献
44
+ </Modal>
45
+ <Modal v-model="isShowArgs" title="参数详情" cancel-text="">
46
+ <Argument />
47
+ </Modal>
48
+ </div>
49
+ </template>
50
+
51
+ <script lang="ts">
52
+ import RequestBody from "./request-body.vue";
53
+ import Main from "./main.vue";
54
+ import Env from "./env.vue";
55
+ import History from "./history.vue";
56
+ import Argument from "./common/arg.vue";
57
+ import Bookmark from "./bookmark.vue";
58
+
59
+ const addTabBtn: any = { label: "+", name: "addTab", closable: false };
60
+
61
+ export default {
62
+ components: { RequestBody, Main, Env, History, Argument, Bookmark },
63
+ data() {
64
+ return {
65
+ activeTab: "tab1",
66
+ mainTabs: [
67
+ {
68
+ label: "获取新闻详情",
69
+ name: "tab1",
70
+ closable: true,
71
+ },
72
+ addTabBtn,
73
+ ],
74
+ isShowEnv: false,
75
+ isShowAbout: false,
76
+ isShowArgs: false,
77
+ };
78
+ },
79
+ methods: {
80
+ ifAdd(name: string): void {
81
+ if (name === "addTab") {
82
+ this.mainTabs.pop(); // 先删除,再增加
83
+
84
+ let tabName: string = "tab" + (this.mainTabs.length + 1);
85
+ this.mainTabs.push({
86
+ label: "新 API",
87
+ name: tabName,
88
+ closable: true,
89
+ });
90
+
91
+ setTimeout(() => {
92
+ this.mainTabs.push(addTabBtn);
93
+ this.activeTab = tabName;
94
+ }, 100);
95
+ }
96
+ },
97
+
98
+ onSelectEnvClk(name: string): void {
99
+ if (name === "config") {
100
+ this.isShowEnv = true;
101
+ }
102
+ },
103
+ },
104
+ };
105
+ </script>
106
+
107
+ <style>
108
+ .mainTab
109
+ > .ivu-tabs-bar
110
+ > .ivu-tabs-nav-container
111
+ > .ivu-tabs-nav-wrap
112
+ > .ivu-tabs-nav-scroll {
113
+ padding-left: 20px;
114
+ margin-top: 3px;
115
+ }
116
+ </style>
117
+
118
+ <style lang="less" scoped>
119
+ nav {
120
+ height: 36px;
121
+ line-height: 36px;
122
+ padding: 0 10px;
123
+ background-color: #f5f5f5;
124
+ border-bottom: 1px solid lightgray;
125
+ }
126
+
127
+ // left-right-layout
128
+ .container {
129
+ display: flex;
130
+ height: 100%;
131
+
132
+ .left {
133
+ height: 100%;
134
+ flex: 0 0 300px;
135
+ border-right: 1px solid lightgray;
136
+ }
137
+
138
+ .right {
139
+ height: 100%;
140
+ flex: 1;
141
+ /*div占据所有剩余宽度 */
142
+ }
143
+ }
144
+ </style>
@@ -0,0 +1,168 @@
1
+ <template>
2
+ <Tree :data="data5" :render="renderContent" class="demo-tree-render"></Tree>
3
+ </template>
4
+ <script>
5
+ export default {
6
+ data() {
7
+ return {
8
+ data5: [
9
+ {
10
+ title: "parent 1",
11
+ expand: true,
12
+ render: (h, { root, node, data }) => {
13
+ return h(
14
+ "span",
15
+ {
16
+ style: {
17
+ display: "inline-block",
18
+ width: "100%",
19
+ },
20
+ },
21
+ [
22
+ h("span", [
23
+ h("Icon", {
24
+ props: {
25
+ type: "ios-folder-outline",
26
+ },
27
+ style: {
28
+ marginRight: "8px",
29
+ },
30
+ }),
31
+ h("span", data.title),
32
+ ]),
33
+ h(
34
+ "span",
35
+ {
36
+ style: {
37
+ display: "inline-block",
38
+ float: "right",
39
+ marginRight: "32px",
40
+ },
41
+ },
42
+ [
43
+ h("Button", {
44
+ props: Object.assign({}, this.buttonProps, {
45
+ icon: "ios-add",
46
+ type: "primary",
47
+ }),
48
+ style: {
49
+ width: "64px",
50
+ },
51
+ on: {
52
+ click: () => {
53
+ this.append(data);
54
+ },
55
+ },
56
+ }),
57
+ ]
58
+ ),
59
+ ]
60
+ );
61
+ },
62
+ children: [
63
+ {
64
+ title: "child 1-1",
65
+ expand: true,
66
+ children: [
67
+ {
68
+ title: "leaf 1-1-1",
69
+ expand: true,
70
+ },
71
+ {
72
+ title: "leaf 1-1-2",
73
+ expand: true,
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ title: "child 1-2",
79
+ expand: true,
80
+ children: [
81
+ {
82
+ title: "leaf 1-2-1",
83
+ expand: true,
84
+ },
85
+ {
86
+ title: "leaf 1-2-1",
87
+ expand: true,
88
+ },
89
+ ],
90
+ },
91
+ ],
92
+ },
93
+ ],
94
+ buttonProps: {
95
+ type: "default",
96
+ size: "small",
97
+ },
98
+ };
99
+ },
100
+ methods: {
101
+ renderContent(h, { root, node, data }) {
102
+ return h(
103
+ "span",
104
+ {
105
+ style: { display: "inline-block", width: "100%" },
106
+ },
107
+ [
108
+ h("span", [
109
+ h("Icon", {
110
+ props: { type: "ios-paper-outline" },
111
+ style: { marginRight: "8px" },
112
+ }),
113
+ h("span", data.title),
114
+ ]),
115
+ h(
116
+ "span",
117
+ {
118
+ style: {
119
+ display: "inline-block",
120
+ float: "right",
121
+ marginRight: "32px",
122
+ },
123
+ },
124
+ [
125
+ h("Button", {
126
+ props: Object.assign({}, this.buttonProps, { icon: "ios-add" }),
127
+ style: { marginRight: "8px" },
128
+ on: {
129
+ click: () => {
130
+ this.append(data);
131
+ },
132
+ },
133
+ }),
134
+ h("Button", {
135
+ props: Object.assign({}, this.buttonProps, {
136
+ icon: "ios-remove",
137
+ }),
138
+ on: {
139
+ click: () => {
140
+ this.remove(root, node, data);
141
+ },
142
+ },
143
+ }),
144
+ ]
145
+ ),
146
+ ]
147
+ );
148
+ },
149
+ append(data) {
150
+ const children = data.children || [];
151
+ children.push({ title: "appended node", expand: true });
152
+ this.$set(data, "children", children);
153
+ },
154
+ remove(root, node, data) {
155
+ const parentKey = root.find((el) => el === node).parent;
156
+ const parent = root.find((el) => el.nodeKey === parentKey).node;
157
+ const index = parent.children.indexOf(data);
158
+ parent.children.splice(index, 1);
159
+ },
160
+ },
161
+ };
162
+ </script>
163
+
164
+ <style>
165
+ .demo-tree-render .ivu-tree-title {
166
+ width: 100%;
167
+ }
168
+ </style>
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <!-- 参数控制 -->
3
+ <Form :label-width="80">
4
+ <FormItem label="参数名称">
5
+ <Input v-model="args.name" placeholder="请输入参数的变量名,必填" />
6
+ </FormItem>
7
+
8
+ <FormItem label="参数类型">
9
+ <Select>
10
+ <Option></Option>
11
+ </Select>
12
+ </FormItem>
13
+
14
+ <FormItem label="是否必填">
15
+ <Checkbox v-model="single">必填</Checkbox>
16
+ </FormItem>
17
+
18
+ <FormItem label="参数值">
19
+ <Select>
20
+ <Option></Option>
21
+ </Select>
22
+ </FormItem>
23
+
24
+ <FormItem label="校验正则">
25
+ <Input v-model="args.name" placeholder="请输入参数的变量名,必填" />
26
+ </FormItem>
27
+
28
+ <FormItem label="参数说明">
29
+ <Input v-model="args.name" type="textarea" :rows="4" placeholder="请输入参数的变量名,必填" />
30
+ </FormItem>
31
+
32
+ </Form>
33
+ </template>
34
+
35
+ <script lang="ts">
36
+ export default {
37
+ data(): {} {
38
+ return {
39
+ args: {} as API_HELPER_ARGUMENT,
40
+ };
41
+ },
42
+ };
43
+ </script>
44
+
45
+ <style lang="less" scoped>
46
+ </style>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <span><span class="httpMethod" :class="type">{{type}}</span></span>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ props: {
8
+ type: {
9
+ type: String,
10
+ required: true,
11
+ },
12
+ },
13
+ };
14
+ </script>
15
+
16
+ <style scoped>
17
+ .httpMethod {
18
+ border: 1px solid;
19
+ border-radius: 3px;
20
+ padding: 0 3px;
21
+ border: 1px solid;
22
+ border-radius: 3px;
23
+ display: inline-block;
24
+ margin-right: 3px;
25
+ font-size: 5px;
26
+ line-height: 15px;
27
+ height: 14px;
28
+ }
29
+
30
+ .GET {
31
+ border-color: #19be6b;
32
+ background-color: #f5fffa;
33
+ color: #19be6b;
34
+ }
35
+
36
+ .POST {
37
+ border-color: #2db7f5;
38
+ background-color: #e8f2fc;
39
+ color: #2db7f5;
40
+ }
41
+
42
+ .PUT {
43
+ border-color: #f90;
44
+ background-color: #fcf3e8;
45
+ color: #f90;
46
+ }
47
+
48
+ .DELETE {
49
+ border-color: #ff4f4f;
50
+ background-color: #ffeeee;
51
+ color: #ff4f4f;
52
+ }
53
+ </style>