2023-10-13 16:43:53 +08:00
|
|
|
<template>
|
|
|
|
|
<n-space vertical justify="space-around" class="dot_matrix_screen_display">
|
|
|
|
|
|
|
|
|
|
<n-grid :cols="count" class="top-container">
|
|
|
|
|
<n-gi v-for="n in count">
|
|
|
|
|
<n-input
|
|
|
|
|
:disabled="!hasFont"
|
|
|
|
|
type="text"
|
|
|
|
|
maxlength="1"
|
|
|
|
|
placeholder=""
|
|
|
|
|
v-model:value="inputValues[n - 1]"
|
|
|
|
|
:allow-input="onlyAllow" />
|
|
|
|
|
</n-gi>
|
|
|
|
|
</n-grid>
|
|
|
|
|
|
|
|
|
|
<LEDPanelView ref="ledPanelViewRef" />
|
|
|
|
|
|
|
|
|
|
<n-space :item-style="itemStyle" class="bottom-container">
|
|
|
|
|
<input type="color" v-model="color" />
|
|
|
|
|
|
|
|
|
|
<n-space vertical>
|
|
|
|
|
<div>
|
2023-10-16 13:55:56 +08:00
|
|
|
<n-text v-if="!hasFont">{{ fontmsg }}</n-text>
|
2023-10-13 16:43:53 +08:00
|
|
|
|
|
|
|
|
<n-radio-group v-else v-model:value="fontLibrarySelected" name="radiogroup">
|
|
|
|
|
<n-space>
|
|
|
|
|
<n-radio v-for="value, key in fontTypes" :key="key" :value="key">
|
|
|
|
|
{{ value }}
|
|
|
|
|
</n-radio>
|
|
|
|
|
</n-space>
|
|
|
|
|
</n-radio-group>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<n-button type="primary" size="large" @click="onClearBtnClick">清理屏幕</n-button>
|
|
|
|
|
</n-space>
|
|
|
|
|
</n-space>
|
|
|
|
|
</n-space>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, watch, onMounted } from 'vue'
|
2023-10-16 13:55:56 +08:00
|
|
|
import { NSpace, NGrid, NGi, NInput, NRadioGroup, NRadio, NText, NButton, useMessage } from 'naive-ui'
|
2023-10-13 16:43:53 +08:00
|
|
|
import { LEDPanelView } from './LEDPanelView'
|
|
|
|
|
import { hasIpcRenderer } from '@/utils'
|
|
|
|
|
|
2023-10-16 13:55:56 +08:00
|
|
|
const message = useMessage()
|
|
|
|
|
|
|
|
|
|
const itemStyle = { textAlign: 'center', flex: '1 1 50%' }
|
2023-10-13 16:43:53 +08:00
|
|
|
|
|
|
|
|
const count = 8
|
|
|
|
|
const hasFont = ref(false)
|
2023-10-16 13:55:56 +08:00
|
|
|
const fontmsg = ref('字库未创建,请先创建字库后重启软件')
|
2023-10-13 16:43:53 +08:00
|
|
|
const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.', '-']
|
|
|
|
|
const onlyAllow = (value: string) => !value || chars.indexOf(value) >= 0
|
|
|
|
|
|
|
|
|
|
const ledPanelViewRef = ref()
|
|
|
|
|
const inputValues = ref(new Array(count).fill(null))
|
2023-10-16 13:55:56 +08:00
|
|
|
|
2023-10-13 16:43:53 +08:00
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
|
watch(
|
|
|
|
|
() => inputValues.value[i],
|
|
|
|
|
value => {
|
2023-10-16 13:55:56 +08:00
|
|
|
const { data } = window.ipcRenderer.sendSync('LOAD_FONT_LIBRARY')
|
|
|
|
|
if (!data) return
|
|
|
|
|
fontLibrary = JSON.parse(data)
|
|
|
|
|
hasFont.value = true
|
2023-10-13 16:43:53 +08:00
|
|
|
if (!value) {
|
|
|
|
|
ledPanelViewRef.value.clearArea(i)
|
|
|
|
|
} else {
|
|
|
|
|
const charData = fontLibrary[fontLibrarySelected.value][value]
|
|
|
|
|
ledPanelViewRef.value.showChar(i, charData, color.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const color = ref('#eeeeee')
|
|
|
|
|
|
|
|
|
|
const fontTypes = { font35: '3*5', font47: '4*7' }
|
|
|
|
|
const fontLibrarySelected = ref(Object.keys(fontTypes)[0])
|
|
|
|
|
let fontLibrary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
if (!hasIpcRenderer()) return
|
|
|
|
|
|
|
|
|
|
const { data } = window.ipcRenderer.sendSync('LOAD_FONT_LIBRARY')
|
|
|
|
|
if (!data) return
|
|
|
|
|
|
|
|
|
|
fontLibrary = JSON.parse(data)
|
|
|
|
|
hasFont.value = true
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const onClearBtnClick = () => {
|
|
|
|
|
inputValues.value.fill(null)
|
2023-10-16 13:55:56 +08:00
|
|
|
ledPanelViewRef.value.clearAll()
|
2023-10-13 16:43:53 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
|
|
.dot_matrix_screen_display {
|
|
|
|
|
|
|
|
|
|
.top-container {
|
|
|
|
|
.n-input {
|
|
|
|
|
height: calc(100vw / 8);
|
|
|
|
|
|
|
|
|
|
:deep(input) {
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-size: 56px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bottom-container {
|
|
|
|
|
gap: 0 !important;
|
|
|
|
|
|
|
|
|
|
input {
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
width: 96px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|