diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/properties/ContiNewAdminProperties.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/properties/ContiNewAdminProperties.java index 13777529025547c02b02e0b6edef558cf663adc8..803c29592ef152ef2086ba43821eb1b4c3e6aa42 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/properties/ContiNewAdminProperties.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/properties/ContiNewAdminProperties.java @@ -64,6 +64,11 @@ public class ContiNewAdminProperties { */ private String url; + /** + * 基本包 + */ + private String basePackage; + /** * 作者信息 */ diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/enums/SuccessFailureStatusEnum.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/enums/SuccessFailureStatusEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..fcd3123601e75edb7998026b7e9136b85916f622 --- /dev/null +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/enums/SuccessFailureStatusEnum.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.charles7c.cnadmin.common.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import top.charles7c.cnadmin.common.base.BaseEnum; + +/** + * 成功/失败状态枚举 + * + * @author Charles7c + * @since 2023/2/26 21:35 + */ +@Getter +@RequiredArgsConstructor +public enum SuccessFailureStatusEnum implements BaseEnum { + + /** 成功 */ + SUCCESS(1, "成功"), + + /** 失败 */ + FAILURE(2, "失败"),; + + private final Integer value; + private final String description; +} diff --git a/continew-admin-ui/components.d.ts b/continew-admin-ui/components.d.ts index 5bca6c687024d1e4bc2f33af692bf4effb6ed070..74f6e6fd2c077df7e1d3b5cb4ad3a5958459aecf 100644 --- a/continew-admin-ui/components.d.ts +++ b/continew-admin-ui/components.d.ts @@ -10,7 +10,6 @@ declare module '@vue/runtime-core' { AAffix: typeof import('@arco-design/web-vue')['Affix'] AAlert: typeof import('@arco-design/web-vue')['Alert'] AAvatar: typeof import('@arco-design/web-vue')['Avatar'] - AAvatarGroup: typeof import('@arco-design/web-vue')['AvatarGroup'] ABadge: typeof import('@arco-design/web-vue')['Badge'] ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb'] ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem'] @@ -20,7 +19,6 @@ declare module '@vue/runtime-core' { ACardMeta: typeof import('@arco-design/web-vue')['CardMeta'] ACarousel: typeof import('@arco-design/web-vue')['Carousel'] ACarouselItem: typeof import('@arco-design/web-vue')['CarouselItem'] - ACascader: typeof import('@arco-design/web-vue')['Cascader'] ACheckbox: typeof import('@arco-design/web-vue')['Checkbox'] ACol: typeof import('@arco-design/web-vue')['Col'] AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider'] @@ -60,7 +58,6 @@ declare module '@vue/runtime-core' { ASelect: typeof import('@arco-design/web-vue')['Select'] ASkeleton: typeof import('@arco-design/web-vue')['Skeleton'] ASkeletonLine: typeof import('@arco-design/web-vue')['SkeletonLine'] - ASkeletonShape: typeof import('@arco-design/web-vue')['SkeletonShape'] ASpace: typeof import('@arco-design/web-vue')['Space'] ASpin: typeof import('@arco-design/web-vue')['Spin'] AStatistic: typeof import('@arco-design/web-vue')['Statistic'] diff --git a/continew-admin-ui/src/api/common/index.ts b/continew-admin-ui/src/api/common/index.ts index 71a63b5dafc29801214659328f90c07a57d32e2e..bc344d707a69548ed5b7ed83ae4a29469b640b52 100644 --- a/continew-admin-ui/src/api/common/index.ts +++ b/continew-admin-ui/src/api/common/index.ts @@ -5,11 +5,7 @@ import { MenuParam } from '@/api/system/menu'; import { RoleParam } from '@/api/system/role'; import { PostParam } from '@/api/system/post'; import { TreeNodeData } from '@arco-design/web-vue'; - -export interface LabelValueRecord { - label: string; - value: any; -} +import { LabelValueState } from '@/store/modules/dict/types'; export function listDeptTree(params: DeptParam) { return axios.get('/common/tree/dept', { @@ -30,7 +26,7 @@ export function listMenuTree(params: MenuParam) { } export function listRoleDict(params: RoleParam) { - return axios.get('/common/dict/role', { + return axios.get('/common/dict/role', { params, paramsSerializer: (obj) => { return qs.stringify(obj); @@ -39,10 +35,14 @@ export function listRoleDict(params: RoleParam) { } export function listPostDict(params: PostParam) { - return axios.get('/common/dict/post', { + return axios.get('/common/dict/post', { params, paramsSerializer: (obj) => { return qs.stringify(obj); }, }); -} \ No newline at end of file +} + +export function listEnumDict(enumTypeName: string) { + return axios.get(`/common/dict/enum/${enumTypeName}`); +} diff --git a/continew-admin-ui/src/main.ts b/continew-admin-ui/src/main.ts index 02574da0ed915f6af8b881f68e2fd7b445a62253..8342c344eda50dc8570bc4581fb7b26a8273d0bc 100644 --- a/continew-admin-ui/src/main.ts +++ b/continew-admin-ui/src/main.ts @@ -4,6 +4,7 @@ import ArcoVueIcon from '@arco-design/web-vue/es/icon'; // eslint-disable-next-line import/no-unresolved import 'virtual:svg-icons-register'; import globalComponents from '@/components'; +import useDict from '@/utils/dict'; import router from './router'; import store from './store'; import i18n from './locale'; @@ -16,6 +17,9 @@ import '@/utils/request'; const app = createApp(App); +// 全局方法挂载 +app.config.globalProperties.useDict = useDict; + app.use(ArcoVue, {}); app.use(ArcoVueIcon); diff --git a/continew-admin-ui/src/store/index.ts b/continew-admin-ui/src/store/index.ts index a1b28123669d2821f16f97199fd6f34e0d2422c5..fa946aa2f2df0916bed82a9444c7ac0b3512ec70 100644 --- a/continew-admin-ui/src/store/index.ts +++ b/continew-admin-ui/src/store/index.ts @@ -1,9 +1,10 @@ import { createPinia } from 'pinia'; import useAppStore from './modules/app'; import useLoginStore from './modules/login'; +import useDictStore from './modules/dict'; import useTabBarStore from './modules/tab-bar'; const pinia = createPinia(); -export { useAppStore, useLoginStore, useTabBarStore }; +export { useAppStore, useLoginStore, useDictStore, useTabBarStore }; export default pinia; diff --git a/continew-admin-ui/src/store/modules/dict/index.ts b/continew-admin-ui/src/store/modules/dict/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..908c43785fa812aaa2008bd3b6a2d9fc193db498 --- /dev/null +++ b/continew-admin-ui/src/store/modules/dict/index.ts @@ -0,0 +1,54 @@ +import { defineStore } from 'pinia'; +import { DictState, LabelValueState } from '@/store/modules/dict/types'; + +const useDictStore = defineStore('dict', { + state: () => ({ dict: [] as Array }), + actions: { + // 获取字典 + getDict(_name: string) { + if (_name === null && _name === '') { + return null; + } + try { + for (let i = 0; i < this.dict.length; i += 1) { + if (this.dict[i].name === _name) { + return this.dict[i].detail; + } + } + } catch (e) { + console.log(e); + } + return null; + }, + // 设置字典 + setDict(_name: string, detail: Array) { + if (_name !== null && _name !== '') { + this.dict.push({ + name: _name, + detail, + }); + } + }, + // 删除字典 + deleteDict(_name: string) { + let bln = false; + try { + for (let i = 0; i < this.dict.length; i += 1) { + if (this.dict[i].name === _name) { + this.dict.splice(i, 1); + return true; + } + } + } catch (e) { + bln = false; + } + return bln; + }, + // 清空字典 + cleanDict() { + this.dict = []; + }, + }, +}); + +export default useDictStore; diff --git a/continew-admin-ui/src/store/modules/dict/types.ts b/continew-admin-ui/src/store/modules/dict/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ff021201d46eb373691a4375f552ad924059902 --- /dev/null +++ b/continew-admin-ui/src/store/modules/dict/types.ts @@ -0,0 +1,9 @@ +export interface LabelValueState { + label: string; + value: any; +} + +export interface DictState { + name: string; + detail: Array; +} diff --git a/continew-admin-ui/src/utils/dict.ts b/continew-admin-ui/src/utils/dict.ts new file mode 100644 index 0000000000000000000000000000000000000000..17573da968cb3b64cfd49debba66371e6f7d98e5 --- /dev/null +++ b/continew-admin-ui/src/utils/dict.ts @@ -0,0 +1,27 @@ +import { ref, toRefs } from 'vue'; +import { listEnumDict } from '@/api/common'; +import { useDictStore } from '@/store'; + +/** + * 获取字典数据 + * + * @param names 字典名列表 + */ +export default function useDict(...names: Array) { + const res = ref({}); + return (() => { + names.forEach((name: string) => { + res.value[name] = []; + const dict = useDictStore().getDict(name); + if (dict) { + res.value[name] = dict; + } else { + listEnumDict(name).then((resp) => { + res.value[name] = resp.data; + useDictStore().setDict(name, res.value[name]); + }); + } + }); + return toRefs(res.value); + })(); +} diff --git a/continew-admin-ui/src/views/monitor/log/login/index.vue b/continew-admin-ui/src/views/monitor/log/login/index.vue index 2f9297a6aae608c1f57d1e13cca698f67eab3252..5afb21f456e4cfc41e12d8ceb20fcac2ea2b84a6 100644 --- a/continew-admin-ui/src/views/monitor/log/login/index.vue +++ b/continew-admin-ui/src/views/monitor/log/login/index.vue @@ -10,10 +10,10 @@ @@ -81,7 +81,6 @@