@mangjuxiong/elpis 1.0.2

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.
Files changed (81) hide show
  1. package/.babelrc +5 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc +66 -0
  4. package/README.md +214 -0
  5. package/app/controller/base.js +39 -0
  6. package/app/controller/project.js +75 -0
  7. package/app/controller/view.js +19 -0
  8. package/app/extend/database.js +5 -0
  9. package/app/extend/logger.js +38 -0
  10. package/app/middleware/api-params-verify.js +74 -0
  11. package/app/middleware/api-sign-verify.js +36 -0
  12. package/app/middleware/error-handle.js +32 -0
  13. package/app/middleware/project-handler.js +26 -0
  14. package/app/middleware.js +39 -0
  15. package/app/pages/asserts/custom.css +14 -0
  16. package/app/pages/boot.js +48 -0
  17. package/app/pages/common/curl.js +80 -0
  18. package/app/pages/common/utils.js +34 -0
  19. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +24 -0
  20. package/app/pages/dashboard/complex-view/header-view/head-view.vue +113 -0
  21. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +43 -0
  22. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +35 -0
  23. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +118 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/components-config.js +23 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +85 -0
  26. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +103 -0
  27. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +112 -0
  28. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +124 -0
  29. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +90 -0
  30. package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +22 -0
  31. package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +113 -0
  32. package/app/pages/dashboard/dashboard.vue +85 -0
  33. package/app/pages/dashboard/entry.dashboard.js +46 -0
  34. package/app/pages/store/index.js +4 -0
  35. package/app/pages/store/menu.js +54 -0
  36. package/app/pages/store/project.js +13 -0
  37. package/app/pages/widgets/head-container/asserts/logo.png +0 -0
  38. package/app/pages/widgets/head-container/head-container.vue +77 -0
  39. package/app/pages/widgets/schema-form/complex-view/input/input.vue +134 -0
  40. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +135 -0
  41. package/app/pages/widgets/schema-form/complex-view/select/select.vue +120 -0
  42. package/app/pages/widgets/schema-form/form-item-config.js +23 -0
  43. package/app/pages/widgets/schema-form/schema-form.vue +130 -0
  44. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +51 -0
  45. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +55 -0
  46. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +38 -0
  47. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +40 -0
  48. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +100 -0
  49. package/app/pages/widgets/schema-search-bar/search-item-config.js +31 -0
  50. package/app/pages/widgets/schema-table/schema-table.vue +225 -0
  51. package/app/pages/widgets/sider-container/sider-container.vue +27 -0
  52. package/app/public/output/entry.page1.tpl +42 -0
  53. package/app/public/static/logo.jpg +0 -0
  54. package/app/public/static/normalize.css +267 -0
  55. package/app/router/project.js +6 -0
  56. package/app/router/view.js +7 -0
  57. package/app/router-schema/project.js +30 -0
  58. package/app/service/base.js +13 -0
  59. package/app/service/project.js +42 -0
  60. package/app/view/entry.tpl +25 -0
  61. package/app/webpack/config/babel.config.js +4 -0
  62. package/app/webpack/config/webpack.base.js +229 -0
  63. package/app/webpack/config/webpack.dev.js +57 -0
  64. package/app/webpack/config/webpack.prod.js +120 -0
  65. package/app/webpack/libs/blank.js +1 -0
  66. package/app/webpack/libs/dev.js +53 -0
  67. package/app/webpack/libs/prod.js +22 -0
  68. package/config/config.default.js +4 -0
  69. package/elpis-core/env.js +20 -0
  70. package/elpis-core/index.js +81 -0
  71. package/elpis-core/loader/config.js +52 -0
  72. package/elpis-core/loader/controller.js +59 -0
  73. package/elpis-core/loader/extend.js +47 -0
  74. package/elpis-core/loader/middleware.js +57 -0
  75. package/elpis-core/loader/router-schema.js +41 -0
  76. package/elpis-core/loader/router.js +42 -0
  77. package/elpis-core/loader/service.js +59 -0
  78. package/index.js +39 -0
  79. package/model/index.js +107 -0
  80. package/package.json +90 -0
  81. package/test/controller/project.test.js +194 -0
