项目需求、任务以及模块精简
This commit is contained in:
@@ -93,19 +93,22 @@
|
||||
});
|
||||
};
|
||||
|
||||
const loadComponent = (vueName: string) => {
|
||||
const loadComponent = (vueName: string): Component => {
|
||||
return defineAsyncComponent({
|
||||
loader: () => import(`./components/${vueName}.vue`),
|
||||
delay: 200,
|
||||
timeout: 5000,
|
||||
onError(error) {
|
||||
console.error('加载组件失败', error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = {
|
||||
ustatus: '1',
|
||||
chartCode: 'erp',
|
||||
ustatus: '1',
|
||||
chartCode: 'erp',
|
||||
};
|
||||
const res = await myChartInfoListAll(reqParams);
|
||||
chartData.value = res || [];
|
||||
@@ -132,7 +135,9 @@
|
||||
await getChartList();
|
||||
|
||||
const newComponentMap: ComponentMap = {};
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))].filter(
|
||||
(vueName) => vueName && vueName !== 'ChartTop',
|
||||
);
|
||||
for (const vueName of uniqueComponents) {
|
||||
if (vueName) {
|
||||
newComponentMap[vueName] = loadComponent(vueName);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { ref, watch, onMounted, defineAsyncComponent } from 'vue';
|
||||
import type { Component } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import ChartTop from './components/ChartTop.vue';
|
||||
@@ -68,21 +68,22 @@
|
||||
});
|
||||
};
|
||||
|
||||
const loadComponent = async (vueName: string): Promise<Component | null> => {
|
||||
try {
|
||||
const module = await import(`./components/${vueName}.vue`);
|
||||
return module.default;
|
||||
} catch (error) {
|
||||
console.error('加载组件失败', error);
|
||||
return null;
|
||||
}
|
||||
const loadComponent = (vueName: string): Component => {
|
||||
return defineAsyncComponent({
|
||||
loader: () => import(`./components/${vueName}.vue`),
|
||||
delay: 200,
|
||||
timeout: 5000,
|
||||
onError(error) {
|
||||
console.error('加载组件失败', error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = {
|
||||
ustatus: '1',
|
||||
chartCode: 'home',
|
||||
ustatus: '1',
|
||||
chartCode: 'home',
|
||||
};
|
||||
const res = await myChartInfoListAll(reqParams);
|
||||
chartData.value = res || [];
|
||||
@@ -95,15 +96,17 @@
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await getChartList();
|
||||
|
||||
|
||||
const newComponentMap: ComponentMap = {};
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))].filter(
|
||||
(vueName) => vueName && vueName !== 'ChartTop',
|
||||
);
|
||||
for (const vueName of uniqueComponents) {
|
||||
if (vueName) {
|
||||
newComponentMap[vueName] = loadComponent(vueName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
componentMap.value = newComponentMap;
|
||||
} catch (error) {
|
||||
console.error('加载图表数据失败:', error);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { ref, watch, onMounted, defineAsyncComponent } from 'vue';
|
||||
import type { Component } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import ChartTop from './components/ChartTop.vue';
|
||||
@@ -68,21 +68,22 @@
|
||||
});
|
||||
};
|
||||
|
||||
const loadComponent = async (vueName: string): Promise<Component | null> => {
|
||||
try {
|
||||
const module = await import(`./components/${vueName}.vue`);
|
||||
return module.default;
|
||||
} catch (error) {
|
||||
console.error('加载组件失败', error);
|
||||
return null;
|
||||
}
|
||||
const loadComponent = (vueName: string): Component => {
|
||||
return defineAsyncComponent({
|
||||
loader: () => import(`./components/${vueName}.vue`),
|
||||
delay: 200,
|
||||
timeout: 5000,
|
||||
onError(error) {
|
||||
console.error('加载组件失败', error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = {
|
||||
ustatus: '1',
|
||||
chartCode: 'sys',
|
||||
ustatus: '1',
|
||||
chartCode: 'sys',
|
||||
};
|
||||
const res = await myChartInfoListAll(reqParams);
|
||||
chartData.value = res || [];
|
||||
@@ -95,15 +96,17 @@
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await getChartList();
|
||||
|
||||
|
||||
const newComponentMap: ComponentMap = {};
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))].filter(
|
||||
(vueName) => vueName && vueName !== 'ChartTop',
|
||||
);
|
||||
for (const vueName of uniqueComponents) {
|
||||
if (vueName) {
|
||||
newComponentMap[vueName] = loadComponent(vueName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
componentMap.value = newComponentMap;
|
||||
} catch (error) {
|
||||
console.error('加载图表数据失败:', error);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { ref, watch, onMounted, defineAsyncComponent } from 'vue';
|
||||
import type { Component } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import ChartTop from './components/ChartTop.vue';
|
||||
@@ -80,21 +80,22 @@
|
||||
});
|
||||
};
|
||||
|
||||
const loadComponent = async (vueName: string): Promise<Component | null> => {
|
||||
try {
|
||||
const module = await import(`./components/${vueName}.vue`);
|
||||
return module.default;
|
||||
} catch (error) {
|
||||
console.error('加载组件失败', error);
|
||||
return null;
|
||||
}
|
||||
const loadComponent = (vueName: string): Component => {
|
||||
return defineAsyncComponent({
|
||||
loader: () => import(`./components/${vueName}.vue`),
|
||||
delay: 200,
|
||||
timeout: 5000,
|
||||
onError(error) {
|
||||
console.error('加载组件失败', error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
async function getChartList() {
|
||||
try {
|
||||
const reqParams = {
|
||||
ustatus: '1',
|
||||
chartCode: 'work',
|
||||
ustatus: '1',
|
||||
chartCode: 'work',
|
||||
};
|
||||
const res = await myChartInfoListAll(reqParams);
|
||||
chartData.value = res || [];
|
||||
@@ -107,15 +108,17 @@
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await getChartList();
|
||||
|
||||
|
||||
const newComponentMap: ComponentMap = {};
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))];
|
||||
const uniqueComponents = [...new Set(chartData.value.map((item) => item.vueName))].filter(
|
||||
(vueName) => vueName && vueName !== 'ChartTop',
|
||||
);
|
||||
for (const vueName of uniqueComponents) {
|
||||
if (vueName) {
|
||||
newComponentMap[vueName] = loadComponent(vueName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
componentMap.value = newComponentMap;
|
||||
} catch (error) {
|
||||
console.error('加载图表数据失败:', error);
|
||||
|
||||
Reference in New Issue
Block a user