Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Prejudice-Studio/Twilight
/ functions
Functions
2,686 in github.com/Prejudice-Studio/Twilight
⨍
Functions
2,686
◇
Types & classes
267
↓ 922 callers
Method
store
()
internal/api/app.go:117
↓ 761 callers
Method
cfg
cfg 返回当前生效的 config.Config 指针:调用方读字段后即可释放快照; 同一次 handler 内若需要前后一致,先 `cfg := a.cfg()` 一次再多次读字段。 返回指针而非值避免在 hot path 上每次拷贝 ~50 字段的 Config struct。
internal/api/app.go:108
↓ 664 callers
Function
toast
({ ...props }: Toast)
webui/src/hooks/use-toast.ts:163
↓ 647 callers
Function
failWithCode
failWithCode 是 fail 的重载,附带业务级错误码(见 errcode.go)。 推荐所有领域错误(容量满 / 绑定冲突 / 弱密码等)使用本函数, 仅协议层错误(参数缺失 / 鉴权失败等通用类)才使用 fail。
internal/api/response.go:106
↓ 355 callers
Method
add
(method, pattern string, auth AuthLevel, handler HandlerFunc)
internal/api/app.go:667
↓ 290 callers
Function
ok
(w http.ResponseWriter, message string, data any)
internal/api/response.go:85
↓ 228 callers
Function
asString
(value any)
internal/api/business.go:1460
↓ 224 callers
Function
stringValue
(payload map[string]any, key string)
internal/api/app.go:1295
↓ 220 callers
Method
request
( endpoint: string, options: RequestInit = {}, extra: ApiRequestExtraOptions = {}, )
webui/src/lib/api.ts:198
↓ 175 callers
Function
newTestApp
(t *testing.T)
internal/api/app_test.go:29
↓ 152 callers
Function
numeric
(value any)
internal/api/business.go:986
↓ 146 callers
Function
firstNonEmpty
(values ...string)
internal/api/handlers.go:2936
↓ 134 callers
Function
doJSON
(app *App, method, path, body string, cookies []*http.Cookie)
internal/api/app_test.go:5399
↓ 132 callers
Method
Close
()
internal/store/store.go:849
↓ 129 callers
Function
doJSONWithHeaders
(app *App, method, path, body string, cookies []*http.Cookie, headers map[string]string)
internal/api/app_test.go:5423
↓ 128 callers
Method
CreateUser
(u User)
internal/store/store.go:1642
↓ 119 callers
Function
current
(r *http.Request)
internal/api/app.go:816
↓ 117 callers
Method
telegramSendMessage
(ctx context.Context, chatID any, text string)
internal/api/telegram.go:159
↓ 115 callers
Method
Get
(ctx context.Context, token string)
internal/api/session.go:156
↓ 111 callers
Function
decodeMap
(r *http.Request)
internal/api/app.go:1253
↓ 108 callers
Method
User
(uid int64)
internal/store/store.go:1877
↓ 102 callers
Function
statusFromError
(w http.ResponseWriter, err error)
internal/api/app.go:1513
↓ 94 callers
Method
UpdateUser
(uid int64, fn func(*User) error)
internal/store/store.go:1884
↓ 94 callers
Function
jsDocParam
(name, typ, description string, required bool)
internal/api/developer_handlers.go:290
↓ 87 callers
Function
cn
(...inputs: ClassValue[])
webui/src/lib/utils.ts:4
↓ 85 callers
Method
Write
(data []byte)
internal/api/app.go:177
↓ 83 callers
Method
stringValue
(fallback string, keys ...string)
internal/config/config.go:1155
↓ 81 callers
Function
jsDocParamDefault
(name, typ, description, fallback string)
internal/api/developer_handlers.go:294
↓ 80 callers
Function
boolValue
(payload map[string]any, key string, fallback bool)
internal/api/app.go:1331
↓ 77 callers
Function
useI18n
()
webui/src/lib/i18n.tsx:170
↓ 76 callers
Method
mutateAndSaveLocked
mutateAndSaveLocked 把"读最新状态 → 变更 → 持久化 → 失败回滚"模板化。 调用方必须已经持有 s.mu 写锁;helper 内部不再额外加锁。 旧的写者模板"refreshLocked → 改 s.state → saveLocked"在 saveLocked 失败 后
internal/store/store.go:1098
↓ 57 callers
Function
intValue
(payload map[string]any, key string, fallback int)
internal/api/app.go:1313
↓ 56 callers
Method
ListUsers
()
internal/store/store.go:2430
↓ 56 callers
Method
audit
audit 是写入操作审计日志的便捷方法。category 为 "admin" / "user" / "system"。 AuditLog.enabled=false 时静默跳过记录。从 current(r) 提取操作者身份。
internal/api/audit_handlers.go:16
↓ 56 callers
Method
intValue
(fallback int, keys ...string)
internal/config/config.go:1180
↓ 53 callers
Function
boolish
(value any)
internal/api/admin_extra.go:1060
↓ 49 callers
Function
registerAndLogin
registerAndLogin 注册并登录指定账户,返回 session cookie 切片。
internal/api/app_test.go:86
↓ 48 callers
Function
clamp
(value, minValue, maxValue int)
internal/api/business.go:26
↓ 47 callers
Function
useToast
()
webui/src/hooks/use-toast.ts:206
↓ 46 callers
Function
redactSensitiveText
(value string)
internal/api/runtime_logs.go:475
↓ 45 callers
Method
boolValue
(fallback bool, keys ...string)
internal/config/config.go:1256
↓ 44 callers
Method
RegCode
(code string)
internal/store/store.go:3611
↓ 44 callers
Function
publicUser
(u store.User)
internal/api/app.go:1380
↓ 42 callers
Method
FindUserByUsername
(username string)
internal/store/store.go:1841
↓ 42 callers
Function
int64Param
(params Params, key string)
internal/api/app.go:1343
↓ 42 callers
Function
queryInt
(r *http.Request, key string, fallback int)
internal/api/business.go:17
↓ 38 callers
Function
rateKey
(parts ...any)
internal/api/ratelimit.go:77
↓ 37 callers
Method
allowRate
(ctx context.Context, key string, limit int, window time.Duration)
internal/api/app.go:661
↓ 36 callers
Function
truncateString
(value string, limit int)
internal/api/business.go:372
↓ 35 callers
Function
Open
(path string)
internal/store/store.go:480
↓ 34 callers
Method
UpsertRegCode
(code RegCode)
internal/store/store.go:3618
↓ 34 callers
Function
findCookie
(cookies []*http.Cookie, name string)
internal/api/app_test.go:5442
↓ 34 callers
Function
intValue
(value string, fallback int)
internal/config/config.go:1407
↓ 31 callers
Method
sessions
()
internal/api/app.go:124
↓ 31 callers
Method
telegramEditPanelWithNotice
(ctx context.Context, panel telegramPanelContext, target store.User, notice string)
internal/api/telegram_inline.go:491
↓ 29 callers
Function
invalidateUsersCache
()
webui/src/app/(main)/admin/users/page.tsx:302
↓ 29 callers
Function
zeroNil
(v int64)
internal/api/handlers.go:2945
↓ 28 callers
Method
embyGet
(ctx context.Context, apiPath string, dst any)
internal/api/emby_client.go:89
↓ 25 callers
Method
clientIP
(r *http.Request)
internal/api/app.go:1128
↓ 25 callers
Method
embyConfigured
embyConfigured 返回 Emby URL 和 Token 是否都已配置。 仅 URL 配置而 Token 为空时视为未鉴权配置,不应发起请求。
internal/api/emby_client.go:85
↓ 24 callers
Function
boolValue
(value string, fallback bool)
internal/config/config.go:1435
↓ 24 callers
Method
saveLocked
()
internal/store/store.go:1118
↓ 23 callers
Function
friendlyError
(code: string | undefined, fallback?: string)
webui/src/lib/validators.ts:341
↓ 23 callers
Function
randomCode
randomCode 生成 hex 编码的随机字符串,用于 API key、绑定码、上传文件名、 临时密码等所有"必须不可预测"的场景。 安全性约束:crypto/rand 故障时**绝不**回退到 time.Now().UnixNano() — 那会让攻击者用本机时钟近似猜出 token,等同于
internal/api/handlers.go:2906
↓ 22 callers
Method
DeleteUser
(ctx context.Context, uid int64)
internal/api/session.go:232
↓ 22 callers
Function
Load
(path string)
internal/config/config.go:328
↓ 22 callers
Function
expiryIsPermanent
(expiredAt int64)
internal/api/business.go:185
↓ 21 callers
Function
urlPathEscape
(value string)
internal/api/app.go:1220
↓ 19 callers
Method
FindUserByTelegramID
(telegramID int64)
internal/store/store.go:2467
↓ 19 callers
Method
refreshLocked
()
internal/store/store.go:1199
↓ 19 callers
Method
telegramRunJSCustomCommand
(code string, c telegramCommandCtx, privateChat bool)
internal/api/telegram_js_commands.go:112
↓ 19 callers
Function
useAsyncResource
( loader: (signal?: AbortSignal) => Promise<T>, options: UseAsyncResourceOptions<T> = {} )
webui/src/hooks/use-async-resource.ts:18
↓ 18 callers
Function
ResolveWithinRoot
ResolveWithinRoot 把 candidate 拼接到 root 下并返回绝对路径,若越界返回 ErrUnsafePath。 candidate 为相对路径或单文件名;绝对路径会先转换为相对 root 再校验。 不做 Lstat / 扩展名 / 符号链接判断,调用方可基于返回值再做。
internal/api/safepath.go:20
↓ 18 callers
Method
auditEntryIP
auditEntryIP 是不依赖 *http.Request 的审计写入入口,供没有 HTTP 上下文的路径 (如 Telegram Bot 命令)使用,IP 由调用方显式传入(如 "telegram")。
internal/api/audit_handlers.go:33
↓ 18 callers
Function
developerJSLimitText
(value string, limit int)
internal/api/telegram_js_commands.go:339
↓ 18 callers
Method
telegramAvailable
()
internal/api/telegram.go:39
↓ 18 callers
Method
userIsProtected
(u store.User)
internal/api/business.go:171
↓ 17 callers
Function
addBatchOutcomeWithCode
(result map[string]any, uid int64, code ErrCode, err error)
internal/api/business.go:1405
↓ 17 callers
Function
formatDate
(date: string | Date | number | null | undefined)
webui/src/lib/utils.ts:48
↓ 17 callers
Function
newJSONStoreForTest
(t *testing.T)
internal/store/store_test.go:12
↓ 17 callers
Method
telegramBindCodeState
telegramBindCodeState checks the status of a bind code. If uid is non-zero (user scene), it also verifies the bind code belongs to that user and check
internal/api/telegram_bind_status.go:30
↓ 16 callers
Method
UpsertInviteCode
(code InviteCode)
internal/store/store.go:3327
↓ 15 callers
Method
DeveloperModeEnabled
()
internal/store/store.go:3312
↓ 15 callers
Function
expireStatus
(expiredAt int64)
internal/api/app.go:1444
↓ 15 callers
Function
jobParamBool
(params map[string]any, key string, fallback bool)
internal/api/scheduler_runner.go:780
↓ 15 callers
Function
nullableInt
(v int64)
internal/api/app.go:1424
↓ 15 callers
Function
useConfirm
()
webui/src/components/ui/confirm-dialog.tsx:173
↓ 14 callers
Method
ServeHTTP
(w http.ResponseWriter, r *http.Request)
internal/api/app.go:574
↓ 14 callers
Function
developerJSBoolOption
(input any, key string)
internal/api/telegram_js_commands.go:1507
↓ 14 callers
Method
disableRemoteEmbyForWebState
(ctx context.Context, u store.User)
internal/api/emby.go:381
↓ 13 callers
Method
AddSchedulerRunReturning
(run SchedulerRun)
internal/store/scheduler.go:22
↓ 13 callers
Method
Backend
()
internal/store/store.go:884
↓ 13 callers
Function
HashPassword
(password string)
internal/security/password.go:39
↓ 13 callers
Method
ListRegCodes
()
internal/store/store.go:3773
↓ 13 callers
Method
ParentOf
(uid int64)
internal/store/store.go:3530
↓ 13 callers
Method
ZapLevel
()
internal/config/config.go:1470
↓ 13 callers
Method
bindCode
(code string)
internal/api/telegram_bind_status.go:122
↓ 13 callers
Function
configValues
(cfg config.Config)
internal/api/config_admin.go:1152
↓ 13 callers
Function
developerJSAdminUser
(user *store.User, logs *[]string, action string)
internal/api/telegram_js_commands.go:1024
↓ 13 callers
Function
listValue
(value string)
internal/config/config.go:1518
next →
1–100 of 2,686, ranked by callers