it-tools/src/tools/device-information/device-information.vue

103 lines
2.2 KiB
Vue
Raw Normal View History

2022-04-18 18:11:06 +02:00
<script setup lang="ts">
2022-04-22 23:31:40 +02:00
import { useWindowSize } from '@vueuse/core';
2022-04-18 18:11:06 +02:00
2022-04-22 23:31:40 +02:00
const { width, height } = useWindowSize();
2022-04-18 18:11:06 +02:00
const sections = [
{
name: 'Screen',
information: [
{
label: 'Screen size',
2022-04-22 23:31:40 +02:00
value: computed(() => `${window.screen.availWidth} x ${window.screen.availHeight}`),
2022-04-18 18:11:06 +02:00
},
{
label: 'Orientation',
2022-04-22 23:31:40 +02:00
value: computed(() => window.screen.orientation.type),
2022-04-18 18:11:06 +02:00
},
{
label: 'Orientation angle',
2022-04-22 23:31:40 +02:00
value: computed(() => `${window.screen.orientation.angle}°`),
2022-04-18 18:11:06 +02:00
},
{
label: 'Color depth',
2022-04-22 23:31:40 +02:00
value: computed(() => `${window.screen.colorDepth} bits`),
2022-04-18 18:11:06 +02:00
},
{
label: 'Pixel ratio',
2022-04-22 23:31:40 +02:00
value: computed(() => `${window.devicePixelRatio} dppx`),
2022-04-18 18:11:06 +02:00
},
{
label: 'Window size',
2022-04-22 23:31:40 +02:00
value: computed(() => `${width.value} x ${height.value}`),
},
],
2022-04-18 18:11:06 +02:00
},
{
name: 'Device',
information: [
{
label: 'Browser vendor',
2022-04-22 23:31:40 +02:00
value: computed(() => navigator.vendor),
2022-04-18 18:11:06 +02:00
},
2022-04-22 23:31:40 +02:00
{
2022-04-18 18:11:06 +02:00
label: 'Languages',
2022-04-22 23:31:40 +02:00
value: computed(() => navigator.languages.join(', ')),
2022-04-18 18:11:06 +02:00
},
2022-04-22 23:31:40 +02:00
{
2022-05-09 14:38:54 +02:00
label: 'Platform',
2022-04-22 23:31:40 +02:00
value: computed(() => navigator.platform),
2022-04-18 18:11:06 +02:00
},
{
label: 'User agent',
2022-04-22 23:31:40 +02:00
value: computed(() => navigator.userAgent),
},
],
},
];
2022-04-18 18:11:06 +02:00
</script>
<template>
<c-card v-for="{ name, information } in sections" :key="name" :title="name">
<n-grid cols="1 400:2" x-gap="12" y-gap="12">
<n-gi v-for="{ label, value: { value } } in information" :key="label" class="information">
<div class="label">
{{ label }}
</div>
<div class="value">
<n-ellipsis v-if="value">
{{ value }}
</n-ellipsis>
<div v-else class="undefined-value">
unknown
</div>
</div>
</n-gi>
</n-grid>
</c-card>
</template>
2022-04-18 18:11:06 +02:00
<style lang="less" scoped>
.information {
padding: 14px 16px;
border-radius: 4px;
background-color: #aaaaaa11;
2022-04-22 23:31:40 +02:00
.label {
2022-04-18 18:11:06 +02:00
font-size: 14px;
opacity: 0.8;
line-height: 1;
margin-bottom: 5px;
}
.value {
font-size: 20px;
font-weight: 400;
}
.undefined-value {
opacity: 0.8;
}
2022-04-18 18:11:06 +02:00
}
2022-04-22 23:31:40 +02:00
</style>