feat: assets程序内嵌全局资源访问

This commit is contained in:
TsMask
2023-10-26 20:23:46 +08:00
parent 2e160ef4d3
commit 1a35240d42
4 changed files with 35 additions and 12 deletions

View File

@@ -147,6 +147,16 @@ func Get(key string) any {
return viper.Get(key)
}
// GetAssetsDirFS 访问程序内全局资源访问
func GetAssetsDirFS() embed.FS {
return viper.Get("AssetsDir").(embed.FS)
}
// SetAssetsDirFS 设置程序内全局资源访问
func SetAssetsDirFS(assetsDir embed.FS) {
viper.Set("AssetsDir", assetsDir)
}
// IsAdmin 用户是否为管理员
func IsAdmin(userID string) bool {
if userID == "" {