Skip to content

Commit

Permalink
更新2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
HGthecode committed Oct 9, 2021
1 parent 9ee1e81 commit 4167ba0
Show file tree
Hide file tree
Showing 25 changed files with 555 additions and 144 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@ant-design/icons-vue": "^6.0.1",
"@vueuse/core": "^5.1.3",
"ant-design-vue": "2.2.6",
"ant-design-vue": "2.2.8",
"axios": "^0.21.1",
"core-js": "^3.6.5",
"echarts": "^5.1.2",
Expand Down
101 changes: 99 additions & 2 deletions public/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ const config = {
// 接口响应超时时间
TIMEOUT: 30000,
// 多个可切换的host
HOSTS: [],
HOSTS: [
{
title: "tp6本地",
host: "http://demo.apidoc.com",
},
],
},
// 多语言
LANG: [
Expand Down Expand Up @@ -45,6 +50,10 @@ const config = {
"common.group": "分组",
"common.notGroup": "未分组",
"common.currentApp": "当前应用",
"common.please.input": "请输入",
"common.file.name": "文件名",
"common.appOrVersion": "应用/版本",
"common.setSuccess": "设置成功",
"lang.change.confirm.title": "您确认切换语言为 {langTitle} 吗?",
"lang.change.confirm.content": "确认后将刷新页面,并回到首页",
"host.change.confirm.title": "您确认切换Host为 {hostTitle} 吗?",
Expand Down Expand Up @@ -75,7 +84,7 @@ const config = {
"layout.tabs.closeRight": "关闭右侧",
"layout.tabs.closeAll": "关闭全部",
"globalParam.title": "全局参数",
"globalParam.header": "Header",
"globalParam.header": "Headers",
"globalParam.header.message": "发送请求时,所有接口将自动携带以下Header参数。",
"globalParam.params": "Params",
"globalParam.params.message": "发送请求时,所有接口将自动携带以下Params参数。",
Expand All @@ -93,6 +102,94 @@ const config = {
"apiPage.debug.event.clearParam": "清除请求参数",
"apiPage.debug.event.handleParam": "处理请求参数",
"apiPage.debug.event.ajax": "发送请求",
"generator.title": "接口生成",
"generator.controller.title.placeholder": "请输入控制器标题",
"generator.controller.title": "标题",
"generator.apps.title": "应用/版本",
"generator.group.title": "分组",
"generator.controller.name.placeholder": "请输入contorller文件名",
},
},
{
title: "Engilsh",
lang: "en-us",
messages: {
"app.title": "Apidoc",
"home.title": "Home",
"home.appCount": "App Count",
"home.apiCount": "API Count",
"home.docsCount": "Docs Count",
"common.ok": "Ok",
"common.cancel": "Cancel",
"common.clear": "Clear",
"common.desc": "Describe",
"common.action": "Action",
"common.field": "Field",
"common.type": "Type",
"common.require": "Require",
"common.defaultValue": "DefaultValue",
"common.value": "Value",
"common.api": "API",
"common.docs": "Docs",
"common.close": "Close",
"common.view": "View",
"common.copySuccess": "Copy Success",
"common.page.404": "404-page",
"common.notdata": "No Data",
"common.group": "Group",
"common.notGroup": "Not Group",
"common.currentApp": "Current App",
"lang.change.confirm.title": "Are you switch the language to {langTitle} ?",
"lang.change.confirm.content":
"After confirmation, the page will refresh and return to the home page",
"host.change.confirm.title": "Are you switch the Host to {hostTitle} ?",
"auth.title": "Authorized Access",
"auth.input.placeholder": "Please input the access password",
"apiPage.update.tip": "The Api has been updated",
"apiPage.update.button": "Click here to update",
"apiPage.author": "Author",
"apiPage.tag": "Tag",
"apiPage.docs": "Docs",
"apiPage.json": "Json",
"apiPage.debug": "Debug",
"apiPage.debug.mock.reload": "Reload Mock",
"apiPage.debug.excute": "Excute",
"apiPage.title.header": "Headers",
"apiPage.title.params": "Parameters",
"apiPage.title.responses": "Responses",
"apiPage.mdDetail.title": "{name} Field Describe",
"layout.menu.reload": "Updated Menu",
"layout.menu.openAll": "Open All",
"layout.menu.hideAll": "Hide All",
"layout.cache.reload": "Reload Cache",
"layout.tabs.leftSide": "Left Side",
"layout.tabs.rightSide": "Right Side",
"layout.tabs.notTab": "Not Tab",
"layout.tabs.closeCurrent": "Close Current",
"layout.tabs.closeLeft": "Close Left",
"layout.tabs.closeRight": "Close Right",
"layout.tabs.closeAll": "Close All",
"globalParam.title": "Global Param",
"globalParam.header": "Header",
"globalParam.header.message":
"When send a request, all Api will auto carry the following header。",
"globalParam.params": "Params",
"globalParam.params.message":
"When send a request, all Api will auto carry the following params。",
"globalParam.cancel.confirm": "Are you sure to clear all the above parameters?",
"globalParam.add": "Add Param",
"apiPage.json.formatError": "Json Format Error",
"apiPage.debug.event.before": "Before Event",
"apiPage.debug.event.after": "After Event",
"apiPage.debug.event.setHeader": "SetHeader",
"apiPage.debug.event.setGlobalHeader": "SetGlobalHeader",
"apiPage.debug.event.setGlobalParam": "SetGlobalParam",
"apiPage.debug.event.clearGlobalHeader": "ClearGlobalHeader",
"apiPage.debug.event.clearGlobalParam": "ClearGlobalParam",
"apiPage.debug.event.setParam": "SetParam",
"apiPage.debug.event.clearParam": "ClearParam",
"apiPage.debug.event.handleParam": "HandleParam",
"apiPage.debug.event.ajax": "Send A Request",
},
},
],
Expand Down
1 change: 1 addition & 0 deletions src/api/interface/apiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ export interface ApiEventItem {
url?: string;
method?: string;
contentType?: string;
appKey?: string;
}
13 changes: 12 additions & 1 deletion src/api/interface/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ConfigInfo {
parameters?: ConfigGlobalParamItem[];
responses?: ConfigGlobalParamItem[];
title?: string;
generator?: ConfigGeneratorItem[];
}

/**
Expand All @@ -25,10 +26,12 @@ export interface ConfigInfo {
export interface ConfigAppItem {
folder: string;
groups?: ConfigAppGroupItem[];
path: string;
path?: string;
title: string;
hasPassword?: boolean;
items?: ConfigAppItem[];
headers?: ConfigGlobalParamItem[];
parameters?: ConfigGlobalParamItem[];
}

/**
Expand Down Expand Up @@ -64,4 +67,12 @@ export interface ConfigGlobalParamItem {
require: boolean;
desc: string;
value?: string;
appKey?: string;
appDisabled?: boolean;
}

export interface ConfigGeneratorItem {
title: string;
name: string;
files: ObjectType;
}
69 changes: 52 additions & 17 deletions src/components/AppSelect/AppSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@
:value="appKey"
class="app-select_select"
option-label-prop="label"
:disabled="disabled"
@change="onChange"
>
<template v-for="item in config.apps" :key="item.folder">
<template v-for="(item, index) in appList">
<template v-if="item.items && item.items.length">
<a-select-opt-group :label="item.title">
<a-select-opt-group :label="item.title" :key="index">
<a-select-option
v-for="option in item.items"
:key="`${item.folder},${option.folder}`"
:value="`${item.folder},${option.folder}`"
:label="`${item.title}-${option.title}`"
>
{{ option.title }}
<span v-if="option.hasPassword" class="app-select-option_icon"><LockOutlined /></span>
<span v-if="option.hasPassword && showLock" class="app-select-option_icon"
><LockOutlined
/></span>
</a-select-option>
</a-select-opt-group>
</template>
<template v-else>
<a-select-option
:value="`${item.folder}`"
:label="`${item.title}`"
:key="`${item.folder}`"
>
<a-select-option :value="`${item.folder}`" :label="`${item.title}`" :key="`${index}`">
{{ item.title }}
<span v-if="item.hasPassword" class="app-select-option_icon"><LockOutlined /></span>
<span v-if="item.hasPassword && showLock" class="app-select-option_icon"
><LockOutlined
/></span>
</a-select-option>
</template>
</template>
Expand All @@ -37,12 +38,12 @@

<script lang="ts">
import { Select } from "ant-design-vue";
import { reactive, defineComponent, toRefs, computed } from "vue";
import { reactive, defineComponent, toRefs, computed, PropType, watch } from "vue";
import { useStore } from "vuex";
import { GlobalState } from "@/store";
// import { useRouter } from "vue-router";
import * as Types from "@/store/modules/App/types";
import { LockOutlined } from "@ant-design/icons-vue";
import { ConfigAppItem } from "@/api/interface/config";
export default defineComponent({
components: {
Expand All @@ -51,17 +52,51 @@ export default defineComponent({
ASelectOptGroup: Select.OptGroup,
LockOutlined,
},
setup() {
props: {
showLock: {
type: Boolean as PropType<boolean>,
required: false,
default: true,
},
value: String,
options: {
type: Array as PropType<ConfigAppItem[]>,
default: () => {
return [];
},
},
disabled: {
type: Boolean as PropType<boolean>,
default: false,
},
},
setup(props, { attrs }) {
let store = useStore<GlobalState>();
const state = reactive({
count: 0,
config: computed(() => store.state.app.config),
feConfig: computed(() => store.state.app.feConfig),
appKey: computed(() => store.state.app.appKey),
appKey: props.value,
appList: computed(() => {
if (props.options && props.options.length) {
return props.options;
}
const config = store.state.app.config;
return config.apps;
}),
});
watch(
() => props.value,
(v) => {
state.appKey = v;
}
);
const onChange = (appKey: string) => {
store.dispatch(`app/${Types.SET_APP_KEY}`, appKey);
if (attrs.onChange) {
const changeFun: any = attrs.onChange;
changeFun(appKey);
} else {
store.dispatch(`app/${Types.SET_APP_KEY}`, appKey);
}
};
return { ...toRefs(state), onChange };
Expand Down
52 changes: 14 additions & 38 deletions src/components/GlobalParams/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@cancel="onCancel"
>
<a-tabs :activeKey="currentTabKey" @change="onTabChange">
<a-tab-pane key="header" :tab="t('globalParam.header')">
<a-tab-pane key="headers" :tab="t('globalParam.header')">
<a-alert
type="info"
show-icon
Expand Down Expand Up @@ -85,27 +85,25 @@ export default defineComponent({
const paramsData = ref<DataItemType[]>([]);
const headerTableRef = ref<HTMLElement | null>(null);
const paramsTableRef = ref<HTMLElement | null>(null);
const currentTabKey = ref<TabKeys>("header");
const currentTabKey = ref<TabKeys>("headers");
function handleData(globalParams: GlobalParamsState) {
if (globalParams.header && globalParams.header.length) {
headerData.value = globalParams.header.map((item) => {
if (globalParams.headers && globalParams.headers.length) {
headerData.value = globalParams.headers.map((item) => {
return {
...item,
id: createRandKey(),
name: item.name,
value: item.value,
desc: item.desc,
appKey: item.appKey ? item.appKey : "global",
};
});
}
if (globalParams.params && globalParams.params.length) {
paramsData.value = globalParams.params.map((item) => {
return {
...item,
id: createRandKey(),
name: item.name,
value: item.value,
desc: item.desc,
appKey: item.appKey ? item.appKey : "global",
};
});
}
Expand All @@ -115,48 +113,26 @@ export default defineComponent({
handleData(globalParams.value);
});
function handleDelete() {
if (currentTabKey.value === "header") {
if (config.value.headers && config.value.headers.length) {
headerData.value = config.value.headers.map((item) => {
return {
id: createRandKey(),
name: item.name,
value: item.value,
desc: item.desc,
};
});
} else {
headerData.value = [];
}
if (currentTabKey.value === "headers") {
headerData.value = [];
} else if (currentTabKey.value === "params") {
if (config.value.parameters && config.value.parameters.length) {
paramsData.value = config.value.parameters.map((item) => {
return {
id: createRandKey(),
name: item.name,
value: item.value,
desc: item.desc,
};
});
} else {
paramsData.value = [];
}
paramsData.value = [];
}
}
function handleOk() {
const json = {
header: headerData.value,
headers: headerData.value,
params: paramsData.value,
};
if (unref(headerTableRef)) {
json.header = (unref(headerTableRef) as any).getData();
json.headers = (unref(headerTableRef) as any).getData();
}
if (unref(paramsTableRef)) {
json.params = (unref(paramsTableRef) as any).getData();
}
store.dispatch(`apidoc/${Types.SET_GLOBAL_PARAMS}`, json);
message.success("设置成功");
message.success(t("common.setSuccess"));
onCancel();
}
Expand Down
Loading

0 comments on commit 4167ba0

Please sign in to comment.