提交 45a8eb97 作者: vben

refactor(dashboard): change to setup syntax

上级 2dd3d854
...@@ -74,10 +74,10 @@ ...@@ -74,10 +74,10 @@
"@types/fs-extra": "^9.0.12", "@types/fs-extra": "^9.0.12",
"@types/inquirer": "^7.3.3", "@types/inquirer": "^7.3.3",
"@types/intro.js": "^3.0.2", "@types/intro.js": "^3.0.2",
"@types/jest": "^27.0.0", "@types/jest": "^27.0.1",
"@types/lodash-es": "^4.17.4", "@types/lodash-es": "^4.17.4",
"@types/mockjs": "^1.0.4", "@types/mockjs": "^1.0.4",
"@types/node": "^16.6.0", "@types/node": "^16.6.1",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@types/qrcode": "^1.4.1", "@types/qrcode": "^1.4.1",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
"vite-plugin-theme": "^0.8.1", "vite-plugin-theme": "^0.8.1",
"vite-plugin-windicss": "^1.2.7", "vite-plugin-windicss": "^1.2.7",
"vue-eslint-parser": "^7.10.0", "vue-eslint-parser": "^7.10.0",
"vue-tsc": "^0.2.2" "vue-tsc": "^0.2.3"
}, },
"resolutions": { "resolutions": {
"//": "Used to install imagemin dependencies, because imagemin may not be installed in China. If it is abroad, you can delete it", "//": "Used to install imagemin dependencies, because imagemin may not be installed in China. If it is abroad, you can delete it",
......
...@@ -26,18 +26,9 @@ ...@@ -26,18 +26,9 @@
</template> </template>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue';
import { CountTo } from '/@/components/CountTo/index'; import { CountTo } from '/@/components/CountTo/index';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
import { Tag, Card } from 'ant-design-vue'; import { Tag, Card } from 'ant-design-vue';
import { growCardList } from '../data'; import { growCardList } from '../data';
export default defineComponent({
components: { CountTo, Tag, Card, Icon },
setup() {
return { growCardList };
},
});
</script> </script>
...@@ -3,15 +3,12 @@ ...@@ -3,15 +3,12 @@
<div ref="chartRef" :style="{ width, height }"></div> <div ref="chartRef" :style="{ width, height }"></div>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, Ref, ref, watch } from 'vue'; import { Ref, ref, watch } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { useECharts } from '/@/hooks/web/useECharts'; import { useECharts } from '/@/hooks/web/useECharts';
export default defineComponent({ const props = defineProps({
components: { Card },
props: {
loading: Boolean, loading: Boolean,
width: { width: {
type: String as PropType<string>, type: String as PropType<string>,
...@@ -21,8 +18,8 @@ ...@@ -21,8 +18,8 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '300px', default: '300px',
}, },
}, });
setup(props) {
const chartRef = ref<HTMLDivElement | null>(null); const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
watch( watch(
...@@ -63,7 +60,4 @@ ...@@ -63,7 +60,4 @@
}, },
{ immediate: true } { immediate: true }
); );
return { chartRef };
},
});
</script> </script>
...@@ -13,17 +13,12 @@ ...@@ -13,17 +13,12 @@
</p> </p>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, ref } from 'vue'; import { ref } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import VisitAnalysis from './VisitAnalysis.vue'; import VisitAnalysis from './VisitAnalysis.vue';
import VisitAnalysisBar from './VisitAnalysisBar.vue'; import VisitAnalysisBar from './VisitAnalysisBar.vue';
export default defineComponent({
components: { Card, VisitAnalysis, VisitAnalysisBar },
setup() {
const activeKey = ref('tab1'); const activeKey = ref('tab1');
const tabListTitle = [ const tabListTitle = [
...@@ -40,7 +35,4 @@ ...@@ -40,7 +35,4 @@
function onTabChange(key) { function onTabChange(key) {
activeKey.value = key; activeKey.value = key;
} }
return { tabListTitle, activeKey, onTabChange };
},
});
</script> </script>
<template> <template>
<div ref="chartRef" :style="{ height, width }"></div> <div ref="chartRef" :style="{ height, width }"></div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, onMounted, ref, Ref } from 'vue'; import { onMounted, ref, Ref } from 'vue';
import { useECharts } from '/@/hooks/web/useECharts'; import { useECharts } from '/@/hooks/web/useECharts';
import { basicProps } from './props'; import { basicProps } from './props';
export default defineComponent({
props: basicProps, defineProps({
setup() { ...basicProps,
});
const chartRef = ref<HTMLDivElement | null>(null); const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
...@@ -80,8 +79,8 @@ ...@@ -80,8 +79,8 @@
{ {
smooth: true, smooth: true,
data: [ data: [
111, 222, 4000, 18000, 33333, 55555, 66666, 33333, 14000, 36000, 66666, 44444, 111, 222, 4000, 18000, 33333, 55555, 66666, 33333, 14000, 36000, 66666, 44444, 22222,
22222, 11111, 4000, 2000, 500, 333, 222, 111, 11111, 4000, 2000, 500, 333, 222, 111,
], ],
type: 'line', type: 'line',
areaStyle: {}, areaStyle: {},
...@@ -92,8 +91,8 @@ ...@@ -92,8 +91,8 @@
{ {
smooth: true, smooth: true,
data: [ data: [
33, 66, 88, 333, 3333, 5000, 18000, 3000, 1200, 13000, 22000, 11000, 2221, 1201, 33, 66, 88, 333, 3333, 5000, 18000, 3000, 1200, 13000, 22000, 11000, 2221, 1201, 390,
390, 198, 60, 30, 22, 11, 198, 60, 30, 22, 11,
], ],
type: 'line', type: 'line',
areaStyle: {}, areaStyle: {},
...@@ -104,7 +103,4 @@ ...@@ -104,7 +103,4 @@
], ],
}); });
}); });
return { chartRef };
},
});
</script> </script>
<template> <template>
<div ref="chartRef" :style="{ height, width }"></div> <div ref="chartRef" :style="{ height, width }"></div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, onMounted, ref, Ref } from 'vue'; import { onMounted, ref, Ref } from 'vue';
import { useECharts } from '/@/hooks/web/useECharts'; import { useECharts } from '/@/hooks/web/useECharts';
import { basicProps } from './props'; import { basicProps } from './props';
export default defineComponent({
props: basicProps, defineProps({
setup() { ...basicProps,
});
const chartRef = ref<HTMLDivElement | null>(null); const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
onMounted(() => { onMounted(() => {
setOptions({ setOptions({
tooltip: { tooltip: {
...@@ -56,7 +55,4 @@ ...@@ -56,7 +55,4 @@
], ],
}); });
}); });
return { chartRef };
},
});
</script> </script>
...@@ -3,15 +3,12 @@ ...@@ -3,15 +3,12 @@
<div ref="chartRef" :style="{ width, height }"></div> <div ref="chartRef" :style="{ width, height }"></div>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, Ref, ref, watch } from 'vue'; import { Ref, ref, watch } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { useECharts } from '/@/hooks/web/useECharts'; import { useECharts } from '/@/hooks/web/useECharts';
export default defineComponent({ const props = defineProps({
components: { Card },
props: {
loading: Boolean, loading: Boolean,
width: { width: {
type: String as PropType<string>, type: String as PropType<string>,
...@@ -21,8 +18,8 @@ ...@@ -21,8 +18,8 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '300px', default: '300px',
}, },
}, });
setup(props) {
const chartRef = ref<HTMLDivElement | null>(null); const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
watch( watch(
...@@ -100,7 +97,4 @@ ...@@ -100,7 +97,4 @@
}, },
{ immediate: true } { immediate: true }
); );
return { chartRef };
},
});
</script> </script>
...@@ -3,15 +3,11 @@ ...@@ -3,15 +3,11 @@
<div ref="chartRef" :style="{ width, height }"></div> <div ref="chartRef" :style="{ width, height }"></div>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, Ref, ref, watch } from 'vue'; import { Ref, ref, watch } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { useECharts } from '/@/hooks/web/useECharts'; import { useECharts } from '/@/hooks/web/useECharts';
const props = defineProps({
export default defineComponent({
components: { Card },
props: {
loading: Boolean, loading: Boolean,
width: { width: {
type: String as PropType<string>, type: String as PropType<string>,
...@@ -21,8 +17,7 @@ ...@@ -21,8 +17,7 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '300px', default: '300px',
}, },
}, });
setup(props) {
const chartRef = ref<HTMLDivElement | null>(null); const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
watch( watch(
...@@ -82,7 +77,4 @@ ...@@ -82,7 +77,4 @@
}, },
{ immediate: true } { immediate: true }
); );
return { chartRef };
},
});
</script> </script>
...@@ -2,38 +2,24 @@ ...@@ -2,38 +2,24 @@
<div class="p-4"> <div class="p-4">
<GrowCard :loading="loading" class="enter-y" /> <GrowCard :loading="loading" class="enter-y" />
<SiteAnalysis class="!my-4 enter-y" :loading="loading" /> <SiteAnalysis class="!my-4 enter-y" :loading="loading" />
<div class="md:flex enter-y"> <div class="md:flex enter-y">
<VisitRadar class="md:w-1/3 w-full" :loading="loading" /> <VisitRadar class="md:w-1/3 w-full" :loading="loading" />
<VisitSource class="md:w-1/3 !md:mx-4 !md:my-0 !my-4 w-full" :loading="loading" /> <VisitSource class="md:w-1/3 !md:mx-4 !md:my-0 !my-4 w-full" :loading="loading" />
<SalesProductPie class="md:w-1/3 w-full" :loading="loading" /> <SalesProductPie class="md:w-1/3 w-full" :loading="loading" />
</div> </div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, ref } from 'vue'; import { ref } from 'vue';
import GrowCard from './components/GrowCard.vue'; import GrowCard from './components/GrowCard.vue';
import SiteAnalysis from './components/SiteAnalysis.vue'; import SiteAnalysis from './components/SiteAnalysis.vue';
import VisitSource from './components/VisitSource.vue'; import VisitSource from './components/VisitSource.vue';
import VisitRadar from './components/VisitRadar.vue'; import VisitRadar from './components/VisitRadar.vue';
import SalesProductPie from './components/SalesProductPie.vue'; import SalesProductPie from './components/SalesProductPie.vue';
export default defineComponent({
components: {
GrowCard,
SiteAnalysis,
VisitRadar,
VisitSource,
SalesProductPie,
},
setup() {
const loading = ref(true); const loading = ref(true);
setTimeout(() => { setTimeout(() => {
loading.value = false; loading.value = false;
}, 1500); }, 1500);
return { loading };
},
});
</script> </script>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<template #extra> <template #extra>
<a-button type="link" size="small">更多</a-button> <a-button type="link" size="small">更多</a-button>
</template> </template>
<List item-layout="horizontal" :data-source="items"> <List item-layout="horizontal" :data-source="dynamicInfoItems">
<template #renderItem="{ item }"> <template #renderItem="{ item }">
<ListItem> <ListItem>
<ListItemMeta> <ListItemMeta>
...@@ -21,18 +21,11 @@ ...@@ -21,18 +21,11 @@
</List> </List>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue';
import { Card, List } from 'ant-design-vue'; import { Card, List } from 'ant-design-vue';
import { dynamicInfoItems } from './data'; import { dynamicInfoItems } from './data';
import headerImg from '/@/assets/images/header.jpg';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
export default defineComponent({ const ListItem = List.Item;
components: { Card, List, ListItem: List.Item, ListItemMeta: List.Item.Meta, Icon }, const ListItemMeta = List.Item.Meta;
setup() {
return { items: dynamicInfoItems, headerImg };
},
});
</script> </script>
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
import { groupItems } from './data'; import { groupItems } from './data';
......
<template> <template>
<Card title="快捷导航" v-bind="$attrs"> <Card title="快捷导航" v-bind="$attrs">
<template v-for="item in items" :key="item"> <template v-for="item in navItems" :key="item">
<CardGrid> <CardGrid>
<span class="flex flex-col items-center"> <span class="flex flex-col items-center">
<Icon :icon="item.icon" :color="item.color" size="20" /> <Icon :icon="item.icon" :color="item.color" size="20" />
...@@ -10,17 +10,10 @@ ...@@ -10,17 +10,10 @@
</template> </template>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { Icon } from '/@/components/Icon';
import { navItems } from './data'; import { navItems } from './data';
import { Icon } from '/@/components/Icon';
export default defineComponent({ const CardGrid = Card.Grid;
components: { Card, CardGrid: Card.Grid, Icon },
setup() {
return { items: navItems };
},
});
</script> </script>
...@@ -3,15 +3,12 @@ ...@@ -3,15 +3,12 @@
<div ref="chartRef" :style="{ width, height }"></div> <div ref="chartRef" :style="{ width, height }"></div>
</Card> </Card>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, Ref, ref, watch } from 'vue'; import { Ref, ref, watch } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { useECharts } from '/@/hooks/web/useECharts'; import { useECharts } from '/@/hooks/web/useECharts';
export default defineComponent({ const props = defineProps({
components: { Card },
props: {
loading: Boolean, loading: Boolean,
width: { width: {
type: String as PropType<string>, type: String as PropType<string>,
...@@ -21,8 +18,8 @@ ...@@ -21,8 +18,8 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '400px', default: '400px',
}, },
}, });
setup(props) {
const chartRef = ref<HTMLDivElement | null>(null); const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
watch( watch(
...@@ -100,7 +97,4 @@ ...@@ -100,7 +97,4 @@
}, },
{ immediate: true } { immediate: true }
); );
return { chartRef };
},
});
</script> </script>
...@@ -22,19 +22,12 @@ ...@@ -22,19 +22,12 @@
</div> </div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { computed, defineComponent } from 'vue'; import { computed } from 'vue';
import { Avatar } from 'ant-design-vue'; import { Avatar } from 'ant-design-vue';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import headerImg from '/@/assets/images/header.jpg'; import headerImg from '/@/assets/images/header.jpg';
export default defineComponent({
components: { Avatar },
setup() {
const userStore = useUserStore(); const userStore = useUserStore();
const userinfo = computed(() => userStore.getUserInfo); const userinfo = computed(() => userStore.getUserInfo);
return { userinfo, headerImg };
},
});
</script> </script>
...@@ -18,9 +18,8 @@ ...@@ -18,9 +18,8 @@
</div> </div>
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, ref } from 'vue'; import { ref } from 'vue';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import { PageWrapper } from '/@/components/Page'; import { PageWrapper } from '/@/components/Page';
import WorkbenchHeader from './components/WorkbenchHeader.vue'; import WorkbenchHeader from './components/WorkbenchHeader.vue';
...@@ -29,26 +28,9 @@ ...@@ -29,26 +28,9 @@
import DynamicInfo from './components/DynamicInfo.vue'; import DynamicInfo from './components/DynamicInfo.vue';
import SaleRadar from './components/SaleRadar.vue'; import SaleRadar from './components/SaleRadar.vue';
export default defineComponent({
components: {
PageWrapper,
WorkbenchHeader,
ProjectCard,
QuickNav,
DynamicInfo,
SaleRadar,
Card,
},
setup() {
const loading = ref(true); const loading = ref(true);
setTimeout(() => { setTimeout(() => {
loading.value = false; loading.value = false;
}, 1500); }, 1500);
return {
loading,
};
},
});
</script> </script>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论