he wei
2025-04-23 b9bd29a1a81f6f7de479e3cc3fdfe3d85fc660bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script setup>
import { ref, computed, } from "vue";
const width = 18;
const borderWidth = 2;
const colors = ["#0d0", "#FF0000", "#804000"];
 
const props = defineProps({
    offset: {
        type: Array,
        default: () => [0, 0],
    },
    points: {
        type: Array,
        default: () => [
            [0, 0],
            [10, 10],
        ],
    },
    color: {
        type: String,
        default: "#804000",
    },
  // 开关状态 0 断开   1 闭合   2 未知
    status: {
        type: Number,
        default: 0,
    },
    currColor: {
        type: String,
        default: "#0f0",
    },
});
 
const fillColor = computed(() => {
  return props.status ? colors[props.status] : 'transparent';
});
 
const strokeColor = computed(() => {
  return colors[props.status];
});
</script>
 
<template>
  <g ref="g" :transform="'translate(' + offset.join(',') + ')'">
    <rect
      :width="width"
      :height="width"
      :stroke="`url(${props.status == 2 ? '#colorBorder1' : '#colorBorder0'})`"
      stroke-width="2"
    />
    <rect
      x="2"
      y="2"
      :width="width - 4"
      :height="width - 4"
      :fill="fillColor"
      :stroke="strokeColor"
    />
  </g>
</template>
 
<style scoped lang="less"></style>