alfred/command/code/encode.go
2026-03-28 19:27:32 +08:00

29 lines
570 B
Go

package code
import (
"encoding/base64"
aw "github.com/deanishe/awgo"
"gitea.micah.wiki/pandora/alfred/model"
"gitea.micah.wiki/pandora/alfred/pkg/stringx"
)
func EncodeDo(args []string) []*model.Item {
if len(args) == 0 {
return nil
}
encodeStr := args[0]
val := base64.RawURLEncoding.EncodeToString([]byte(encodeStr))
items := make([]*model.Item, 0)
items = append(items, &model.Item{
Title: val,
Subtitle: stringx.NewStrPoint("URL Encode"),
Icon: aw.IconInfo,
Arg: []string{"copytext", val},
Valid: true,
})
return items
}