add drawer

This commit is contained in:
Fine 2022-09-26 11:27:05 +08:00
parent d50e9fc261
commit 209619255f
3 changed files with 29 additions and 4 deletions

View File

@ -17,6 +17,7 @@
import "element-plus/es/components/message/style/css"; import "element-plus/es/components/message/style/css";
import "element-plus/es/components/message-box/style/css"; import "element-plus/es/components/message-box/style/css";
import "element-plus/es/components/notification/style/css"; import "element-plus/es/components/notification/style/css";
import "element-plus/es/components/drawer/style/css";
import "./grid.scss"; import "./grid.scss";
import "./lib.scss"; import "./lib.scss";
import "./reset.scss"; import "./reset.scss";

View File

@ -9,6 +9,7 @@ declare module '@vue/runtime-core' {
ElCollapse: typeof import('element-plus/es')['ElCollapse'] ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElDialog: typeof import('element-plus/es')['ElDialog'] ElDialog: typeof import('element-plus/es')['ElDialog']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']

View File

@ -15,7 +15,12 @@ limitations under the License. -->
<template> <template>
<div class="top-list" v-if="available"> <div class="top-list" v-if="available">
<div class="chart-slow-i" v-for="(i, index) in data[key]" :key="index"> <div
class="chart-slow-i"
v-for="(i, index) in data[key]"
:key="index"
@click="viewTrace(i)"
>
<div class="ell tools flex-h"> <div class="ell tools flex-h">
<div class="desc"> <div class="desc">
<span class="calls mr-10">{{ i.value }}</span> <span class="calls mr-10">{{ i.value }}</span>
@ -28,7 +33,7 @@ limitations under the License. -->
iconName="review-list" iconName="review-list"
size="middle" size="middle"
class="cp" class="cp"
@click="handleClick(i.name)" @click="handleClick($event, i.name)"
/> />
</div> </div>
</div> </div>
@ -39,12 +44,23 @@ limitations under the License. -->
:show-text="false" :show-text="false"
/> />
</div> </div>
<el-drawer
v-model="showTrace"
:title="t('trace')"
size="70%"
:destroy-on-close="true"
:before-close="() => (showTrace = false)"
:append-to-body="true"
>
<span>Hi, trace!</span>
</el-drawer>
</div> </div>
<div class="center no-data" v-else>No Data</div> <div class="center no-data" v-else>No Data</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from "vue"; import type { PropType } from "vue";
import { computed } from "vue"; import { useI18n } from "vue-i18n";
import { computed, ref } from "vue";
import copy from "@/utils/copy"; import copy from "@/utils/copy";
import { TextColors } from "@/views/dashboard/data"; import { TextColors } from "@/views/dashboard/data";
/*global defineProps */ /*global defineProps */
@ -61,6 +77,8 @@ const props = defineProps({
}, },
intervalTime: { type: Array as PropType<string[]>, default: () => [] }, intervalTime: { type: Array as PropType<string[]>, default: () => [] },
}); });
const { t } = useI18n();
const showTrace = ref<boolean>(false);
const key = computed(() => Object.keys(props.data)[0] || ""); const key = computed(() => Object.keys(props.data)[0] || "");
const available = computed( const available = computed(
() => () =>
@ -75,9 +93,14 @@ const maxValue = computed(() => {
const temp: number[] = props.data[key.value].map((i: any) => i.value); const temp: number[] = props.data[key.value].map((i: any) => i.value);
return Math.max.apply(null, temp); return Math.max.apply(null, temp);
}); });
function handleClick(i: string) { function handleClick(event: PointerEvent, i: string) {
event.stopPropagation();
copy(i); copy(i);
} }
function viewTrace(item: { name: string }) {
console.log(item);
showTrace.value = true;
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.top-list { .top-list {