perf: standard code format

This commit is contained in:
xiaoxian521
2022-05-14 09:59:02 +08:00
parent 2214ce7911
commit 1cf82eb7a4
29 changed files with 85 additions and 82 deletions

View File

@@ -0,0 +1,96 @@
<script lang="ts">
export default {
name: "Bar"
};
</script>
<script setup lang="ts">
import { ECharts } from "echarts";
import echarts from "/@/plugins/echarts";
import { onBeforeMount, onMounted, nextTick } from "vue";
import { useEventListener, tryOnUnmounted, useTimeoutFn } from "@vueuse/core";
let echartInstance: ECharts;
const props = defineProps({
index: {
type: Number,
default: 0
}
});
function initechartInstance() {
const echartDom = document.querySelector(".bar" + props.index);
if (!echartDom) return;
// @ts-ignore
echartInstance = echarts.init(echartDom);
echartInstance.clear(); //清除旧画布 重新渲染
echartInstance.setOption({
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow"
}
},
grid: {
bottom: "20%",
height: "68%",
containLabel: true
},
xAxis: [
{
type: "category",
axisTick: {
alignWithLabel: true
},
axisLabel: {
interval: 0
// width: "70",
// overflow: "truncate"
},
data: ["open_issues", "forks", "watchers", "star"]
}
],
yAxis: [
{
type: "value"
}
],
series: [
{
name: "GitHub信息",
type: "bar",
data: [3, 204, 1079, 1079]
}
]
});
}
onBeforeMount(() => {
nextTick(() => {
initechartInstance();
});
});
onMounted(() => {
nextTick(() => {
useEventListener("resize", () => {
if (!echartInstance) return;
useTimeoutFn(() => {
echartInstance.resize();
}, 180);
});
});
});
tryOnUnmounted(() => {
if (!echartInstance) return;
echartInstance.dispose();
echartInstance = null;
});
</script>
<template>
<div :class="'bar' + props.index" style="width: 100%; height: 35vh" />
</template>

View File

