remove none support commands

This commit is contained in:
tickstep 2024-04-27 22:18:38 +08:00
parent 4a0ad141dc
commit 504d38db90
3 changed files with 15 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import (
"github.com/tickstep/aliyunpan/cmder/cmdliner" "github.com/tickstep/aliyunpan/cmder/cmdliner"
"github.com/tickstep/aliyunpan/internal/config" "github.com/tickstep/aliyunpan/internal/config"
"github.com/tickstep/aliyunpan/internal/functions/panlogin" "github.com/tickstep/aliyunpan/internal/functions/panlogin"
"github.com/tickstep/aliyunpan/internal/global"
_ "github.com/tickstep/library-go/requester" _ "github.com/tickstep/library-go/requester"
"github.com/urfave/cli" "github.com/urfave/cli"
"strings" "strings"
@ -129,8 +130,14 @@ func RunLogin() (ticketId string, openapiToken, webapiToken *config.PanClientTok
} }
ticketId = qrCodeUrlResult.TokenId ticketId = qrCodeUrlResult.TokenId
loginUrl := &strings.Builder{} loginUrl := &strings.Builder{}
if global.IsSupportNoneOpenApiCommands {
// 兼容以前的版本
fmt.Fprintf(loginUrl, "https://openapi.alipan.com/oauth/authorize?client_id=%s&redirect_uri=https%%3A%%2F%%2Fapi.tickstep.com%%2Fauth%%2Ftickstep%%2Faliyunpan%%2Ftoken%%2Fopenapi%%2F%s%%2Fauth&scope=user:base,file:all:read,file:all:write", fmt.Fprintf(loginUrl, "https://openapi.alipan.com/oauth/authorize?client_id=%s&redirect_uri=https%%3A%%2F%%2Fapi.tickstep.com%%2Fauth%%2Ftickstep%%2Faliyunpan%%2Ftoken%%2Fopenapi%%2F%s%%2Fauth&scope=user:base,file:all:read,file:all:write",
config.Config.ClientId, ticketId) config.Config.ClientId, ticketId)
} else {
fmt.Fprintf(loginUrl, "https://openapi.alipan.com/oauth/authorize?client_id=%s&redirect_uri=https%%3A%%2F%%2Fapi.tickstep.com%%2Fauth%%2Ftickstep%%2Faliyunpan%%2Ftoken%%2Fopenapi%%2F%s%%2Fauth2&scope=user:base,file:all:read,file:all:write",
config.Config.ClientId, ticketId)
}
fmt.Printf("请在浏览器打开以下链接进行登录链接有效时间为5分钟。\n注意你需要进行一次授权一次扫码的两次登录。\n%s\n\n", loginUrl) fmt.Printf("请在浏览器打开以下链接进行登录链接有效时间为5分钟。\n注意你需要进行一次授权一次扫码的两次登录。\n%s\n\n", loginUrl)
// handler waiting // handler waiting

View File

@ -7,6 +7,6 @@ var (
// IsAppInCliMode 是否在交互模式 // IsAppInCliMode 是否在交互模式
IsAppInCliMode = false IsAppInCliMode = false
// IsSupportNoneOpenApiCommands 是否支持非OpenAPI的命令 // IsSupportNoneOpenApiCommands 是否开启非OpenAPI的命令
IsSupportNoneOpenApiCommands = false IsSupportNoneOpenApiCommands = false
) )

View File

@ -62,6 +62,11 @@ var (
) )
func init() { func init() {
b, ok := os.LookupEnv("ALIYUNPAN_NONE_OPENAPI")
if ok && b == "1" {
global.IsSupportNoneOpenApiCommands = true
}
global.AppVersion = Version global.AppVersion = Version
cmdutil.ChWorkDir() cmdutil.ChWorkDir()