Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1175adec62 | ||
|
|
97a046ab00 | ||
|
|
74355c1dd2 | ||
|
|
a446a1ba37 | ||
|
|
f997035972 | ||
|
|
ead706ea52 | ||
|
|
bf381d8034 | ||
|
|
f283b4eae0 | ||
|
|
78d4a7c3aa | ||
|
|
fb3f549acc | ||
|
|
336c41a90f | ||
|
|
5d9c2ca0c9 | ||
|
|
944c3f31b3 | ||
|
|
5b193181d1 | ||
|
|
b7461cee27 | ||
|
|
02bb727f33 | ||
|
|
9b7cc01c3a | ||
|
|
c21326eea8 | ||
|
|
98ca1a6190 | ||
|
|
7d1ad7a417 | ||
|
|
6067e9517e | ||
|
|
ccdf5bd19b | ||
|
|
a98c9a36ac | ||
|
|
40c930cdbb |
@@ -1,4 +1,4 @@
|
||||
// vfyfix — 修正 .vfy 壳头里的两个 CRC(crcV / crcFile)
|
||||
// vfyfix — 修正壳节(.load,旧产物 .vfy)头里的两个 CRC(crcV / crcFile)
|
||||
//
|
||||
// 场景:先用 verify 的加壳链路打壳(signed=false,壳会校验整文件 CRC),再用别的工具
|
||||
// (如 DogProtect)二次加壳。后者重写了 PE,壳一校验就退出。本工具在最后一步重算:
|
||||
@@ -27,7 +27,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
secName = ".vfy"
|
||||
secName = ".load"
|
||||
legacySecName = ".vfy"
|
||||
hdrSize = 48
|
||||
crcOff = 36
|
||||
)
|
||||
@@ -57,7 +58,7 @@ func main() {
|
||||
|
||||
var sec *pe.Section
|
||||
for _, s := range f.Sections {
|
||||
if strings.HasPrefix(s.Name, secName) {
|
||||
if strings.HasPrefix(s.Name, secName) || strings.HasPrefix(s.Name, legacySecName) {
|
||||
sec = s
|
||||
}
|
||||
}
|
||||
@@ -80,7 +81,7 @@ func main() {
|
||||
flags := binary.LittleEndian.Uint32(data[off+32:])
|
||||
oldV := binary.LittleEndian.Uint32(data[off+crcOff:])
|
||||
oldF := binary.LittleEndian.Uint32(data[off+crcOff+4:])
|
||||
fmt.Printf("%s\n .vfy 文件偏移=0x%x 原始大小=%d flags=0x%x(bit1=%d)\n", path, off, rawSize, flags, (flags>>1)&1)
|
||||
fmt.Printf("%s\n 壳节 %s 文件偏移=0x%x 原始大小=%d flags=0x%x(bit1=%d)\n", path, sec.Name, off, rawSize, flags, (flags>>1)&1)
|
||||
fmt.Printf(" 旧: crcV=%08x crcFile=%08x\n", oldV, oldF)
|
||||
|
||||
// ---- 重算 crcV:节内跳过 36..44 ----
|
||||
|
||||
@@ -4,6 +4,8 @@ app:
|
||||
port: "8080"
|
||||
jwt_secret: "your-secret-key-change-in-production"
|
||||
jwt_expire_hours: "24"
|
||||
# 加壳时写进壳 cfg 的站点根地址;留空则按请求头推断(反代需要传 X-Forwarded-Host)
|
||||
public_url: ""
|
||||
|
||||
database:
|
||||
host: "localhost"
|
||||
|
||||
@@ -240,6 +240,16 @@ func runMigrations() {
|
||||
// 导致心跳写设备时 Error 1265 Data truncated,设备表永远是空的。
|
||||
fixDeviceIDColumnType()
|
||||
|
||||
// 登录方式开关(login_mode)上线:enforce 为空的历史行补成 warn(只记录不拦截),
|
||||
// 这样升级后行为完全不变,面板也能显示真实状态;管理员确认影响面后再切 strict。
|
||||
if DB.Migrator().HasTable(&model.Application{}) {
|
||||
if err := DB.Model(&model.Application{}).
|
||||
Where("login_mode_enforce IS NULL OR login_mode_enforce = ''").
|
||||
Update("login_mode_enforce", "warn").Error; err != nil {
|
||||
log.Printf("[WARN] 回填 applications.login_mode_enforce 失败: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 迁移后复核:仍有表不存在时明确打出来,避免后续写库时报 1146 无从排查
|
||||
for _, m := range models {
|
||||
if !DB.Migrator().HasTable(m) {
|
||||
|
||||
@@ -174,7 +174,11 @@ type Application struct {
|
||||
AppKey string `gorm:"unique;size:50" json:"app_key"`
|
||||
BillingType string `gorm:"size:20" json:"billing_type"`
|
||||
LoginPolicy string `gorm:"size:20;default:loose" json:"login_policy"`
|
||||
LoginMode string `gorm:"size:20;default:account" json:"login_mode"` // account = 账号密码, card = 单卡直登, both = 两种都开
|
||||
LoginMode string `gorm:"size:20;default:both" json:"login_mode"` // account = 账号密码, card = 单卡直登, both = 两种都开
|
||||
// 登录方式开关的生效级别:off = 不校验(旧行为), warn = 只记录不拦截(灰度用), strict = 真正拦截
|
||||
LoginModeEnforce string `gorm:"size:16;default:warn" json:"login_mode_enforce"`
|
||||
// 切换登录方式后的宽限期截止时间:在此之前旧凭证仍然可用(避免一刀切锁死存量用户)
|
||||
LoginModeGraceUntil *time.Time `json:"login_mode_grace_until"`
|
||||
CardLoginBindDevice bool `gorm:"default:true" json:"card_login_bind_device"` // 卡密登录是否也受设备上限约束
|
||||
CardLoginAllowPassword bool `gorm:"default:false" json:"card_login_allow_password"` // 卡密主体是否允许再设一个登录密码
|
||||
EncryptType string `gorm:"size:20" json:"encrypt_type"`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package protect:服务端给 PE 注入验证壳(改入口 + 内嵌壳 DLL + 双层 CRC32)
|
||||
//
|
||||
// 产物结构:原 exe 追加 .vfy 节 = [48B 头][引导 blob][壳 DLL][配置 JSON]
|
||||
// 入口指向 .vfy 内的引导代码;引导代码反射加载 DLL(零落盘)。
|
||||
// 产物结构:原 exe 追加 .load 节 = [48B 头][引导 blob][壳 DLL][配置 JSON]
|
||||
// 入口指向 .load 内的引导代码;引导代码反射加载 DLL(零落盘)。
|
||||
package protect
|
||||
|
||||
import (
|
||||
@@ -24,7 +24,8 @@ var assets embed.FS
|
||||
const (
|
||||
hdrSize = 48
|
||||
crcOff = 36
|
||||
secName = ".vfy"
|
||||
secName = ".load"
|
||||
legacySec = ".vfy" // 旧产物用 .vfy,检测时一并识别(新产物一律写 .load)
|
||||
shellVer = 8
|
||||
secAttrib = 0x60000020 // CODE | EXECUTE | READ
|
||||
)
|
||||
@@ -96,8 +97,8 @@ func AssetsThemed(arch, theme string) (blob, dll []byte, err error) {
|
||||
return blob, dll, nil
|
||||
}
|
||||
|
||||
// HasVfy 判断 PE 里是不是已经有 .vfy 节(已被加过壳)。
|
||||
// 二次加壳会在文件里留下两个 .vfy:旧壳的 cfg 指向老服务器、白占几百 KB,
|
||||
// HasVfy 判断 PE 里是不是已经有壳节(.load,或旧产物的 .vfy)。
|
||||
// 二次加壳会在文件里留下两个壳节:旧壳的 cfg 指向老服务器、白占几百 KB,
|
||||
// 目标机跳的却是新节,排查时极易被旧头误导,所以入口直接挡掉。
|
||||
func HasVfy(target []byte) bool {
|
||||
f, err := pe.NewFile(bytes.NewReader(target))
|
||||
@@ -106,7 +107,7 @@ func HasVfy(target []byte) bool {
|
||||
}
|
||||
defer f.Close()
|
||||
for _, s := range f.Sections {
|
||||
if strings.HasPrefix(s.Name, secName) {
|
||||
if strings.HasPrefix(s.Name, secName) || strings.HasPrefix(s.Name, legacySec) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func createTask(app *model.Application, userID uint, srcName string, data []byte
|
||||
return nil, "", err
|
||||
}
|
||||
if det.Kind == KindPE && HasVfy(data) {
|
||||
return nil, "", fmt.Errorf("这个文件已经是云端加密后的产物(带 .vfy 节),请上传未加密的原始程序")
|
||||
return nil, "", fmt.Errorf("这个文件已经是云端加密后的产物(带 .load/.vfy 节),请上传未加密的原始程序")
|
||||
}
|
||||
// 签名证书必须在建任务时就落库:execute 是 go 协程,事后 UPDATE 有窗口
|
||||
// 被它读到 NULL,导致证书被静默忽略(任务照样成功,只是没重签)。
|
||||
@@ -199,5 +199,5 @@ func infoMessage(info Info) string {
|
||||
if info.Note != "" {
|
||||
return info.Note
|
||||
}
|
||||
return fmt.Sprintf("入口 0x%x → 0x%x,.vfy RVA=0x%x", info.EntryOld, info.EntryNew, info.SecRVA)
|
||||
return fmt.Sprintf("入口 0x%x → 0x%x,壳节 RVA=0x%x", info.EntryOld, info.EntryNew, info.SecRVA)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ func SetupApplicationRoutes(r *gin.RouterGroup) {
|
||||
applications.PUT("/:id", handleUpdateApplication)
|
||||
applications.DELETE("/:id", handleDeleteApplication)
|
||||
applications.GET("/:id", handleGetApplication)
|
||||
applications.GET("/:id/login-mode-impact", handleLoginModeImpact)
|
||||
applications.POST("/:id/icon", handleUploadIcon)
|
||||
applications.POST("/:id/upload", handleUploadVersionFile)
|
||||
applications.GET("/:id/versions", handleGetVersions)
|
||||
@@ -212,6 +213,8 @@ func handleCreateApplication(c *gin.Context) {
|
||||
EncryptKey: encryptKey,
|
||||
BillingType: req.BillingType,
|
||||
LoginPolicy: loginPolicy,
|
||||
LoginMode: "both", // 新建应用默认两种登录方式都开,避免上线即把某一类用户挡在门外
|
||||
LoginModeEnforce: "warn", // 默认只记录不拦截,管理员确认影响面后再切 strict
|
||||
EncryptType: encryptType,
|
||||
BindType: req.BindType,
|
||||
MaxDevices: maxDevices,
|
||||
@@ -302,6 +305,9 @@ func handleUpdateApplication(c *gin.Context) {
|
||||
BillingType string `form:"billing_type" json:"billing_type"`
|
||||
LoginPolicy string `form:"login_policy" json:"login_policy"`
|
||||
LoginMode string `form:"login_mode" json:"login_mode"`
|
||||
// 登录方式开关的生效级别与宽限期(前端「登录方式」卡片里的那两项)
|
||||
LoginModeEnforce string `form:"login_mode_enforce" json:"login_mode_enforce"`
|
||||
LoginModeGraceDays *int `form:"login_mode_grace_days" json:"login_mode_grace_days"`
|
||||
CardLoginBindDevice *bool `form:"card_login_bind_device" json:"card_login_bind_device"`
|
||||
CardLoginAllowPassword *bool `form:"card_login_allow_password" json:"card_login_allow_password"`
|
||||
AllowRegister bool `form:"allow_register" json:"allow_register"`
|
||||
@@ -378,12 +384,32 @@ func handleUpdateApplication(c *gin.Context) {
|
||||
if req.BillingType != "" {
|
||||
app.BillingType = req.BillingType
|
||||
}
|
||||
oldLoginMode := app.LoginMode
|
||||
if req.LoginMode != "" {
|
||||
switch req.LoginMode {
|
||||
case "account", "card", "both":
|
||||
app.LoginMode = req.LoginMode
|
||||
}
|
||||
}
|
||||
if req.LoginModeEnforce != "" {
|
||||
switch req.LoginModeEnforce {
|
||||
case "off", "warn", "strict":
|
||||
app.LoginModeEnforce = req.LoginModeEnforce
|
||||
}
|
||||
}
|
||||
// 宽限期:显式传了按传的算(0 = 立即生效,顺带清掉截止时间);
|
||||
// 没传但刚切换了登录方式,自动给 7 天,避免存量用户被一刀切挡在门外。
|
||||
if req.LoginModeGraceDays != nil {
|
||||
if *req.LoginModeGraceDays > 0 {
|
||||
until := time.Now().AddDate(0, 0, *req.LoginModeGraceDays)
|
||||
app.LoginModeGraceUntil = &until
|
||||
} else {
|
||||
app.LoginModeGraceUntil = nil
|
||||
}
|
||||
} else if req.LoginMode != "" && req.LoginMode != oldLoginMode {
|
||||
until := time.Now().AddDate(0, 0, 7)
|
||||
app.LoginModeGraceUntil = &until
|
||||
}
|
||||
if req.CardLoginBindDevice != nil {
|
||||
app.CardLoginBindDevice = *req.CardLoginBindDevice
|
||||
}
|
||||
@@ -1143,3 +1169,62 @@ func handleManualDeduct(c *gin.Context) {
|
||||
"message": "扣费成功",
|
||||
})
|
||||
}
|
||||
|
||||
// handleLoginModeImpact 登录方式切换的影响面。
|
||||
// 面板在把 login_mode 改成 account / card 之前先调这个,看清楚有多少主体会被挡住,
|
||||
// 再决定是「只记录」「开宽限期」还是「先跑迁移动作」。
|
||||
func handleLoginModeImpact(c *gin.Context) {
|
||||
userID := c.GetUint("user_id")
|
||||
|
||||
var app model.Application
|
||||
if err := database.DB.Where("id = ? AND user_id = ?", c.Param("id"), userID).First(&app).Error; err != nil {
|
||||
response.Error(c, 404, "应用不存在")
|
||||
return
|
||||
}
|
||||
|
||||
var total, cardSubjects, cardWithEmail, onlyAccount int64
|
||||
database.DB.Model(&model.AppUser{}).Where("application_id = ?", app.ID).Count(&total)
|
||||
|
||||
// 卡密主体的密码是建主体时写进去的随机散列(卡密才是它的钥匙),所以不能靠 password 是否为空判断。
|
||||
// 这里用「有没有绑邮箱」来区分:绑了邮箱的卡密主体有自助设密码的通道,没绑的只能靠卡密登录。
|
||||
database.DB.Model(&model.AppUser{}).
|
||||
Where("application_id = ? AND subject_type = ?", app.ID, "card").
|
||||
Count(&cardSubjects)
|
||||
database.DB.Model(&model.AppUser{}).
|
||||
Where("application_id = ? AND subject_type = ?", app.ID, "card").
|
||||
Where("email IS NOT NULL AND email <> ''").
|
||||
Count(&cardWithEmail)
|
||||
onlyCard := cardSubjects - cardWithEmail
|
||||
if onlyCard < 0 {
|
||||
onlyCard = 0
|
||||
}
|
||||
|
||||
// 仅账号主体:有账号但没绑任何「登录卡」→ 切到 card 后他们登不进来
|
||||
database.DB.Model(&model.AppUser{}).
|
||||
Where("application_id = ? AND subject_type = ?", app.ID, "account").
|
||||
Where("NOT EXISTS (SELECT 1 FROM cards WHERE cards.subject_id = app_users.id AND cards.purpose = ? AND cards.deleted_at IS NULL)", "credential").
|
||||
Count(&onlyAccount)
|
||||
|
||||
mode := service.AppLoginMode(&app)
|
||||
graceDays := service.LoginModeGraceDaysLeft(&app)
|
||||
blocking := (mode == "account" && onlyCard > 0) || (mode == "card" && onlyAccount > 0)
|
||||
|
||||
// 切换成该模式后会被挡住的人数(给前端直接显示,不用自己算)
|
||||
blockedIfSwitch := onlyCard
|
||||
if mode == "card" {
|
||||
blockedIfSwitch = onlyAccount
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{
|
||||
"login_mode": mode,
|
||||
"login_mode_enforce": service.AppLoginModeEnforce(&app),
|
||||
"login_mode_grace_days": graceDays,
|
||||
"total_subjects": total,
|
||||
"card_subjects": cardSubjects,
|
||||
"card_subjects_with_email": cardWithEmail,
|
||||
"only_card_subjects": onlyCard,
|
||||
"only_account_subjects": onlyAccount,
|
||||
"blocking": blocking,
|
||||
"blocked_if_switch": blockedIfSwitch,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,13 +2,16 @@ package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
"verification-platform-backend/internal/database"
|
||||
"verification-platform-backend/internal/model"
|
||||
"verification-platform-backend/internal/service"
|
||||
"verification-platform-backend/pkg/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FinanceRecordResponse struct {
|
||||
@@ -89,10 +92,20 @@ func handleGetFinanceStatistics(c *gin.Context) {
|
||||
Select("COALESCE(SUM(amount), 0)").
|
||||
Scan(&totalExpense)
|
||||
|
||||
// 本月流水条数:两个空数据分支都在返回它,正常分支以前漏了
|
||||
monthStart := time.Now().Format("2006-01") + "-01 00:00:00"
|
||||
var monthly int64
|
||||
database.DB.Model(&model.RechargeRecord{}).
|
||||
Where("user_id IN ? AND created_at >= ?", appUserIDs, monthStart).Count(&monthly)
|
||||
var monthlyCons int64
|
||||
database.DB.Model(&model.ConsumptionRecord{}).
|
||||
Where("user_id IN ? AND created_at >= ?", appUserIDs, monthStart).Count(&monthlyCons)
|
||||
|
||||
response.Success(c, gin.H{
|
||||
"total_income": totalIncome,
|
||||
"total_expense": totalExpense,
|
||||
"net_profit": totalIncome - totalExpense,
|
||||
"total_income": totalIncome,
|
||||
"total_expense": totalExpense,
|
||||
"net_profit": totalIncome - totalExpense,
|
||||
"monthly_transactions": monthly + monthlyCons,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -132,8 +145,7 @@ func handleGetRechargeRecords(c *gin.Context) {
|
||||
status := c.Query("status")
|
||||
startDate := c.Query("start_date")
|
||||
endDate := c.Query("end_date")
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
|
||||
page, pageSize := parsePageParams(c)
|
||||
|
||||
if search != "" {
|
||||
query = query.Where("order_no LIKE ? OR card_code LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
@@ -202,8 +214,7 @@ func handleGetConsumptionRecords(c *gin.Context) {
|
||||
status := c.Query("status")
|
||||
startDate := c.Query("start_date")
|
||||
endDate := c.Query("end_date")
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
|
||||
page, pageSize := parsePageParams(c)
|
||||
|
||||
if search != "" {
|
||||
query = query.Where("order_no LIKE ? OR content LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
@@ -238,182 +249,244 @@ func handleGetConsumptionRecords(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// 财务记录:充值表 + 消费表合并成一条时间线。
|
||||
//
|
||||
// 之前的实现有两个硬伤:
|
||||
// 1. 两张表全量 Find 进内存再切片,数据一多就是内存炸弹,total 也只是 len();
|
||||
// 2. 前端不传分页参数 → 只拿回 10 条,而页面上的「充值总额/消费总额/利润」
|
||||
// 又是对这 10 条 reduce 出来的,于是库里 40 条只算 10 条。
|
||||
// 现在分页与汇总都放在 SQL 层:records 是当前页,summary 是全量(同样带筛选条件)。
|
||||
func handleGetFinanceRecords(c *gin.Context) {
|
||||
userID, exists := c.Get("user_id")
|
||||
if !exists {
|
||||
response.Error(c, 401, "未授权")
|
||||
return
|
||||
}
|
||||
userID := c.GetUint("user_id")
|
||||
|
||||
var appIDs []uint
|
||||
database.DB.Model(&model.Application{}).Where("user_id = ?", userID).Pluck("id", &appIDs)
|
||||
|
||||
if len(appIDs) == 0 {
|
||||
page, pageSize := parsePageParams(c)
|
||||
empty := func() {
|
||||
response.Success(c, gin.H{
|
||||
"recharge_records": []FinanceRecordResponse{},
|
||||
"consumption_records": []FinanceRecordResponse{},
|
||||
"total": 0,
|
||||
"records": []FinanceRecordResponse{},
|
||||
"total": 0,
|
||||
"page": page,
|
||||
"page_size": pageSize,
|
||||
"total_page": 0,
|
||||
"summary": gin.H{
|
||||
"recharge_amount": 0,
|
||||
"recharge_count": 0,
|
||||
"consumption_amount": 0,
|
||||
"consumption_count": 0,
|
||||
"profit": 0,
|
||||
},
|
||||
})
|
||||
}
|
||||
if len(appIDs) == 0 {
|
||||
empty()
|
||||
return
|
||||
}
|
||||
|
||||
// 按应用收窄(必须是自己名下的应用)
|
||||
scopeAppIDs := appIDs
|
||||
if v := c.Query("application_id"); v != "" && v != "all" {
|
||||
id, err := strconv.ParseUint(v, 10, 64)
|
||||
owned := false
|
||||
for _, a := range appIDs {
|
||||
if a == uint(id) {
|
||||
owned = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil || !owned {
|
||||
response.Error(c, 403, "无权查看该应用")
|
||||
return
|
||||
}
|
||||
scopeAppIDs = []uint{uint(id)}
|
||||
}
|
||||
|
||||
var appUserIDs []uint
|
||||
database.DB.Model(&model.AppUser{}).Where("application_id IN ?", appIDs).Pluck("id", &appUserIDs)
|
||||
|
||||
database.DB.Model(&model.AppUser{}).Where("application_id IN ?", scopeAppIDs).Pluck("id", &appUserIDs)
|
||||
if len(appUserIDs) == 0 {
|
||||
response.Success(c, gin.H{
|
||||
"recharge_records": []FinanceRecordResponse{},
|
||||
"consumption_records": []FinanceRecordResponse{},
|
||||
"total": 0,
|
||||
})
|
||||
empty()
|
||||
return
|
||||
}
|
||||
|
||||
page := c.DefaultQuery("page", "1")
|
||||
pageSize := c.DefaultQuery("page_size", "10")
|
||||
search := c.Query("search")
|
||||
recordType := c.Query("type")
|
||||
status := c.Query("status")
|
||||
search := c.Query("search")
|
||||
startDate := c.Query("start_date")
|
||||
endDate := c.Query("end_date")
|
||||
|
||||
var rechargeRecords []model.RechargeRecord
|
||||
rechargeQuery := database.DB.Model(&model.RechargeRecord{}).Preload("AppUser").Where("user_id IN ?", appUserIDs)
|
||||
wantRecharge := recordType == "" || recordType == "all" || recordType == "recharge"
|
||||
wantConsumption := recordType == "" || recordType == "all" || recordType == "consumption"
|
||||
|
||||
if search != "" {
|
||||
rechargeQuery = rechargeQuery.Where("order_no LIKE ? OR card_code LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
if recordType == "recharge" || recordType == "" || recordType == "all" {
|
||||
// 每处都重新构造查询,避免链式 Where 互相污染
|
||||
rechargeQuery := func() *gorm.DB {
|
||||
q := database.DB.Model(&model.RechargeRecord{}).Where("user_id IN ?", appUserIDs)
|
||||
if search != "" {
|
||||
q = q.Where("order_no LIKE ? OR card_code LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
if status != "" && status != "all" {
|
||||
rechargeQuery = rechargeQuery.Where("status = ?", status)
|
||||
q = q.Where("status = ?", status)
|
||||
}
|
||||
if startDate != "" {
|
||||
rechargeQuery = rechargeQuery.Where("created_at >= ?", startDate)
|
||||
q = q.Where("created_at >= ?", startDate)
|
||||
}
|
||||
if endDate != "" {
|
||||
rechargeQuery = rechargeQuery.Where("created_at <= ?", endDate+" 23:59:59")
|
||||
q = q.Where("created_at <= ?", endDate+" 23:59:59")
|
||||
}
|
||||
if err := rechargeQuery.Order("created_at DESC").Find(&rechargeRecords).Error; err != nil {
|
||||
return q
|
||||
}
|
||||
consumptionQuery := func() *gorm.DB {
|
||||
q := database.DB.Model(&model.ConsumptionRecord{}).Where("user_id IN ?", appUserIDs)
|
||||
if search != "" {
|
||||
q = q.Where("order_no LIKE ? OR content LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
if status != "" && status != "all" {
|
||||
q = q.Where("status = ?", status)
|
||||
}
|
||||
if startDate != "" {
|
||||
q = q.Where("created_at >= ?", startDate)
|
||||
}
|
||||
if endDate != "" {
|
||||
q = q.Where("created_at <= ?", endDate+" 23:59:59")
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
// 汇总走 SQL 聚合:不受分页影响,前端卡片直接用,不要自己 reduce 当前页
|
||||
var rechargeAmount, consumptionAmount float64
|
||||
var rechargeCount, consumptionCount int64
|
||||
if wantRecharge {
|
||||
rechargeQuery().Where("status = ?", "success").Select("COALESCE(SUM(amount), 0)").Scan(&rechargeAmount)
|
||||
rechargeQuery().Count(&rechargeCount)
|
||||
}
|
||||
if wantConsumption {
|
||||
consumptionQuery().Where("status = ?", "success").Select("COALESCE(SUM(amount), 0)").Scan(&consumptionAmount)
|
||||
consumptionQuery().Count(&consumptionCount)
|
||||
}
|
||||
total := rechargeCount + consumptionCount
|
||||
|
||||
// 合并分页:两张表各取前 offset+pageSize 条,排序后再切当前页
|
||||
offset := (page - 1) * pageSize
|
||||
need := offset + pageSize
|
||||
if need > 1000 {
|
||||
need = 1000 // 深翻页保护:最多让前 1000 条参与合并
|
||||
}
|
||||
|
||||
var rechargeRecords []model.RechargeRecord
|
||||
if wantRecharge {
|
||||
if err := rechargeQuery().Preload("AppUser").Order("created_at DESC").Limit(need).Find(&rechargeRecords).Error; err != nil {
|
||||
response.Error(c, 500, "获取充值记录失败")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var consumptionRecords []model.ConsumptionRecord
|
||||
consumptionQuery := database.DB.Model(&model.ConsumptionRecord{}).Preload("AppUser").Where("user_id IN ?", appUserIDs)
|
||||
|
||||
if search != "" {
|
||||
consumptionQuery = consumptionQuery.Where("order_no LIKE ? OR content LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
if recordType == "consumption" || recordType == "" || recordType == "all" {
|
||||
if status != "" && status != "all" {
|
||||
consumptionQuery = consumptionQuery.Where("status = ?", status)
|
||||
}
|
||||
if startDate != "" {
|
||||
consumptionQuery = consumptionQuery.Where("created_at >= ?", startDate)
|
||||
}
|
||||
if endDate != "" {
|
||||
consumptionQuery = consumptionQuery.Where("created_at <= ?", endDate+" 23:59:59")
|
||||
}
|
||||
if err := consumptionQuery.Order("created_at DESC").Find(&consumptionRecords).Error; err != nil {
|
||||
if wantConsumption {
|
||||
if err := consumptionQuery().Preload("AppUser").Order("created_at DESC").Limit(need).Find(&consumptionRecords).Error; err != nil {
|
||||
response.Error(c, 500, "获取消费记录失败")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var allRecords []FinanceRecordResponse
|
||||
for _, r := range rechargeRecords {
|
||||
var user *struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
if r.AppUser != nil && r.AppUser.ID != 0 {
|
||||
user = &struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
}{
|
||||
ID: r.AppUser.ID,
|
||||
Username: r.AppUser.Username,
|
||||
Email: r.AppUser.Email,
|
||||
}
|
||||
}
|
||||
allRecords = append(allRecords, FinanceRecordResponse{
|
||||
ID: r.ID,
|
||||
OrderNo: r.OrderNo,
|
||||
Type: "recharge",
|
||||
UserID: r.UserID,
|
||||
AppID: r.AppUser.ApplicationID,
|
||||
Amount: r.Amount,
|
||||
Detail: r.CardCode,
|
||||
Status: r.Status,
|
||||
PaymentType: r.PaymentType,
|
||||
Remark: r.Remark,
|
||||
CreatedAt: r.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
User: user,
|
||||
})
|
||||
type mergedRow struct {
|
||||
at time.Time
|
||||
resp FinanceRecordResponse
|
||||
}
|
||||
|
||||
for _, r := range consumptionRecords {
|
||||
var user *struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
if r.AppUser != nil && r.AppUser.ID != 0 {
|
||||
user = &struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
}{
|
||||
ID: r.AppUser.ID,
|
||||
Username: r.AppUser.Username,
|
||||
Email: r.AppUser.Email,
|
||||
}
|
||||
}
|
||||
allRecords = append(allRecords, FinanceRecordResponse{
|
||||
ID: r.ID,
|
||||
OrderNo: r.OrderNo,
|
||||
Type: "consumption",
|
||||
UserID: r.UserID,
|
||||
AppID: r.AppUser.ApplicationID,
|
||||
Amount: r.Amount,
|
||||
Detail: r.Content,
|
||||
Status: r.Status,
|
||||
PaymentType: r.PaymentType,
|
||||
Remark: r.Remark,
|
||||
CreatedAt: r.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
User: user,
|
||||
})
|
||||
merged := make([]mergedRow, 0, len(rechargeRecords)+len(consumptionRecords))
|
||||
for i := range rechargeRecords {
|
||||
merged = append(merged, mergedRow{rechargeRecords[i].CreatedAt, rechargeToFinanceResponse(&rechargeRecords[i])})
|
||||
}
|
||||
|
||||
total := len(allRecords)
|
||||
start := 0
|
||||
end := total
|
||||
if p, err := parseInt(page); err == nil && p > 0 {
|
||||
if ps, err := parseInt(pageSize); err == nil && ps > 0 {
|
||||
start = (p - 1) * ps
|
||||
end = start + ps
|
||||
if start > total {
|
||||
start = total
|
||||
}
|
||||
if end > total {
|
||||
end = total
|
||||
}
|
||||
}
|
||||
for i := range consumptionRecords {
|
||||
merged = append(merged, mergedRow{consumptionRecords[i].CreatedAt, consumptionToFinanceResponse(&consumptionRecords[i])})
|
||||
}
|
||||
sort.SliceStable(merged, func(i, j int) bool { return merged[i].at.After(merged[j].at) })
|
||||
|
||||
if start > end {
|
||||
start = end
|
||||
startIdx, endIdx := offset, offset+pageSize
|
||||
if startIdx > len(merged) {
|
||||
startIdx = len(merged)
|
||||
}
|
||||
if endIdx > len(merged) {
|
||||
endIdx = len(merged)
|
||||
}
|
||||
pageRows := make([]FinanceRecordResponse, 0, endIdx-startIdx)
|
||||
for _, r := range merged[startIdx:endIdx] {
|
||||
pageRows = append(pageRows, r.resp)
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{
|
||||
"records": allRecords[start:end],
|
||||
"total": total,
|
||||
"records": pageRows,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"page_size": pageSize,
|
||||
"total_page": (total + int64(pageSize) - 1) / int64(pageSize),
|
||||
"summary": gin.H{
|
||||
"recharge_amount": rechargeAmount,
|
||||
"recharge_count": rechargeCount,
|
||||
"consumption_amount": consumptionAmount,
|
||||
"consumption_count": consumptionCount,
|
||||
"profit": rechargeAmount - consumptionAmount,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 主体信息:AppUser 为空(主体被删/记录user_id悬空)时返回 nil,
|
||||
// 不要像以前那样直接解引用 r.AppUser.ApplicationID —— 那是 nil 指针 panic。
|
||||
func financeUserBrief(u *model.AppUser) *struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
} {
|
||||
if u == nil || u.ID == 0 {
|
||||
return nil
|
||||
}
|
||||
return &struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
}{ID: u.ID, Username: u.Username, Email: u.Email}
|
||||
}
|
||||
|
||||
func rechargeToFinanceResponse(r *model.RechargeRecord) FinanceRecordResponse {
|
||||
appID := uint(0)
|
||||
if r.AppUser != nil {
|
||||
appID = r.AppUser.ApplicationID
|
||||
}
|
||||
return FinanceRecordResponse{
|
||||
ID: r.ID,
|
||||
OrderNo: r.OrderNo,
|
||||
Type: "recharge",
|
||||
UserID: r.UserID,
|
||||
AppID: appID,
|
||||
Amount: r.Amount,
|
||||
Detail: r.CardCode,
|
||||
Status: r.Status,
|
||||
PaymentType: r.PaymentType,
|
||||
Remark: r.Remark,
|
||||
CreatedAt: r.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
User: financeUserBrief(r.AppUser),
|
||||
}
|
||||
}
|
||||
|
||||
func consumptionToFinanceResponse(r *model.ConsumptionRecord) FinanceRecordResponse {
|
||||
appID := r.ApplicationID
|
||||
if r.AppUser != nil && r.AppUser.ApplicationID != 0 {
|
||||
appID = r.AppUser.ApplicationID
|
||||
}
|
||||
return FinanceRecordResponse{
|
||||
ID: r.ID,
|
||||
OrderNo: r.OrderNo,
|
||||
Type: "consumption",
|
||||
UserID: r.UserID,
|
||||
AppID: appID,
|
||||
Amount: r.Amount,
|
||||
Detail: r.Content,
|
||||
Status: r.Status,
|
||||
PaymentType: r.PaymentType,
|
||||
Remark: r.Remark,
|
||||
CreatedAt: r.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
User: financeUserBrief(r.AppUser),
|
||||
}
|
||||
}
|
||||
|
||||
func parseInt(s string) (int, error) {
|
||||
var result int
|
||||
_, err := fmt.Sscanf(s, "%d", &result)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"verification-platform-backend/internal/database"
|
||||
"verification-platform-backend/internal/model"
|
||||
"verification-platform-backend/pkg/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func SetupLogRoutes(r *gin.RouterGroup) {
|
||||
@@ -22,8 +22,7 @@ func handleGetLogs(c *gin.Context) {
|
||||
var appIDs []uint
|
||||
database.DB.Model(&model.Application{}).Where("user_id = ?", userID).Pluck("id", &appIDs)
|
||||
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
|
||||
page, pageSize := parsePageParams(c)
|
||||
logType := c.Query("type")
|
||||
status := c.Query("status")
|
||||
applicationID := c.Query("application_id")
|
||||
@@ -68,10 +67,41 @@ func handleGetLogs(c *gin.Context) {
|
||||
|
||||
query.Count(&total)
|
||||
|
||||
// 三个统计数字必须和列表同源(同一个 Log 表 + 同一套筛选),
|
||||
// 否则会出现「列表 0 条、顶部写着成功 128」这种对不上的情况。
|
||||
// 以前用的是 ApiUsage 表,而且完全不带筛选条件。
|
||||
baseQuery := func() *gorm.DB {
|
||||
q := database.DB.Model(&model.Log{})
|
||||
if len(appIDs) > 0 {
|
||||
q = q.Where("application_id IN ? OR user_id = ?", appIDs, userID)
|
||||
} else {
|
||||
q = q.Where("user_id = ?", userID)
|
||||
}
|
||||
if logType != "" && logType != "all" {
|
||||
q = q.Where("log_type = ?", logType)
|
||||
}
|
||||
if status != "" && status != "all" {
|
||||
q = q.Where("status = ?", status)
|
||||
}
|
||||
if applicationID != "" && applicationID != "all" {
|
||||
q = q.Where("application_id = ?", applicationID)
|
||||
}
|
||||
if startDate != "" {
|
||||
q = q.Where("created_at >= ?", startDate+" 00:00:00")
|
||||
}
|
||||
if endDate != "" {
|
||||
q = q.Where("created_at <= ?", endDate+" 23:59:59")
|
||||
}
|
||||
if search != "" {
|
||||
q = q.Where("action LIKE ? OR details LIKE ? OR resource LIKE ?", "%"+search+"%", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
var successCount, failedCount, operationCount int64
|
||||
database.DB.Model(&model.ApiUsage{}).Where("application_id IN ? OR user_id = ?", appIDs, userID).Where("status = ?", "success").Count(&successCount)
|
||||
database.DB.Model(&model.ApiUsage{}).Where("application_id IN ? OR user_id = ?", appIDs, userID).Where("status = ?", "failed").Count(&failedCount)
|
||||
database.DB.Model(&model.ApiUsage{}).Where("application_id IN ? OR user_id = ?", appIDs, userID).Where("log_type = ?", "operation").Count(&operationCount)
|
||||
baseQuery().Where("status = ?", "success").Count(&successCount)
|
||||
baseQuery().Where("status = ?", "failed").Count(&failedCount)
|
||||
baseQuery().Where("log_type = ?", "operation").Count(&operationCount)
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
if err := query.Preload("User").Preload("Application").Preload("AppUser").Order("created_at DESC").Offset(offset).Limit(pageSize).Find(&logs).Error; err != nil {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 分页参数的统一入口。
|
||||
//
|
||||
// 之前每个 handler 都自己 strconv.Atoi 然后用,没有下限也没有上限:
|
||||
// - page=0 / 负数 → offset 变负数,MySQL 里直接报错或结果诡异
|
||||
// - page_size=-1 → GORM 的 Limit(-1) 等于「不加 LIMIT」,一次把全表拉出来
|
||||
// - page_size=100000 → 同样等于导出全表
|
||||
// 所以统一在这里夹紧:page >= 1,pageSize ∈ [1, maxPageSize],默认 20。
|
||||
const (
|
||||
defaultPageSize = 20
|
||||
maxPageSize = 200
|
||||
)
|
||||
|
||||
func parsePageParams(c *gin.Context) (page, pageSize int) {
|
||||
page, err := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
if err != nil || page < 1 {
|
||||
page = 1
|
||||
}
|
||||
pageSize, err = strconv.Atoi(c.DefaultQuery("page_size", strconv.Itoa(defaultPageSize)))
|
||||
if err != nil || pageSize < 1 {
|
||||
pageSize = defaultPageSize
|
||||
}
|
||||
if pageSize > maxPageSize {
|
||||
pageSize = maxPageSize
|
||||
}
|
||||
return page, pageSize
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"verification-platform-backend/internal/config"
|
||||
"verification-platform-backend/internal/database"
|
||||
"verification-platform-backend/internal/model"
|
||||
"verification-platform-backend/internal/protect"
|
||||
@@ -31,8 +32,14 @@ func SetupProtectRoutes(r *gin.RouterGroup) {
|
||||
}
|
||||
}
|
||||
|
||||
// baseURL 从请求推断站点根地址(面板/应用共用同一域名)
|
||||
func baseURL(c *gin.Context) string {
|
||||
// baseURL 推断站点根地址(面板/应用共用同一域名)。
|
||||
//
|
||||
// 这里踩过一次真实的坑:AcePanel 默认的反代模板写的是 `proxy_set_header Host $proxy_host`,
|
||||
// 于是后端看到的 Host 是 `127.0.0.1:9998`,打包出来的每个客户端都会把
|
||||
// `https://127.0.0.1:9998/api/v1/app/<key>/login` 写进壳 cfg —— 到了客户机上根本连不上。
|
||||
// 所以:优先 X-Forwarded-Host,其次(配置里的站点地址),最后才是请求 Host;
|
||||
// 一旦推断出来是本机/内网地址,宁可让加壳任务报错,也不要产出一个连不上服务器的产物。
|
||||
func baseURL(c *gin.Context) (string, error) {
|
||||
scheme := c.GetHeader("X-Forwarded-Proto")
|
||||
if scheme == "" {
|
||||
if c.Request.TLS != nil {
|
||||
@@ -41,11 +48,48 @@ func baseURL(c *gin.Context) string {
|
||||
scheme = "http"
|
||||
}
|
||||
}
|
||||
host := c.GetHeader("X-Forwarded-Host")
|
||||
|
||||
// 反代应当带上 X-Forwarded-Host;它才是用户浏览器里那个域名
|
||||
host := strings.TrimSpace(c.GetHeader("X-Forwarded-Host"))
|
||||
if host == "" {
|
||||
host = c.Request.Host
|
||||
host = strings.TrimSpace(c.Request.Host)
|
||||
}
|
||||
return fmt.Sprintf("%s://%s", scheme, host)
|
||||
|
||||
// 站点地址可以在 config.yaml 里显式指定(app.public_url),配了就优先用
|
||||
if pub := strings.TrimRight(config.GetString("app.public_url"), "/"); pub != "" {
|
||||
return pub, nil
|
||||
}
|
||||
|
||||
if host == "" || isInternalHost(host) {
|
||||
return "", fmt.Errorf("无法推断站点地址(反向代理没有传 X-Forwarded-Host,Host 为 %q),请在 config.yaml 配置 app.public_url", host)
|
||||
}
|
||||
return fmt.Sprintf("%s://%s", scheme, host), nil
|
||||
}
|
||||
|
||||
// isInternalHost 判断 host 是不是只在本机/内网有意义(127.x、localhost、内网网段、无域名端口等)
|
||||
func isInternalHost(host string) bool {
|
||||
h := host
|
||||
if i := strings.LastIndex(h, ":"); i > 0 && !strings.Contains(h[i:], "]") {
|
||||
h = h[:i] // 去掉端口
|
||||
}
|
||||
h = strings.ToLower(strings.Trim(h, "[]"))
|
||||
switch {
|
||||
case h == "", h == "localhost", h == "0.0.0.0", h == "::1":
|
||||
return true
|
||||
case strings.HasPrefix(h, "127."), strings.HasPrefix(h, "10."), strings.HasPrefix(h, "192.168."):
|
||||
return true
|
||||
case strings.HasPrefix(h, "172."):
|
||||
// 172.16.0.0/12
|
||||
parts := strings.Split(h, ".")
|
||||
if len(parts) == 4 {
|
||||
if n, err := strconv.Atoi(parts[1]); err == nil && n >= 16 && n <= 31 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
case strings.HasPrefix(h, "169.254."):
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HandleCreateProtectTask 上传原始程序 → 建任务 → 异步加壳
|
||||
@@ -227,7 +271,12 @@ func HandleCreateProtectTask(c *gin.Context) {
|
||||
response.Error(c, 400, "程序版本号只能包含字母、数字、点、下划线和横线,例如 1.2.3")
|
||||
return
|
||||
}
|
||||
task, err := protect.CreateAndRunThemedVer(&app, userID, name, data, baseURL(c), signProfileID, certIdentity, theme, programVer)
|
||||
siteURL, err := baseURL(c)
|
||||
if err != nil {
|
||||
response.Error(c, 400, err.Error())
|
||||
return
|
||||
}
|
||||
task, err := protect.CreateAndRunThemedVer(&app, userID, name, data, siteURL, signProfileID, certIdentity, theme, programVer)
|
||||
if err != nil {
|
||||
response.ParamError(c, err.Error())
|
||||
return
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TestIsInternalHost(t *testing.T) {
|
||||
cases := map[string]bool{
|
||||
"127.0.0.1:9998": true,
|
||||
"127.0.0.1": true,
|
||||
"localhost:8080": true,
|
||||
"localhost": true,
|
||||
"10.0.0.5": true,
|
||||
"192.168.1.10:443": true,
|
||||
"172.16.0.1": true,
|
||||
"172.31.255.1:8080": true,
|
||||
"169.254.1.1": true,
|
||||
"": true,
|
||||
"[::1]:8080": true,
|
||||
"0.0.0.0:8080": true,
|
||||
"v.viaeon.com": false,
|
||||
"v.viaeon.com:443": false,
|
||||
"172.32.0.1": false, // 不在 172.16/12 里
|
||||
"verify.example.com": false,
|
||||
"8.8.8.8": false,
|
||||
}
|
||||
for host, want := range cases {
|
||||
if got := isInternalHost(host); got != want {
|
||||
t.Fatalf("isInternalHost(%q) = %v, want %v", host, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func newCtx(host, xfh, proto string) *gin.Context {
|
||||
gin.SetMode(gin.TestMode)
|
||||
req := httptest.NewRequest("POST", "/", nil)
|
||||
req.Host = host
|
||||
if xfh != "" {
|
||||
req.Header.Set("X-Forwarded-Host", xfh)
|
||||
}
|
||||
if proto != "" {
|
||||
req.Header.Set("X-Forwarded-Proto", proto)
|
||||
}
|
||||
c, _ := gin.CreateTestContext(httptest.NewRecorder())
|
||||
c.Request = req
|
||||
return c
|
||||
}
|
||||
|
||||
// 反代把 Host 改写成 127.0.0.1 时必须报错,绝不能把内网地址打进产物
|
||||
func TestBaseURLRejectsLoopback(t *testing.T) {
|
||||
u, err := baseURL(newCtx("127.0.0.1:9998", "", "https"))
|
||||
if err == nil {
|
||||
t.Fatalf("期望报错,实际返回 %q", u)
|
||||
}
|
||||
}
|
||||
|
||||
// 反代带了 X-Forwarded-Host 就用它
|
||||
func TestBaseURLPrefersForwardedHost(t *testing.T) {
|
||||
u, err := baseURL(newCtx("127.0.0.1:9998", "v.viaeon.com", "https"))
|
||||
if err != nil {
|
||||
t.Fatalf("期望成功,实际 %v", err)
|
||||
}
|
||||
if want := "https://v.viaeon.com"; u != want {
|
||||
t.Fatalf("baseURL = %q, want %q", u, want)
|
||||
}
|
||||
}
|
||||
|
||||
// 直连(无反代)时用请求 Host
|
||||
func TestBaseURLUsesRequestHost(t *testing.T) {
|
||||
u, err := baseURL(newCtx("v.viaeon.com", "", "https"))
|
||||
if err != nil {
|
||||
t.Fatalf("期望成功,实际 %v", err)
|
||||
}
|
||||
if want := "https://v.viaeon.com"; u != want {
|
||||
t.Fatalf("baseURL = %q, want %q", u, want)
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func handleAppSendEmailCode(c *gin.Context) {
|
||||
}
|
||||
} else if req.Purpose == "bind_email" {
|
||||
// 卡密主体给自己绑邮箱:只在这类应用开启「允许卡密用户设密码」时给发码
|
||||
if !app.CardLoginAllowPassword && app.LoginMode != "card" && app.LoginMode != "both" {
|
||||
if !app.CardLoginAllowPassword {
|
||||
response.Error(c, 400, "该应用未开启卡密绑定邮箱")
|
||||
return
|
||||
}
|
||||
@@ -207,6 +207,19 @@ func handleAppRegister(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 卡密直登模式下注册出来的账号没有登录入口,直接挡掉(宽限期内放行,和登录 gate 保持一致)
|
||||
if service.AppLoginMode(appModel) == "card" && service.AppLoginModeEnforce(appModel) == "strict" && service.LoginModeGraceDaysLeft(appModel) == 0 {
|
||||
service.LogVerification(c, &appModel.ID, nil, "register_blocked",
|
||||
"注册被登录方式策略拦截: mode=card", "", fmt.Errorf("该应用仅支持卡密登录"))
|
||||
c.JSON(403, gin.H{
|
||||
"code": 403,
|
||||
"message": "该应用使用卡密登录,无需注册",
|
||||
"error_code": "LOGIN_MODE_DISABLED",
|
||||
"data": gin.H{"login_mode": "card", "allowed": []string{"card"}},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
@@ -459,6 +472,40 @@ func handleAppLogin(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 登录方式开关(login_mode):这是应用级登录策略,客户端界面只是体验,判定必须在服务端。
|
||||
// 位置故意放在查询主体、写设备绑定、记失败次数之前——被策略拒绝的请求不产生任何副作用。
|
||||
loginDeprecated := false
|
||||
graceDaysLeft := 0
|
||||
if !service.LoginTypeAllowedByMode(appModel, req.LoginType) {
|
||||
mode := service.AppLoginMode(appModel)
|
||||
switch service.AppLoginModeEnforce(appModel) {
|
||||
case "strict":
|
||||
if days := service.LoginModeGraceDaysLeft(appModel); days > 0 {
|
||||
// 宽限期内旧凭证仍然可用,只在响应里提醒用户尽快换钥匙
|
||||
loginDeprecated, graceDaysLeft = true, days
|
||||
log.Printf("[INFO] login_mode grace: app=%s mode=%s login_type=%s days_left=%d", appKey, mode, req.LoginType, days)
|
||||
} else {
|
||||
service.LogVerification(c, &appModel.ID, nil, "login_mode_blocked",
|
||||
"登录被登录方式策略拦截: mode="+mode+" login_type="+req.LoginType, req.DeviceID,
|
||||
fmt.Errorf("该应用仅允许: %s", strings.Join(service.AllowedLoginTypes(mode), ",")))
|
||||
c.JSON(403, gin.H{
|
||||
"code": 403,
|
||||
"message": service.LoginModeBlockMessage(mode),
|
||||
"error_code": "LOGIN_MODE_DISABLED",
|
||||
"data": gin.H{
|
||||
"login_mode": mode,
|
||||
"allowed": service.AllowedLoginTypes(mode),
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
case "warn":
|
||||
log.Printf("[WARN] login_mode(warn-only) 会拦截但已放行: app=%s mode=%s login_type=%s", appKey, mode, req.LoginType)
|
||||
_ = service.LogVerification(c, &appModel.ID, nil, "login_mode_blocked",
|
||||
"[warn-only] 登录方式与策略不符,已放行: mode="+mode+" login_type="+req.LoginType, req.DeviceID, nil)
|
||||
}
|
||||
}
|
||||
|
||||
var user model.AppUser
|
||||
cardAuth := false
|
||||
if req.LoginType == "card" {
|
||||
@@ -782,6 +829,14 @@ func handleAppLogin(c *gin.Context) {
|
||||
loginData["balance"] = user.Balance
|
||||
}
|
||||
|
||||
// 宽限期内的旧凭证登录:明确告诉壳/用户还剩几天,好引导换钥匙
|
||||
if loginDeprecated {
|
||||
loginData["deprecated_login"] = true
|
||||
loginData["grace_days_left"] = graceDaysLeft
|
||||
loginData["login_mode"] = service.AppLoginMode(appModel)
|
||||
loginData["allowed_login_types"] = service.AllowedLoginTypes(service.AppLoginMode(appModel))
|
||||
}
|
||||
|
||||
response.SuccessWithMessage(c, "登录成功", loginData)
|
||||
}
|
||||
|
||||
@@ -978,7 +1033,7 @@ func handleAppCardBind(c *gin.Context) {
|
||||
response.Error(c, 404, "应用不存在")
|
||||
return
|
||||
}
|
||||
if !app.CardLoginAllowPassword && app.LoginMode != "card" && app.LoginMode != "both" {
|
||||
if !app.CardLoginAllowPassword {
|
||||
response.Error(c, 400, "该应用未开启卡密绑定邮箱")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -252,7 +252,10 @@ func handleAppGetInfo(c *gin.Context) {
|
||||
"enable_free_period": app.EnableFreePeriod,
|
||||
"trial_days": app.TrialDays,
|
||||
"bind_type": app.BindType,
|
||||
"login_mode": app.LoginMode,
|
||||
"login_mode": service.AppLoginMode(&app),
|
||||
"login_mode_enforce": service.AppLoginModeEnforce(&app),
|
||||
"login_mode_grace_days": service.LoginModeGraceDaysLeft(&app),
|
||||
"allowed_login_types": service.AllowedLoginTypes(service.AppLoginMode(&app)),
|
||||
"card_login_bind_device": app.CardLoginBindDevice,
|
||||
"card_login_allow_password": app.CardLoginAllowPassword,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"verification-platform-backend/internal/model"
|
||||
)
|
||||
|
||||
// 登录方式开关(login_mode)的判定逻辑集中在这里,供 app 侧(登录/注册/信息下发)
|
||||
// 与 admin 侧(设置、影响面统计)共用。
|
||||
//
|
||||
// 设计约定:
|
||||
// - login_mode 是应用级**策略**,客户端界面只影响体验,真正的判定必须发生在服务端;
|
||||
// - 判定必须早于任何副作用(建绑定、记失败、改 last_login、触发风控锁定);
|
||||
// - 空值/非法值一律按 both 处理(fail-open),任何时候都不把用户锁在门外;
|
||||
// - 生效级别由 LoginModeEnforce 控制:off = 不校验,warn = 只记录,strict = 拦截;
|
||||
// - 处于宽限期(LoginModeGraceUntil 未过)时旧凭证仍可用,只在响应里带 deprecated 标记。
|
||||
|
||||
// AppLoginMode 归一化应用的登录方式;空值/未知值按 both 处理。
|
||||
func AppLoginMode(app *model.Application) string {
|
||||
if app == nil {
|
||||
return "both"
|
||||
}
|
||||
switch app.LoginMode {
|
||||
case "account", "card", "both":
|
||||
return app.LoginMode
|
||||
}
|
||||
return "both"
|
||||
}
|
||||
|
||||
// AllowedLoginTypes 返回该模式下允许的凭证类型。
|
||||
func AllowedLoginTypes(mode string) []string {
|
||||
switch mode {
|
||||
case "account":
|
||||
return []string{"account"}
|
||||
case "card":
|
||||
return []string{"card"}
|
||||
default:
|
||||
return []string{"account", "card"}
|
||||
}
|
||||
}
|
||||
|
||||
// AppLoginModeEnforce 归一化生效级别;空值/未知值按 off 处理,保证升级后行为不变。
|
||||
func AppLoginModeEnforce(app *model.Application) string {
|
||||
if app == nil {
|
||||
return "off"
|
||||
}
|
||||
switch app.LoginModeEnforce {
|
||||
case "off", "warn", "strict":
|
||||
return app.LoginModeEnforce
|
||||
}
|
||||
return "off"
|
||||
}
|
||||
|
||||
// LoginModeLabel 用于错误文案。
|
||||
func LoginModeLabel(mode string) string {
|
||||
switch mode {
|
||||
case "account":
|
||||
return "账号密码"
|
||||
case "card":
|
||||
return "卡密"
|
||||
default:
|
||||
return "账号密码或卡密"
|
||||
}
|
||||
}
|
||||
|
||||
// LoginModeGraceDaysLeft 返回宽限期剩余天数(向上取整);不在宽限期返回 0。
|
||||
func LoginModeGraceDaysLeft(app *model.Application) int {
|
||||
if app == nil || app.LoginModeGraceUntil == nil {
|
||||
return 0
|
||||
}
|
||||
d := time.Until(*app.LoginModeGraceUntil)
|
||||
if d <= 0 {
|
||||
return 0
|
||||
}
|
||||
days := int(math.Ceil(d.Hours() / 24))
|
||||
if days < 1 {
|
||||
days = 1
|
||||
}
|
||||
return days
|
||||
}
|
||||
|
||||
// LoginTypeAllowedByMode 判断某凭证类型在当前模式下是否允许。
|
||||
func LoginTypeAllowedByMode(app *model.Application, loginType string) bool {
|
||||
for _, t := range AllowedLoginTypes(AppLoginMode(app)) {
|
||||
if t == loginType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// LoginModeBlockMessage 生成给终端用户看的拒绝文案。
|
||||
func LoginModeBlockMessage(mode string) string {
|
||||
switch mode {
|
||||
case "account":
|
||||
return "该应用仅支持账号密码登录"
|
||||
case "card":
|
||||
return "该应用仅支持卡密登录"
|
||||
default:
|
||||
return "该应用当前不支持的登录方式"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"verification-platform-backend/internal/model"
|
||||
)
|
||||
|
||||
func TestAppLoginModeNormalize(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
{"account", "account"},
|
||||
{"card", "card"},
|
||||
{"both", "both"},
|
||||
{"", "both"}, // 空值按 both:任何情况下都不把用户锁在门外
|
||||
{"weird", "both"}, // 非法值同上
|
||||
}
|
||||
for _, c := range cases {
|
||||
app := &model.Application{LoginMode: c.in}
|
||||
if got := AppLoginMode(app); got != c.want {
|
||||
t.Fatalf("AppLoginMode(%q) = %q, want %q", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
if got := AppLoginMode(nil); got != "both" {
|
||||
t.Fatalf("AppLoginMode(nil) = %q, want both", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppLoginModeEnforceNormalize(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
{"off", "off"},
|
||||
{"warn", "warn"},
|
||||
{"strict", "strict"},
|
||||
{"", "off"}, // 空值不拦截
|
||||
{"bogus", "off"}, // 非法值不拦截
|
||||
}
|
||||
for _, c := range cases {
|
||||
app := &model.Application{LoginModeEnforce: c.in}
|
||||
if got := AppLoginModeEnforce(app); got != c.want {
|
||||
t.Fatalf("AppLoginModeEnforce(%q) = %q, want %q", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginTypeAllowedByMode(t *testing.T) {
|
||||
m := func(mode, enforce string) *model.Application {
|
||||
return &model.Application{LoginMode: mode, LoginModeEnforce: enforce}
|
||||
}
|
||||
cases := []struct {
|
||||
app *model.Application
|
||||
typ string
|
||||
allow bool
|
||||
}{
|
||||
{m("account", "strict"), "account", true},
|
||||
{m("account", "strict"), "card", false},
|
||||
{m("card", "strict"), "card", true},
|
||||
{m("card", "strict"), "account", false},
|
||||
{m("both", "strict"), "account", true},
|
||||
{m("both", "strict"), "card", true},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := LoginTypeAllowedByMode(c.app, c.typ); got != c.allow {
|
||||
t.Fatalf("mode=%s login_type=%s got %v want %v", c.app.LoginMode, c.typ, got, c.allow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginModeGraceDaysLeft(t *testing.T) {
|
||||
past := time.Now().Add(-1 * time.Hour)
|
||||
future := time.Now().Add(72 * time.Hour)
|
||||
if got := LoginModeGraceDaysLeft(&model.Application{LoginModeGraceUntil: nil}); got != 0 {
|
||||
t.Fatalf("nil grace = %d, want 0", got)
|
||||
}
|
||||
if got := LoginModeGraceDaysLeft(&model.Application{LoginModeGraceUntil: &past}); got != 0 {
|
||||
t.Fatalf("expired grace = %d, want 0", got)
|
||||
}
|
||||
if got := LoginModeGraceDaysLeft(&model.Application{LoginModeGraceUntil: &future}); got != 3 {
|
||||
t.Fatalf("72h grace = %d, want 3", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllowedLoginTypes(t *testing.T) {
|
||||
if got := len(AllowedLoginTypes("account")); got != 1 {
|
||||
t.Fatalf("account should allow 1 type, got %d", got)
|
||||
}
|
||||
if got := len(AllowedLoginTypes("card")); got != 1 {
|
||||
t.Fatalf("card should allow 1 type, got %d", got)
|
||||
}
|
||||
if got := len(AllowedLoginTypes("both")); got != 2 {
|
||||
t.Fatalf("both should allow 2 types, got %d", got)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
# 财务 / 日志模块检查报告(2026-11-24)
|
||||
|
||||
检查方式:读代码 + 在本地起一套干净后端(sqlite)造 40 条流水、61 条日志,用真请求验证。下面标 ✅ 的已经修好并实测,标 ⚠️ 的需要产品上拍板。
|
||||
|
||||
## 财务(`/dev/finance/*`)
|
||||
|
||||
| # | 问题 | 证据 | 处理 |
|
||||
|---|---|---|---|
|
||||
| F1 | **财务页只显示 10 条,且「充值总额/消费总额/利润」是对这 10 条 reduce 出来的** | 前端 `fetchRecords()` 不带 `page_size`,后端默认 10;库里 40 条时页面只拿到 10 条,卡片数字按 10 条算 | ✅ 后端 `/finance/records` 增加 SQL 聚合 `summary`(带全部筛选条件)+ 真分页;前端卡片改用 `summary`,表格改成服务端分页(实测 40 条 / 2 页,卡片 25 笔 ¥250 / 15 笔 ¥45 / 净收益 ¥205,与库一致) |
|
||||
| F2 | **两张表全量捞进内存再切片**,`total` 是 `len()` | `handleGetFinanceRecords` 用 `Find` 无 limit | ✅ 改成 SQL 层 `Limit(offset+pageSize)` 合并分页,深翻页限制 1000 条 |
|
||||
| F3 | **分页参数零校验**:`page=0` / `page_size=0/-5` 会一次返回全部记录 | 实测 `page=0&page_size=0` 返回 40 条全量 | ✅ 统一 `parsePageParams()`:page≥1、page_size∈[1,200]、默认 20(实测同样的请求现在返回 20 条) |
|
||||
| F4 | **接口支持删财务流水**(单条 + 批量),软删后不碰 `app_user.balance` | `DELETE /dev/finance/records/:id`、`POST .../batch-delete` | ⚠️ 没有自动改。财务流水是审计凭证,"删了流水钱还在"会导致账面与余额永久不一致;批量删除也只记条数不记 ID/金额。**建议:改成只能导出不能删,或者删除必须写全量审计(ID/金额/操作人)** |
|
||||
| F5 | **软删一个主体后,它的历史流水在面板里消失**,`/finance/stats` 的累计收入也跟着减少 | 实测软删有流水的主体后,列表从 20 条变 19 条 | ⚠️ 根因是 `app_user_ids` 用 GORM 默认查询(自动过滤软删主体)。要不要"历史流水不受主体删除影响"是业务口径问题 |
|
||||
| F6 | `AppID: r.AppUser.ApplicationID` 对 nil 指针直接解引用 | 代码审查;当前路径被主体过滤挡住,属潜在 panic | ✅ 抽成 `rechargeToFinanceResponse` / `consumptionToFinanceResponse`,nil 安全 |
|
||||
| F7 | `/finance/stats` 正常分支漏返回 `monthly_transactions`(只有空数据分支有) | 代码审查 | ✅ 正常分支也返回本月流水条数 |
|
||||
| F8 | `start_date` 直接拼 `" 00:00:00"` | 前端传 ISO 带 T 时会筛选错/500 | ⚠️ 前端目前传的是 `split('T')[0]`,暂无触发;接口层没做容错 |
|
||||
|
||||
## 日志(`/dev/logs`)
|
||||
|
||||
| # | 问题 | 证据 | 处理 |
|
||||
|---|---|---|---|
|
||||
| L1 | **顶部三个统计与列表不同源**:统计查 `api_usages` 表,列表查 `logs` 表,且统计**完全不带筛选** | 实测列表 61 条、`success=0 failed=0 operation=0`(api_usages 空);带 `status=failed` 筛选后统计也不变 | ✅ 统计改成同一张 `logs` 表 + 同一套筛选条件(实测 success=53 / failed=8 / operation=15,带筛选时为 0/0/0 与列表一致) |
|
||||
| L2 | **分页参数零校验**:`page_size=-1` → GORM `Limit(-1)` 等于不加 LIMIT | 实测 `page=-1&page_size=-1` 返回 59 条 | ✅ 用同一个 `parsePageParams()` |
|
||||
| L3 | `query.Count(&total)` 忽略错误 | 代码审查 | ✅ 顺带改为新逻辑(count 与统计共用 baseQuery) |
|
||||
| L4 | `search` 的 LIKE 没转义 `%` `_`,输入 `%` 会命中全部 | 代码审查 | ⚠️ 未改(影响小,但用户输入 `%` 会得到全量结果) |
|
||||
| L5 | 日志表无索引提示,`details LIKE %x%` 全表扫描 | 代码审查 | ⚠️ 建议给 `logs(application_id, created_at)`、`logs(log_type, status)` 加复合索引 |
|
||||
|
||||
## 顺带
|
||||
|
||||
- 分页参数统一收口在 `backend/internal/router/admin/pagination.go`,以后新接口直接用 `parsePageParams(c)`,别再各写一遍。
|
||||
- 财务/日志都还有"无法导出"的问题(前端没有导出按钮,后端没有 export 接口)——要的话可以按现有 `cards/export` 的路子补。
|
||||
|
||||
## 复现脚本
|
||||
|
||||
`/root/work/audit_finance_logs.py`(对着本地 sqlite 后端跑,打印每一项的实测结果)。
|
||||
@@ -1,4 +1,9 @@
|
||||
# 二次加壳(verify 壳 + 其他加壳器)实测结论
|
||||
> **壳节已改名**:2026-11 起产物里的壳节从 `.vfy` 改为 **`.load`**(`protect.go` 的 `secName`),
|
||||
> 旧产物的 `.vfy` 仍被识别(`HasVfy` 与 `cmd/vfyfix` 都同时接受两种名字)。
|
||||
> 原因是引导 blob 里的节名比较已按 `.load` 打补丁(x64 `blob64.bin` 偏移 `0x85/0x8b/0x91`:`76 66 79` → `6c 6f 61`,
|
||||
> x86 `blob32.bin` 偏移 `0x73/0x79/0x7f` 同理)—— 两者必须一起改,只改 Go 侧产物会启动即退(引导找不到壳节,`return 2`)。
|
||||
|
||||
|
||||
被测组合:`protect.Patch`(离线工具 `cmd/packtest`)打的 verify 壳产物 + DogProtect 加壳。
|
||||
运行环境 wine;`exit=124` 表示 GUI 起来在等 API(超时被杀),是**正常启动**的表现;
|
||||
@@ -19,6 +24,59 @@
|
||||
| 改造前:壳(默认)→ DogProtect | 13 ❌ | 整文件 CRC 与变长后的文件对不上 |
|
||||
| DogProtect → 壳(不论模式) | 222 ❌ | 引导把控制权交给 DogProtect 的 loader,交不过去 |
|
||||
|
||||
### 用当前壳资产(含设备管理页)重测 —— 功能级验证
|
||||
|
||||
上面那批是「能不能启动」;下面这批验证**双层产物里的壳功能是否完整**(2026-11 当前资产:
|
||||
`blob64.bin` 10,000 字节、`shell64_dui.bin` 907,264 字节,dark 皮肤):
|
||||
|
||||
```
|
||||
单层 dp_single.exe 957,440 字节 → wine exit=124
|
||||
双层 dp_double.exe(DogProtect 外挂)7,326,720 字节 → wine exit=124
|
||||
```
|
||||
|
||||
把双层产物接上 mock 服务端走完整流程,实测请求序列:
|
||||
|
||||
```
|
||||
POST /api/v1/app/dogtest/login {"login_type":"account","username":"123","password":"***",
|
||||
"device_id":"C36E-0A03-F08D","device_name":"VIAEON","device_type":"windows",
|
||||
"instance_id":"C36E-0A03-F08D"} ← 被 403 DEVICE_LIMIT 拦下
|
||||
→ 界面切到独立「设备管理」页(窗口 620×620、标题「设备管理 - dogtest」、3 行设备各带解绑按钮)
|
||||
点第 2 行「解绑」
|
||||
POST /api/v1/app/dogtest/unbind-device-with-auth {"username":"123","password":"***",
|
||||
"device_id":"BBBB-4444-5555-6666"} ← 第 2 台,不是最早那台
|
||||
POST /api/v1/app/dogtest/login … ← 解绑后自动重试
|
||||
```
|
||||
|
||||
结论:**DogProtect 外层不影响壳内的设备管理页、行内解绑、窗口放大与标题切换**,双层产物功能与单层一致。
|
||||
|
||||
### 分层证据(外层 / 内层到底谁在里面)
|
||||
|
||||
| 项目 | 单层(verify 壳) | 双层(verify 内 + DogProtect 外) |
|
||||
|---|---|---|
|
||||
| 入口 RVA | `0x10030` = `.vfy`(0x10000) + 48 字节头 | `0x4a7ce9` → 落在 DogProtect 新加的 `.UPX3` 段里 |
|
||||
| 节表 | … `.reloc@0xf000`, `.vfy@0x10000` | … `.UPX0@0xf000`, **`.vfy@0x10000`(原位不动)**, `.UPX1@0xf0000`, `.UPX2`, `.UPX3`, `.reloc` |
|
||||
| `.vfy` 内容 sha256(前16) | `4f48879143b676a7` | **`4f48879143b676a7`(完全相同)** |
|
||||
|
||||
也就是说:**verify 的验证壳(引导 + 壳 DLL + cfg)原封不动留在内层 `.vfy` 里**,
|
||||
DogProtect 只是把入口接管到自己的 loader 段、把原程序压缩/虚拟化后追加 `.UPX*`,
|
||||
解包完再把控制权交回「原入口」—— 那个原入口正是 `.vfy+48`,于是壳照常跑。
|
||||
|
||||
**注意**:DogProtect 目前虚拟化的是**原始程序里被 `VMProtectBegin/End` 标记的函数**,
|
||||
`.vfy` 里的验证壳代码本身**没有被虚拟化**(内容 hash 一致即证明)。若要让验证壳也被 DogProtect 保护,
|
||||
需要给壳函数加标记并在打包后重算 `.vfy` 头的 `crcV`(否则壳会以 `exit=6` 拒绝启动)—— 属另一个课题。
|
||||
|
||||
复现命令:
|
||||
|
||||
```bash
|
||||
# 1) 打壳(api 用完整 login URL)
|
||||
./packthemed sample.exe single.exe cfg.json dark
|
||||
# 2) 外层再加 DogProtect(项目文件里 InputFileName 指向 single.exe)
|
||||
LD_LIBRARY_PATH=<vmprotect>/bin <vmprotect>/bin/64/release/dogprotect_con \
|
||||
single.exe double.exe -pf project.dog
|
||||
# 3) 跑起来 + mock 服务端(scripts/mock-vfy-device-limit.py)按 docs/shell-device-ui.md 的清单验收
|
||||
```
|
||||
|
||||
|
||||
## 引导补丁(1 字节,可逆)
|
||||
|
||||
引导里整文件 CRC 的比较是 `cmp [hdr+0x28], eax` 紧跟 `je <通过>`;把那个 `je` 改成 `jmp`,
|
||||
@@ -72,3 +130,19 @@ go build ./cmd/packsigned && ./packsigned <src.exe> <out.exe> <cfg.json>
|
||||
|
||||
即 `PatchSigned(..., signed=true)`,`flags.bit1=1`、`crcFile=0`。引导改造后它不再是二次加壳的前提,
|
||||
但保留给「签名产物」(Authenticode 与整文件 CRC 也互斥)这一路使用。
|
||||
|
||||
### 32 位(x86)实测
|
||||
|
||||
改名在 32 位链路上同样验证过(`wine32:i386` + 独立 `WINEARCH=win32` prefix):
|
||||
|
||||
| 项目 | 结果 |
|
||||
|---|---|
|
||||
| 32 位样本 | `GOOS=windows GOARCH=386 go build` 产出的 PE32(无需 i686 mingw 工具链) |
|
||||
| 产物 | `ld32.exe` 2,198,016 字节,架构 x86(自动选 `blob32.bin` + `shell32.bin`) |
|
||||
| 节表 | `… .idata, .reloc, .symtab, .load` —— 壳节名已生效 |
|
||||
| 入口 | RVA `0x212030` = `.load`(0x212000) + 48 ✅ |
|
||||
| 启动 | `wine` 起窗口,引导阶段标记 `F`(CRC 通过 + 壳 DLL 映射完成),classic 壳登录页正常渲染,exit=124 ✅ |
|
||||
| 篡改 `.load` 内容 | exit=**6**(节级 `crcV` 拦住)✅ |
|
||||
|
||||
注意:64 位 prefix 里跑 32 位产物会 `could not load kernel32.dll`,必须用 `WINEARCH=win32` 的独立 prefix。
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
# 登录方式开关(login_mode)
|
||||
|
||||
每个应用可以独立决定「用哪种凭证登录」:账号密码 / 卡密直登 / 两者都开。这个开关**在服务端真正生效**,不只是界面藏控件。
|
||||
|
||||
## 一句话架构
|
||||
|
||||
```
|
||||
面板配置(login_mode + enforce + 宽限期)
|
||||
↓
|
||||
服务端强制(/login、/register 里 gate,早于任何副作用)
|
||||
↓
|
||||
客户端呈现(/info 下发 login_mode,壳按它决定显示哪些控件)
|
||||
```
|
||||
|
||||
壳能被破解替换,**判定只在服务端**;壳按 `/info` 只是把不该出现的输入框藏起来,让用户少困惑。
|
||||
|
||||
## 三种模式
|
||||
|
||||
| login_mode | 语义 | 允许的凭证 |
|
||||
|---|---|---|
|
||||
| `account` | 账号密码登录;卡密只用于充值 | `account` |
|
||||
| `card` | 一张卡就是一个用户,输入卡密即登录 | `card` |
|
||||
| `both` | 两种都开 | `account` + `card` |
|
||||
|
||||
**卡密的两种语义不要混**:①登录凭证(`purpose=credential`,`login_mode` 管这个)②充值手段(`purpose=recharge`,由 `billing_type` 管)。关掉卡密直登不会连带关掉卡密充值。
|
||||
|
||||
## 生效级别(login_mode_enforce)
|
||||
|
||||
配置改了不会立刻拦人,`enforce` 决定它到底管不管:
|
||||
|
||||
| 值 | 行为 | 用途 |
|
||||
|---|---|---|
|
||||
| `off` | 完全不校验(升级前的行为) | 回滚 |
|
||||
| `warn` | 校验但放行,只写一条 `login_mode_blocked` 审计日志(`[warn-only]` 前缀) | 灰度:先看会挡到谁 |
|
||||
| `strict` | 真正拦截:HTTP 403 + `error_code=LOGIN_MODE_DISABLED` | 上线 |
|
||||
|
||||
新建应用默认 `login_mode=both`、`enforce=warn`;存量应用升级时 `enforce` 会被回填成 `warn`(启动时一次性 UPDATE,幂等),所以**升级本身不改变任何行为**。
|
||||
|
||||
## 宽限期
|
||||
|
||||
`applications.login_mode_grace_until`:切换模式时自动给 7 天(也可以在面板里填 0 = 立即生效)。
|
||||
|
||||
宽限期内旧凭证仍可用,但登录成功的响应里会带:
|
||||
|
||||
```json
|
||||
{"deprecated_login": true, "grace_days_left": 7,
|
||||
"login_mode": "account", "allowed_login_types": ["account"]}
|
||||
```
|
||||
|
||||
壳拿这些字段提示「该登录方式将在 X 天后停用」。这层是给**老客户端**留的活路:老壳不认识新字段、也显示不了提示,但至少不会被一刀切挡在门外。
|
||||
|
||||
## 服务端拦截点
|
||||
|
||||
`backend/internal/router/app/auth.go` 的 `/login`:`login_type` 归一化(`auto` → `account`/`card`)**之后**、查主体/写设备绑定/记失败次数**之前**。
|
||||
|
||||
这样被策略拒绝的请求**不产生任何副作用**:不建绑定行、不加失败计数、不写 `last_login`、不触发「异常登录自动锁定」,只留一条审计日志。
|
||||
|
||||
拒绝响应(固定错误码,壳可以按它做文案):
|
||||
|
||||
```json
|
||||
HTTP 403
|
||||
{"code":403,"error_code":"LOGIN_MODE_DISABLED",
|
||||
"message":"该应用仅支持账号密码登录",
|
||||
"data":{"login_mode":"account","allowed":["account"]}}
|
||||
```
|
||||
|
||||
`/register` 同样有一道:`card` + `strict` + 不在宽限期时返回「该应用使用卡密登录,无需注册」(卡密模式下注册出来的账号根本没有登录入口)。
|
||||
|
||||
## 影响面预检
|
||||
|
||||
`GET /api/v1/dev/applications/:id/login-mode-impact`
|
||||
|
||||
```json
|
||||
{"total_subjects":2,"card_subjects":1,"card_subjects_with_email":0,
|
||||
"only_card_subjects":1,"only_account_subjects":1,
|
||||
"blocking":false,"blocked_if_switch":1,
|
||||
"login_mode":"both","login_mode_enforce":"warn","login_mode_grace_days":0}
|
||||
```
|
||||
|
||||
- `only_card_subjects`:卡密主体的密码是建主体时写进去的**随机散列**(卡密才是它的钥匙),所以不能靠 `password` 是否为空判断,这里用「没绑邮箱」来近似——绑了邮箱才有自助设密码的通道。
|
||||
- `only_account_subjects`:有账号但没绑任何 `purpose=credential` 的卡 → 切到 `card` 会登不进来。
|
||||
|
||||
面板在「登录方式」卡片里直接显示这两个数字,切换模式时给出「约 N 个主体将无法登录」的黄色提示。
|
||||
|
||||
## 面板位置
|
||||
|
||||
应用详情 → 设置 → **登录方式**卡片:
|
||||
|
||||
1. 三选一(账号密码 / 卡密直登 / 两者都开)
|
||||
2. **生效方式**(关闭校验 / 仅记录 / 已生效)
|
||||
3. **切换后的宽限期(天)**
|
||||
4. 影响面提示条(会挡住多少人)
|
||||
5. 卡密相关两个开关(是否受设备上限约束、是否允许卡密主体再设密码),仅在非 `account` 模式下显示
|
||||
|
||||
## 实测矩阵
|
||||
|
||||
`/root/work/e2e_login_mode.py`(对着干净 sqlite 后端起真服务跑,不是单测):
|
||||
|
||||
| 模式/级别 | 提交 account | 提交 card | auto(卡密塞 username、密码空) | auto(账号+密码) |
|
||||
|---|---|---|---|---|
|
||||
| both / off | 200 | 200 | 200 | 200 |
|
||||
| account / strict | 200 | **403 LOGIN_MODE_DISABLED** | **403** | 200 |
|
||||
| card / strict | **403** | 200 | 200 | **403** |
|
||||
| account / warn | 200 | 200(写 `[warn-only]` 日志) | 200 | 200 |
|
||||
| account / strict + 7 天宽限 | 200 | 200 + `deprecated=7天` | 200 + `deprecated=7天` | 200 |
|
||||
|
||||
纯逻辑另有单测:`go test ./internal/service -run "LoginMode|LoginType|Allowed"`。
|
||||
|
||||
## 存量用户怎么迁移(本期只做「不锁死人」的部分)
|
||||
|
||||
原则:**主体不动,只补另一种钥匙**(`app_users` 是主体,卡密与账号都是它的凭证)。
|
||||
|
||||
已经不锁人的三道保险:
|
||||
|
||||
1. 存量应用 `enforce` 回填 `warn` → 升级不改行为
|
||||
2. 切换模式自动给 7 天宽限 → 旧凭证还能用,且壳能提示
|
||||
3. 影响面接口 + 面板黄色提示 → 管理员切之前就看得到会挡住谁
|
||||
|
||||
**还没做**(下一步,按这个顺序):
|
||||
|
||||
1. `POST /app/:key/card-to-account`:持有效卡密即可给自己设密码(纯卡密主体唯一的活路)
|
||||
2. `POST /app/:key/account-to-card`:给已登录账号签发一张 `credential` 卡
|
||||
3. 管理端批量迁移向导(批量生成初始密码 / 批量签发迁移卡 + 导出清单 + `must_change_password`)
|
||||
|
||||
## 已知未做
|
||||
|
||||
- **classic 壳**(`shell64.bin` / `shell32.bin`)不读 `login_mode`:界面照旧给「账号或卡密」单框。服务端会拦,并返回可读的 `message`;UI 适配需要二进制补丁或重编源码(二期)。
|
||||
- **Android 壳**(`shell_smali.tgz`)同样不读 `login_mode`:仍是「账号或卡密 + 密码」两框。server 已保证策略正确。
|
||||
- DuiLib 壳(7 套皮肤)**已经**按 `login_mode` 自适应:`card` 模式隐藏密码框、输入框改「卡密」、按钮改「卡密登录」;`both` 模式仍是「密码留空走卡密」的隐式判定(后续可以加显式切换)。
|
||||
@@ -0,0 +1,66 @@
|
||||
# 加壳产物的服务器地址是怎么来的(`app.public_url` / 反代头)
|
||||
|
||||
## 结论
|
||||
|
||||
打包时写进壳 cfg 的 `api` 字段 = `<站点根地址>/api/v1/app/<app_key>/login`。
|
||||
站点根地址按下面的顺序确定(`backend/internal/router/admin/protect.go` 的 `baseURL()`):
|
||||
|
||||
1. `config.yaml` 里的 **`app.public_url`**(配了就最优先,推荐生产环境配上)
|
||||
2. 请求头 **`X-Forwarded-Host`**(反向代理应当传,值就是用户浏览器地址栏里的域名)
|
||||
3. 请求的 `Host`
|
||||
4. 上面两者都没有,或者拿到的是本机/内网地址(`127.x` / `localhost` / `10.x` / `172.16-31.x` / `192.168.x` / `169.254.x`)→ **加壳任务直接报错**,不产出连不上服务器的产物
|
||||
|
||||
## 为什么这么写(真实事故)
|
||||
|
||||
服务器上的站点是 AcePanel 管的,它默认的反向代理模板写的是:
|
||||
|
||||
```nginx
|
||||
proxy_set_header Host $proxy_host; # ← 后端会看到 127.0.0.1:9998
|
||||
```
|
||||
|
||||
于是 `baseURL()` 推断出 `https://127.0.0.1:9998`,产出的每个客户端壳里都写着:
|
||||
|
||||
```
|
||||
{"api":"https://127.0.0.1:9998/api/v1/app/f26091ac.../login"}
|
||||
```
|
||||
|
||||
客户机上的壳去连自己的 127.0.0.1:9998 —— 必然失败。已确认修复前产出的 `data/protect/*/…_protected.exe` 全部带这个错误地址。
|
||||
|
||||
## 正确配法
|
||||
|
||||
站点反代(AcePanel → 站点 → 反向代理)里应当是:
|
||||
|
||||
```nginx
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
```
|
||||
|
||||
`$host` 是请求里的域名(经 Cloudflare 到达时是 `v.viaeon.com`),`$proxy_host` 是上游地址(`127.0.0.1:9998`)。
|
||||
|
||||
懒得依赖反代的话,直接在部署目录的 `data/config.yaml` 里写死:
|
||||
|
||||
```yaml
|
||||
app:
|
||||
public_url: "https://v.viaeon.com"
|
||||
```
|
||||
|
||||
改完重启容器生效(`docker compose restart app`)。
|
||||
|
||||
## 自查方法
|
||||
|
||||
产物里直接能看出来:
|
||||
|
||||
```bash
|
||||
grep -aoE '\{"api":"[^"]*"' 产物.exe
|
||||
```
|
||||
|
||||
应该看到 `"api":"https://v.viaeon.com/api/v1/app/<key>/login"`。
|
||||
看到 `127.0.0.1` / `localhost` / 内网 IP 就是踩了这个坑,需要重新打包。
|
||||
|
||||
## 验收记录(2026-11-24)
|
||||
|
||||
- 反代改前:`proxy_set_header Host $proxy_host` → 探针实测后端收到 `Host: 127.0.0.1:9998`
|
||||
- 反代改后:`Host $host` + `X-Forwarded-Host $host` → 探针实测后端收到
|
||||
`Host: v.viaeon.com`、`X-Forwarded-Host: v.viaeon.com`、`X-Forwarded-Proto: https`
|
||||
- 代码单测:`go test ./internal/router/admin -run "BaseURL|IsInternalHost"`(4 例通过,含「本机地址必须报错」)
|
||||
@@ -0,0 +1,149 @@
|
||||
# 验证壳的设备管理页(Windows / Android)
|
||||
|
||||
这份文档记录 2026-11 这轮壳改动的**最终形态、交互契约、验收方法和踩过的坑**,换人接手不用再从二进制里挖。
|
||||
|
||||
涉及资产:
|
||||
|
||||
| 资产 | 说明 |
|
||||
|---|---|
|
||||
| `backend/internal/protect/assets/shell64_dui.bin` | x64 DuiLib 壳(7 套皮肤:dark/light/industrial/compact/split/card/terminal) |
|
||||
| `backend/internal/protect/assets/shell64.bin`、`shell32.bin` | classic(Direct2D 单皮肤)壳 |
|
||||
| `backend/internal/protect/assets/shell_smali.tgz` | Android 壳(smali 源码,加壳时由 apktool 合并进 APK) |
|
||||
| `shell/duilib/shell9_v6.cpp` + `skins_v4.h` | DuiLib 壳的完整源码(XML 皮肤在头文件里) |
|
||||
| `shell/classic/shell6.cpp` | classic 壳源码 |
|
||||
|
||||
> 改完源码后:`shell/duilib/build-duilib.sh` → 产物拷进 `assets/shell64_dui.bin` → **必须重编 `cmd/packthemed`**(见坑 1)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 设备满时:独立「设备管理」页(QQ 式)
|
||||
|
||||
触发:登录返回 HTTP 403 + `error_code=DEVICE_LIMIT_EXCEEDED`。
|
||||
|
||||
行为:
|
||||
|
||||
1. 窗口从登录页尺寸(470×428 一类)**临时放大到 620×620 并居中**
|
||||
2. 标题栏文字切为 **`设备管理 - <应用名>`**(cfg 的 `name`)
|
||||
3. 内容区小标题 `设备管理`,副标题 `已绑定 3 / 2 台,解绑一台后即可登录`
|
||||
4. 登录页的 4 个 tab(登录/注册/卡密充值/忘记密码)与品牌字**隐藏**
|
||||
5. 每台设备一行卡片:`序号. 名称 设备ID ● 在线 / ○ 离线`,**右侧一个蓝色「解绑」按钮**
|
||||
6. 底部:`解绑最早一台` / `重试` / `返回`
|
||||
7. **点哪一行的「解绑」就解绑那一台**;成功后自动重试登录
|
||||
8. 点「返回 / 重试」→ 标题复原为 `软件授权验证`、tab 回来、窗口缩回原尺寸
|
||||
|
||||
### 交互契约(前端 ↔ 后端)
|
||||
|
||||
| 步骤 | 请求 | 说明 |
|
||||
|---|---|---|
|
||||
| 登录 | `POST /api/v1/app/:appKey/login` `{login_type,username,password,device_id,device_name,device_type,instance_id}` | 设备绑定 + 会话都在这一步完成 |
|
||||
| 被拦 | HTTP 403 `{error_code:"DEVICE_LIMIT_EXCEEDED", data:{max_devices, device_count, devices:[{id,device_id,device_name,device_type,online_count,created_at}]}}` | 壳解析 `devices` 渲染列表,`online_count>0` → ● 在线 |
|
||||
| 解绑 | `POST /api/v1/app/:appKey/unbind-device-with-auth` `{username,password,device_id}` | 卡密用户走 `/card-unbind` `{card_key,device_id}` |
|
||||
| 重试 | 再发一次 login | 解绑成功后自动重试,不用用户再点 |
|
||||
|
||||
**注意**:壳只做**解绑**(删绑定行、连带断会话),不做「下线/踢线」(`POST /instances/:instance_id/offline` 未接入)。所以界面文案里不能用「下线」,否则用户会以为能保留授权只断会话。
|
||||
|
||||
### 手动选择,不自动解
|
||||
|
||||
- 明细行是可点按钮:`devRowN`(信息)+ `devUnbindN`(右侧「解绑」),点击 → `UnbindDeviceIdx(N+1)`
|
||||
- **序号输入框已整块拿掉**(`devIdx` / `btnUnbind` 在 XML 里 `visible="false"` 兜底保留,代码不再走输入路径)
|
||||
- 空列表(服务端没返回明细)时只给「重试」,不会默认解绑任何一台
|
||||
|
||||
---
|
||||
|
||||
## 2. 卡密用户的「我的设备」
|
||||
|
||||
同一套面板复用(`g_devManage=1`):卡密就是身份,不需要先登录。
|
||||
- 列表来源:`POST /api/v1/app/:appKey/card-devices` `{card_key}`
|
||||
- 解绑:`POST /api/v1/app/:appKey/card-unbind` `{card_key,device_id}`
|
||||
- 面板里多一个「卡密」输入框(`devCardKey`),未填时提示「先在『登录』里填入卡密,再点这里的『我的设备』」
|
||||
|
||||
---
|
||||
|
||||
## 3. Android 壳的界面(`shell_smali.tgz`)
|
||||
|
||||
没有 XML 布局、没有皮肤,是运行时拼的原生 `AlertDialog`:
|
||||
|
||||
```
|
||||
┌────────────────────────────────────┐
|
||||
│ <应用名>(cfg.name,缺省「验证」) │
|
||||
│ 请输入账号或卡密完成验证 │
|
||||
│ ┌────────────────────────────────┐ │
|
||||
│ │ 账号或卡密 │ │
|
||||
│ └────────────────────────────────┘ │
|
||||
│ ┌────────────────────────────────┐ │
|
||||
│ │ 密码(留空则用内置) │ │
|
||||
│ └────────────────────────────────┘ │
|
||||
│ 通过后自动进入应用 │
|
||||
│ 验证 退出 │
|
||||
└────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- 填了密码 → 覆盖 cfg 里的 `password`(`cfg.put("password", ...)`)后调 `verify()`
|
||||
- 「退出」= `Activity.finish()` + `Process.killProcess(myPid())`
|
||||
- 设备超限文案:`设备数超限,请先在平台解绑一台设备`
|
||||
- 设备标识:`ANDROID-` + Android ID
|
||||
- **手机端没有设备列表/自助解绑页**(只有这一道登录闸),要补就照桌面端的接口接 `/card-devices` + `/card-unbind`
|
||||
|
||||
改了 smali 先离线校验语法:
|
||||
|
||||
```bash
|
||||
cd <解开 shell_smali.tgz 的目录>
|
||||
smali assemble vfy -o /tmp/vfy.dex # 能出 dex 就说明语法与引用都对得上
|
||||
tar czf shell_smali.tgz vfy # 结构必须是 vfy/*.smali
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 验收方法(可复现)
|
||||
|
||||
需要:`Xvfb :99` + `openbox` + wine + 一个 mock 验证服务端。
|
||||
|
||||
```bash
|
||||
# 1) mock 服务端:/login 一律回 403 DEVICE_LIMIT(3 台/上限 2),其它接口回成功
|
||||
python3 scripts/mock-vfy-device-limit.py & # 监听 127.0.0.1:9998
|
||||
|
||||
# 2) 打一个 dark 主题的壳产物(api 必须是完整的 login URL)
|
||||
cat > /tmp/cfg.json <<'JSON'
|
||||
{"api":"http://127.0.0.1:9998/api/v1/app/dogtest/login","name":"dogtest","device_auto":1,"shell_ver":8,"theme":"dark","ver":"1.0.0"}
|
||||
JSON
|
||||
go build -o /tmp/packthemed ./cmd/packthemed # 改过 assets 必须重编!
|
||||
/tmp/packthemed sample.exe /tmp/out.exe /tmp/cfg.json dark
|
||||
|
||||
# 3) 跑起来看
|
||||
DISPLAY=:99 wine /tmp/out.exe
|
||||
```
|
||||
|
||||
验收清单(每项都要肉眼/日志对得上):
|
||||
|
||||
- [ ] 单层产物启动 → 登录页(exit=124 = GUI 在等网络)
|
||||
- [ ] 输入账号+密码点登录 → 服务端收到 login,含 `device_id/device_name/device_type/instance_id`
|
||||
- [ ] 被 403 拦下 → **窗口放大、标题变「设备管理 - 应用名」、tab 消失、每行右侧有「解绑」**
|
||||
- [ ] 列表在线状态与 mock 的 `online_count` 一致(● 在线 / ○ 离线)
|
||||
- [ ] 点**第 2 行**「解绑」→ 服务端收到 `unbind-device-with-auth`,`device_id` = 第 2 台(不是最早那台)
|
||||
- [ ] 解绑后自动重试登录
|
||||
- [ ] 点「返回」→ 标题复原、tab 回来、窗口缩回登录尺寸
|
||||
- [ ] 无「下线/踢线」按钮(当前设计不含该能力)
|
||||
|
||||
---
|
||||
|
||||
## 5. 踩过的坑(每条都真踩过)
|
||||
|
||||
1. **`cmd/packthemed` 是 `//go:embed` 内嵌壳资产的**:改完 `assets/*.bin` 不重编它,打出来的产物还是旧壳。
|
||||
症状:改了半天什么都没变,字节数一模一样。规矩:**改资产 → `go build ./cmd/packthemed`**。
|
||||
2. **wine 下 DuiLib 原生 EDIT 点击不转移焦点**:点一下只是激活窗口,输入会打到上一个输入框。
|
||||
规矩:**同一点位点两次**(第一次激活、第二次聚焦)再输入。
|
||||
3. **`devBody` 那个多行 Label 的字色在重编产物里压不住**:XML `textcolor`、运行时 `SetTextColor`、`SetAttribute("textcolor")` 都不行;`CListLabelElementUI` 连 `SetTextColor` 都没有;`CButtonUI::SetAttribute` 只吃 `hot/pushed/focusedtextcolor`。
|
||||
最终解法:设备行做成**按钮**(信息按钮 + 解绑按钮),跟「重试/返回」同一套渲染 → 亮度和它们一致。
|
||||
4. **`m_pm.SetSize` 不存在**(`CPaintManagerUI` 只有 `SetSizeBox`):窗口尺寸直接 `SetWindowPos`,DuiLib 会在 `WM_SIZE` 里自己重排。
|
||||
5. **残留 wine 进程会叠窗污染截图**:脚本开头要 `wineserver -k9` + 杀光 `*.exe`,否则截到的是上一轮的窗口。
|
||||
6. **`pkill -9 -f "themed/"` 会把自己杀掉**(命令行里含 `packthemed` 字样):模式写成 `wine.*themed/dev`。
|
||||
7. **面板高度改大不能只改 XML**:`panelDevice` 用 `height="-1"` 跟随窗口,否则登录页会被撑出一个空面板。
|
||||
8. 皮肤里只有 3 套有「软件授权验证」标题 Label(已命名 `lblTitle` 支持动态改),其余 4 套是 `VFY` 品牌栏设计,标题不随页切换属预期。
|
||||
|
||||
---
|
||||
|
||||
## 6. 已知未做
|
||||
|
||||
- 手机端的设备列表 / 自助解绑页(桌面端已有)
|
||||
- 「下线(踢线)」按钮 —— 按需求方口径**不做**,有解绑即可
|
||||
- 设备管理页在多语言 skin(industrial/terminal)里标题仍是各自品牌词,未做本地化
|
||||
@@ -0,0 +1,28 @@
|
||||
# 皮肤选择卡片的预览图是怎么来的
|
||||
|
||||
面板「云端加密 → 验证界面」里 8 张预览图是**真机截图**,不是设计稿:
|
||||
|
||||
```
|
||||
frontend/public/theme-previews/{classic,dark,light,industrial,compact,split,card,terminal}.png
|
||||
```
|
||||
|
||||
统一 560×420(4:3),窗口居中、去掉黑边,单张 14–33KB,合计约 190KB。构建时由 Vite 原样拷进 `dist/theme-previews/`,页面里按 `/theme-previews/<theme>.png` 引用。
|
||||
|
||||
## 重新生成(换皮肤/改布局后要重跑)
|
||||
|
||||
1. **打 8 个样本**:`packthemed origin64.exe themed/prev_<theme>.exe cfg_prev_<theme>.json <theme>`
|
||||
- `cfg_prev_<theme>.json` 里的 `name` 用中性值(例如「示例软件」),不要留测试名
|
||||
- **`cfg` 里的 `theme` 必须和该主题一致**:`PatchSignedThemed` 只按第四个参数挑要嵌的 shell DLL,不会改写 cfg;cfg 里写错皮肤名,8 个产物会渲染成同一套
|
||||
2. **截图**:`/root/work/shot64.sh prev_classic prev_dark …`
|
||||
- `Xvfb :99` + `openbox` + `scrot`
|
||||
- **必须用独立的 64 位 prefix**(`WINEPREFIX=/root/.wine64 WINEARCH=win64`):装了 `wine32:i386` 之后默认 prefix 会报 `could not load kernel32.dll`
|
||||
- 每轮开始前 `wineserver -k` 并等到可见窗口数归零,否则会截到上一套皮肤的窗口
|
||||
3. **裁边 + 统一尺寸**:`python3 /root/work/mktheme_previews.py`
|
||||
- 不依赖 PIL:用 `ffmpeg -f rawvideo -pix_fmt rgb24` 取出像素
|
||||
- 窗口边界用**逐列/逐行亮像素密度**判定(阈值 + 最小像素数),避免桌面上的零星亮像素把边界撑大导致缩略图偏心
|
||||
- `scale=W:H:force_original_aspect_ratio=decrease` 后再 `pad`,保证任何宽高比的窗口都不变形
|
||||
4. **重新构建前端**:`npm run build`,否则页面拿到的还是旧的 `dist/theme-previews/`
|
||||
|
||||
## 位宽徽标
|
||||
|
||||
卡片右上角的徽标由 `themeBits()` 决定:`classic` 显示「32/64 位」,其余 7 套显示「64 位」—— 因为 DuiLib 皮肤只做了 64 位构建,32 位程序加壳时服务端会自动回落到经典壳。
|
||||
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Info, Loader2, Upload, X } from 'lucide-vue-next'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { toast } from 'vue-sonner'
|
||||
|
||||
@@ -32,6 +32,8 @@ interface AppData {
|
||||
billing_type: string
|
||||
login_policy: string
|
||||
login_mode: string
|
||||
login_mode_enforce: string
|
||||
login_mode_grace_days: number
|
||||
card_login_bind_device: boolean
|
||||
card_login_allow_password: boolean
|
||||
allow_register: boolean
|
||||
@@ -55,6 +57,49 @@ interface AppData {
|
||||
}
|
||||
|
||||
const app = ref<AppData | null>(null)
|
||||
const impact = ref<{
|
||||
total_subjects: number
|
||||
only_card_subjects: number
|
||||
only_account_subjects: number
|
||||
blocking: boolean
|
||||
} | null>(null)
|
||||
|
||||
const enforceOptions = [
|
||||
{ value: 'off', title: '关闭校验', desc: '不按登录方式拦人,与升级前行为一致' },
|
||||
{ value: 'warn', title: '仅记录', desc: '只写审计日志不拦截,用来观察会挡到谁' },
|
||||
{ value: 'strict', title: '已生效', desc: '真正拦截;宽限期内旧方式仍放行并提示' },
|
||||
]
|
||||
|
||||
// 切到当前选中的模式,会被挡住的主体数
|
||||
const selectedBlocked = computed(() => {
|
||||
if (!impact.value)
|
||||
return 0
|
||||
if (form.value.login_mode === 'account')
|
||||
return impact.value.only_card_subjects
|
||||
if (form.value.login_mode === 'card')
|
||||
return impact.value.only_account_subjects
|
||||
return 0
|
||||
})
|
||||
|
||||
function modeLabel(mode: string) {
|
||||
return mode === 'account' ? '账号密码' : mode === 'card' ? '卡密直登' : '两者都开'
|
||||
}
|
||||
|
||||
async function fetchImpact() {
|
||||
try {
|
||||
const token = localStorage.getItem('token')
|
||||
const res = await fetch(`${API_BASE}/dev/applications/${route.params.id}/login-mode-impact`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
const data = await res.json()
|
||||
if (data.code === 200)
|
||||
impact.value = data.data
|
||||
}
|
||||
catch (error) {
|
||||
console.error('获取登录方式影响面失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const emailConfigs = ref<EmailConfig[]>([])
|
||||
const smsConfigs = ref<SmsConfig[]>([])
|
||||
|
||||
@@ -66,7 +111,9 @@ const form = ref({
|
||||
iconPreview: '',
|
||||
billing_type: 'free',
|
||||
login_policy: 'loose',
|
||||
login_mode: 'account',
|
||||
login_mode: 'both',
|
||||
login_mode_enforce: 'warn',
|
||||
login_mode_grace_days: 7,
|
||||
card_login_bind_device: true,
|
||||
card_login_allow_password: false,
|
||||
allow_register: true,
|
||||
@@ -194,7 +241,9 @@ async function fetchApp() {
|
||||
iconPreview: getIconUrl(appData.icon_url),
|
||||
billing_type: appData.billing_type || 'free',
|
||||
login_policy: appData.login_policy || 'loose',
|
||||
login_mode: appData.login_mode || 'account',
|
||||
login_mode: appData.login_mode || 'both',
|
||||
login_mode_enforce: appData.login_mode_enforce || 'warn',
|
||||
login_mode_grace_days: appData.login_mode_grace_days ?? 7,
|
||||
card_login_bind_device: appData.card_login_bind_device !== false,
|
||||
card_login_allow_password: appData.card_login_allow_password === true,
|
||||
allow_register: appData.allow_register ?? true,
|
||||
@@ -245,6 +294,8 @@ async function handleSave() {
|
||||
formDataToSend.append('billing_type', form.value.billing_type)
|
||||
formDataToSend.append('login_policy', form.value.login_policy)
|
||||
formDataToSend.append('login_mode', form.value.login_mode)
|
||||
formDataToSend.append('login_mode_enforce', form.value.login_mode_enforce)
|
||||
formDataToSend.append('login_mode_grace_days', String(form.value.login_mode_grace_days ?? 7))
|
||||
formDataToSend.append('card_login_bind_device', form.value.card_login_bind_device.toString())
|
||||
formDataToSend.append('card_login_allow_password', form.value.card_login_allow_password.toString())
|
||||
formDataToSend.append('allow_register', form.value.allow_register.toString())
|
||||
@@ -307,6 +358,12 @@ onMounted(() => {
|
||||
fetchApp()
|
||||
fetchEmailConfigs()
|
||||
fetchSmsConfigs()
|
||||
fetchImpact()
|
||||
})
|
||||
|
||||
// 换登录方式时重新算一遍影响面,切换前就能看到会挡住多少人
|
||||
watch(() => form.value.login_mode, () => {
|
||||
fetchImpact()
|
||||
})
|
||||
|
||||
function toggleWeekday(index: number) {
|
||||
@@ -719,6 +776,53 @@ function toggleWeekday(index: number) {
|
||||
<UiSwitch v-model="form.card_login_allow_password" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 生效方式:开关只是配置,这里决定它是不是真的拦人 -->
|
||||
<div class="space-y-3 pt-2 border-t">
|
||||
<div>
|
||||
<p class="font-medium">生效方式</p>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
配置改了要经过这一步才真正生效。建议先「仅记录」,看几天日志确认拦的都是该拦的,再切「已生效」。
|
||||
</p>
|
||||
</div>
|
||||
<UiRadioGroup v-model="form.login_mode_enforce" class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<div
|
||||
v-for="opt in enforceOptions"
|
||||
:key="opt.value"
|
||||
class="flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors"
|
||||
:class="form.login_mode_enforce === opt.value ? 'border-primary bg-primary/5' : 'hover:bg-accent'"
|
||||
@click="form.login_mode_enforce = opt.value"
|
||||
>
|
||||
<UiRadioGroupItem :value="opt.value" class="mt-0.5" />
|
||||
<div>
|
||||
<p class="font-medium">{{ opt.title }}</p>
|
||||
<p class="text-sm text-muted-foreground">{{ opt.desc }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</UiRadioGroup>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<p class="font-medium">切换后的宽限期(天)</p>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
宽限期内旧登录方式仍可用,客户端会提示「X 天后停用」,避免存量用户被一刀切挡在门外。填 0 = 立即生效
|
||||
</p>
|
||||
</div>
|
||||
<UiInput v-model.number="form.login_mode_grace_days" type="number" min="0" max="365" class="w-24" />
|
||||
</div>
|
||||
<div v-if="impact && selectedBlocked > 0" class="rounded-lg border border-amber-500/40 bg-amber-500/10 p-3 space-y-1">
|
||||
<p class="font-medium text-amber-600 dark:text-amber-400">
|
||||
切到「{{ modeLabel(form.login_mode) }}」后,约 {{ selectedBlocked }} 个现存在册主体将无法登录
|
||||
</p>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
共 {{ impact.total_subjects }} 个主体:仅能卡密登录 {{ impact.only_card_subjects }} 个,仅能账号登录 {{ impact.only_account_subjects }} 个。
|
||||
建议先开宽限期,或用「卡密换密码 / 签发登录卡」的迁移通道给他们换钥匙。
|
||||
</p>
|
||||
</div>
|
||||
<div v-else-if="impact" class="rounded-lg border bg-muted/40 p-3 text-sm text-muted-foreground">
|
||||
当前 {{ impact.total_subjects }} 个主体:仅卡密登录 {{ impact.only_card_subjects }} 个,仅账号登录 {{ impact.only_account_subjects }} 个 ——
|
||||
切到「{{ modeLabel(form.login_mode) }}」不会挡住任何人。
|
||||
</div>
|
||||
</div>
|
||||
</UiCardContent>
|
||||
</UiCard>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { toast } from 'vue-sonner'
|
||||
|
||||
import ConfirmDialog from '@/components/confirm-dialog.vue'
|
||||
import type { ServerPagination } from '@/components/data-table/types'
|
||||
import DataTablePagination from '@/components/data-table/table-pagination.vue'
|
||||
import { BasicPage } from '@/components/global-layout'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
@@ -66,6 +67,18 @@ const loading = ref(true)
|
||||
const records = ref<FinanceRecord[]>([])
|
||||
const applications = ref<Application[]>([])
|
||||
|
||||
// 服务端分页 + 服务端汇总:records 只是当前页,卡片数字用后端算好的 summary
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const total = ref(0)
|
||||
const summary = ref({
|
||||
recharge_amount: 0,
|
||||
recharge_count: 0,
|
||||
consumption_amount: 0,
|
||||
consumption_count: 0,
|
||||
profit: 0,
|
||||
})
|
||||
|
||||
const appFilter = ref<string>('all')
|
||||
const statusFilter = ref<string>('all')
|
||||
const dateRange = ref<{ from: string, to: string }>({ from: '', to: '' })
|
||||
@@ -93,48 +106,17 @@ function setQuickRange(range: 'today' | 'week' | 'month') {
|
||||
}
|
||||
}
|
||||
|
||||
const filteredRecords = computed(() => {
|
||||
let result = records.value
|
||||
// 筛选条件全部交给后端(客户端只有当前页,过滤等于筛一小撮数据)
|
||||
const filteredRecords = computed(() => records.value)
|
||||
|
||||
if (appFilter.value !== 'all') {
|
||||
result = result.filter(r => r.app_id === Number(appFilter.value))
|
||||
}
|
||||
|
||||
if (statusFilter.value !== 'all') {
|
||||
result = result.filter(r => r.status === statusFilter.value)
|
||||
}
|
||||
|
||||
if (dateRange.value.from) {
|
||||
const fromDateTime = dateRange.value.from.includes('T')
|
||||
? dateRange.value.from.replace('T', ' ')
|
||||
: `${dateRange.value.from} 00:00`
|
||||
result = result.filter(r => r.created_at >= fromDateTime)
|
||||
}
|
||||
if (dateRange.value.to) {
|
||||
const toDateTime = dateRange.value.to.includes('T')
|
||||
? dateRange.value.to.replace('T', ' ')
|
||||
: `${dateRange.value.to} 23:59`
|
||||
result = result.filter(r => r.created_at <= toDateTime)
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
const stats = computed(() => {
|
||||
const rechargeRecords = filteredRecords.value.filter(r => r.type === 'recharge' && r.status === 'success')
|
||||
const consumptionRecords = filteredRecords.value.filter(r => r.type === 'consumption' && r.status === 'success')
|
||||
|
||||
const totalRecharge = rechargeRecords.reduce((sum, r) => sum + r.amount, 0)
|
||||
const totalConsumption = consumptionRecords.reduce((sum, r) => sum + r.amount, 0)
|
||||
|
||||
return {
|
||||
rechargeCount: rechargeRecords.length,
|
||||
rechargeAmount: totalRecharge,
|
||||
consumptionCount: consumptionRecords.length,
|
||||
consumptionAmount: totalConsumption,
|
||||
profit: totalRecharge - totalConsumption,
|
||||
}
|
||||
})
|
||||
// 卡片数字直接取后端的全量聚合(带上当前所有筛选条件),不再 reduce 当前页
|
||||
const stats = computed(() => ({
|
||||
rechargeCount: summary.value.recharge_count,
|
||||
rechargeAmount: summary.value.recharge_amount,
|
||||
consumptionCount: summary.value.consumption_count,
|
||||
consumptionAmount: summary.value.consumption_amount,
|
||||
profit: summary.value.profit,
|
||||
}))
|
||||
|
||||
function formatTime(time: string) {
|
||||
if (!time)
|
||||
@@ -285,9 +267,9 @@ const table = useVueTable({
|
||||
onColumnVisibilityChange: updaterOrValue => valueUpdater(updaterOrValue, columnVisibility),
|
||||
onRowSelectionChange: updaterOrValue => valueUpdater(updaterOrValue, rowSelection),
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getFilteredRowModel: getFilteredRowModel(),
|
||||
getPaginationRowModel: getPaginationRowModel(),
|
||||
getSortedRowModel: getSortedRowModel(),
|
||||
manualPagination: true,
|
||||
get pageCount() { return Math.ceil(total.value / pageSize.value) || 1 }
|
||||
})
|
||||
|
||||
async function confirmBatchDelete() {
|
||||
@@ -325,8 +307,25 @@ async function fetchApplications() {
|
||||
async function fetchRecords() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await api.get<{ records: FinanceRecord[] }>('/dev/finance/records')
|
||||
const params = new URLSearchParams()
|
||||
params.append('page', String(currentPage.value))
|
||||
params.append('page_size', String(pageSize.value))
|
||||
if (appFilter.value !== 'all')
|
||||
params.append('application_id', appFilter.value)
|
||||
if (statusFilter.value !== 'all')
|
||||
params.append('status', statusFilter.value)
|
||||
if (dateRange.value.from)
|
||||
params.append('start_date', dateRange.value.from.split('T')[0])
|
||||
if (dateRange.value.to)
|
||||
params.append('end_date', dateRange.value.to.split('T')[0])
|
||||
|
||||
const data = await api.get<{ records: FinanceRecord[], total: number, summary?: typeof summary.value }>(
|
||||
`/dev/finance/records?${params.toString()}`,
|
||||
)
|
||||
records.value = data?.records || []
|
||||
total.value = data?.total || 0
|
||||
if (data?.summary)
|
||||
summary.value = data.summary
|
||||
}
|
||||
catch (error) {
|
||||
console.error('获取财务记录失败:', error)
|
||||
@@ -336,6 +335,26 @@ async function fetchRecords() {
|
||||
}
|
||||
}
|
||||
|
||||
const serverPagination = computed<ServerPagination>(() => ({
|
||||
page: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
total: total.value,
|
||||
onPageChange: (page: number) => {
|
||||
currentPage.value = page
|
||||
fetchRecords()
|
||||
},
|
||||
onPageSizeChange: (size: number) => {
|
||||
pageSize.value = size
|
||||
currentPage.value = 1
|
||||
fetchRecords()
|
||||
},
|
||||
}))
|
||||
|
||||
watch([appFilter, statusFilter, dateRange], () => {
|
||||
currentPage.value = 1
|
||||
fetchRecords()
|
||||
}, { deep: true })
|
||||
|
||||
onMounted(() => {
|
||||
fetchApplications()
|
||||
fetchRecords()
|
||||
@@ -542,7 +561,12 @@ onMounted(() => {
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
<DataTablePagination v-if="!loading && table.getRowModel().rows?.length" :table="table" class="mt-4" />
|
||||
<DataTablePagination
|
||||
v-if="!loading && table.getRowModel().rows?.length"
|
||||
:table="table"
|
||||
:server-pagination="serverPagination"
|
||||
class="mt-4"
|
||||
/>
|
||||
</UiCardContent>
|
||||
</UiCard>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { SignProfile } from '@/pages/admin/sign-profiles/data/schema'
|
||||
import type { Component } from 'vue'
|
||||
|
||||
import { CheckCircle2, FileUp, Loader2, PackageCheck, RefreshCw, ShieldCheck, Trash2, XCircle } from 'lucide-vue-next'
|
||||
import { CheckCircle2, FileUp, Loader2, PackageCheck, RefreshCw, ShieldCheck, Trash2, XCircle, ZoomIn } from 'lucide-vue-next'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { toast } from 'vue-sonner'
|
||||
@@ -87,6 +87,25 @@ const themeOptions = computed(() => [
|
||||
{ value: 'terminal', label: t('admin.protect.themeTerminal') },
|
||||
])
|
||||
// DuiLib 壳目前只有 64 位构建;32 位程序产物会回落到 classic 壳(服务端处理)
|
||||
// 皮肤名形如「深色 · 卡密登录」:卡片上标题取前半,副标题取后半
|
||||
function themeTitle(label: string) {
|
||||
return label.split('·')[0].trim()
|
||||
}
|
||||
function themeSub(label: string) {
|
||||
const parts = label.split('·')
|
||||
return parts.length > 1 ? parts.slice(1).join('·').trim() : ''
|
||||
}
|
||||
// 位宽提示:经典壳 32/64 位都有产物,DuiLib 那几套只有 64 位构建
|
||||
// 点卡片角上的放大镜看大图
|
||||
const previewTheme = ref<{ value: string, label: string } | null>(null)
|
||||
const previewOpen = ref(false)
|
||||
function openThemePreview(theme: { value: string, label: string }) {
|
||||
previewTheme.value = theme
|
||||
previewOpen.value = true
|
||||
}
|
||||
function themeBits(theme: string) {
|
||||
return theme === 'classic' ? t('admin.protect.themeBits32') : t('admin.protect.themeBits64')
|
||||
}
|
||||
const themeDisabled = computed(() => false)
|
||||
|
||||
// 证书选择:直接列「每一套证书」(不再先选文件、再选身份)
|
||||
@@ -535,25 +554,81 @@ onBeforeUnmount(() => {
|
||||
{{ certOptionsForFile.length ? t('admin.protect.signProfileHint') : t('admin.protect.signProfileEmpty') }}
|
||||
</p>
|
||||
|
||||
<!-- 验证界面皮肤:云端加密时选择,产物里的壳按此渲染 -->
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<UiLabel class="shrink-0 text-sm font-medium">
|
||||
{{ t('admin.protect.themeLabel') }}
|
||||
</UiLabel>
|
||||
<UiSelect v-model="shellTheme" :disabled="themeDisabled">
|
||||
<UiSelectTrigger class="w-full sm:max-w-xs">
|
||||
<UiSelectValue :placeholder="t('admin.protect.themeClassic')" />
|
||||
</UiSelectTrigger>
|
||||
<UiSelectContent>
|
||||
<UiSelectItem v-for="o in themeOptions" :key="o.value" :value="o.value">
|
||||
{{ o.label }}
|
||||
</UiSelectItem>
|
||||
</UiSelectContent>
|
||||
</UiSelect>
|
||||
<!-- 验证界面皮肤:云端加密时选择,产物里的壳按此渲染(带界面预览,选哪套一眼就能看出来) -->
|
||||
<div class="space-y-3">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<UiLabel class="shrink-0 text-sm font-medium">
|
||||
{{ t('admin.protect.themeLabel') }}
|
||||
</UiLabel>
|
||||
<span class="text-xs text-muted-foreground">{{ t('admin.protect.themeGridHint') }}</span>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<button
|
||||
v-for="o in themeOptions" :key="o.value" type="button"
|
||||
class="group relative overflow-hidden rounded-lg border text-left transition-all"
|
||||
:class="shellTheme === o.value
|
||||
? 'border-primary ring-2 ring-primary/25'
|
||||
: 'border-border hover:border-primary/40'"
|
||||
@click="shellTheme = o.value"
|
||||
>
|
||||
<img
|
||||
:src="`/theme-previews/${o.value}.png`" :alt="o.label"
|
||||
class="aspect-[4/3] w-full bg-[#101419] object-cover transition-transform group-hover:scale-[1.02]"
|
||||
loading="lazy"
|
||||
>
|
||||
<!-- 放大看大图:只拦自己这一下,不改变选中项 -->
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 flex items-end justify-end p-2 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100"
|
||||
:aria-label="t('admin.protect.themeZoom')"
|
||||
@click.stop="openThemePreview(o)"
|
||||
>
|
||||
<span class="flex items-center gap-1 rounded-md bg-black/60 px-2 py-1 text-[11px] text-white backdrop-blur-sm">
|
||||
<ZoomIn class="size-3.5" />{{ t('admin.protect.themeZoom') }}
|
||||
</span>
|
||||
</button>
|
||||
<span
|
||||
class="absolute right-1.5 top-1.5 rounded bg-black/55 px-1.5 py-0.5 text-[10px] leading-none text-white/90 backdrop-blur-sm"
|
||||
>{{ themeBits(o.value) }}</span>
|
||||
<div class="space-y-0.5 px-2 py-1.5">
|
||||
<div class="flex items-center justify-between gap-1">
|
||||
<span class="truncate text-xs font-medium">{{ themeTitle(o.label) }}</span>
|
||||
<CheckCircle2 v-if="shellTheme === o.value" class="size-3.5 shrink-0 text-primary" />
|
||||
</div>
|
||||
<p v-if="themeSub(o.label)" class="truncate text-[11px] text-muted-foreground">
|
||||
{{ themeSub(o.label) }}
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('admin.protect.themeHint') }}
|
||||
</p>
|
||||
|
||||
<!-- 点预览图上的放大镜看 1:1 大图 -->
|
||||
<UiDialog v-model:open="previewOpen">
|
||||
<UiDialogContent class="max-w-4xl">
|
||||
<UiDialogHeader>
|
||||
<UiDialogTitle>{{ previewTheme?.label }}</UiDialogTitle>
|
||||
<UiDialogDescription>{{ t('admin.protect.themeZoomHint') }}</UiDialogDescription>
|
||||
</UiDialogHeader>
|
||||
<img
|
||||
v-if="previewTheme"
|
||||
:src="`/theme-previews/${previewTheme.value}.png`"
|
||||
:alt="previewTheme.label"
|
||||
class="w-full rounded-md border bg-[#101419]"
|
||||
>
|
||||
<UiDialogFooter class="gap-2">
|
||||
<UiButton variant="outline" @click="previewOpen = false">
|
||||
{{ t('common.close') }}
|
||||
</UiButton>
|
||||
<UiButton @click="shellTheme = previewTheme!.value; previewOpen = false">
|
||||
{{ t('admin.protect.themeUseThis') }}
|
||||
</UiButton>
|
||||
</UiDialogFooter>
|
||||
</UiDialogContent>
|
||||
</UiDialog>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t('admin.protect.themeHint') }}
|
||||
</p>
|
||||
|
||||
<!-- 程序版本:壳拿它和平台已发布版本比对,决定是否提示/强制更新 -->
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
|
||||
@@ -2662,14 +2662,20 @@
|
||||
"themeDark": "Dark · card key login",
|
||||
"themeLight": "Light · office style",
|
||||
"themeIndustrial": "Industrial blue · device licensing",
|
||||
"themeHint": "DuiLib skins apply to 64-bit builds; 32-bit binaries keep the classic shell.",
|
||||
"themeHint": "DuiLib skins are 64-bit builds only; 32-bit programs fall back to the classic shell automatically.",
|
||||
"themeCompact": "Compact banner · single row",
|
||||
"themeSplit": "Split · brand sidebar",
|
||||
"themeCard": "Wide card · two columns",
|
||||
"themeTerminal": "Terminal style",
|
||||
"programVersionLabel": "Program version",
|
||||
"programVersionPlaceholder": "e.g. 1.2.3 (leave empty to skip update check)",
|
||||
"programVersionHint": "When set, the packaged program asks the platform for updates on startup. Publishing a newer version shows an update prompt; forced updates cannot be skipped."
|
||||
"programVersionHint": "When set, the packaged program asks the platform for updates on startup. Publishing a newer version shows an update prompt; forced updates cannot be skipped.",
|
||||
"themeGridHint": "Click a skin to apply it to the build — screenshots are from the real client",
|
||||
"themeBits64": "64-bit",
|
||||
"themeBits32": "32/64-bit",
|
||||
"themeZoom": "Preview",
|
||||
"themeZoomHint": "Actual rendering of the produced verification dialog (raw screenshot)",
|
||||
"themeUseThis": "Use this skin"
|
||||
},
|
||||
"signProfiles": {
|
||||
"title": "Signing certificates",
|
||||
|
||||
@@ -2681,14 +2681,20 @@
|
||||
"themeDark": "深色 · 卡密登录",
|
||||
"themeLight": "浅色 · 办公风",
|
||||
"themeIndustrial": "工业蓝 · 设备授权",
|
||||
"themeHint": "DuiLib 皮肤目前 64 位生效;32 位程序仍用经典壳。选好皮肤后云端加密,产物弹窗就按该皮肤渲染。",
|
||||
"themeHint": "DuiLib 皮肤只做了 64 位构建,32 位程序固定用经典壳(服务端会自动回落)。选好后云端加密,产物验证弹窗就按这套皮肤渲染。",
|
||||
"themeCompact": "极简横幅 · 单行激活",
|
||||
"themeSplit": "左右分栏 · 品牌竖栏",
|
||||
"themeCard": "宽扁卡片 · 双列说明",
|
||||
"themeTerminal": "终端风 · 命令行",
|
||||
"programVersionLabel": "程序版本",
|
||||
"programVersionPlaceholder": "例如 1.2.3(留空则不检查更新)",
|
||||
"programVersionHint": "填了版本号后,程序启动时会向平台查询是否有更新;平台里发布更高版本就会弹出更新提示,设为强制更新时不允许跳过。"
|
||||
"programVersionHint": "填了版本号后,程序启动时会向平台查询是否有更新;平台里发布更高版本就会弹出更新提示,设为强制更新时不允许跳过。",
|
||||
"themeGridHint": "点一套直接套用到产物,下面是各套界面实拍",
|
||||
"themeBits64": "64 位",
|
||||
"themeBits32": "32/64 位",
|
||||
"themeZoom": "看大图",
|
||||
"themeZoomHint": "这是产物验证弹窗的实际渲染效果(截图,未做任何美化)",
|
||||
"themeUseThis": "用这套皮肤"
|
||||
},
|
||||
"signProfiles": {
|
||||
"title": "签名证书",
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python3
|
||||
"""财务/日志接口审查:用真请求验证可疑点(本地 sqlite 后端)。"""
|
||||
import json
|
||||
import sqlite3
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
B = "http://127.0.0.1:8080"
|
||||
DB = "/root/work/vfy_e2e/verification_platform.db"
|
||||
|
||||
|
||||
def call(method, path, data=None, tok=None):
|
||||
body = json.dumps(data).encode() if data is not None else None
|
||||
req = urllib.request.Request(B + path, data=body, method=method,
|
||||
headers={"Content-Type": "application/json"})
|
||||
if tok:
|
||||
req.add_header("Authorization", "Bearer " + tok)
|
||||
try:
|
||||
resp = urllib.request.urlopen(req, timeout=30)
|
||||
return resp.status, json.loads(resp.read().decode())
|
||||
except urllib.error.HTTPError as e:
|
||||
return e.code, {"_raw": e.read().decode()[:300]}
|
||||
except Exception as e:
|
||||
return 0, {"_err": str(e)}
|
||||
|
||||
|
||||
def login():
|
||||
_, r = call("POST", "/api/v1/auth/login", {"username": "e2eadmin", "password": "admin123456"})
|
||||
return r["data"]["token"]
|
||||
|
||||
|
||||
def db():
|
||||
con = sqlite3.connect(DB)
|
||||
return con, con.cursor()
|
||||
|
||||
|
||||
def main():
|
||||
tok = login()
|
||||
con, cur = db()
|
||||
total_recharge = cur.execute("SELECT COUNT(*) FROM recharge_records").fetchone()[0]
|
||||
total_cons = cur.execute("SELECT COUNT(*) FROM consumption_records").fetchone()[0]
|
||||
print(f"库里实际: 充值 {total_recharge} 条 / 消费 {total_cons} 条")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/finance/records", None, tok)
|
||||
d = r.get("data") or {}
|
||||
recs = d.get("records") or []
|
||||
got_r = len([x for x in recs if x["type"] == "recharge"])
|
||||
got_c = len([x for x in recs if x["type"] == "consumption"])
|
||||
print(f"[1] 前端原样请求 /finance/records(无 page_size): HTTP {st} 返回 {len(recs)} 条"
|
||||
f"(充值{got_r}/消费{got_c})data.total={d.get('total')}")
|
||||
print(f" → 前端按这 {len(recs)} 条算总额,库里实有 {total_recharge + total_cons} 条")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/finance/records?page=2&page_size=10", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[2] 翻到第 2 页: HTTP {st} 返回 {len(d.get('records') or [])} 条, total={d.get('total')}")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/finance/records?page=0&page_size=0", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[3] page=0&page_size=0: HTTP {st} 返回 {len(d.get('records') or [])} 条")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/finance/records?page=-1&page_size=-5", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[4] page=-1&page_size=-5: HTTP {st} 返回 {len(d.get('records') or [])} 条")
|
||||
|
||||
# 主体被软删(正常业务操作)后,它的财务流水还能不能查
|
||||
victim = cur.execute("SELECT user_id FROM recharge_records GROUP BY user_id ORDER BY COUNT(*) DESC LIMIT 1").fetchone()[0]
|
||||
cur.execute("UPDATE app_users SET deleted_at = '2026-11-24 12:00:00' WHERE id = ?", (victim,))
|
||||
con.commit()
|
||||
st, r = call("GET", "/api/v1/dev/finance/records", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[5] 把一个有流水的主体软删后 /finance/records: HTTP {st} "
|
||||
f"返回 {len(d.get('records') or [])} 条 {'⚠ panic/500' if st >= 500 else ''} {r.get('_raw','')[:120]}")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/finance/recharge-records", None, tok)
|
||||
print(f"[6] 同场景 /finance/recharge-records: HTTP {st} {r.get('_raw','')[:120]}")
|
||||
cur.execute("UPDATE app_users SET deleted_at = NULL WHERE id = ?", (victim,))
|
||||
con.commit()
|
||||
|
||||
# 日志
|
||||
st, r = call("GET", "/api/v1/dev/logs?page_size=5", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[7] /logs?page_size=5: HTTP {st} 列表 {len(d.get('logs') or [])} 条, total={d.get('total')}, "
|
||||
f"success={d.get('success_count')} failed={d.get('failed_count')} operation={d.get('operation_count')}")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/logs?status=failed&type=exception&page_size=5", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[8] /logs?status=failed&type=exception: 列表 {len(d.get('logs') or [])} 条, total={d.get('total')}, "
|
||||
f"success={d.get('success_count')} failed={d.get('failed_count')} operation={d.get('operation_count')}")
|
||||
print(" → 筛选条件对上面三个统计数字没有影响(统计走的是 ApiUsage,且没带任何筛选)")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/logs?page=-1&page_size=-1", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[9] /logs?page=-1&page_size=-1: HTTP {st} 返回 {len(d.get('logs') or [])} 条(负数未校验)")
|
||||
|
||||
st, r = call("GET", "/api/v1/dev/logs?page_size=100000", None, tok)
|
||||
d = r.get("data") or {}
|
||||
print(f"[10] /logs?page_size=100000: HTTP {st} 返回 {len(d.get('logs') or [])} 条(无上限)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env python3
|
||||
"""登录方式开关(login_mode)端到端验证。
|
||||
|
||||
前置:一个干净的后端(sqlite)已经装好管理员,环境变量按需覆盖:
|
||||
VFY_BASE=http://127.0.0.1:8080 VFY_DB=<sqlite 文件> VFY_STATE=<状态文件>
|
||||
|
||||
跑法:
|
||||
python3 scripts/e2e-login-mode.py setup # 建应用 / 账号用户 / credential 卡
|
||||
python3 scripts/e2e-login-mode.py matrix # 跑 5 组模式×凭证的登录矩阵
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
BASE = os.environ.get("VFY_BASE", "http://127.0.0.1:8080")
|
||||
DB = os.environ.get("VFY_DB", "/root/work/vfy_e2e/verification_platform.db")
|
||||
ADMIN = {"username": "e2eadmin", "password": "admin123456"}
|
||||
APP_NAME = "e2e-loginmode"
|
||||
STATE = os.environ.get("VFY_STATE", "/root/work/e2e_state.json")
|
||||
|
||||
|
||||
def call(method, path, data=None, tok=None):
|
||||
body = json.dumps(data).encode() if data is not None else None
|
||||
req = urllib.request.Request(BASE + path, data=body, method=method,
|
||||
headers={"Content-Type": "application/json"})
|
||||
if tok:
|
||||
req.add_header("Authorization", "Bearer " + tok)
|
||||
try:
|
||||
return json.loads(urllib.request.urlopen(req, timeout=25).read())
|
||||
except urllib.error.HTTPError as e:
|
||||
raw = e.read().decode()
|
||||
try:
|
||||
j = json.loads(raw)
|
||||
j["_http"] = e.code
|
||||
return j
|
||||
except Exception:
|
||||
return {"_http": e.code, "_raw": raw[:400]}
|
||||
|
||||
|
||||
def admin_token():
|
||||
r = call("POST", "/api/v1/auth/login", ADMIN)
|
||||
return r["data"]["token"]
|
||||
|
||||
|
||||
def setup():
|
||||
tok = admin_token()
|
||||
r = call("POST", "/api/v1/dev/applications",
|
||||
{"name": APP_NAME, "description": "e2e 登录方式验证", "billing_type": "free"}, tok)
|
||||
print("建应用:", json.dumps(r, ensure_ascii=False)[:300])
|
||||
app = r.get("data", {})
|
||||
if isinstance(app.get("application"), dict):
|
||||
app = app["application"]
|
||||
app_id, app_key = app.get("id"), app.get("app_key")
|
||||
if not app_id:
|
||||
print("拿不到应用 ID,终止")
|
||||
return
|
||||
# 打开注册、关闭各种验证,方便造数据
|
||||
call("PUT", f"/api/v1/dev/applications/{app_id}",
|
||||
{"allow_register": True, "enable_register_verify": False, "enable_login_verify": False,
|
||||
"bind_type": "none", "max_devices": 5}, tok)
|
||||
|
||||
reg = call("POST", f"/api/v1/app/{app_key}/register",
|
||||
{"username": "e2euser", "password": "user123456", "device_id": "DEV-E2E-0001",
|
||||
"device_name": "e2e-pc", "device_type": "windows", "instance_id": "DEV-E2E-0001"})
|
||||
print("注册账号用户:", json.dumps(reg, ensure_ascii=False)[:300])
|
||||
|
||||
# 直接插一张 credential 卡(管理端建卡接口在这个版本里是桩)
|
||||
con = sqlite3.connect(DB)
|
||||
cur = con.cursor()
|
||||
cur.execute("SELECT id FROM card_types WHERE application_id=? LIMIT 1", (app_id,))
|
||||
row = cur.fetchone()
|
||||
if row:
|
||||
ct_id = row[0]
|
||||
else:
|
||||
cols = [r[1] for r in cur.execute("PRAGMA table_info(card_types)")]
|
||||
vals = {"application_id": app_id, "name": "e2e登录卡", "purpose": "credential",
|
||||
"recharge_type": "balance", "value": 0, "value_unit": "day", "price": 0,
|
||||
"status": "active", "created_at": "2026-11-24 00:00:00", "updated_at": "2026-11-24 00:00:00"}
|
||||
use = {k: v for k, v in vals.items() if k in cols}
|
||||
cur.execute("INSERT INTO card_types (%s) VALUES (%s)" % (
|
||||
",".join(use), ",".join("?" * len(use))), list(use.values()))
|
||||
ct_id = cur.lastrowid
|
||||
|
||||
cols = [r[1] for r in cur.execute("PRAGMA table_info(cards)")]
|
||||
vals = {"application_id": app_id, "card_type_id": ct_id, "card_key": "E2E-CARD-0001",
|
||||
"purpose": "credential", "status": "unused", "creator_id": 1,
|
||||
"created_at": "2026-11-24 00:00:00", "updated_at": "2026-11-24 00:00:00"}
|
||||
use = {k: v for k, v in vals.items() if k in cols}
|
||||
cur.execute("INSERT INTO cards (%s) VALUES (%s)" % (",".join(use), ",".join("?" * len(use))),
|
||||
list(use.values()))
|
||||
con.commit()
|
||||
con.close()
|
||||
print(f"已插入 credential 卡 E2E-CARD-0001(card_type_id={ct_id})")
|
||||
|
||||
json.dump({"app_id": app_id, "app_key": app_key, "token": tok}, open(STATE, "w"))
|
||||
print(f"state 已保存: app_id={app_id} app_key={app_key}")
|
||||
|
||||
|
||||
def set_mode(tok, app_id, mode=None, enforce=None, grace=None):
|
||||
body = {}
|
||||
if mode is not None:
|
||||
body["login_mode"] = mode
|
||||
if enforce is not None:
|
||||
body["login_mode_enforce"] = enforce
|
||||
if grace is not None:
|
||||
body["login_mode_grace_days"] = grace
|
||||
r = call("PUT", f"/api/v1/dev/applications/{app_id}", body, tok)
|
||||
return r
|
||||
|
||||
|
||||
def login(app_key, payload):
|
||||
r = call("POST", f"/api/v1/app/{app_key}/login", payload)
|
||||
code = r.get("code") or r.get("_http")
|
||||
return code, r.get("error_code"), r.get("message") or r.get("msg"), r.get("data")
|
||||
|
||||
|
||||
def matrix():
|
||||
st = json.load(open(STATE))
|
||||
tok, app_id, app_key = st["token"], st["app_id"], st["app_key"]
|
||||
|
||||
acc = {"username": "e2euser", "password": "user123456", "login_type": "account",
|
||||
"device_id": "DEV-E2E-0001", "device_name": "e2e-pc", "device_type": "windows",
|
||||
"instance_id": "DEV-E2E-0001"}
|
||||
crd = {"card_key": "E2E-CARD-0001", "login_type": "card",
|
||||
"device_id": "DEV-E2E-0002", "device_name": "e2e-pc2", "device_type": "windows",
|
||||
"instance_id": "DEV-E2E-0002"}
|
||||
# auto:把卡密塞进 username、密码留空 → 归一化成 card
|
||||
auto_card = {"username": "E2E-CARD-0001", "password": "", "login_type": "auto",
|
||||
"device_id": "DEV-E2E-0003", "device_name": "e2e-pc3", "device_type": "windows",
|
||||
"instance_id": "DEV-E2E-0003"}
|
||||
auto_acc = {"username": "e2euser", "password": "user123456", "login_type": "auto",
|
||||
"device_id": "DEV-E2E-0004", "device_name": "e2e-pc4", "device_type": "windows",
|
||||
"instance_id": "DEV-E2E-0004"}
|
||||
|
||||
cases = [
|
||||
("both/off", "both", "off", 0),
|
||||
("account/strict", "account", "strict", 0),
|
||||
("card/strict", "card", "strict", 0),
|
||||
("account/warn", "account", "warn", 0),
|
||||
("account/strict+7天宽限", "account", "strict", 7),
|
||||
]
|
||||
rows = []
|
||||
for label, mode, enforce, grace in cases:
|
||||
set_mode(tok, app_id, mode, enforce, grace)
|
||||
for tname, payload in (("account", acc), ("card", crd), ("auto→card", auto_card), ("auto→account", auto_acc)):
|
||||
code, ecode, msg, data = login(app_key, payload)
|
||||
extra = ""
|
||||
if isinstance(data, dict):
|
||||
if data.get("deprecated_login"):
|
||||
extra = f" deprecated={data.get('grace_days_left')}天"
|
||||
rows.append((label, tname, code, ecode or "", (msg or "")[:22], extra))
|
||||
print(f"--- {label} ---")
|
||||
for r in rows[-4:]:
|
||||
print(f" {r[1]:<14} code={r[2]} error_code={r[3]:<20} {r[4]}{r[5]}")
|
||||
|
||||
# 恢复默认,别把环境留成 strict
|
||||
set_mode(tok, app_id, "both", "warn", 0)
|
||||
|
||||
# impact 接口
|
||||
imp = call("GET", f"/api/v1/dev/applications/{app_id}/login-mode-impact", None, tok)
|
||||
print("影响面:", json.dumps(imp.get("data"), ensure_ascii=False))
|
||||
return rows
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cmd = sys.argv[1] if len(sys.argv) > 1 else "setup"
|
||||
if cmd == "setup":
|
||||
setup()
|
||||
elif cmd == "matrix":
|
||||
matrix()
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
"""mock 验证服务端(仅开发/验收用)
|
||||
|
||||
/login 一律回 HTTP 403 + error_code=DEVICE_LIMIT_EXCEEDED(带 3 台设备明细,上限 2),
|
||||
/unbind-device-with-auth、/card-devices、/info、/check-update、/announcements 回成功 JSON。
|
||||
|
||||
用途:不需要真数据库就能把壳的「设备管理页 / 每行解绑 / 在线状态」全程跑一遍。
|
||||
用法:python3 scripts/mock-vfy-device-limit.py (监听 127.0.0.1:9998)
|
||||
配套验收步骤见 docs/shell-device-ui.md
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
|
||||
DEVICES = [
|
||||
{"id": 11, "device_id": "AAAA-1111-2222-3333", "device_name": "工作室-PC01", "device_type": "windows", "online_count": 1, "created_at": "2026-11-01T10:00:00+08:00"},
|
||||
{"id": 12, "device_id": "BBBB-4444-5555-6666", "device_name": "笔记本-Liu", "device_type": "windows", "online_count": 0, "created_at": "2026-11-10T21:12:00+08:00"},
|
||||
{"id": 13, "device_id": "CCCC-7777-8888-9999", "device_name": "ANDROID-9f3c", "device_type": "android", "online_count": 1, "created_at": "2026-11-20T08:30:00+08:00"},
|
||||
]
|
||||
|
||||
|
||||
class H(BaseHTTPRequestHandler):
|
||||
def _log(self, body=b""):
|
||||
sys.stderr.write("[mock] %s %s %s\n" % (self.command, self.path, body[:200].decode("utf-8", "replace")))
|
||||
sys.stderr.flush()
|
||||
|
||||
def do_GET(self):
|
||||
self._log()
|
||||
if "info" in self.path:
|
||||
return self._json(200, {"code": 200, "data": {
|
||||
"allow_register": 1, "enable_register_verify": 1, "enable_password_reset": 1,
|
||||
"password_reset_method": "email", "billing_type": "card", "max_devices": 2,
|
||||
"name": "dogtest"}})
|
||||
if "devices" in self.path or "instances" in self.path:
|
||||
return self._json(200, {"code": 200, "data": {"devices": DEVICES, "max_devices": 2, "device_count": 3}})
|
||||
return self._json(200, {"code": 200, "data": {}})
|
||||
|
||||
def do_POST(self):
|
||||
n = int(self.headers.get("Content-Length") or 0)
|
||||
body = self.rfile.read(n) if n else b""
|
||||
self._log(body)
|
||||
if self.path.rstrip("/").endswith("/login"):
|
||||
# 与真实后端一致:error_code 放在 data 里;顶层也带一份,壳只按 "DEVICE_LIMIT" 字符串判断
|
||||
return self._json(403, {"code": 403, "error_code": "DEVICE_LIMIT_EXCEEDED",
|
||||
"message": "设备绑定数量已达上限,请解绑后再试",
|
||||
"data": {"error_code": "DEVICE_LIMIT_EXCEEDED",
|
||||
"max_devices": 2, "device_count": 3, "devices": DEVICES}})
|
||||
if "unbind" in self.path:
|
||||
return self._json(200, {"code": 200, "message": "解绑成功"})
|
||||
if "card-devices" in self.path:
|
||||
return self._json(200, {"code": 200, "data": {"devices": DEVICES, "max_devices": 2, "device_count": 3}})
|
||||
return self._json(200, {"code": 200, "data": {}})
|
||||
|
||||
def _json(self, code, obj):
|
||||
raw = json.dumps(obj, ensure_ascii=False, separators=(",", ":")).encode()
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", "application/json; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(raw)))
|
||||
self.end_headers()
|
||||
self.wfile.write(raw)
|
||||
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ThreadingHTTPServer(("127.0.0.1", 9998), H).serve_forever()
|
||||
@@ -90,3 +90,32 @@ open(p, 'wb').write(bytes(d))
|
||||
- 壳 DLL 的日志走 `logf_`(本仓库资产里已禁用)。要排查界面/网络问题时,用未打补丁的 DLL
|
||||
或在源码里给 `logf_` 加重定向,别直接改 `%TEMP%` 路径——那是唯一能落盘的取证点。
|
||||
- 验证界面需要窗口管理器:`Xvfb :99` + `openbox`,否则 wine 窗口不映射、截图全是黑屏。
|
||||
|
||||
## 设备已满页 / 我的设备页(2026-11 改版)
|
||||
|
||||
- **设备页做成独立页(QQ 那种观感)**:设备满时窗口从登录尺寸临时放大到 **620×620** 并居中,内容标题变「设备管理」、
|
||||
登录页的 4 个 tab 与品牌字隐藏;点「返回/重试」时窗口尺寸与 tab 自动还原。
|
||||
- 列表每行 = `HorizontalLayout(rowBoxN)` 里「信息按钮(devRowN) + 右侧蓝色『解绑』按钮(devUnbindN)」,行高 40、行间 6px;
|
||||
文字 `序号. 名称 设备ID ● 在线 / ○ 离线`(`online_count > 0` 判在线)。
|
||||
- **点哪行的『解绑』就解绑哪台**,不再需要输入序号(序号输入框整块隐藏,`devIdx`/`btnUnbind` 在 XML 里 `visible="false"` 兜底保留);
|
||||
解绑成功后自动重试登录。实测:点第 2 行的解绑 → `POST /unbind-device-with-auth` 带的是第 2 台的 `device_id`。
|
||||
- 文案:「设备数量已达上限,请先在平台**解绑**一台设备」「超出设备上限时请先**解绑**一台」——原来写「下线」,与按钮实际动作不一致。
|
||||
- 踩坑:`packthemed` 用 `//go:embed` 内嵌壳资产,**改完 assets 必须重编 packthemed**,否则测的还是旧壳(我在这上面浪费过几轮)。
|
||||
- 踩坑:wine 下 DuiLib 的原生 EDIT 子窗口点击不转移焦点,**要点两次**(第一次激活窗口、第二次才聚焦),否则输入会打到上一个输入框。
|
||||
## 手机端壳(Android,`assets/shell_smali.tgz`)
|
||||
|
||||
- 用 `smali assemble vfy -o /tmp/x.dex` 可离线校验语法;平台侧走 apktool 合并 smali 后重建 APK。
|
||||
- 界面是**运行时拼的原生 AlertDialog**(没有 XML 布局、没有皮肤):标题取 `cfg.name`,内容为竖向 LinearLayout(padding 16dp):
|
||||
说明「请输入账号或卡密完成验证」+ 输入框「账号或卡密」+ 密码框(留空则用 cfg 里的 password)+ 提示「通过后自动进入应用」;
|
||||
按钮「验证」(走 `verify()`)与「退出」(`finish()` + `killProcess`)。
|
||||
- 设备超限文案:「设备数超限,请先在平台解绑一台设备」。手机端目前**没有**设备列表/自助解绑页(只有这一道登录闸)。
|
||||
|
||||
## 壳节名:.load(2026-11 起)
|
||||
|
||||
产物里的壳节原名 `.vfy`,现改为 **`.load`**;旧产物仍可识别。改名必须成对做:
|
||||
|
||||
1. `backend/internal/protect/protect.go` 的 `secName = ".load"`(`HasVfy` 同时识别旧 `.vfy`)
|
||||
2. 引导 blob 的节名比较补丁:`blob64.bin` 偏移 `0x85/0x8b/0x91`、`blob32.bin` 偏移 `0x73/0x79/0x7f`,
|
||||
把 `76 66 79`(`vfy`)改成 `6c 6f 61`(`loa`,按前 4 字节匹配 `.load`)
|
||||
|
||||
只改 Go 侧不改 blob → 引导找不到节头,产物启动即 `return 2`;只改 blob 不改 Go → 写进去的还是 `.vfy`,同样对不上。
|
||||
|
||||
@@ -23,7 +23,7 @@ mkdir -p "$OUTDIR"
|
||||
# 导入表按实测产物取:ADVAPI32/bcrypt/COMCTL32/GDI32/gdiplus/KERNEL32/msvcrt/ole32/SHELL32/USER32/WINHTTP
|
||||
x86_64-w64-mingw32-g++ -std=c++17 -O2 -shared -s \
|
||||
-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0601 -D_WIN32_LEAN_AND_MEAN \
|
||||
-I"$DUILIB_DIR" -I"$DUILIB_DIR/DuiLib" -include "$DUILIB_DIR/shim/compat.h" -fpermissive -w \
|
||||
-I"$DUILIB_DIR/shim" -I"$DUILIB_DIR" -I"$DUILIB_DIR/DuiLib" -I"$DUILIB_DIR/DuiLib/Core" -I"$DUILIB_DIR/DuiLib/Control" -I"$DUILIB_DIR/DuiLib/Layout" -I"$DUILIB_DIR/DuiLib/Utils" -include "$DUILIB_DIR/shim/compat.h" -fpermissive -w \
|
||||
-o "$OUTDIR/shell64_dui.dll" "$SRC" "$LIBDUILIB" \
|
||||
-static -lcomctl32 -lgdiplus -lole32 -loleaut32 -luuid -lshlwapi -limm32 -lwinmm -lversion \
|
||||
-lgdi32 -luser32 -lwinhttp -ladvapi32 -lbcrypt -Wl,--kill-at
|
||||
|
||||
@@ -42,9 +42,11 @@ static char g_lastResp[8192] = ""; // 上一次 /login 原始响应(设备
|
||||
static int g_overlay = 0; // 0=正常 1=公告 2=更新 3=设备
|
||||
static int g_devManage = 0; // 1 = 设备面板处于「我的设备」自助模式
|
||||
|
||||
struct DevItem { char id[64]; char name[64]; char created[32]; };
|
||||
struct DevItem { char id[64]; char name[64]; char created[32]; int online; };
|
||||
static DevItem g_devs[16];
|
||||
static int g_devCount = 0, g_devMax = 0;
|
||||
static int g_selIdx = 0; // 设备页手动选中的那台(1 起;0=未选)
|
||||
static int g_baseW = 0, g_baseH = 0; // 登录页原始窗口尺寸(设备管理页会临时放大)
|
||||
|
||||
struct Notice { int id; char title[128]; char body[1024]; };
|
||||
static Notice g_notices[8];
|
||||
@@ -268,7 +270,7 @@ static int api_login(const char *user, const char *pass, char *msg, int cap) {
|
||||
snprintf(g_lastResp, sizeof(g_lastResp), "%s", resp);
|
||||
if (strstr(resp, "\"code\":0") || strstr(resp, "\"code\":200") || strstr(resp, "\"success\":true")) ok = 1;
|
||||
if (!json_str(resp, "message", msg, cap) || !msg[0]) {
|
||||
if (strstr(resp, "DEVICE_LIMIT")) snprintf(msg, cap, "设备数量已达上限,请先在平台下线一台设备");
|
||||
if (strstr(resp, "DEVICE_LIMIT")) snprintf(msg, cap, "设备数量已达上限,请先在平台解绑一台设备");
|
||||
else if (strstr(resp, "IP_LIMIT")) snprintf(msg, cap, "IP 绑定已达上限,请解绑后再试");
|
||||
else if (ok) snprintf(msg, cap, "登录成功");
|
||||
else snprintf(msg, cap, "账号或密码错误");
|
||||
@@ -901,6 +903,11 @@ public:
|
||||
if (!_tcsicmp(nm, _T("btnNoticeOk"))) { SaveNoticeSeen(); HideOverlays(); return; }
|
||||
if (!_tcsicmp(nm, _T("btnUpdate"))) { DoUpdate(); return; }
|
||||
if (!_tcsicmp(nm, _T("btnUpdLater"))) { HideOverlays(); return; }
|
||||
if (!_tcsnicmp(nm, _T("devUnbind"), 9) || !_tcsnicmp(nm, _T("devRow"), 6)) {
|
||||
int sel = _ttoi(nm + (!_tcsnicmp(nm, _T("devUnbind"), 9) ? 9 : 6)) + 1;
|
||||
if (sel >= 1 && sel <= g_devCount) UnbindDeviceIdx(sel);
|
||||
return;
|
||||
}
|
||||
if (!_tcsicmp(nm, _T("btnUnbind"))) { UnbindByIndex(); return; }
|
||||
if (!_tcsicmp(nm, _T("btnUnbindOld"))) { UnbindOldest(); return; }
|
||||
if (!_tcsicmp(nm, _T("btnRetryLogin"))) { HideOverlays(); DoLogin(); return; }
|
||||
@@ -1191,7 +1198,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void ShowTabsAgain() {
|
||||
const TCHAR *names[] = {_T("tabLogin"), _T("tabRegister"), _T("tabCard"), _T("tabReset"), _T("lblApp"), _T("lblBrand")};
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (CControlUI *c = static_cast<CControlUI *>(m_pm.FindControl(names[i]))) c->SetVisible(true);
|
||||
}
|
||||
if (CLabelUI *h = static_cast<CLabelUI *>(m_pm.FindControl(_T("devHead")))) h->SetText(L"设备数量已满");
|
||||
if (CLabelUI *t = static_cast<CLabelUI *>(m_pm.FindControl(_T("lblTitle")))) t->SetText(L"软件授权验证");
|
||||
}
|
||||
|
||||
void RestoreWindowSize() {
|
||||
if (g_baseW > 0) {
|
||||
RECT rc; ::GetWindowRect(m_hWnd, &rc);
|
||||
int sw = ::GetSystemMetrics(SM_CXSCREEN), sh = ::GetSystemMetrics(SM_CYSCREEN);
|
||||
::SetWindowPos(m_hWnd, NULL, (sw - g_baseW) / 2, (sh - g_baseH) / 2, g_baseW, g_baseH, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
void HideOverlays() {
|
||||
RestoreWindowSize();
|
||||
ShowTabsAgain();
|
||||
HideByName("panelNotice"); HideByName("panelUpdate"); HideByName("panelDevice");
|
||||
g_overlay = 0;
|
||||
SwitchTab(g_tab);
|
||||
@@ -1366,6 +1392,7 @@ public:
|
||||
// 把 g_lastResp 里的设备数组解析到 g_devs/后面统一渲染
|
||||
void ParseDevicesInto() {
|
||||
g_devCount = 0;
|
||||
g_selIdx = 0;
|
||||
g_devMax = json_int(g_lastResp, "max_devices", g_maxDevices);
|
||||
const char *p = g_lastResp;
|
||||
while ((p = strstr(p, "\"device_id\":\"")) && g_devCount < 16) {
|
||||
@@ -1379,13 +1406,51 @@ public:
|
||||
}
|
||||
snprintf(g_devs[g_devCount].id, sizeof(g_devs[0].id), "%s", id);
|
||||
snprintf(g_devs[g_devCount].name, sizeof(g_devs[0].name), "%s", name[0] ? name : "未命名设备");
|
||||
g_devs[g_devCount].online = 0;
|
||||
if (const char *oc = strstr(p, "\"online_count\":")) g_devs[g_devCount].online = atoi(oc + 15);
|
||||
g_devCount++;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
// 设备列表渲染:每行 = 信息按钮 + 右侧「解绑」按钮;每行点哪个解哪台
|
||||
void RenderDeviceList() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
TCHAR nm[16];
|
||||
_stprintf(nm, _T("devRow%d"), i);
|
||||
CButtonUI *b = static_cast<CButtonUI *>(m_pm.FindControl(nm));
|
||||
TCHAR bn[16];
|
||||
_stprintf(bn, _T("rowBox%d"), i);
|
||||
CControlUI *box = static_cast<CControlUI *>(m_pm.FindControl(bn));
|
||||
if (!b) continue;
|
||||
if (i < g_devCount) {
|
||||
wchar_t line[320];
|
||||
swprintf(line, 320, L"%d. %ls %ls %ls", i + 1,
|
||||
U8(g_devs[i].name).c_str(), U8(g_devs[i].id).c_str(),
|
||||
g_devs[i].online > 0 ? L"\u25cf \u5728\u7ebf" : L"\u25cb \u79bb\u7ebf");
|
||||
b->SetText(line);
|
||||
if (box) box->SetVisible(true);
|
||||
} else {
|
||||
b->SetText(L"");
|
||||
if (box) box->SetVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShowDevicePanel() {
|
||||
ParseDevicesInto();
|
||||
g_selIdx = 0;
|
||||
// 设备管理页比登录页大:临时放大窗口(QQ 那种独立设备页的观感)
|
||||
if (g_baseW == 0) {
|
||||
RECT rc; ::GetClientRect(m_hWnd, &rc);
|
||||
g_baseW = rc.right - rc.left; g_baseH = rc.bottom - rc.top;
|
||||
}
|
||||
{
|
||||
int nw = 620, nh = 620;
|
||||
RECT rc; ::GetWindowRect(m_hWnd, &rc);
|
||||
int sw = ::GetSystemMetrics(SM_CXSCREEN), sh = ::GetSystemMetrics(SM_CYSCREEN);
|
||||
::SetWindowPos(m_hWnd, NULL, (sw - nw) / 2, (sh - nh) / 2, nw, nh, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
std::wstring body;
|
||||
for (int i = 0; i < g_devCount; i++) {
|
||||
wchar_t line[256];
|
||||
@@ -1393,6 +1458,7 @@ public:
|
||||
body += line;
|
||||
}
|
||||
if (body.empty()) body = L"(服务器没有返回设备明细,可直接重试登录)";
|
||||
else body = L"点选下面要解绑的那台设备,再按「解绑该设备」";
|
||||
#ifdef VFY_DEBUG
|
||||
{ HANDLE f = ::CreateFileW(L"C:\\vfy_dev.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
if (f != INVALID_HANDLE_VALUE) { std::string dump; char tmp[2048];
|
||||
@@ -1400,11 +1466,21 @@ public:
|
||||
dump = tmp; for (int i2 = 0; i2 < g_devCount; i2++) { snprintf(tmp, sizeof(tmp), "ITEM[%d] name=<%s> id=<%s>\n", i2, g_devs[i2].name, g_devs[i2].id); dump += tmp; }
|
||||
DWORD wr = 0; ::WriteFile(f, dump.c_str(), (DWORD)dump.size(), &wr, NULL); ::CloseHandle(f); } }
|
||||
#endif
|
||||
if (CLabelUI *b = static_cast<CLabelUI *>(m_pm.FindControl(_T("devBody")))) b->SetText(body.c_str());
|
||||
RenderDeviceList(); // 列表正文由它写进 devBody
|
||||
wchar_t title[160];
|
||||
swprintf(title, 160, L"已绑定 %d / %d 台,解绑一台后即可登录", g_devCount, g_devMax > 0 ? g_devMax : g_maxDevices);
|
||||
if (CLabelUI *t = static_cast<CLabelUI *>(m_pm.FindControl(_T("devTitle")))) t->SetText(title);
|
||||
ShowOverlay("panelDevice");
|
||||
if (CLabelUI *h = static_cast<CLabelUI *>(m_pm.FindControl(_T("devHead")))) h->SetText(L"设备管理");
|
||||
if (CLabelUI *t = static_cast<CLabelUI *>(m_pm.FindControl(_T("lblTitle")))) {
|
||||
std::wstring wt = L"设备管理 - " + U8(g_name);
|
||||
t->SetText(wt.c_str());
|
||||
}
|
||||
HideByName("tabLogin"); HideByName("tabRegister"); HideByName("tabCard"); HideByName("tabReset");
|
||||
HideByName("lblApp"); HideByName("lblBrand");
|
||||
if (CLabelUI *tp = static_cast<CLabelUI *>(m_pm.FindControl(_T("devTip"))))
|
||||
tp->SetText(L"点任一行右侧的「解绑」即解绑那一台设备");
|
||||
if (CEditUI *e = static_cast<CEditUI *>(m_pm.FindControl(_T("devIdx")))) { e->SetText(L""); e->SetVisible(false); }
|
||||
}
|
||||
|
||||
// 一键解绑最早绑定的一台(服务器按 created_at DESC 返回,最后一台最老)
|
||||
@@ -1465,7 +1541,7 @@ public:
|
||||
text += line;
|
||||
}
|
||||
if (text.empty()) text = L"当前没有已绑定设备";
|
||||
if (CLabelUI *b = static_cast<CLabelUI *>(m_pm.FindControl(_T("devBody")))) b->SetText(text.c_str());
|
||||
RenderDeviceList(); // 列表正文由它写进 devBody
|
||||
wchar_t title[160];
|
||||
swprintf(title, 160, L"已绑定 %d / %d 台,解绑一台即可换设备登录", g_devCount, g_devMax > 0 ? g_devMax : g_maxDevices);
|
||||
if (CLabelUI *t = static_cast<CLabelUI *>(m_pm.FindControl(_T("devTitle")))) t->SetText(title);
|
||||
@@ -1476,7 +1552,14 @@ public:
|
||||
CLabelUI *tip = static_cast<CLabelUI *>(m_pm.FindControl(_T("devTip")));
|
||||
if (!e || !tip) return;
|
||||
int idx = _wtoi(e->GetText().GetData());
|
||||
if (idx < 1 || idx > g_devCount) { tip->SetText(L"请输入列表里的序号,例如 1"); return; }
|
||||
if (idx < 1) idx = g_selIdx; // 没填序号时用列表里点选的那台
|
||||
if (idx < 1 || idx > g_devCount) { tip->SetText(L"请先在「输入要解绑的设备序号」里填上列表中的序号(例如 1),再按「解绑该设备」"); return; }
|
||||
{
|
||||
wchar_t conf[256];
|
||||
swprintf(conf, 256, L"正在解绑第 %d 台:%ls(%ls)", idx,
|
||||
U8(g_devs[idx - 1].name).c_str(), g_devs[idx - 1].online > 0 ? L"在线" : L"离线");
|
||||
tip->SetText(conf);
|
||||
}
|
||||
UnbindDeviceIdx(idx);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
// 由 gen_skins_v3.py 生成,不要手改
|
||||
#pragma once
|
||||
|
||||
static const char *kSkin_dark = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="452,548" caption="0,0,-1,44" mininfo="452,548" bkcolor="#FF141418">
|
||||
<VerticalLayout bkcolor="#FF141418" bordercolor="#FF32323A" bordersize="1">
|
||||
<HorizontalLayout height="44" bkcolor="#FF1D1D24">
|
||||
<Label text="软件授权验证" textcolor="#FFF0F0F4" font="1" inset="20,0,0,0" />
|
||||
<Control />
|
||||
<Button name="btnClose" text="X" width="38" height="44" textcolor="#FF9A9AA6"
|
||||
bkcolor="#FF1D1D24" hotbkcolor="#33FFFFFF" pushedbkcolor="#66FFFFFF" />
|
||||
</HorizontalLayout>
|
||||
|
||||
<HorizontalLayout height="42" bkcolor="#FF1D1D24">
|
||||
<VerticalLayout width="86">
|
||||
<Button name="tabLogin" text="登录" textcolor="#FF4EA3E8" bkcolor="#00000000" height="40" />
|
||||
<Control height="2" bkcolor="#FF4EA3E8" />
|
||||
</VerticalLayout>
|
||||
<VerticalLayout width="86">
|
||||
<Button name="tabRegister" text="注册" textcolor="#FF85858F" bkcolor="#00000000" height="40" />
|
||||
<Control height="2" bkcolor="#00000000" name="tabRegLine" />
|
||||
</VerticalLayout>
|
||||
</HorizontalLayout>
|
||||
|
||||
<VerticalLayout inset="26,14,26,14">
|
||||
<Label name="lblApp" text="演示程序" textcolor="#FF6FB6E8" height="26" font="1" />
|
||||
<Control height="6" />
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<Label text="账号或卡密" textcolor="#FFB4B4BE" height="18" />
|
||||
<Edit name="editUser" height="40" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" />
|
||||
<Control height="10" />
|
||||
<Label text="密码" textcolor="#FFB4B4BE" height="18" />
|
||||
<Edit name="editPass" height="40" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" password="true" />
|
||||
<Control height="10" />
|
||||
<HorizontalLayout height="22">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FFB4B4BE" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FFB4B4BE" bkcolor="#00000000" width="78" />
|
||||
</HorizontalLayout>
|
||||
<Control height="12" />
|
||||
<Button name="btnLogin" text="登 录" height="44" bkcolor="#FF146FB8" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="lblTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<Label text="用户名" textcolor="#FFB4B4BE" height="18" />
|
||||
<Edit name="regUser" height="34" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="邮箱" textcolor="#FFB4B4BE" height="18" />
|
||||
<HorizontalLayout height="38">
|
||||
<Edit name="regEmail" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="104" height="34" bkcolor="#FF2F6E4E" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<Label text="邮箱验证码" textcolor="#FFB4B4BE" height="18" />
|
||||
<Edit name="regCode" height="34" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="密码" textcolor="#FFB4B4BE" height="18" />
|
||||
<Edit name="regPass" height="34" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" password="true" />
|
||||
<Control height="6" />
|
||||
<Label text="确认密码" textcolor="#FFB4B4BE" height="18" />
|
||||
<Edit name="regPass2" height="34" bkcolor="#FF2A2A33" nativebkcolor="#FF2A2A33" textcolor="#FFF4F4F8" bordercolor="#FF474755" inset="10,0,0,0" password="true" />
|
||||
<Control height="12" />
|
||||
<Button name="btnRegister" text="注册并登录" height="44" bkcolor="#FF1F8A5B" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="regTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<Control height="6" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF5C5C68" height="18" />
|
||||
<HorizontalLayout height="24">
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF7FA5CC" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF7FA5CC" bkcolor="#00000000" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
static const char *kSkin_light = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="452,548" caption="0,0,-1,44" mininfo="452,548" bkcolor="#FFFAFAFC">
|
||||
<VerticalLayout bkcolor="#FFFAFAFC" bordercolor="#FFDCDCE3" bordersize="1">
|
||||
<HorizontalLayout height="44" bkcolor="#FFFFFFFF">
|
||||
<Label text="软件授权验证" textcolor="#FF1F1F24" font="1" inset="20,0,0,0" />
|
||||
<Control />
|
||||
<Button name="btnClose" text="X" width="38" height="44" textcolor="#FF6B6B75"
|
||||
bkcolor="#FFFFFFFF" hotbkcolor="#33FFFFFF" pushedbkcolor="#66FFFFFF" />
|
||||
</HorizontalLayout>
|
||||
|
||||
<HorizontalLayout height="20" />
|
||||
<HorizontalLayout height="42" inset="26,0,26,0">
|
||||
<Button name="tabLogin" text="登录" width="100" height="40" bkcolor="#FF1B6FD6" textcolor="#FFFFFFFF" font="1" />
|
||||
<Control width="8" />
|
||||
<Button name="tabRegister" text="注册" width="100" height="40" bkcolor="#FFEDF0F5" textcolor="#FF5B6270" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
<VerticalLayout inset="26,16,26,14">
|
||||
<Label name="lblApp" text="演示程序" textcolor="#FF1B6FD6" height="26" font="1" />
|
||||
<Control height="6" />
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<Label text="账号或卡密" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="editUser" height="40" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control height="10" />
|
||||
<Label text="密码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="editPass" height="40" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" password="true" />
|
||||
<Control height="10" />
|
||||
<HorizontalLayout height="22">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FF4B5563" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FF4B5563" bkcolor="#00000000" width="78" />
|
||||
</HorizontalLayout>
|
||||
<Control height="12" />
|
||||
<Button name="btnLogin" text="登录" height="44" bkcolor="#FF1B6FD6" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="lblTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<Label text="用户名" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regUser" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="邮箱" textcolor="#FF4B5563" height="18" />
|
||||
<HorizontalLayout height="38">
|
||||
<Edit name="regEmail" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="104" height="34" bkcolor="#FFD8EAE0" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<Label text="邮箱验证码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regCode" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="密码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regPass" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" password="true" />
|
||||
<Control height="6" />
|
||||
<Label text="确认密码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regPass2" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" password="true" />
|
||||
<Control height="12" />
|
||||
<Button name="btnRegister" text="注册并登录" height="44" bkcolor="#FF128A5B" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="regTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<Control height="6" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF8A8F99" height="18" />
|
||||
<HorizontalLayout height="24">
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF3B62B8" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF3B62B8" bkcolor="#00000000" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
static const char *kSkin_split = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="660,548" caption="0,0,0,0" mininfo="660,548" bkcolor="#FF12151A">
|
||||
<HorizontalLayout bkcolor="#FF12151A" bordercolor="#FF282D35" bordersize="1">
|
||||
<VerticalLayout width="200" bkcolor="#FF1A2230">
|
||||
<HorizontalLayout height="44" inset="24,0,0,0">
|
||||
<Label text="VFY" textcolor="#FF4CC2FF" font="1" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
<VerticalLayout inset="24,4,24,0">
|
||||
<Label text="软件授权" textcolor="#FFC8D3E0" height="28" font="1" />
|
||||
<Label text="SOFTWARE LICENSE" textcolor="#FF63707E" height="20" />
|
||||
<Label text="账号登录后可绑定本机设备" textcolor="#FF4C5A68" height="20" margin="0,14,0,0" />
|
||||
</VerticalLayout>
|
||||
<VerticalLayout />
|
||||
<HorizontalLayout height="28" inset="24,0,24,16">
|
||||
<Label text="v9 · DuiLib" textcolor="#FF4A5764" />
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
<VerticalLayout>
|
||||
<HorizontalLayout height="46" inset="28,0,0,0">
|
||||
<VerticalLayout width="80">
|
||||
<Button name="tabLogin" text="登录" height="44" bkcolor="#00000000" textcolor="#FF4CC2FF" font="1" />
|
||||
<Control height="2" bkcolor="#FF4CC2FF" />
|
||||
</VerticalLayout>
|
||||
<VerticalLayout width="80">
|
||||
<Button name="tabRegister" text="注册" height="44" bkcolor="#00000000" textcolor="#FF7A8794" />
|
||||
<Control name="tabRegLine" height="2" bkcolor="#00000000" />
|
||||
</VerticalLayout>
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
<VerticalLayout inset="28,8,28,16">
|
||||
<Label name="lblApp" text="演示程序" textcolor="#FFF0F5FA" height="26" font="1" />
|
||||
<Control height="6" />
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<Label text="账号或卡密" textcolor="#FF8794A3" height="18" />
|
||||
<Edit name="editUser" height="40" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" />
|
||||
<Control height="10" />
|
||||
<Label text="密码" textcolor="#FF8794A3" height="18" />
|
||||
<Edit name="editPass" height="40" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" password="true" />
|
||||
<Control height="10" />
|
||||
<HorizontalLayout height="22">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FF8794A3" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FF8794A3" bkcolor="#00000000" width="78" />
|
||||
</HorizontalLayout>
|
||||
<Control height="12" />
|
||||
<Button name="btnLogin" text="登录" height="44" bkcolor="#FF2C7BE5" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="lblTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<Label text="用户名" textcolor="#FF8794A3" height="18" />
|
||||
<Edit name="regUser" height="34" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="邮箱" textcolor="#FF8794A3" height="18" />
|
||||
<HorizontalLayout height="38">
|
||||
<Edit name="regEmail" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="104" height="34" bkcolor="#FF2B6A50" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<Label text="邮箱验证码" textcolor="#FF8794A3" height="18" />
|
||||
<Edit name="regCode" height="34" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="密码" textcolor="#FF8794A3" height="18" />
|
||||
<Edit name="regPass" height="34" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" password="true" />
|
||||
<Control height="6" />
|
||||
<Label text="确认密码" textcolor="#FF8794A3" height="18" />
|
||||
<Edit name="regPass2" height="34" bkcolor="#FF1A1F27" nativebkcolor="#FF1A1F27" textcolor="#FFF2F6FA" bordercolor="#FF2E343D" inset="10,0,0,0" password="true" />
|
||||
<Control height="12" />
|
||||
<Button name="btnRegister" text="注册并登录" height="44" bkcolor="#FF1F8A5B" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="regTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<Control height="6" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF5E6B78" height="18" />
|
||||
<HorizontalLayout height="24">
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF6FA8DC" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF6FA8DC" bkcolor="#00000000" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</HorizontalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
static const char *kSkin_card = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="700,564" caption="0,0,-1,92" mininfo="700,564" bkcolor="#FFF5F6F9">
|
||||
<VerticalLayout bkcolor="#FFF5F6F9" bordercolor="#FFD7DBE3" bordersize="1">
|
||||
<HorizontalLayout height="92" bkcolor="#FF3B2BD6">
|
||||
<VerticalLayout inset="28,16,0,0">
|
||||
<Label text="软件授权验证" textcolor="#FFFFFFFF" font="1" height="34" />
|
||||
<Label name="lblApp" text="演示程序" textcolor="#FFD9D4FF" height="22" />
|
||||
</VerticalLayout>
|
||||
<Control />
|
||||
<Button name="btnClose" text="X" width="46" height="92" textcolor="#FFEDEBFF" bkcolor="#FF3B2BD6" hotbkcolor="#33FFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<HorizontalLayout height="54" inset="28,14,28,0">
|
||||
<Button name="tabLogin" text="登录" width="112" height="38" bkcolor="#FFFFFFFF" textcolor="#FF3B2BD6" font="1" />
|
||||
<Control width="8" />
|
||||
<Button name="tabRegister" text="注册" width="112" height="38" bkcolor="#FFE8E6FF" textcolor="#FF5B56A8" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
<HorizontalLayout inset="28,16,28,18">
|
||||
<VerticalLayout width="260">
|
||||
<Label text="账号安全" textcolor="#FF1F2430" height="26" font="1" />
|
||||
<Label text="登录后账号与本机设备绑定," textcolor="#FF4B5563" height="20" />
|
||||
<Label text="超出设备上限时请先下线一台。" textcolor="#FF4B5563" height="20" />
|
||||
<Control height="12" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF8A8F99" height="20" />
|
||||
<VerticalLayout />
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF3B2BD6" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF3B2BD6" bkcolor="#00000000" />
|
||||
</VerticalLayout>
|
||||
<Control width="28" />
|
||||
<VerticalLayout>
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<Label text="账号或卡密" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="editUser" height="40" bkcolor="#FFFFFFFF" nativebkcolor="#FFFFFFFF" textcolor="#FF1F2430" bordercolor="#FFC9D1DC" inset="10,0,0,0" />
|
||||
<Control height="10" />
|
||||
<Label text="密码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="editPass" height="40" bkcolor="#FFFFFFFF" nativebkcolor="#FFFFFFFF" textcolor="#FF1F2430" bordercolor="#FFC9D1DC" inset="10,0,0,0" password="true" />
|
||||
<Control height="10" />
|
||||
<HorizontalLayout height="22">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FF4B5563" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FF4B5563" bkcolor="#00000000" width="78" />
|
||||
</HorizontalLayout>
|
||||
<Control height="12" />
|
||||
<Button name="btnLogin" text="登录" height="44" bkcolor="#FF3B2BD6" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="lblTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<Label text="用户名" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regUser" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="邮箱" textcolor="#FF4B5563" height="18" />
|
||||
<HorizontalLayout height="38">
|
||||
<Edit name="regEmail" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="104" height="34" bkcolor="#FFD8EAE0" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<Label text="邮箱验证码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regCode" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="密码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regPass" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" password="true" />
|
||||
<Control height="6" />
|
||||
<Label text="确认密码" textcolor="#FF4B5563" height="18" />
|
||||
<Edit name="regPass2" height="34" bkcolor="#FFF1F3F7" nativebkcolor="#FFF1F3F7" textcolor="#FF1F2430" bordercolor="#FFC3CBD8" inset="10,0,0,0" password="true" />
|
||||
<Control height="12" />
|
||||
<Button name="btnRegister" text="注册并登录" height="44" bkcolor="#FF128A5B" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="regTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
static const char *kSkin_industrial = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="580,548" caption="0,0,-1,46" mininfo="580,548" bkcolor="#FF0A1520">
|
||||
<VerticalLayout bkcolor="#FF0A1520" bordercolor="#FF1F4E79" bordersize="1">
|
||||
<HorizontalLayout height="46" bkcolor="#FF10304C">
|
||||
<Label text="AUTHORIZATION" textcolor="#FF7FD1FF" font="1" inset="18,0,0,0" />
|
||||
<Control />
|
||||
<Button name="tabLogin" text="LOGIN" width="80" height="46" bkcolor="#FF1A5A8C" textcolor="#FFFFFFFF" />
|
||||
<Button name="tabRegister" text="REGISTER" width="96" height="46" bkcolor="#00000000" textcolor="#FF9FC8E6" />
|
||||
<Button name="btnClose" text="X" width="46" height="46" textcolor="#FFBEE3FF" bkcolor="#FF10304C" hotbkcolor="#33FFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<VerticalLayout inset="24,16,24,16">
|
||||
<Label name="lblApp" text="演示程序" textcolor="#FF8FC4E6" height="26" font="1" />
|
||||
<Control height="6" />
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<Label text="账号或卡密" textcolor="#FF9FC0D8" height="18" />
|
||||
<Edit name="editUser" height="40" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" />
|
||||
<Control height="10" />
|
||||
<Label text="密码" textcolor="#FF9FC0D8" height="18" />
|
||||
<Edit name="editPass" height="40" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" password="true" />
|
||||
<Control height="10" />
|
||||
<HorizontalLayout height="22">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FF9FC0D8" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FF9FC0D8" bkcolor="#00000000" width="78" />
|
||||
</HorizontalLayout>
|
||||
<Control height="12" />
|
||||
<Button name="btnLogin" text="登录" height="44" bkcolor="#FF1F6FB2" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="lblTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<Label text="用户名" textcolor="#FF9FC0D8" height="18" />
|
||||
<Edit name="regUser" height="34" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="邮箱" textcolor="#FF9FC0D8" height="18" />
|
||||
<HorizontalLayout height="38">
|
||||
<Edit name="regEmail" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="104" height="34" bkcolor="#FF1B4A3C" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<Label text="邮箱验证码" textcolor="#FF9FC0D8" height="18" />
|
||||
<Edit name="regCode" height="34" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="密码" textcolor="#FF9FC0D8" height="18" />
|
||||
<Edit name="regPass" height="34" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" password="true" />
|
||||
<Control height="6" />
|
||||
<Label text="确认密码" textcolor="#FF9FC0D8" height="18" />
|
||||
<Edit name="regPass2" height="34" bkcolor="#FF14304A" nativebkcolor="#FF14304A" textcolor="#FFEAF6FF" bordercolor="#FF23567F" inset="10,0,0,0" password="true" />
|
||||
<Control height="12" />
|
||||
<Button name="btnRegister" text="注册并登录" height="44" bkcolor="#FF1F7A5E" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="regTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<Control height="6" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF5F89A6" height="18" />
|
||||
<HorizontalLayout height="24">
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF6FA8C8" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF6FA8C8" bkcolor="#00000000" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
static const char *kSkin_terminal = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="600,548" caption="0,0,-1,38" mininfo="600,548" bkcolor="#FF0B0F0C">
|
||||
<VerticalLayout bkcolor="#FF0B0F0C" bordercolor="#FF2B3A2D" bordersize="1">
|
||||
<HorizontalLayout height="38" bkcolor="#FF101710">
|
||||
<Label text="vfy@local:~$" textcolor="#FF54C97A" inset="14,0,0,0" />
|
||||
<Control />
|
||||
<Button name="btnClose" text="X" width="38" height="38" textcolor="#FF7FB08C" bkcolor="#FF101710" hotbkcolor="#33FFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<HorizontalLayout height="34" bkcolor="#FF0E150F">
|
||||
<Button name="tabLogin" text="[ login ]" width="96" height="34" bkcolor="#00000000" textcolor="#FF7FE39B" />
|
||||
<Button name="tabRegister" text="[ register ]" width="108" height="34" bkcolor="#00000000" textcolor="#FF4E7A5C" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
<VerticalLayout inset="16,10,16,12">
|
||||
<Label name="lblApp" text="# 演示程序" textcolor="#FF7FE39B" height="24" />
|
||||
<Control height="6" />
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<Label text="账号或卡密" textcolor="#FF5E8A6C" height="18" />
|
||||
<Edit name="editUser" height="40" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" />
|
||||
<Control height="10" />
|
||||
<Label text="密码" textcolor="#FF5E8A6C" height="18" />
|
||||
<Edit name="editPass" height="40" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" password="true" />
|
||||
<Control height="10" />
|
||||
<HorizontalLayout height="22">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FF5E8A6C" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FF5E8A6C" bkcolor="#00000000" width="78" />
|
||||
</HorizontalLayout>
|
||||
<Control height="12" />
|
||||
<Button name="btnLogin" text="[ 执行登录 ]" height="44" bkcolor="#FF1B7A4E" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="lblTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<Label text="用户名" textcolor="#FF5E8A6C" height="18" />
|
||||
<Edit name="regUser" height="34" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="邮箱" textcolor="#FF5E8A6C" height="18" />
|
||||
<HorizontalLayout height="38">
|
||||
<Edit name="regEmail" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="104" height="34" bkcolor="#FF234A33" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<Label text="邮箱验证码" textcolor="#FF5E8A6C" height="18" />
|
||||
<Edit name="regCode" height="34" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" />
|
||||
<Control height="6" />
|
||||
<Label text="密码" textcolor="#FF5E8A6C" height="18" />
|
||||
<Edit name="regPass" height="34" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" password="true" />
|
||||
<Control height="6" />
|
||||
<Label text="确认密码" textcolor="#FF5E8A6C" height="18" />
|
||||
<Edit name="regPass2" height="34" bkcolor="#FF16211A" nativebkcolor="#FF16211A" textcolor="#FFD7F5DF" bordercolor="#FF2B3A2D" inset="10,0,0,0" password="true" />
|
||||
<Control height="12" />
|
||||
<Button name="btnRegister" text="注册并登录" height="44" bkcolor="#FF1B7A4E" textcolor="#FFFFFFFF" font="1" />
|
||||
<Label name="regTip" text="" textcolor="#FFE08A8A" height="24" inset="0,6,0,0" />
|
||||
|
||||
</VerticalLayout>
|
||||
<Control height="6" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF4E7A5C" height="18" />
|
||||
<HorizontalLayout height="24">
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF6FA08A" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF6FA08A" bkcolor="#00000000" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
static const char *kSkin_compact = R"SKIN(<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window size="760,206" caption="0,0,-1,38" mininfo="760,206" bkcolor="#FF11151A">
|
||||
<VerticalLayout bkcolor="#FF11151A" bordercolor="#FF2A3440" bordersize="1">
|
||||
<HorizontalLayout height="38" bkcolor="#FF161C22">
|
||||
<Label text="账号" textcolor="#FFA8BCCE" inset="16,0,0,0" />
|
||||
<Control />
|
||||
<Button name="btnClose" text="X" width="38" height="38" textcolor="#FFA8BCCE" bkcolor="#FF161C22" hotbkcolor="#33FFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<HorizontalLayout inset="16,12,16,10">
|
||||
<VerticalLayout width="200">
|
||||
<Label name="lblApp" text="演示程序" textcolor="#FFEAF2FA" height="26" font="1" />
|
||||
<Label name="lblDevice" text="设备" textcolor="#FF6B7C8C" height="20" />
|
||||
<Control height="12" />
|
||||
<Button name="tabLogin" text="登录" width="90" height="32" bkcolor="#FF2E9E6B" textcolor="#FFFFFFFF" />
|
||||
<Control height="6" />
|
||||
<Button name="tabRegister" text="注册" width="90" height="32" bkcolor="#FF1B232B" textcolor="#FF9FB3C8" />
|
||||
</VerticalLayout>
|
||||
<Control width="16" />
|
||||
<VerticalLayout>
|
||||
<VerticalLayout name="panelLogin" height="auto">
|
||||
<HorizontalLayout height="40">
|
||||
<HorizontalLayout width="214" bkcolor="#FF1B232B">
|
||||
<Label text="账号" width="46" textcolor="#FF7E90A2" inset="10,0,0,0" />
|
||||
<Edit name="editUser" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" inset="0,0,0,0" />
|
||||
</HorizontalLayout>
|
||||
<Control width="10" />
|
||||
<HorizontalLayout width="214" bkcolor="#FF1B232B">
|
||||
<Label text="密码" width="46" textcolor="#FF7E90A2" inset="10,0,0,0" />
|
||||
<Edit name="editPass" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" inset="0,0,0,0" password="true" />
|
||||
</HorizontalLayout>
|
||||
<Control width="10" />
|
||||
<Button name="btnLogin" text="登录" width="110" height="40" bkcolor="#FF2E9E6B" textcolor="#FFFFFFFF" font="1" />
|
||||
</HorizontalLayout>
|
||||
<HorizontalLayout height="26">
|
||||
<Label name="chkBox" width="14" height="14" bkcolor="#00000000" bordercolor="#FF6B7C8C" bordersize="1" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRemember" text="记住账号" textcolor="#FF6B7C8C" bkcolor="#00000000" width="120" />
|
||||
<Label name="lblTip" text="" textcolor="#FFD98A8A" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<HorizontalLayout height="24">
|
||||
<Button name="btnLinkCard" text="卡密充值" width="96" textcolor="#FF7FA5CC" bkcolor="#00000000" />
|
||||
<Button name="btnLinkForgot" text="忘记密码" width="96" textcolor="#FF7FA5CC" bkcolor="#00000000" />
|
||||
<Control />
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
<VerticalLayout name="panelRegister" height="auto" visible="false">
|
||||
<HorizontalLayout height="36">
|
||||
<Edit name="regUser" width="160" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" bordercolor="#FF32404E" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Edit name="regEmail" width="200" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" bordercolor="#FF32404E" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Button name="btnSendCode" text="发送验证码" width="100" height="36" bkcolor="#FF234A33" textcolor="#FFFFFFFF" />
|
||||
</HorizontalLayout>
|
||||
<Control height="6" />
|
||||
<HorizontalLayout height="36">
|
||||
<Edit name="regCode" width="160" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" bordercolor="#FF32404E" inset="10,0,0,0" />
|
||||
<Control width="8" />
|
||||
<Edit name="regPass" width="150" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" bordercolor="#FF32404E" inset="10,0,0,0" password="true" />
|
||||
<Control width="8" />
|
||||
<Edit name="regPass2" width="150" bkcolor="#FF1B232B" nativebkcolor="#FF1B232B" textcolor="#FFFFFFFF" bordercolor="#FF32404E" inset="10,0,0,0" password="true" />
|
||||
<Control width="8" />
|
||||
<Button name="btnRegister" text="注册" width="90" height="36" bkcolor="#FF2E9E6B" textcolor="#FFFFFFFF" font="1" />
|
||||
</HorizontalLayout>
|
||||
<Label name="regTip" text="" textcolor="#FFD98A8A" height="22" />
|
||||
</VerticalLayout>
|
||||
</VerticalLayout>
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
</Window>)SKIN";
|
||||
|
||||
struct SkinDef { const char *name; const char *xml; int w, h; };
|
||||
static const SkinDef kSkins[] = {
|
||||
{ "dark", kSkin_dark, 452, 548 },
|
||||
{ "light", kSkin_light, 452, 548 },
|
||||
{ "split", kSkin_split, 660, 548 },
|
||||
{ "card", kSkin_card, 700, 564 },
|
||||
{ "industrial", kSkin_industrial, 580, 548 },
|
||||
{ "terminal", kSkin_terminal, 600, 548 },
|
||||
{ "compact", kSkin_compact, 760, 206 },
|
||||
{ NULL, NULL, 0, 0 }
|
||||
};
|
||||