Skip to content

Commit 91220f6

Browse files
xrgzsj2rong4cn
andauthored
fix(useLink): adjust path handling for share links (#358)
* fix(useLink): adjust path handling for share links Signed-off-by: MadDogOwner <xiaoran@xrgzs.top> * fix(useLink): adjust path handling for share links * update share visibility logic to include isShare check --------- Signed-off-by: MadDogOwner <xiaoran@xrgzs.top> Co-authored-by: j2rong4cn <j2rong@qq.com>
1 parent 7b16751 commit 91220f6

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/hooks/useLink.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,16 @@ export const getLinkByDirAndObj = (
6767
export const useLink = () => {
6868
const { pathname, isShare } = useRouter()
6969
const getLinkByObj = (obj: Obj, type?: URLType, encodeAll?: boolean) => {
70-
const dir = objStore.state !== State.File ? pathname() : pathDir(pathname())
70+
let dir: string
71+
if (objStore.state === State.File) {
72+
dir = pathDir(pathname())
73+
if (isShare() && dir === "/@s") {
74+
dir = pathname()
75+
obj = { ...obj, name: "" }
76+
}
77+
} else {
78+
dir = pathname()
79+
}
7180
return getLinkByDirAndObj(dir, obj, type, isShare(), encodeAll)
7281
}
7382
const rawLink = (obj: Obj, encodeAll?: boolean) => {

src/pages/home/folder/context-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const ContextMenu = () => {
6565
)}
6666
</For>
6767
<Item
68-
hidden={!userCan("share")}
68+
hidden={!userCan("share") || isShare()}
6969
onClick={() => {
7070
bus.emit("tool", "share")
7171
}}

src/pages/home/toolbar/Center.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const Center = () => {
7171
}}
7272
</For>
7373
</Show>
74-
<Show when={userCan("share")}>
74+
<Show when={userCan("share") && !isShare()}>
7575
<CenterIcon
7676
name="share"
7777
onClick={() => {

0 commit comments

Comments
 (0)