-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
utils.go
41 lines (35 loc) · 876 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package storer
import (
"path/filepath"
"github.com/webx-top/echo"
"github.com/webx-top/image"
)
var (
Default = Info{Name: `local`}
DefaultWatermarkOptions = &image.WatermarkOptions{
Watermark: filepath.Join(echo.Wd(), `public/assets/backend/images/nging-gear.png`),
Type: "image",
On: true,
}
)
func GetOk() (*Info, bool) {
storerConfig, ok := echo.Get(StorerInfoKey).(*Info)
if !ok {
storerConfig, ok = echo.GetStore(`NgingConfig`).GetStore(`base`).Get(`storer`).(*Info)
}
return storerConfig, ok
}
func Get() Info {
storerConfig, ok := GetOk()
if !ok {
return Default
}
return *storerConfig
}
func GetWatermarkOptions() *image.WatermarkOptions {
options, ok := echo.GetStore(`NgingConfig`).GetStore(`base`).Get(`watermark`).(*image.WatermarkOptions)
if ok {
return options
}
return DefaultWatermarkOptions
}