wip: refactor(client): migrate components to composition api

This commit is contained in:
syuilo
2022-01-15 17:58:35 +09:00
parent ffc07a08d7
commit 41e18aa993
5 changed files with 100 additions and 156 deletions

View File

@ -10,32 +10,19 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import { } from 'vue';
import XPie from './pie.vue';
import bytes from '@/filters/bytes';
export default defineComponent({
components: {
XPie
},
props: {
meta: {
required: true,
}
},
data() {
return {
usage: this.meta.fs.used / this.meta.fs.total,
total: this.meta.fs.total,
used: this.meta.fs.used,
available: this.meta.fs.total - this.meta.fs.used,
};
},
methods: {
bytes
}
});
const props = defineProps<{
meta: any; // TODO
}>();
const usage = $computed(() => props.meta.fs.used / props.meta.fs.total);
const total = $computed(() => props.meta.fs.total);
const used = $computed(() => props.meta.fs.used);
const available = $computed(() => props.meta.fs.total - props.meta.fs.used);
</script>
<style lang="scss" scoped>

View File

@ -20,30 +20,17 @@
</svg>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import { } from 'vue';
export default defineComponent({
props: {
value: {
type: Number,
required: true
}
},
data() {
return {
r: 0.45
};
},
computed: {
color(): string {
return `hsl(${180 - (this.value * 180)}, 80%, 70%)`;
},
strokeDashoffset(): number {
return (1 - this.value) * (Math.PI * (this.r * 2));
}
}
});
const props = defineProps<{
value: number;
}>();
const r = 0.45;
const color = $computed(() => `hsl(${180 - (props.value * 180)}, 80%, 70%)`);
const strokeDashoffset = $computed(() => (1 - props.value) * (Math.PI * (r * 2)));
</script>
<style lang="scss" scoped>