修改创建共享链接的方法

原始代码如下:

Y.createShareLink = function(Y) {
    return this.post("".concat(t3, "/share/create"), Y);
}

如果你想在 Y.createShareLink 函数的返回值中修改 share_url 的域名部分,你可以在函数返回前修改相应的属性。以下是一个示例:

Y.createShareLink = function(Y) {
    // 发起 POST 请求
    const createLinkResponse = this.post("".concat(t3, "/share/create"), Y);

    // 如果请求成功,且返回了 share_url
    if (createLinkResponse && createLinkResponse.share_url) {
        // 将 share_url 中的域名部分替换为 "https://chat.openai.yt"
        createLinkResponse.share_url = createLinkResponse.share_url.replace("https://chat.openai.com", "https://chat.openai.yt");
    }

    // 返回修改后的结果
    return createLinkResponse;
}

同样的,我们可以修复下面的代码

 if (s && !r.current) {
                    r.current = !0;
                    var e = E.tQ.getThreadCurrentLeafId(t),
                    a = E.tQ.getTree(t).getMessageId(e);
                    P.ZP.createShareLink({
                        current_node_id: a,
                        conversation_id: t,
                        is_anonymous: !0
                    }).then(function(e) {
                        n.setState({
                            shareLinkId: e.share_id,
                            shareLinkUrl: e.share_url,
                            isPublic: e.is_public,
                            isDeleted: !e.is_visible,
                            title: e.title,
                            highlightedMessageId: e.highlighted_message_id,
                            initiallyHighlightedMessageId: e.highlighted_message_id,
                            currentNodeId: e.current_node_id,
                            linkAlreadyExisted: e.already_exists,
                            isAnonymous: e.is_anonymous,
                            moderationState: e.moderation_state
                        })
                    }).
                    catch(function(e) {
                        e instanceof eJ.Q0 && "string" == typeof e.message ? n.setState({
                            linkError: e.message
                        }) : (en.m.danger("Failed to copy link to clipboard - could not create link"), L.vm.closeSharingModal())
                    })
                }

在n.setState({前插入:

                        // 替换 share_url 中的域名部分为 "https://chat.openai.yt"
                        e.share_url = e.share_url.replace("https://chat.openai.com", "https://chat.openai.yt");

最终改成:

 if (s && !r.current) {
                    r.current = !0;
                    var e = E.tQ.getThreadCurrentLeafId(t),
                    a = E.tQ.getTree(t).getMessageId(e);
                    P.ZP.createShareLink({
                        current_node_id: a,
                        conversation_id: t,
                        is_anonymous: !0
                    }).then(function(e) {
                        // 替换 share_url 中的域名部分为 "https://chat.openai.yt"
                        e.share_url = e.share_url.replace("https://chat.openai.com", "https://chat.openai.yt");
                        n.setState({
                            shareLinkId: e.share_id,
                            shareLinkUrl: e.share_url,
                            isPublic: e.is_public,
                            isDeleted: !e.is_visible,
                            title: e.title,
                            highlightedMessageId: e.highlighted_message_id,
                            initiallyHighlightedMessageId: e.highlighted_message_id,
                            currentNodeId: e.current_node_id,
                            linkAlreadyExisted: e.already_exists,
                            isAnonymous: e.is_anonymous,
                            moderationState: e.moderation_state
                        })
                    }).
                    catch(function(e) {
                        e instanceof eJ.Q0 && "string" == typeof e.message ? n.setState({
                            linkError: e.message
                        }) : (en.m.danger("Failed to copy link to clipboard - could not create link"), L.vm.closeSharingModal())
                    })
                }
点赞