<template>
    <div class="full-screen h-full cursor-pointer flex items-center px-2" @click="handleClean">
        <icon :size="18" name="el-icon-printer" />
    </div>
</template>

<script setup lang="ts" name="printer">
import { printerList } from "@/utils/print"
const handleClean = async () => {
    if(!localStorage.getItem('hiprint')) window.open("hiprint://");
    const list = printerList();
    if(list.length) {
        localStorage.setItem('hiprint', '1');
        let flag = 0;
        list.forEach((item: any) => {
            if(item.name == 'HPRT D35' || item.displayName == 'HPRT D35'){
                flag = 1;
            }
        });
        if(flag==1) ElMessage.success('已找到HPRT D35打印机, 请确保其为默认打印机');
        else ElMessage.error('未找到HPRT D35打印机, 请检查是否安装打印机驱动');
    }
    else localStorage.removeItem('hiprint');
}
</script>

<style scoped>

</style>