2023-09-12 22:05:48 +00:00
|
|
|
<template>
|
|
|
|
<slot v-if="show" name="default" />
|
|
|
|
<span v-else>***</span>
|
|
|
|
<button :class="`tag button icon is-${button_class} ml-2`" @click="on_click">
|
|
|
|
<font-awesome-icon :icon="`fa-solid fa-${button_icon}`" />
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Options, Vue } from "vue-class-component";
|
|
|
|
|
|
|
|
enum ClickState {
|
|
|
|
Green = 0,
|
|
|
|
Yellow = 1,
|
|
|
|
Red = 2,
|
|
|
|
}
|
|
|
|
|
|
|
|
@Options({
|
|
|
|
emits: ["load"],
|
|
|
|
})
|
|
|
|
export default class extends Vue {
|
2023-09-14 04:00:04 +00:00
|
|
|
public state = ClickState.Green;
|
2023-09-12 22:05:48 +00:00
|
|
|
|
|
|
|
public on_click(): void {
|
2023-09-14 04:00:04 +00:00
|
|
|
this.state++;
|
|
|
|
this.state %= 3;
|
2023-09-12 22:05:48 +00:00
|
|
|
|
2023-09-14 04:00:04 +00:00
|
|
|
if (this.state === ClickState.Red) {
|
2023-09-12 22:05:48 +00:00
|
|
|
this.$emit("load");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public get show(): boolean {
|
2023-09-14 04:00:04 +00:00
|
|
|
return this.state === ClickState.Red;
|
2023-09-12 22:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public get button_class(): string {
|
2023-09-14 04:00:04 +00:00
|
|
|
switch (this.state) {
|
2023-09-12 22:05:48 +00:00
|
|
|
case ClickState.Red:
|
|
|
|
return "danger";
|
|
|
|
case ClickState.Yellow:
|
|
|
|
return "warning";
|
|
|
|
default:
|
|
|
|
return "primary";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public get button_icon(): string {
|
2023-09-14 04:00:04 +00:00
|
|
|
if (this.state === ClickState.Red) {
|
2023-09-12 22:05:48 +00:00
|
|
|
return "eye-slash";
|
|
|
|
} else {
|
|
|
|
return "eye";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|