Skip to content

Commit

Permalink
更新2.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
HGthecode committed Nov 9, 2021
1 parent 41ecdf1 commit 2a848a9
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 12 deletions.
4 changes: 4 additions & 0 deletions public/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const config = {
// 多个可切换的host
HOSTS: [],
},
MENU: {
SHOWURL: false,
WIDTH: 300,
},
// 多语言
LANG: [
{
Expand Down
45 changes: 44 additions & 1 deletion src/api/interface/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FormItemType } from "@/components/DataForm/interface";

export interface GetConfigState {
lang?: string;
}
Expand Down Expand Up @@ -41,6 +43,9 @@ export interface ConfigAppItem {
export interface ConfigAppGroupItem {
title: string;
name: string;
label?: string;
value?: string;
key?: string;
children?: ConfigAppGroupItem[];
}

Expand Down Expand Up @@ -75,5 +80,43 @@ export interface ConfigGlobalParamItem {
export interface ConfigGeneratorItem {
title: string;
name: string;
files: ObjectType;
files: ConfigGeneratorItemFilesItem[];
form?: ConfigGeneratorItemForm;
table?: ConfigGeneratorItemTable;
}

export interface ConfigGeneratorItemForm {
[key: string]: any;
items: FormItemType[];
}

export interface ConfigGeneratorItemTable {
field_types: any;
items: ConfigGeneratorItemTableItem[];
}

export interface ConfigGeneratorItemTableItem {
title: string;
model_path: string;
default_fields: any;
namespace?: string;
model_tpl?: string;
columns?: ConfigGeneratorItemTableColumn[];
}

export interface ConfigGeneratorItemTableColumn {
title: string;
field: string;
type: string;
slots?: any;
width?: number;
align?: string;
}

export interface ConfigGeneratorItemFilesItem {
name: string;
path: string;
namespace: string;
template?: string;
rules?: any;
}
23 changes: 21 additions & 2 deletions src/components/Menu/src/MenuItemContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
<FileMarkdownOutlined v-else-if="item.path && item.type === 'md'" />
<FolderOutlined v-else />

{{ title }}
<span>{{ title }} </span>
<span
v-if="item.controller && feConfig && feConfig.MENU && feConfig.MENU.SHOWURL"
class="menu-item-text"
>{{ item.controller }}
</span>
<span
v-if="item.url && feConfig && feConfig.MENU && feConfig.MENU.SHOWURL"
class="menu-item-text"
>{{ item.url }}
</span>
</span>
</template>
<script lang="ts">
Expand All @@ -24,6 +34,8 @@ import {
FolderOutlined,
FileMarkdownOutlined,
} from "@ant-design/icons-vue";
import { useStore } from "vuex";
import { GlobalState } from "@/store";
export default defineComponent({
components: {
Expand All @@ -41,13 +53,15 @@ export default defineComponent({
},
setup(props) {
const { t } = useI18n();
let store = useStore<GlobalState>();
const title = computed(() => {
if (props.item.title === "未分组") {
return t("common.notGroup");
}
return props.item.title;
});
return { title };
const feConfig = computed(() => store.state.app.feConfig);
return { title, feConfig };
},
});
</script>
Expand All @@ -74,4 +88,9 @@ export default defineComponent({
padding: 0px 10px;
border-radius: 2px;
}
.menu-item-text {
color: #999;
margin-left: 10px;
display: inline-block;
}
</style>
1 change: 1 addition & 0 deletions src/components/Menu/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface MenuItemType {
url?: string;
key?: string;
path?: string;
controller?: string;
}

export interface MenuGroupType {
Expand Down
4 changes: 2 additions & 2 deletions src/components/TableInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineComponent, ref, watchEffect } from "vue";
import { defineComponent, ref, watchEffect, PropType } from "vue";
import { Input } from "ant-design-vue";
import style from "./index.module.less";

export default defineComponent({
props: {
data: {
type: String,
type: [String, Number] as PropType<string | number>,
default: "",
},
placeholder: {
Expand Down
1 change: 0 additions & 1 deletion src/components/VerifyAuth/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<a-modal
:visible="visible"
:width="500"
:closable="false"
:destroyOnClose="true"
:maskClosable="false"
:title="t('auth.title')"
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/multitabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default defineComponent({
});
state.activeKey = route.fullPath;
} else {
message.error(t("common.page.404"));
// message.error(t("common.page.404"));
router.push({
name: "Home",
});
Expand Down Expand Up @@ -104,7 +104,7 @@ export default defineComponent({
});
state.activeKey = route.fullPath;
} else {
message.error(t("common.page.404"));
// message.error(t("common.page.404"));
router.push({
name: "Home",
});
Expand Down
29 changes: 26 additions & 3 deletions src/store/modules/Apidoc/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { MenuItemType } from "@/components/Menu/src/interface";
import { createApiPageKey } from "@/utils";
import { ApiAnalysisData } from "@/store/modules/Apidoc/interface";
import { MdMenuItem } from "@/api/interface/markdown";
import { ConfigAppItem, ConfigGlobalParamItem, ConfigInfo } from "@/api/interface/config";
import {
ConfigAppGroupItem,
ConfigAppItem,
ConfigGlobalParamItem,
ConfigInfo,
} from "@/api/interface/config";
import Cache from "@/utils/cache";
import * as Types from "./types";
import { cloneDeep } from "lodash";
Expand Down Expand Up @@ -127,6 +132,7 @@ export function handleApiData(data: ApiDataInfo, appKey: string): ReturnHandleAp
method: item.method as string,
url: item.url,
tag: item.tag,
controller: item.controller,
key,
};
if (item.children && item.children.length) {
Expand Down Expand Up @@ -174,7 +180,7 @@ export function handleConfigAppsData(data: ConfigAppItem[]): HandleConfigAppData
params: [],
};
function renderAppsData(list: ConfigAppItem[], appKey = ""): any {
const mdMenus = list.map((item) => {
const apps = list.map((item) => {
const currentAppKey = `${appKey}${appKey ? "," : ""}${item.folder}`;
if (item.folder && !(item.items && item.items.length)) {
result.count++;
Expand All @@ -197,17 +203,34 @@ export function handleConfigAppsData(data: ConfigAppItem[]): HandleConfigAppData
}
}
}
if (item.groups && item.groups.length) {
item.groups = handleConfigAppsGroupData(item.groups);
}
if (item.items && item.items.length) {
item.items = renderAppsData(item.items, currentAppKey);
}
return item;
});
return mdMenus;
return apps;
}
renderAppsData(data, "");
return result;
}

function handleConfigAppsGroupData(list: ConfigAppGroupItem[]) {
const groups = list.map((item) => {
item.label = item.title;
item.value = item.name;
item.key = item.name;
if (item.children && item.children.length) {
item.children = handleConfigAppsGroupData(item.children);
}

return item;
});
return groups;
}

interface handleInitGlobalParamsResult {
headers: ConfigGlobalParamItem[];
params: ConfigGlobalParamItem[];
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/App/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const app: Module<AppState, GlobalState> = {
if (localStorage.APIDOC_CONFIG) {
const apidocConfig = JSON.parse(localStorage.APIDOC_CONFIG);
commit(Types.SET_FE_CONFIG, apidocConfig);
if (apidocConfig && apidocConfig.MENU && apidocConfig.MENU.WIDTH) {
commit(Types.SET_SIDE_WIDTH, apidocConfig.MENU.WIDTH);
}
}
},
// 设置前端配置
Expand Down
5 changes: 5 additions & 0 deletions src/store/modules/App/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ export interface FeConfigState {
LANG?: FeConfigLangState[];
HTTP: FeConfigHTTPState;
PUBLICPATH?: string;
MENU?: FeConfigMenuState;
}

export interface FeConfigMenuState {
SHOWURL: boolean;
WIDTH: number;
}
export interface FeConfigLangState {
title: string;
lang: string;
Expand Down
3 changes: 2 additions & 1 deletion src/views/apiDetail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<a-tab-pane key="json" :tab="t('apiPage.json')">
<json-tab :detail="detail" />
</a-tab-pane>
<a-tab-pane key="debug" :tab="t('apiPage.debug')">
<a-tab-pane v-if="detail.notDebug !== true" key="debug" :tab="t('apiPage.debug')">
<debug-tab :detail="detail" :currentMethod="currentMethod" />
</a-tab-pane>
</a-tabs>
Expand Down Expand Up @@ -113,6 +113,7 @@ export default defineComponent({
const methodList: string[] = [];
const state = reactive({
config: computed(() => store.state.app.config),
pageData: computed(() => store.state.app.pageData),
apiObject: computed(() => store.state.apidoc.apiObject),
detail: detail,
Expand Down

0 comments on commit 2a848a9

Please sign in to comment.