mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 22:42:15 +08:00
adapt resource drive
This commit is contained in:
parent
0edf7d0af2
commit
55e989d821
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -82,6 +82,8 @@ func CmdPwd() cli.Command {
|
|||||||
activeUser := config.Config.ActiveUser()
|
activeUser := config.Config.ActiveUser()
|
||||||
if activeUser.IsFileDriveActive() {
|
if activeUser.IsFileDriveActive() {
|
||||||
fmt.Println(activeUser.Workdir)
|
fmt.Println(activeUser.Workdir)
|
||||||
|
} else if activeUser.IsResourceDriveActive() {
|
||||||
|
fmt.Println(activeUser.ResourceWorkdir)
|
||||||
} else if activeUser.IsAlbumDriveActive() {
|
} else if activeUser.IsAlbumDriveActive() {
|
||||||
fmt.Println(activeUser.AlbumWorkdir)
|
fmt.Println(activeUser.AlbumWorkdir)
|
||||||
}
|
}
|
||||||
@ -125,6 +127,9 @@ func RunChangeDirectory(driveId, targetPath string) {
|
|||||||
if user.IsFileDriveActive() {
|
if user.IsFileDriveActive() {
|
||||||
user.Workdir = targetPathInfo.Path
|
user.Workdir = targetPathInfo.Path
|
||||||
user.WorkdirFileEntity = *targetPathInfo
|
user.WorkdirFileEntity = *targetPathInfo
|
||||||
|
} else if user.IsResourceDriveActive() {
|
||||||
|
user.ResourceWorkdir = targetPathInfo.Path
|
||||||
|
user.ResourceWorkdirFileEntity = *targetPathInfo
|
||||||
} else if user.IsAlbumDriveActive() {
|
} else if user.IsAlbumDriveActive() {
|
||||||
user.AlbumWorkdir = targetPathInfo.Path
|
user.AlbumWorkdir = targetPathInfo.Path
|
||||||
user.AlbumWorkdirFileEntity = *targetPathInfo
|
user.AlbumWorkdirFileEntity = *targetPathInfo
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -100,6 +100,11 @@ func RunSwitchDriveList(targetDriveId string) {
|
|||||||
config.Config.ActiveUser().Workdir = "/"
|
config.Config.ActiveUser().Workdir = "/"
|
||||||
config.Config.ActiveUser().WorkdirFileEntity = *aliyunpan.NewFileEntityForRootDir()
|
config.Config.ActiveUser().WorkdirFileEntity = *aliyunpan.NewFileEntityForRootDir()
|
||||||
}
|
}
|
||||||
|
} else if activeUser.IsResourceDriveActive() {
|
||||||
|
if activeUser.ResourceWorkdir == "" {
|
||||||
|
config.Config.ActiveUser().ResourceWorkdir = "/"
|
||||||
|
config.Config.ActiveUser().ResourceWorkdirFileEntity = *aliyunpan.NewFileEntityForRootDir()
|
||||||
|
}
|
||||||
} else if activeUser.IsAlbumDriveActive() {
|
} else if activeUser.IsAlbumDriveActive() {
|
||||||
if activeUser.AlbumWorkdir == "" {
|
if activeUser.AlbumWorkdir == "" {
|
||||||
config.Config.ActiveUser().AlbumWorkdir = "/"
|
config.Config.ActiveUser().AlbumWorkdir = "/"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -398,6 +398,15 @@ func (c *PanConfig) ActiveUser() *PanUser {
|
|||||||
} else {
|
} else {
|
||||||
u.WorkdirFileEntity = *fe
|
u.WorkdirFileEntity = *fe
|
||||||
}
|
}
|
||||||
|
} else if user.IsResourceDriveActive() {
|
||||||
|
fe, err1 := u.PanClient().FileInfoByPath(u.ActiveDriveId, u.ResourceWorkdir)
|
||||||
|
if err1 != nil {
|
||||||
|
// default to root
|
||||||
|
u.ResourceWorkdir = "/"
|
||||||
|
u.ResourceWorkdirFileEntity = *aliyunpan.NewFileEntityForRootDir()
|
||||||
|
} else {
|
||||||
|
u.ResourceWorkdirFileEntity = *fe
|
||||||
|
}
|
||||||
} else if user.IsAlbumDriveActive() {
|
} else if user.IsAlbumDriveActive() {
|
||||||
fe, err1 := u.PanClient().FileInfoByPath(u.ActiveDriveId, u.AlbumWorkdir)
|
fe, err1 := u.PanClient().FileInfoByPath(u.ActiveDriveId, u.AlbumWorkdir)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -48,14 +48,29 @@ func (d DriveInfoList) GetAlbumDriveId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d DriveInfoList) GetResourceDriveId() string {
|
||||||
|
for _, drive := range d {
|
||||||
|
if drive.DriveTag == "Resource" {
|
||||||
|
return drive.DriveId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type PanUser struct {
|
type PanUser struct {
|
||||||
UserId string `json:"userId"`
|
UserId string `json:"userId"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
|
// 文件/备份盘
|
||||||
Workdir string `json:"workdir"`
|
Workdir string `json:"workdir"`
|
||||||
WorkdirFileEntity aliyunpan.FileEntity `json:"workdirFileEntity"`
|
WorkdirFileEntity aliyunpan.FileEntity `json:"workdirFileEntity"`
|
||||||
|
|
||||||
|
// 资源库
|
||||||
|
ResourceWorkdir string `json:"resourceWorkdir"`
|
||||||
|
ResourceWorkdirFileEntity aliyunpan.FileEntity `json:"resourceWorkdirFileEntity"`
|
||||||
|
|
||||||
|
// 相册
|
||||||
AlbumWorkdir string `json:"albumWorkdir"`
|
AlbumWorkdir string `json:"albumWorkdir"`
|
||||||
AlbumWorkdirFileEntity aliyunpan.FileEntity `json:"albumWorkdirFileEntity"`
|
AlbumWorkdirFileEntity aliyunpan.FileEntity `json:"albumWorkdirFileEntity"`
|
||||||
|
|
||||||
@ -129,7 +144,8 @@ doLoginAct:
|
|||||||
|
|
||||||
// drive list
|
// drive list
|
||||||
u.DriveList = DriveInfoList{
|
u.DriveList = DriveInfoList{
|
||||||
{DriveId: userInfo.FileDriveId, DriveTag: "File", DriveName: "文件"},
|
{DriveId: userInfo.FileDriveId, DriveTag: "File", DriveName: "备份盘"},
|
||||||
|
{DriveId: userInfo.ResourceDriveId, DriveTag: "Resource", DriveName: "资源库"},
|
||||||
{DriveId: userInfo.AlbumDriveId, DriveTag: "Album", DriveName: "相册"},
|
{DriveId: userInfo.AlbumDriveId, DriveTag: "Album", DriveName: "相册"},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -165,6 +181,8 @@ func (pu *PanUser) PathJoin(driveId, p string) string {
|
|||||||
if di != nil {
|
if di != nil {
|
||||||
if di.IsFileDrive() {
|
if di.IsFileDrive() {
|
||||||
wd = pu.Workdir
|
wd = pu.Workdir
|
||||||
|
} else if di.IsResourceDrive() {
|
||||||
|
wd = pu.ResourceWorkdir
|
||||||
} else if di.IsAlbumDrive() {
|
} else if di.IsAlbumDrive() {
|
||||||
wd = pu.AlbumWorkdir
|
wd = pu.AlbumWorkdir
|
||||||
}
|
}
|
||||||
@ -239,6 +257,11 @@ func (pu *PanUser) IsAlbumDriveActive() bool {
|
|||||||
return d != nil && d.IsAlbumDrive()
|
return d != nil && d.IsAlbumDrive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pu *PanUser) IsResourceDriveActive() bool {
|
||||||
|
d := pu.GetActiveDriveInfo()
|
||||||
|
return d != nil && d.IsResourceDrive()
|
||||||
|
}
|
||||||
|
|
||||||
func (di *DriveInfo) IsFileDrive() bool {
|
func (di *DriveInfo) IsFileDrive() bool {
|
||||||
return di.DriveTag == "File"
|
return di.DriveTag == "File"
|
||||||
}
|
}
|
||||||
@ -246,3 +269,7 @@ func (di *DriveInfo) IsFileDrive() bool {
|
|||||||
func (di *DriveInfo) IsAlbumDrive() bool {
|
func (di *DriveInfo) IsAlbumDrive() bool {
|
||||||
return di.DriveTag == "Album"
|
return di.DriveTag == "Album"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (di *DriveInfo) IsResourceDrive() bool {
|
||||||
|
return di.DriveTag == "Resource"
|
||||||
|
}
|
||||||
|
9
main.go
9
main.go
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -253,6 +253,8 @@ func main() {
|
|||||||
wd := "/"
|
wd := "/"
|
||||||
if activeUser.IsFileDriveActive() {
|
if activeUser.IsFileDriveActive() {
|
||||||
wd = activeUser.Workdir
|
wd = activeUser.Workdir
|
||||||
|
} else if activeUser.IsResourceDriveActive() {
|
||||||
|
wd = activeUser.ResourceWorkdir
|
||||||
} else if activeUser.IsAlbumDriveActive() {
|
} else if activeUser.IsAlbumDriveActive() {
|
||||||
wd = activeUser.AlbumWorkdir
|
wd = activeUser.AlbumWorkdir
|
||||||
}
|
}
|
||||||
@ -347,7 +349,10 @@ func main() {
|
|||||||
wd := "/"
|
wd := "/"
|
||||||
if activeUser.IsFileDriveActive() {
|
if activeUser.IsFileDriveActive() {
|
||||||
wd = activeUser.Workdir
|
wd = activeUser.Workdir
|
||||||
prompt = app.Name + ":" + converter.ShortDisplay(path.Base(wd), NameShortDisplayNum) + " " + activeUser.Nickname + "$ "
|
prompt = app.Name + ":" + converter.ShortDisplay(path.Base(wd), NameShortDisplayNum) + " " + activeUser.Nickname + "(备份盘)$ "
|
||||||
|
} else if activeUser.IsResourceDriveActive() {
|
||||||
|
wd = activeUser.ResourceWorkdir
|
||||||
|
prompt = app.Name + ":" + converter.ShortDisplay(path.Base(wd), NameShortDisplayNum) + " " + activeUser.Nickname + "(资源库)$ "
|
||||||
} else if activeUser.IsAlbumDriveActive() {
|
} else if activeUser.IsAlbumDriveActive() {
|
||||||
wd = activeUser.AlbumWorkdir
|
wd = activeUser.AlbumWorkdir
|
||||||
prompt = app.Name + ":" + converter.ShortDisplay(path.Base(wd), NameShortDisplayNum) + " " + activeUser.Nickname + "(相册)$ "
|
prompt = app.Name + ":" + converter.ShortDisplay(path.Base(wd), NameShortDisplayNum) + " " + activeUser.Nickname + "(相册)$ "
|
||||||
|
Loading…
Reference in New Issue
Block a user