新增 XSLPrintDot 项目,包含打印服务的核心功能和相关配置。实现打印机查询、打印任务处理、远程转发功能,并支持多平台设备ID获取。优化打印数据准备逻辑,增强系统的可维护性和扩展性,同时更新工作区配置以支持新项目。
This commit is contained in:
33
XSLPrintDot/device_id_darwin.go
Normal file
33
XSLPrintDot/device_id_darwin.go
Normal file
@@ -0,0 +1,33 @@
|
||||
//go:build darwin
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getDeviceID() (string, error) {
|
||||
out, err := exec.Command("ioreg", "-rd1", "-c", "IOPlatformExpertDevice").Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
lines := bytes.Split(out, []byte("\n"))
|
||||
for _, line := range lines {
|
||||
text := strings.TrimSpace(string(line))
|
||||
if !strings.Contains(text, "IOPlatformUUID") {
|
||||
continue
|
||||
}
|
||||
if idx := strings.Index(text, "="); idx >= 0 {
|
||||
value := strings.TrimSpace(text[idx+1:])
|
||||
value = strings.Trim(value, "\"")
|
||||
if value != "" {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
Reference in New Issue
Block a user