@@ -0,0 +1,87 @@
<script setup lang="ts">
import { ref } from "vue";
const lists = ref([
{ type: "", label: "善良" },
{ type: "success", label: "好学" },
{ type: "info", label: "幽默" },
{ type: "danger", label: "旅游" },
{ type: "warning", label: "追剧" }
]);
</script>
<template>
<el-descriptions class="margin-top" direction="vertical" :column="3" border>
<el-descriptions-item>
<template #label>
<el-icon>
<IconifyIconOffline icon="user" />
</el-icon>
用户名
</template>
xiaoxian
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<el-icon>
<IconifyIconOffline icon="iphone" />
</el-icon>
手机号
</template>
123456789
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<el-icon>
<IconifyIconOffline icon="location" />
</el-icon>
居住地
</template>
上海
</el-descriptions-item>
</el-descriptions>
<el-descriptions class="margin-top" direction="vertical" :column="2" border>
<el-descriptions-item>
<template #label>
<el-icon>
<IconifyIconOffline icon="tickets" />
</el-icon>
标签
</template>
<el-tag
v-for="item in lists"
:key="item.label"
:type="item.type"
size="small"
effect="dark"
>
{{ item.label }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<el-icon>
<IconifyIconOffline icon="office-building" />
</el-icon>
联系地址
</template>
上海市徐汇区
</el-descriptions-item>
</el-descriptions>
<el-descriptions class="margin-top" direction="vertical" :column="1" border>
<el-descriptions-item>
<template #label>
<el-icon>
<IconifyIconOffline icon="notebook" />
</el-icon>
留言
</template>
好好学习天天向上
</el-descriptions-item>
</el-descriptions>
</template>
<style scoped>
.el-tag {
margin-right: 10px !important;
}
</style>

View File

@@ -0,0 +1,134 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { templateRef } from "@vueuse/core";
import SeamlessScroll from "/@/components/ReSeamlessScroll";
const scroll = templateRef<ElRef | null>("scroll", null);
let listData = ref([
{
date: "2021-09-01",
name: "vue-pure-admin",
star: "1000"
},
{
date: "2021-09-02",
name: "vue-pure-admin",
star: "1100"
},
{
date: "2021-09-03",
name: "vue-pure-admin",
star: "1200"
},
{
date: "2021-09-04",
name: "vue-pure-admin",
star: "1300"
},
{
date: "2021-09-05",
name: "vue-pure-admin",
star: "1400"
},
{
date: "2021-09-06",
name: "vue-pure-admin",
star: "1500"
},
{
date: "2021-09-07",
name: "vue-pure-admin",
star: "1600"
},
{
date: "2021-09-08",
name: "vue-pure-admin",
star: "1700"
},
{
date: "2021-09-09",
name: "vue-pure-admin",
star: "1800"
},
{
date: "2021-09-10",
name: "vue-pure-admin",
star: "1900"
}
]);
let classOption = reactive({
direction: "top"
});
</script>
<template>
<div class="infinite">
<ul class="top">
<li>更新日期</li>
<li>项目名称</li>
<li>Star数量</li>
</ul>
<SeamlessScroll
ref="scroll"
:data="listData"
:class-option="classOption"
class="warp"
>
<ul class="item">
<li v-for="(item, index) in listData" :key="index">
<span v-text="item.date" />
<span v-text="item.name" />
<span v-text="item.star" />
</li>
</ul>
</SeamlessScroll>
</div>
</template>
<style lang="scss" scoped>
.infinite {
.top {
width: 95%;
height: 40px;
line-height: 40px;
display: flex;
margin: 0 auto;
font-size: 14px;
color: #909399;
font-weight: 400;
background: #fafafa;
li {
width: 34%;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.warp {
width: 95%;
height: 215px;
margin: 0 auto;
overflow: hidden;
li {
height: 30px;
line-height: 30px;
display: flex;
font-size: 15px;
}
span {
width: 34%;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
</style>

View File

@@ -0,0 +1,84 @@
<script lang="ts">
export default {
name: "Line"
};
</script>
<script setup lang="ts">
import { ECharts } from "echarts";
import echarts from "/@/plugins/echarts";
import { onBeforeMount, onMounted, nextTick } from "vue";
import { useEventListener, tryOnUnmounted, useTimeoutFn } from "@vueuse/core";
let echartInstance: ECharts;
const props = defineProps({
index: {
type: Number,
default: 0
}
});
function initechartInstance() {
const echartDom = document.querySelector(".line" + props.index);
if (!echartDom) return;
// @ts-ignore
echartInstance = echarts.init(echartDom);
echartInstance.clear(); //清除旧画布 重新渲染
echartInstance.setOption({
grid: {
bottom: "20%",
height: "68%",
containLabel: true
},
tooltip: {
trigger: "item"
},
xAxis: {
type: "category",
axisLabel: {
interval: 0
},
data: ["open_issues", "forks", "watchers", "star"]
},
yAxis: {
type: "value"
},
series: [
{
data: [3, 204, 1079, 1079],
type: "line",
areaStyle: {}
}
]
});
}
onBeforeMount(() => {
nextTick(() => {
initechartInstance();
});
});
onMounted(() => {
nextTick(() => {
useEventListener("resize", () => {
if (!echartInstance) return;
useTimeoutFn(() => {
echartInstance.resize();
}, 180);
});
});
});
tryOnUnmounted(() => {
if (!echartInstance) return;
echartInstance.dispose();
echartInstance = null;
});
</script>
<template>
<div :class="'line' + props.index" style="width: 100%; height: 35vh" />
</template>

View File

@@ -0,0 +1,87 @@
<script lang="ts">
export default {
name: "Pie"
};
</script>
<script setup lang="ts">
import { ECharts } from "echarts";
import echarts from "/@/plugins/echarts";
import { onBeforeMount, onMounted, nextTick } from "vue";
import { useEventListener, tryOnUnmounted, useTimeoutFn } from "@vueuse/core";
let echartInstance: ECharts;
const props = defineProps({
index: {
type: Number,
default: 0
}
});
function initechartInstance() {
const echartDom = document.querySelector(".pie" + props.index);
if (!echartDom) return;
// @ts-ignore
echartInstance = echarts.init(echartDom);
echartInstance.clear(); //清除旧画布 重新渲染
echartInstance.setOption({
tooltip: {
trigger: "item"
},
legend: {
orient: "vertical",
right: true
},
series: [
{
name: "Github信息",
type: "pie",
radius: "60%",
center: ["40%", "50%"],
data: [
{ value: 1079, name: "watchers" },
{ value: 1079, name: "star" },
{ value: 204, name: "forks" },
{ value: 3, name: "open_issues" }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)"
}
}
}
]
});
}
onBeforeMount(() => {
nextTick(() => {
initechartInstance();
});
});
onMounted(() => {
nextTick(() => {
useEventListener("resize", () => {
if (!echartInstance) return;
useTimeoutFn(() => {
echartInstance.resize();
}, 180);
});
});
});
tryOnUnmounted(() => {
if (!echartInstance) return;
echartInstance.dispose();
echartInstance = null;
});
</script>
<template>
<div :class="'pie' + props.index" style="width: 100%; height: 35vh" />
</template>

View File

@@ -0,0 +1,38 @@
import reInfinite from "./Infinite.vue";
import reGithub from "./Github.vue";
import reLine from "./Line.vue";
import reBar from "./Bar.vue";
import rePie from "./Pie.vue";
import { App } from "vue";
const ReInfinite = Object.assign(reInfinite, {
install(app: App) {
app.component(reInfinite.name, reInfinite);
}
});
const ReGithub = Object.assign(reGithub, {
install(app: App) {
app.component(reGithub.name, reGithub);
}
});
const ReLine = Object.assign(reLine, {
install(app: App) {
app.component(reLine.name, reLine);
}
});
const ReBar = Object.assign(reBar, {
install(app: App) {
app.component(reBar.name, reBar);
}
});
const RePie = Object.assign(rePie, {
install(app: App) {
app.component(rePie.name, rePie);
}
});
export { ReInfinite, ReGithub, ReLine, ReBar, RePie };

249
src/views/welcome/index.vue Normal file
View File

@@ -0,0 +1,249 @@
<script setup lang="ts">
import { ReGithub, ReInfinite, RePie, ReLine, ReBar } from "./components";
import { ref, computed } from "vue";
import avatars from "/@/assets/avatars.jpg";
const date: Date = new Date();
let loading = ref<boolean>(true);
setTimeout(() => {
loading.value = !loading.value;
}, 800);
let greetings = computed(() => {
if (date.getHours() >= 0 && date.getHours() < 12) {
return "上午阳光明媚,祝你薪水翻倍🌞!";
} else if (date.getHours() >= 12 && date.getHours() < 18) {
return "下午小风娇好,愿你青春不老😃!";
} else {
return "折一根天使羽毛,愿拂去您的疲惫烦恼忧伤🌛!";
}
});
const openDepot = (): void => {
window.open("https://github.com/xiaoxian521/vue-pure-admin");
};
</script>
<template>
<div class="welcome">
<el-card class="top-content">
<div class="left-mark">
<img :src="avatars" title="直达仓库地址" @click="openDepot" />
<span>{{ greetings }}</span>
</div>
</el-card>
<el-row :gutter="24" style="margin: 20px">
<el-col
:xs="24"
:sm="24"
:md="12"
:lg="12"
:xl="12"
style="margin-bottom: 20px"
v-motion
:initial="{
opacity: 0,
y: 100
}"
:enter="{
opacity: 1,
y: 0,
transition: {
delay: 200
}
}"
>
<el-card style="height: 360px">
<template #header>
<span style="font-size: 16px; font-weight: 500">GitHub信息</span>
</template>
<el-skeleton animated :rows="7" :loading="loading">
<template #default>
<ReGithub />
</template>
</el-skeleton>
</el-card>
</el-col>
<el-col
:xs="24"
:sm="24"
:md="12"
:lg="12"
:xl="12"
style="margin-bottom: 20px"
v-motion
:initial="{
opacity: 0,
y: 100
}"
:enter="{
opacity: 1,
y: 0,
transition: {
delay: 200
}
}"
>
<el-card style="height: 360px">
<template #header>
<span style="font-size: 16px; font-weight: 500"
>GitHub滚动信息</span
>
</template>
<el-skeleton animated :rows="7" :loading="loading">
<template #default>
<ReInfinite />
</template>
</el-skeleton>
</el-card>
</el-col>
<el-col
:xs="24"
:sm="24"
:md="12"
:lg="8"
:xl="8"
style="margin-bottom: 20px"
v-motion
:initial="{
opacity: 0,
y: 100
}"
:enter="{
opacity: 1,
y: 0,
transition: {
delay: 400
}
}"
>
<el-card>
<template #header>
<span style="font-size: 16px; font-weight: 500"
>GitHub饼图信息</span
>
</template>
<el-skeleton animated :rows="7" :loading="loading">
<template #default>
<RePie />
</template>
</el-skeleton>
</el-card>
</el-col>
<el-col
:xs="24"
:sm="24"
:md="12"
:lg="8"
:xl="8"
style="margin-bottom: 20px"
v-motion
:initial="{
opacity: 0,
y: 100
}"
:enter="{
opacity: 1,
y: 0,
transition: {
delay: 400
}
}"
>
<el-card>
<template #header>
<span style="font-size: 16px; font-weight: 500"
>GitHub折线图信息</span
>
</template>
<el-skeleton animated :rows="7" :loading="loading">
<template #default>
<ReLine />
</template>
</el-skeleton>
</el-card>
</el-col>
<el-col
:xs="24"
:sm="24"
:md="24"
:lg="8"
:xl="8"
style="margin-bottom: 20px"
v-motion
:initial="{
opacity: 0,
y: 100
}"
:enter="{
opacity: 1,
y: 0,
transition: {
delay: 400
}
}"
>
<el-card>
<template #header>
<span style="font-size: 16px; font-weight: 500"
>GitHub柱状图信息</span
>
</template>
<el-skeleton animated :rows="7" :loading="loading">
<template #default>
<ReBar />
</template>
</el-skeleton>
</el-card>
</el-col>
</el-row>
</div>
</template>
<style module scoped>
.size {
height: 335px;
}
</style>
<style lang="scss" scoped>
.main-content {
margin: 0 !important;
}
.welcome {
height: 100%;
.top-content {
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
background: #fff;
.left-mark {
display: flex;
align-items: center;
img {
display: block;
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 10px;
cursor: pointer;
}
span {
font-size: 14px;
}
}
}
}
</style>