feat: 初始化小米 IoT (MIoT) 智能家居 Go 库
- 实现 MIoT 客户端核心功能(MQTT 连接、设备管理、属性读写) - 支持云端 API 调用与局域网设备发现(mDNS) - 集成国际化(i18n)多语言支持 - 添加 MIoT 设备规约解析器(spec_parser) - 包含单元测试与使用示例
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Package miot provides MIoT core client for Xiaomi Home devices.
|
||||
// This file is a direct port of py-miot/web_pages.py.
|
||||
package miot
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed resource/oauth_redirect_page.html
|
||||
var oauthRedirectTemplate string
|
||||
|
||||
// OAuthRedirectPage returns the OAuth redirect page HTML.
|
||||
// Replaces TITLE_PLACEHOLDER, CONTENT_PLACEHOLDER, BUTTON_PLACEHOLDER,
|
||||
// and STATUS_PLACEHOLDER in the embedded template.
|
||||
func OAuthRedirectPage(title, content, button string, success bool) string {
|
||||
status := "false"
|
||||
if success {
|
||||
status = "true"
|
||||
}
|
||||
html := oauthRedirectTemplate
|
||||
html = strings.Replace(html, "TITLE_PLACEHOLDER", title, 1)
|
||||
html = strings.Replace(html, "CONTENT_PLACEHOLDER", content, 1)
|
||||
html = strings.Replace(html, "BUTTON_PLACEHOLDER", button, 1)
|
||||
html = strings.Replace(html, "STATUS_PLACEHOLDER", status, 1)
|
||||
return html
|
||||
}
|
||||
Reference in New Issue
Block a user