@@ -0,0 +1,103 @@
1
+ <template>
2
+ <el-drawer v-model="isShow" direction="rtl" :destory-on-close="true" :size="550">
3
+ <template #header>
4
+ <h3>{{ title }}</h3>
5
+ </template>
6
+
7
+ <template #default>
8
+ <el-card v-loading="loading" class="detail-panel" shadow="always">
9
+ <el-row
10
+ v-for="(item, key) in components[name]?.schema?.properties"
11
+ :key="key"
12
+ type="flex"
13
+ align="middle"
14
+ class="row-item"
15
+ >
16
+ <el-row class="item-label">{{ item.label }}:</el-row>
17
+ <el-row class="item-value">
18
+ {{ dtoModel[key] }}
19
+ </el-row>
20
+ </el-row>
21
+ </el-card>
22
+ </template>
23
+ </el-drawer>
24
+ </template>
25
+
26
+ <script setup>
27
+ import { ref, inject } from 'vue';
28
+ import $curl from '@elpisCommon/curl';
29
+
30
+ const { api, components } = inject('schemaViewData');
31
+
32
+ const name = ref('detailPanel');
33
+
34
+ const isShow = ref(false);
35
+ const loading = ref(false);
36
+ const title = ref('');
37
+ const mainKey = ref('');
38
+ const mainValue = ref();
39
+ const dtoModel = ref({});
40
+
41
+ const show = (rowData) => {
42
+ const { config } = components.value[name.value];
43
+
44
+ title.value = config.title;
45
+ mainKey.value = config.mainKey;
46
+ mainValue.value = rowData[mainKey.value];
47
+ dtoModel.value = {};
48
+
49
+ isShow.value = true;
50
+
51
+ fetchFormData();
52
+ };
53
+
54
+ const fetchFormData = async () => {
55
+ if (loading.value) return;
56
+
57
+ loading.value = true;
58
+
59
+ const res = await $curl({
60
+ url: api.value,
61
+ method: 'get',
62
+ query: {
63
+ [mainKey.value]: mainValue.value,
64
+ },
65
+ });
66
+
67
+ loading.value = false;
68
+
69
+ if (!res || !res.success || !res.data) return;
70
+
71
+ dtoModel.value = res.data;
72
+ };
73
+
74
+ defineExpose({
75
+ name,
76
+ show,
77
+ });
78
+ </script>
79
+
80
+ <style lang="less" scoped>
81
+ .detail-panel {
82
+ border: 1px solid #a6a6a6;
83
+ padding: 30px;
84
+
85
+ .row-item {
86
+ line-height: 40px;
87
+ font-size: 20px;
88
+ align-items: normal;
89
+
90
+ .item-label {
91
+ margin-right: 20px;
92
+ color: #fff;
93
+ width: 120px;
94
+ }
95
+
96
+ .item-value {
97
+ color: #d2dae4;
98
+ width: 250px;
99
+ word-break: break-word;
100
+ }
101
+ }
102
+ }
103
+ </style>
@@ -0,0 +1,112 @@
1
+ <template>
2
+ <el-drawer v-model="isShow" direction="rtl" :destory-on-close="true" :size="550">
3
+ <template #header>
4
+ <h3>{{ title }}</h3>
5
+ </template>
6
+ <template #default>
7
+ <schema-form
8
+ ref="schemaFormRef"
9
+ v-loading="loading"
10
+ :schema="components[name]?.schema"
11
+ :model="dtoModel"
12
+ ></schema-form>
13
+ </template>
14
+ <template #footer>
15
+ <el-button type="primary" @click="save">{{ saveBtnText }}</el-button>
16
+ </template>
17
+ </el-drawer>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { ref, inject } from 'vue';
22
+ import SchemaForm from '@elpisWidgets/schema-form/schema-form.vue';
23
+ import $curl from '@elpisCommon/curl.js';
24
+ import { ElNotification } from 'element-plus';
25
+
26
+ const { api, components } = inject('schemaViewData');
27
+
28
+ const emit = defineEmits(['command']);
29
+
30
+ const name = ref('editForm');
31
+
32
+ const isShow = ref(false);
33
+ const loading = ref(false);
34
+ const title = ref('');
35
+ const saveBtnText = ref('');
36
+ const mainKey = ref('');
37
+ const mainValue = ref();
38
+ const dtoModel = ref({});
39
+ const schemaFormRef = ref();
40
+
41
+ const show = (rowData) => {
42
+ const { config } = components.value[name.value];
43
+
44
+ title.value = config.title;
45
+ saveBtnText.value = config.saveBtnText;
46
+ mainKey.value = config.mainKey; // 表单主键
47
+ mainValue.value = rowData[config.mainKey]; //表单主键的值
48
+ dtoModel.value = {};
49
+
50
+ isShow.value = true;
51
+
52
+ fetchFormData();
53
+ };
54
+
55
+ const close = () => {
56
+ isShow.value = false;
57
+ };
58
+
59
+ const fetchFormData = async () => {
60
+ if (loading.value) return;
61
+ loading.value = true;
62
+ const res = await $curl({
63
+ method: 'get',
64
+ url: api.value,
65
+ query: {
66
+ [mainKey.value]: mainValue.value,
67
+ },
68
+ });
69
+ loading.value = false;
70
+
71
+ if (!res || !res.success || !res.data) return;
72
+
73
+ dtoModel.value = res.data;
74
+ };
75
+
76
+ const save = async () => {
77
+ if (loading.value) return;
78
+
79
+ if (!schemaFormRef.value.validate()) return;
80
+
81
+ loading.value = true;
82
+ const res = await $curl({
83
+ method: 'put',
84
+ url: api.value,
85
+ data: {
86
+ [mainKey.value]: mainValue.value,
87
+ ...schemaFormRef.value.getValue(),
88
+ },
89
+ });
90
+ loading.value = false;
91
+ if (!res || !res.success) return;
92
+
93
+ ElNotification({
94
+ title: ' 修改成功',
95
+ message: '修改成功',
96
+ type: 'success',
97
+ });
98
+
99
+ close();
100
+
101
+ emit('command', {
102
+ event: 'loadTableData',
103
+ });
104
+ };
105
+
106
+ defineExpose({
107
+ name,
108
+ show,
109
+ });
110
+ </script>
111
+
112
+ <style lang="less" scoped></style>
@@ -0,0 +1,124 @@
1
+ import { ref, watch, onMounted, nextTick } from 'vue';
2
+ import { useRoute } from 'vue-router';
3
+ import { useMenuStore } from '@elpisStore/menu';
4
+
5
+ export const useSchema = () => {
6
+ const route = useRoute();
7
+ const menuStore = useMenuStore();
8
+
9
+ const api = ref('');
10
+ const tableSchema = ref({});
11
+ const tableConfig = ref();
12
+ const searchSchema = ref({});
13
+ const searchConfig = ref();
14
+ const components = ref({});
15
+
16
+ // 构造shemaConfig相关配置给schema-view用
17
+ const buildData = () => {
18
+ const { key, sider_key } = route.query;
19
+
20
+ const mItem = menuStore.findMenuItem({
21
+ key: 'key',
22
+ value: sider_key ?? key,
23
+ });
24
+
25
+ if (mItem && mItem.schemaConfig) {
26
+ const { schemaConfig } = mItem;
27
+
28
+ const configSchema = JSON.parse(JSON.stringify(schemaConfig.schema || {}));
29
+
30
+ api.value = schemaConfig.api ?? '';
31
+
32
+ tableSchema.value = {};
33
+ tableConfig.value = undefined;
34
+ searchSchema.value = {};
35
+ searchConfig.value = undefined;
36
+ components.value = {};
37
+ nextTick(() => {
38
+ // 构造 tableSchema 和 tableConfig
39
+ tableSchema.value = buildDtoSchema(configSchema, 'table');
40
+ tableConfig.value = schemaConfig.tableConfig;
41
+
42
+ // 构造 searchSchema 和 searchConfig
43
+ const DtoSearchSchema = buildDtoSchema(configSchema, 'search');
44
+ for (const key in DtoSearchSchema.properties) {
45
+ if (route.query[key] !== undefined) {
46
+ DtoSearchSchema.properties[key].default = route.query[key];
47
+ }
48
+ }
49
+ searchSchema.value = DtoSearchSchema;
50
+ searchConfig.value = schemaConfig.searchConfig;
51
+
52
+ // 构造 components = { comKey: { schmea: {},config: {} } }
53
+ const { componentConfig } = schemaConfig;
54
+ if (componentConfig && Object.keys(componentConfig).length > 0) {
55
+ const dtoComponents = {};
56
+ for (const comName in componentConfig) {
57
+ dtoComponents[comName] = {
58
+ schema: buildDtoSchema(configSchema, comName),
59
+ config: componentConfig[comName],
60
+ };
61
+ }
62
+ components.value = dtoComponents;
63
+ }
64
+ });
65
+ }
66
+ };
67
+
68
+ // 通用构建Schema方法,清除噪音
69
+ const buildDtoSchema = (_schema, comName) => {
70
+ if (!_schema?.properties) return {};
71
+
72
+ const dtoSchema = {
73
+ type: 'Object',
74
+ properties: {},
75
+ };
76
+ // 提取有效schema字段信息
77
+ for (const key in _schema.properties) {
78
+ const props = _schema.properties[key];
79
+ // tableOptions就是table的配置
80
+ if (props[`${comName}Options`]) {
81
+ let dtoProps = {};
82
+ // 提取props中非options部分存在dtoSchema中
83
+ for (const pKey in props) {
84
+ if (pKey.indexOf('Options') < 0) {
85
+ dtoProps[pKey] = props[pKey];
86
+ }
87
+ }
88
+ // 处理 comName Options
89
+ dtoProps = Object.assign({}, dtoProps, { options: props[`${comName}Options`] });
90
+
91
+ // 处理必填required 字段
92
+ const { required } = _schema;
93
+ if (required && required.find((pk) => pk === key)) {
94
+ dtoProps.options.required = true;
95
+ }
96
+
97
+ dtoSchema.properties[key] = dtoProps;
98
+ }
99
+ }
100
+
101
+ return dtoSchema;
102
+ };
103
+
104
+ watch(
105
+ [() => route.query.key, () => route.query.sider_key, () => menuStore.menuList],
106
+ () => {
107
+ buildData();
108
+ },
109
+ { deep: true }
110
+ );
111
+
112
+ onMounted(() => {
113
+ buildData();
114
+ });
115
+
116
+ return {
117
+ api,
118
+ tableSchema,
119
+ tableConfig,
120
+ searchSchema,
121
+ searchConfig,
122
+ components,
123
+ };
124
+ };
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <el-row class="schema-view">
3
+ <search-panel
4
+ v-if="searchSchema?.properties && Object.keys(searchSchema.properties).length > 0"
5
+ @search="onSearch"
6
+ />
7
+ <table-panel ref="tablePanelRef" @operate="onTableOperate" />
8
+ <Component
9
+ :is="ComponentConfig[key]?.component"
10
+ v-for="(item, key) in components"
11
+ :key="key"
12
+ ref="comListRef"
13
+ @command="onComponentCommand"
14
+ />
15
+ </el-row>
16
+ </template>
17
+
18
+ <script setup>
19
+ import { provide, ref } from 'vue';
20
+ import SearchPanel from './complex-view/search-panel/search-panel.vue';
21
+ import TablePanel from './complex-view/table-panel/table-panel.vue';
22
+ import { useSchema } from './hook/schema.js';
23
+ import ComponentConfig from './components/components-config.js';
24
+
25
+ const { api, tableSchema, tableConfig, searchSchema, searchConfig, components } = useSchema();
26
+
27
+ const apiParams = ref({});
28
+
29
+ provide('schemaViewData', {
30
+ api,
31
+ apiParams,
32
+ tableSchema,
33
+ tableConfig,
34
+ searchSchema,
35
+ searchConfig,
36
+ components,
37
+ });
38
+
39
+ const tablePanelRef = ref(null);
40
+ const comListRef = ref([]);
41
+
42
+ const onSearch = (searchParams) => {
43
+ apiParams.value = searchParams;
44
+ };
45
+
46
+ // table 事件映射
47
+ const EventHandlerMap = {
48
+ showComponent: showComponent,
49
+ };
50
+
51
+ const onTableOperate = ({ btnConfig, rowData }) => {
52
+ const { eventKey } = btnConfig;
53
+ if (EventHandlerMap[eventKey]) {
54
+ EventHandlerMap[eventKey]({ btnConfig, rowData });
55
+ }
56
+ };
57
+
58
+ // showComponent 展示动态组件
59
+ function showComponent({ btnConfig, rowData }) {
60
+ const { comName } = btnConfig.eventOptions;
61
+ if (!comName) {
62
+ console.error('没配置组件名');
63
+ return;
64
+ }
65
+ const comRef = comListRef.value.find((item) => item.name === comName);
66
+ if (!comRef || typeof comRef.show !== 'function') {
67
+ console.error(`找不到组件${comName}`);
68
+ return;
69
+ }
70
+
71
+ comRef.show(rowData);
72
+ }
73
+
74
+ // 相应组件事件
75
+ const onComponentCommand = (data) => {
76
+ const { event } = data;
77
+ if (event === 'loadTableData') {
78
+ tablePanelRef.value.loadTableData();
79
+ }
80
+ };
81
+ </script>
82
+
83
+ <style lang="less" scoped>
84
+ .schema-view {
85
+ display: flex;
86
+ flex-direction: column;
87
+ height: 100%;
88
+ width: 100%;
89
+ }
90
+ </style>
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <el-sub-menu :index="menuItem.key || ''">
3
+ <template #title>{{ menuItem.name }}</template>
4
+ <div :key="item.key" v-for="item in menuItem.subMenu">
5
+ <sub-menu v-if="item.subMenu && item.subMenu.length > 0" :menu-item="item"></sub-menu>
6
+ <el-menu-item :index="item.key" v-else>
7
+ <template #title>{{ item.name }}</template>
8
+ </el-menu-item>
9
+ </div>
10
+ </el-sub-menu>
11
+ </template>
12
+
13
+ <script setup>
14
+ const { menuItem } = defineProps({
15
+ menuItem: {
16
+ type: Object,
17
+ default: () => {},
18
+ },
19
+ });
20
+ </script>
21
+
22
+ <style lang="less" scoped></style>
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <sider-container>
3
+ <template #menu-content>
4
+ <el-menu :default-active="activeMenuKey" :ellipsis="false" @select="onMenuSelect">
5
+ <template v-for="item in menuList">
6
+ <!-- group -->
7
+ <sub-menu v-if="item.subMenu && item.subMenu.length > 0" :menu-item="item"></sub-menu>
8
+ <!-- module -->
9
+ <el-menu-item v-else :index="item.key">
10
+ <template #title>
11
+ <span>{{ item.name }}</span>
12
+ </template>
13
+ </el-menu-item>
14
+ </template>
15
+ </el-menu>
16
+ </template>
17
+ <template #main-content>
18
+ <router-view></router-view>
19
+ </template>
20
+ </sider-container>
21
+ </template>
22
+
23
+ <script setup>
24
+ import SiderContainer from '@elpisWidgets/sider-container/sider-container';
25
+ import { ref, watch, onMounted } from 'vue';
26
+ import { useRoute, useRouter } from 'vue-router';
27
+ import { useMenuStore } from '@elpisStore/menu';
28
+ import SubMenu from './complex-view/sub-menu/sub-menu.vue';
29
+
30
+ const router = useRouter();
31
+ const route = useRoute();
32
+ const menuStore = useMenuStore();
33
+
34
+ const activeMenuKey = ref('');
35
+ // 设置激活菜单
36
+ const setActiveMenuKey = () => {
37
+ let subMenuItem = menuStore.findMenuItem({
38
+ key: 'key',
39
+ value: route.query.sider_key,
40
+ });
41
+ // 如果首次加载side-view,用户未选中,则默认选中第一个
42
+ if (!subMenuItem) {
43
+ const headMenuItem = menuStore.findMenuItem({
44
+ key: 'key',
45
+ value: route.query.key,
46
+ });
47
+ const sideMenuList = headMenuItem?.siderConfig?.menu || [];
48
+ // 找出左侧菜单中的第一项
49
+ const sideMenuItem = menuStore.findFirstMenuItem(sideMenuList);
50
+ if (sideMenuItem) {
51
+ subMenuItem = sideMenuItem;
52
+ // 处理选中菜单逻辑
53
+ handleMenuSelect(sideMenuItem.key);
54
+ }
55
+ }
56
+ activeMenuKey.value = subMenuItem?.key;
57
+ };
58
+
59
+ const menuList = ref([]);
60
+ // 设置菜单列表
61
+ const setMenuList = () => {
62
+ const menuItem = menuStore.findMenuItem({
63
+ key: 'key',
64
+ value: route.query.key,
65
+ });
66
+ menuList.value = menuItem?.siderConfig?.menu || [];
67
+ };
68
+
69
+ // 选择菜单
70
+ const onMenuSelect = (menuKey) => {
71
+ handleMenuSelect(menuKey);
72
+ };
73
+
74
+ const handleMenuSelect = (menuKey) => {
75
+ const menuItem = menuStore.findMenuItem({
76
+ key: 'key',
77
+ value: menuKey,
78
+ });
79
+
80
+ const { moduleType, key, customConfig } = menuItem;
81
+
82
+ if (key === route.query.side_key) return;
83
+
84
+ const pathMap = {
85
+ iframe: '/iframe',
86
+ schema: '/schema',
87
+ custom: customConfig?.path,
88
+ };
89
+ router.push({
90
+ path: `/view/dashboard/sider${pathMap[moduleType]}`,
91
+ query: {
92
+ proj_key: route.query.proj_key,
93
+ key: route.query.key,
94
+ sider_key: key,
95
+ },
96
+ });
97
+ };
98
+
99
+ watch(
100
+ [() => route.query.key, () => menuStore.menuList],
101
+ () => {
102
+ setMenuList();
103
+ setActiveMenuKey();
104
+ },
105
+ { deep: true }
106
+ );
107
+ onMounted(() => {
108
+ setMenuList();
109
+ setActiveMenuKey();
110
+ });
111
+ </script>
112
+
113
+ <style lang="less" scoped></style>
@@ -0,0 +1,85 @@
1
+ <template>
2
+ <el-config-provider :locale="zhCn">
3
+ <header-view :project-name="projectName" @menu-select="onMenuSelect">
4
+ <template #main-content>
5
+ <router-view />
6
+ </template>
7
+ </header-view>
8
+ </el-config-provider>
9
+ </template>
10
+
11
+ <script setup>
12
+ import zhCn from 'element-plus/es/locale/lang/zh-cn';
13
+ import HeaderView from './complex-view/header-view/head-view.vue';
14
+ import { ref, onMounted } from 'vue';
15
+ import { useMenuStore } from '@elpisStore/menu.js';
16
+ import { useProjectStore } from '@elpisStore/project.js';
17
+ import { useRouter, useRoute } from 'vue-router';
18
+ import $curl from '@elpisCommon/curl';
19
+
20
+ const router = useRouter();
21
+ const route = useRoute();
22
+ const menuStore = useMenuStore();
23
+ const projectStore = useProjectStore();
24
+
25
+ const projectName = ref('order');
26
+
27
+ onMounted(() => {
28
+ getProjectList();
29
+ getProjectConfig();
30
+ });
31
+
32
+ // 请求/api/project/list接口,获取项目列表,存在projectStore
33
+ async function getProjectList() {
34
+ const res = await $curl({
35
+ url: '/api/project/list',
36
+ method: 'get',
37
+ // 动态获取当前项目key
38
+ query: { proj_key: route.query.proj_key },
39
+ errorMessage: '获取项目列表失败',
40
+ });
41
+ if (!res || !res.success || !res.data) {
42
+ return;
43
+ }
44
+ projectStore.setProjectList(res.data);
45
+ }
46
+
47
+ // 请求/api/project接口,获取项目列表,存在menuStore
48
+ async function getProjectConfig() {
49
+ const res = await $curl({
50
+ url: '/api/project',
51
+ method: 'get',
52
+ // 动态获取当前项目key
53
+ query: { proj_key: route.query.proj_key },
54
+ errorMessage: '获取项目配置失败',
55
+ });
56
+ if (!res || !res.success || !res.data) {
57
+ return;
58
+ }
59
+ const { name, menu } = res.data;
60
+ projectName.value = name;
61
+ menuStore.setMenuList(menu);
62
+ }
63
+
64
+ // 点击菜单回调
65
+ const onMenuSelect = (menuItem) => {
66
+ const { moduleType, key, customConfig } = menuItem;
67
+
68
+ // 如果是当前页面就不处理
69
+ if (route.query.key === key) return;
70
+
71
+ const pathMap = {
72
+ sider: '/sider',
73
+ iframe: '/iframe',
74
+ schema: '/schema',
75
+ custom: customConfig?.path,
76
+ };
77
+
78
+ router.push({
79
+ path: `/view/dashboard${pathMap[moduleType]}`,
80
+ query: { key, proj_key: route.query.proj_key },
81
+ });
82
+ };
83
+ </script>
84
+
85
+ <style lang="less" scoped></style>
@@ -0,0 +1,46 @@
1
+ import boot from '@elpisPages/boot';
2
+ import dashboard from './dashboard';
3
+ import businessDashboardRouterConfig from '@businessDashboardRouterConfig';
4
+
5
+ const routes = [];
6
+
7
+ // 头部菜单路由
8
+ routes.push({
9
+ path: '/view/dashboard/iframe',
10
+ component: () => import('@elpisPages/dashboard/complex-view/iframe-view/iframe-view'),
11
+ });
12
+ routes.push({
13
+ path: '/view/dashboard/schema',
14
+ component: () => import('@elpisPages/dashboard/complex-view/schema-view/schema-view'),
15
+ });
16
+
17
+ const siderRoutes = [
18
+ {
19
+ path: 'iframe',
20
+ component: () => import('@elpisPages/dashboard/complex-view/iframe-view/iframe-view'),
21
+ },
22
+ {
23
+ path: 'schema',
24
+ component: () => import('@elpisPages/dashboard/complex-view/schema-view/schema-view'),
25
+ },
26
+ ];
27
+
28
+ // 侧边栏菜单路由
29
+ routes.push({
30
+ path: '/view/dashboard/sider',
31
+ component: () => import('@elpisPages/dashboard/complex-view/sider-view/sider-view'),
32
+ children: siderRoutes,
33
+ });
34
+
35
+ // 业务拓展路由
36
+ if (typeof businessDashboardRouterConfig === 'function') {
37
+ businessDashboardRouterConfig({ routes, siderRoutes });
38
+ }
39
+
40
+ // 侧边栏兜底策略
41
+ routes.push({
42
+ path: '/view/dashboard/sider/:chapters+',
43
+ component: () => import('@elpisPages/dashboard/complex-view/sider-view/sider-view'),
44
+ });
45
+
46
+ boot(dashboard, { routes });
@@ -0,0 +1,4 @@
1
+ import { createPinia } from "pinia";
2
+
3
+ const pinia = createPinia();
4
+ export default pinia;