refactor: optimize driver initialization need to manually deserialize and assign values, and remove redundant driver registration parameters (#2691)
* refactor: optimize driver initialization need to manually deserialize and assign values, and remove redundant driver registration parameters * fix typo Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
@ -22,15 +22,10 @@ func (d *Pan115) Config() driver.Config {
|
||||
}
|
||||
|
||||
func (d *Pan115) GetAddition() driver.Additional {
|
||||
return d.Addition
|
||||
return &d.Addition
|
||||
}
|
||||
|
||||
func (d *Pan115) Init(ctx context.Context, storage model.Storage) error {
|
||||
d.Storage = storage
|
||||
err := utils.Json.UnmarshalFromString(d.Storage.Addition, &d.Addition)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (d *Pan115) Init(ctx context.Context) error {
|
||||
return d.login()
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type Addition struct {
|
||||
Cookie string `json:"cookie"`
|
||||
Cookie string `json:"cookie"`
|
||||
QRCodeToken string `json:"qrcode_token"`
|
||||
driver.RootID
|
||||
}
|
||||
@ -18,10 +18,8 @@ var config = driver.Config{
|
||||
OnlyLocal: true,
|
||||
}
|
||||
|
||||
func New() driver.Driver {
|
||||
return &Pan115{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
op.RegisterDriver(config, New)
|
||||
op.RegisterDriver(func() driver.Driver {
|
||||
return &Pan115{}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user