rewrite using IoC and DI

This commit is contained in:
Aynakeya
2022-12-23 05:06:57 -08:00
parent 0498d2dbf3
commit c47d338a9e
88 changed files with 2295 additions and 1856 deletions

View File

@@ -8,7 +8,7 @@ import (
const (
ProgramName = "卡西米尔唱片机"
Version = "beta 0.9.3"
Version = "beta 0.9.5"
)
const (
@@ -55,7 +55,7 @@ func init() {
fmt.Println("config not found, using default config")
ConfigFile = ini.Empty()
}
for _, cfg := range []Config{Log, Player, Provider, General} {
for _, cfg := range []Config{Log, General} {
LoadConfig(cfg)
}
}

View File

@@ -1,55 +0,0 @@
package config
type _PlayerConfig struct {
PlaylistData string
Playlists []*PlayerPlaylist `ini:"-"`
//PlaylistsProvider []string
PlaylistIndex int
PlaylistRandom bool
UserPlaylistRandom bool
AudioDevice string
Volume float64
SkipPlaylist bool
}
type PlayerPlaylist struct {
ID string
Provider string
}
func (c *_PlayerConfig) Name() string {
return "Player"
}
func (c *_PlayerConfig) OnLoad() {
//c.Playlists = make([]*PlayerPlaylist, 0)
_ = LoadJson(c.PlaylistData, &c.Playlists)
}
func (c *_PlayerConfig) OnSave() {
_ = SaveJson(c.PlaylistData, &c.Playlists)
}
var Player = &_PlayerConfig{
PlaylistData: "playlists.json",
Playlists: []*PlayerPlaylist{
{
"2382819181",
"netease",
},
{
"4987059624",
"netease",
},
{
"list1",
"local",
},
},
PlaylistIndex: 0,
PlaylistRandom: true,
UserPlaylistRandom: false,
AudioDevice: "auto",
Volume: 100,
SkipPlaylist: false,
}

View File

@@ -1,16 +0,0 @@
package config
type _ProviderConfig struct {
BaseConfig
Priority []string
LocalDir string
}
func (c *_ProviderConfig) Name() string {
return "Provider"
}
var Provider = &_ProviderConfig{
Priority: []string{"netease", "kuwo", "bilibili", "local", "bilibili-video"},
LocalDir: "./music",
}