Skip to content

Commit 4167ba0

Browse files
committed
更新2.0.5
1 parent 9ee1e81 commit 4167ba0

File tree

25 files changed

+555
-144
lines changed

25 files changed

+555
-144
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@ant-design/icons-vue": "^6.0.1",
1212
"@vueuse/core": "^5.1.3",
13-
"ant-design-vue": "2.2.6",
13+
"ant-design-vue": "2.2.8",
1414
"axios": "^0.21.1",
1515
"core-js": "^3.6.5",
1616
"echarts": "^5.1.2",

public/config.js

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ const config = {
1212
// 接口响应超时时间
1313
TIMEOUT: 30000,
1414
// 多个可切换的host
15-
HOSTS: [],
15+
HOSTS: [
16+
{
17+
title: "tp6本地",
18+
host: "http://demo.apidoc.com",
19+
},
20+
],
1621
},
1722
// 多语言
1823
LANG: [
@@ -45,6 +50,10 @@ const config = {
4550
"common.group": "分组",
4651
"common.notGroup": "未分组",
4752
"common.currentApp": "当前应用",
53+
"common.please.input": "请输入",
54+
"common.file.name": "文件名",
55+
"common.appOrVersion": "应用/版本",
56+
"common.setSuccess": "设置成功",
4857
"lang.change.confirm.title": "您确认切换语言为 {langTitle} 吗?",
4958
"lang.change.confirm.content": "确认后将刷新页面,并回到首页",
5059
"host.change.confirm.title": "您确认切换Host为 {hostTitle} 吗?",
@@ -75,7 +84,7 @@ const config = {
7584
"layout.tabs.closeRight": "关闭右侧",
7685
"layout.tabs.closeAll": "关闭全部",
7786
"globalParam.title": "全局参数",
78-
"globalParam.header": "Header",
87+
"globalParam.header": "Headers",
7988
"globalParam.header.message": "发送请求时,所有接口将自动携带以下Header参数。",
8089
"globalParam.params": "Params",
8190
"globalParam.params.message": "发送请求时,所有接口将自动携带以下Params参数。",
@@ -93,6 +102,94 @@ const config = {
93102
"apiPage.debug.event.clearParam": "清除请求参数",
94103
"apiPage.debug.event.handleParam": "处理请求参数",
95104
"apiPage.debug.event.ajax": "发送请求",
105+
"generator.title": "接口生成",
106+
"generator.controller.title.placeholder": "请输入控制器标题",
107+
"generator.controller.title": "标题",
108+
"generator.apps.title": "应用/版本",
109+
"generator.group.title": "分组",
110+
"generator.controller.name.placeholder": "请输入contorller文件名",
111+
},
112+
},
113+
{
114+
title: "Engilsh",
115+
lang: "en-us",
116+
messages: {
117+
"app.title": "Apidoc",
118+
"home.title": "Home",
119+
"home.appCount": "App Count",
120+
"home.apiCount": "API Count",
121+
"home.docsCount": "Docs Count",
122+
"common.ok": "Ok",
123+
"common.cancel": "Cancel",
124+
"common.clear": "Clear",
125+
"common.desc": "Describe",
126+
"common.action": "Action",
127+
"common.field": "Field",
128+
"common.type": "Type",
129+
"common.require": "Require",
130+
"common.defaultValue": "DefaultValue",
131+
"common.value": "Value",
132+
"common.api": "API",
133+
"common.docs": "Docs",
134+
"common.close": "Close",
135+
"common.view": "View",
136+
"common.copySuccess": "Copy Success",
137+
"common.page.404": "404-page",
138+
"common.notdata": "No Data",
139+
"common.group": "Group",
140+
"common.notGroup": "Not Group",
141+
"common.currentApp": "Current App",
142+
"lang.change.confirm.title": "Are you switch the language to {langTitle} ?",
143+
"lang.change.confirm.content":
144+
"After confirmation, the page will refresh and return to the home page",
145+
"host.change.confirm.title": "Are you switch the Host to {hostTitle} ?",
146+
"auth.title": "Authorized Access",
147+
"auth.input.placeholder": "Please input the access password",
148+
"apiPage.update.tip": "The Api has been updated",
149+
"apiPage.update.button": "Click here to update",
150+
"apiPage.author": "Author",
151+
"apiPage.tag": "Tag",
152+
"apiPage.docs": "Docs",
153+
"apiPage.json": "Json",
154+
"apiPage.debug": "Debug",
155+
"apiPage.debug.mock.reload": "Reload Mock",
156+
"apiPage.debug.excute": "Excute",
157+
"apiPage.title.header": "Headers",
158+
"apiPage.title.params": "Parameters",
159+
"apiPage.title.responses": "Responses",
160+
"apiPage.mdDetail.title": "{name} Field Describe",
161+
"layout.menu.reload": "Updated Menu",
162+
"layout.menu.openAll": "Open All",
163+
"layout.menu.hideAll": "Hide All",
164+
"layout.cache.reload": "Reload Cache",
165+
"layout.tabs.leftSide": "Left Side",
166+
"layout.tabs.rightSide": "Right Side",
167+
"layout.tabs.notTab": "Not Tab",
168+
"layout.tabs.closeCurrent": "Close Current",
169+
"layout.tabs.closeLeft": "Close Left",
170+
"layout.tabs.closeRight": "Close Right",
171+
"layout.tabs.closeAll": "Close All",
172+
"globalParam.title": "Global Param",
173+
"globalParam.header": "Header",
174+
"globalParam.header.message":
175+
"When send a request, all Api will auto carry the following header。",
176+
"globalParam.params": "Params",
177+
"globalParam.params.message":
178+
"When send a request, all Api will auto carry the following params。",
179+
"globalParam.cancel.confirm": "Are you sure to clear all the above parameters?",
180+
"globalParam.add": "Add Param",
181+
"apiPage.json.formatError": "Json Format Error",
182+
"apiPage.debug.event.before": "Before Event",
183+
"apiPage.debug.event.after": "After Event",
184+
"apiPage.debug.event.setHeader": "SetHeader",
185+
"apiPage.debug.event.setGlobalHeader": "SetGlobalHeader",
186+
"apiPage.debug.event.setGlobalParam": "SetGlobalParam",
187+
"apiPage.debug.event.clearGlobalHeader": "ClearGlobalHeader",
188+
"apiPage.debug.event.clearGlobalParam": "ClearGlobalParam",
189+
"apiPage.debug.event.setParam": "SetParam",
190+
"apiPage.debug.event.clearParam": "ClearParam",
191+
"apiPage.debug.event.handleParam": "HandleParam",
192+
"apiPage.debug.event.ajax": "Send A Request",
96193
},
97194
},
98195
],

src/api/interface/apiData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ export interface ApiEventItem {
5656
url?: string;
5757
method?: string;
5858
contentType?: string;
59+
appKey?: string;
5960
}

src/api/interface/config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ConfigInfo {
1717
parameters?: ConfigGlobalParamItem[];
1818
responses?: ConfigGlobalParamItem[];
1919
title?: string;
20+
generator?: ConfigGeneratorItem[];
2021
}
2122

2223
/**
@@ -25,10 +26,12 @@ export interface ConfigInfo {
2526
export interface ConfigAppItem {
2627
folder: string;
2728
groups?: ConfigAppGroupItem[];
28-
path: string;
29+
path?: string;
2930
title: string;
3031
hasPassword?: boolean;
3132
items?: ConfigAppItem[];
33+
headers?: ConfigGlobalParamItem[];
34+
parameters?: ConfigGlobalParamItem[];
3235
}
3336

3437
/**
@@ -64,4 +67,12 @@ export interface ConfigGlobalParamItem {
6467
require: boolean;
6568
desc: string;
6669
value?: string;
70+
appKey?: string;
71+
appDisabled?: boolean;
72+
}
73+
74+
export interface ConfigGeneratorItem {
75+
title: string;
76+
name: string;
77+
files: ObjectType;
6778
}

src/components/AppSelect/AppSelect.vue

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@
44
:value="appKey"
55
class="app-select_select"
66
option-label-prop="label"
7+
:disabled="disabled"
78
@change="onChange"
89
>
9-
<template v-for="item in config.apps" :key="item.folder">
10+
<template v-for="(item, index) in appList">
1011
<template v-if="item.items && item.items.length">
11-
<a-select-opt-group :label="item.title">
12+
<a-select-opt-group :label="item.title" :key="index">
1213
<a-select-option
1314
v-for="option in item.items"
1415
:key="`${item.folder},${option.folder}`"
1516
:value="`${item.folder},${option.folder}`"
1617
:label="`${item.title}-${option.title}`"
1718
>
1819
{{ option.title }}
19-
<span v-if="option.hasPassword" class="app-select-option_icon"><LockOutlined /></span>
20+
<span v-if="option.hasPassword && showLock" class="app-select-option_icon"
21+
><LockOutlined
22+
/></span>
2023
</a-select-option>
2124
</a-select-opt-group>
2225
</template>
2326
<template v-else>
24-
<a-select-option
25-
:value="`${item.folder}`"
26-
:label="`${item.title}`"
27-
:key="`${item.folder}`"
28-
>
27+
<a-select-option :value="`${item.folder}`" :label="`${item.title}`" :key="`${index}`">
2928
{{ item.title }}
30-
<span v-if="item.hasPassword" class="app-select-option_icon"><LockOutlined /></span>
29+
<span v-if="item.hasPassword && showLock" class="app-select-option_icon"
30+
><LockOutlined
31+
/></span>
3132
</a-select-option>
3233
</template>
3334
</template>
@@ -37,12 +38,12 @@
3738

3839
<script lang="ts">
3940
import { Select } from "ant-design-vue";
40-
import { reactive, defineComponent, toRefs, computed } from "vue";
41+
import { reactive, defineComponent, toRefs, computed, PropType, watch } from "vue";
4142
import { useStore } from "vuex";
4243
import { GlobalState } from "@/store";
43-
// import { useRouter } from "vue-router";
4444
import * as Types from "@/store/modules/App/types";
4545
import { LockOutlined } from "@ant-design/icons-vue";
46+
import { ConfigAppItem } from "@/api/interface/config";
4647
4748
export default defineComponent({
4849
components: {
@@ -51,17 +52,51 @@ export default defineComponent({
5152
ASelectOptGroup: Select.OptGroup,
5253
LockOutlined,
5354
},
54-
setup() {
55+
props: {
56+
showLock: {
57+
type: Boolean as PropType<boolean>,
58+
required: false,
59+
default: true,
60+
},
61+
value: String,
62+
options: {
63+
type: Array as PropType<ConfigAppItem[]>,
64+
default: () => {
65+
return [];
66+
},
67+
},
68+
disabled: {
69+
type: Boolean as PropType<boolean>,
70+
default: false,
71+
},
72+
},
73+
setup(props, { attrs }) {
5574
let store = useStore<GlobalState>();
5675
const state = reactive({
57-
count: 0,
58-
config: computed(() => store.state.app.config),
59-
feConfig: computed(() => store.state.app.feConfig),
60-
appKey: computed(() => store.state.app.appKey),
76+
appKey: props.value,
77+
appList: computed(() => {
78+
if (props.options && props.options.length) {
79+
return props.options;
80+
}
81+
const config = store.state.app.config;
82+
return config.apps;
83+
}),
6184
});
6285
86+
watch(
87+
() => props.value,
88+
(v) => {
89+
state.appKey = v;
90+
}
91+
);
92+
6393
const onChange = (appKey: string) => {
64-
store.dispatch(`app/${Types.SET_APP_KEY}`, appKey);
94+
if (attrs.onChange) {
95+
const changeFun: any = attrs.onChange;
96+
changeFun(appKey);
97+
} else {
98+
store.dispatch(`app/${Types.SET_APP_KEY}`, appKey);
99+
}
65100
};
66101
67102
return { ...toRefs(state), onChange };

src/components/GlobalParams/Index.vue

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@cancel="onCancel"
1212
>
1313
<a-tabs :activeKey="currentTabKey" @change="onTabChange">
14-
<a-tab-pane key="header" :tab="t('globalParam.header')">
14+
<a-tab-pane key="headers" :tab="t('globalParam.header')">
1515
<a-alert
1616
type="info"
1717
show-icon
@@ -85,27 +85,25 @@ export default defineComponent({
8585
const paramsData = ref<DataItemType[]>([]);
8686
const headerTableRef = ref<HTMLElement | null>(null);
8787
const paramsTableRef = ref<HTMLElement | null>(null);
88-
const currentTabKey = ref<TabKeys>("header");
88+
const currentTabKey = ref<TabKeys>("headers");
8989
9090
function handleData(globalParams: GlobalParamsState) {
91-
if (globalParams.header && globalParams.header.length) {
92-
headerData.value = globalParams.header.map((item) => {
91+
if (globalParams.headers && globalParams.headers.length) {
92+
headerData.value = globalParams.headers.map((item) => {
9393
return {
94+
...item,
9495
id: createRandKey(),
95-
name: item.name,
96-
value: item.value,
97-
desc: item.desc,
96+
appKey: item.appKey ? item.appKey : "global",
9897
};
9998
});
10099
}
101100
102101
if (globalParams.params && globalParams.params.length) {
103102
paramsData.value = globalParams.params.map((item) => {
104103
return {
104+
...item,
105105
id: createRandKey(),
106-
name: item.name,
107-
value: item.value,
108-
desc: item.desc,
106+
appKey: item.appKey ? item.appKey : "global",
109107
};
110108
});
111109
}
@@ -115,48 +113,26 @@ export default defineComponent({
115113
handleData(globalParams.value);
116114
});
117115
function handleDelete() {
118-
if (currentTabKey.value === "header") {
119-
if (config.value.headers && config.value.headers.length) {
120-
headerData.value = config.value.headers.map((item) => {
121-
return {
122-
id: createRandKey(),
123-
name: item.name,
124-
value: item.value,
125-
desc: item.desc,
126-
};
127-
});
128-
} else {
129-
headerData.value = [];
130-
}
116+
if (currentTabKey.value === "headers") {
117+
headerData.value = [];
131118
} else if (currentTabKey.value === "params") {
132-
if (config.value.parameters && config.value.parameters.length) {
133-
paramsData.value = config.value.parameters.map((item) => {
134-
return {
135-
id: createRandKey(),
136-
name: item.name,
137-
value: item.value,
138-
desc: item.desc,
139-
};
140-
});
141-
} else {
142-
paramsData.value = [];
143-
}
119+
paramsData.value = [];
144120
}
145121
}
146122
147123
function handleOk() {
148124
const json = {
149-
header: headerData.value,
125+
headers: headerData.value,
150126
params: paramsData.value,
151127
};
152128
if (unref(headerTableRef)) {
153-
json.header = (unref(headerTableRef) as any).getData();
129+
json.headers = (unref(headerTableRef) as any).getData();
154130
}
155131
if (unref(paramsTableRef)) {
156132
json.params = (unref(paramsTableRef) as any).getData();
157133
}
158134
store.dispatch(`apidoc/${Types.SET_GLOBAL_PARAMS}`, json);
159-
message.success("设置成功");
135+
message.success(t("common.setSuccess"));
160136
onCancel();
161137
}
162138

0 commit comments

Comments
 (0)