V2EX - 超级增强

楼中楼回复(支持感谢数排序)、自动签到、快捷回复图片和表情、列表预览内容、点击帖子弹框展示详情、对用户打标签、回复上下文、记录上次阅读位置、自定义背景、使用 SOV2EX 搜索、正文超长自动折叠、划词 base64 解码、一键@所有人,@管理员、操作按钮(感谢、收藏、回复、隐藏)异步请求、支持黑暗模式

当前为 2023-07-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name V2EX - 超级增强
  3. // @namespace http://tampermonkey.net/
  4. // @version 5.9
  5. // @author zyronon
  6. // @description 楼中楼回复(支持感谢数排序)、自动签到、快捷回复图片和表情、列表预览内容、点击帖子弹框展示详情、对用户打标签、回复上下文、记录上次阅读位置、自定义背景、使用 SOV2EX 搜索、正文超长自动折叠、划词 base64 解码、一键@所有人,@管理员、操作按钮(感谢、收藏、回复、隐藏)异步请求、支持黑暗模式
  7. // @license GPL License
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
  9. // @match https://v2ex.com/
  10. // @match https://v2ex.com/?tab=*
  11. // @match https://v2ex.com/t/*
  12. // @match https://v2ex.com/recent*
  13. // @match https://v2ex.com/go/*
  14. // @match https://*.v2ex.com/
  15. // @match https://*.v2ex.com/?tab=*
  16. // @match https://*.v2ex.com/t/*
  17. // @match https://*.v2ex.com/recent*
  18. // @match https://*.v2ex.com/go/*
  19. // @require https://cdn.jsdelivr.net/npm/vue@3.2.47/dist/vue.global.prod.js
  20. // @grant GM_notification
  21. // @grant GM_openInTab
  22. // @grant GM_registerMenuCommand
  23. // ==/UserScript==
  24.  
  25. (t=>{const e=document.createElement("style");e.dataset.source="vite-plugin-monkey",e.textContent=t,document.head.append(e)})(' .v-enter-active,.v-leave-active{transition:opacity .3s ease}.v-enter-from,.v-leave-to{opacity:0}.username{font-weight:700;font-size:1.4rem;margin-right:1rem}.op{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;margin-right:1rem;transform:scale(.8)}.mod{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;transform:scale(.8);background:#1484cd;color:#fff;margin-right:1rem}.my-tag{font-size:1.4rem;color:red;margin-left:1rem}.my-tag:hover .remove{display:inline}.my-tag .remove{cursor:pointer;margin-left:.5rem;display:none}.floor{margin-left:1rem;font-size:1.2rem;line-height:1rem;border-radius:1rem;display:inline-block;background-color:#f0f0f0;color:#ccc;padding:.2rem .5rem;cursor:default}html,body{font-size:62.5%}.flex{display:flex;align-items:center;justify-content:space-between}.flex-end{justify-content:flex-end}.flex-center{justify-content:center}.p1{padding:1rem}.p0{padding:0!important}.post-author{display:flex;align-items:center;position:relative;color:#ccc!important}.post-author>.username{font-size:1.2rem}.sticky{position:sticky;bottom:0}.sticky[stuck]{box-shadow:0 2px 20px #00000059}a{color:#778087;text-decoration:none;cursor:pointer}a:hover{text-decoration:underline}.base-loading{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear}.loading-c{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;width:3rem;height:3rem}.loading-b{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;border-color:#ffffff rgba(178,177,177,.2) rgba(178,177,177,.2) rgba(178,177,177,.2);width:3rem;height:3rem}@keyframes circle{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.button{cursor:pointer;padding:.4rem 2.4rem;border-radius:5px;display:inline-flex;justify-content:center;align-items:center;font-weight:700;font-size:1.2rem;color:#fff;background:#40a9ff;border:1px solid #40a9ff;user-select:none}.button:hover{opacity:.9}.button.info{color:#000;border:1px solid #40a9ff;background:white}.button.gray{color:#f5f5f5;border:1px solid #b6b6b6;background:#b6b6b6}.button.light{color:gray;border:1px solid #e2e2e2;background:#e2e2e2}.button:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;border-color:#fff transparent transparent transparent;width:1rem;height:1rem;margin-right:1rem;display:none}.button.loading{cursor:not-allowed;opacity:.5}.button.loading:before{display:block}.button.disabled{cursor:not-allowed;color:#c6c6c6;background:#8d8d8d;border:1px solid transparent}.button.isNight{color:#c6c6c6;background:#2b4054;border:1px solid transparent}.tool{position:relative;margin-left:1rem;display:flex;align-items:center;font-size:1.2rem;font-weight:700;border-radius:.2rem;cursor:pointer;height:3rem;padding:0 .5rem}.tool:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;border-color:transparent #929596 #929596 #929596;width:1rem;height:1rem;margin-left:1rem;display:none}.tool.loading{cursor:not-allowed;opacity:.5}.tool.loading:before{display:block}.tool.loading:hover{background:unset}.tool>svg{width:1.6rem!important;height:1.6rem!important;margin-right:.4rem;box-sizing:border-box;border-radius:.2rem}.tool:hover{background:#e8e8e8}.tool.no-hover{cursor:default}.tool.no-hover:hover{background:unset}.my-node{border-radius:.2rem;padding:.4rem;font-size:1rem;color:#999;background:#f5f5f5;cursor:pointer}.my-node:hover{text-decoration:none;background:#e2e2e2}.msgs{position:fixed;margin-left:calc(50% - 25rem);width:50rem;z-index:9999;bottom:0;left:0;right:0}.msg{cursor:default;margin-bottom:2rem;background:white;display:flex;color:#000;font-size:1.4rem;box-sizing:border-box;border-radius:.4rem;box-shadow:0 0 1rem 1px silver}.msg.success .left{background:#40a9ff}.msg.warning .left{background:#c8c002}.msg.error .left{background:red}.msg .left{border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;background:#40a9ff}.msg .left svg{margin:0 .3rem;cursor:pointer}.msg .right{flex:1;padding:1rem 2rem;display:flex;justify-content:space-between;align-items:center}.line{border-bottom:1px solid #e2e2e2}.my-box{box-shadow:0 2px 3px #0000001a;border-radius:.4rem;background:white;margin-bottom:2rem;width:100%;overflow:hidden;box-sizing:border-box}.my-cell{padding:1rem;font-size:1.4rem;line-height:150%;text-align:left;border-bottom:1px solid #e2e2e2}.f14{font-size:1.4rem}.switch{width:4.5rem;height:2rem;border-radius:2rem;position:relative;display:flex;align-items:center;transition:all .3s}.switch.light{border:1px solid #e2e2e2}.switch.light.active{background:#e2e2e2}.switch.light.active:before{right:.2rem;background:white}.switch.light:before{background:#e2e2e2}.switch.gray{border:1px solid #ccc}.switch.gray.active{background:#ccc}.switch.gray.active:before{right:.2rem;background:white}.switch.gray:before{background:#ccc}.switch.isNight{border:1px solid #31475e}.switch.isNight.active{background:#31475e}.switch.isNight.active:before{right:.2rem;background:gray}.switch.isNight:before{background:#31475e}.switch:before{position:absolute;content:" ";transition:all .3s;right:calc(100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%}.modal{position:fixed;z-index:100;width:100vw;height:100vh;left:0;top:0;display:flex;justify-content:center;align-items:center}.modal .title{font-size:2.4rem;margin-bottom:1rem;text-align:center}.modal .option{display:flex;justify-content:space-between;align-items:center;padding:.6rem 0}.modal .mask{position:fixed;width:100vw;height:100vh;left:0;top:0;background:rgba(0,0,0,.3)}.radio-group2{display:inline-flex;border-radius:.5rem;overflow:hidden;border:1px solid #e2e2e2}.radio-group2 .radio{cursor:pointer;background:transparent;padding:.4rem 1rem;border-left:1px solid #e2e2e2;color:#9ca1a4;font-size:1.2rem}.radio-group2 .radio:first-child{border-left:none}.radio-group2 .active{background:#e2e2e2;color:gray}.radio-group2.isNight{border:1px solid #454847}.radio-group2.isNight .radio{border-left:1px solid #454847;color:#fff}.radio-group2.isNight .active{background:#31475e}.pop-confirm{position:relative;display:inline-flex;justify-content:center}.tip{position:fixed;background:black;color:#fff;max-width:10rem;padding:.7rem 1rem;border-radius:.5rem;transform:translate(-50%);z-index:999}input{height:3rem;outline:unset;border:1px solid #e1e1e1;padding:0 .5rem;border-radius:5px;box-sizing:border-box}.isNight .wrapper[data-v-2c468bc2]{background:#22303f!important}.isNight .wrapper .title[data-v-2c468bc2],.isNight .wrapper .option-title[data-v-2c468bc2],.isNight .wrapper .option>span[data-v-2c468bc2]{color:#a9a9a9}.isNight .wrapper .notice[data-v-2c468bc2]{color:gray!important}.setting-modal .wrapper[data-v-2c468bc2]{z-index:9;background:#f1f1f1;border-radius:.8rem;font-size:1.4rem;padding:2rem;max-height:80vh;max-width:80vw;overflow:auto}.setting-modal .wrapper .sub-title[data-v-2c468bc2]{color:gray;font-size:1.4rem}.setting-modal .wrapper .option-title[data-v-2c468bc2]{text-align:start;font-size:1.6rem;font-weight:700;margin-top:1.5rem}.setting-modal .wrapper .body[data-v-2c468bc2]{display:flex;gap:3rem}.setting-modal .wrapper .body .option-list[data-v-2c468bc2]{width:40rem}.setting-modal .wrapper .notice[data-v-2c468bc2]{font-size:12px;padding-left:3rem;text-align:left}.setting-modal .wrapper .notice a[data-v-2c468bc2]{color:#00f}.pop-confirm-content[data-v-8df5d12b]{position:fixed;background:white;padding:1.5rem;box-shadow:0 0 12px #0003;border-radius:.4rem;transform:translate(-50%,calc(-100% - 1rem));z-index:999}.pop-confirm-content .text[data-v-8df5d12b]{color:#000;text-align:start;font-size:1.4rem;width:15rem;min-width:15rem}.pop-confirm-content .options[data-v-8df5d12b]{margin-top:1.5rem;display:flex;justify-content:flex-end;align-items:center;gap:1rem;font-size:1rem}.pop-confirm-content .options div[data-v-8df5d12b]{cursor:pointer}.pop-confirm-content .options .main[data-v-8df5d12b]{color:gray;background:#e2e2e2;padding:.3rem .8rem;border-radius:.2rem}.point[data-v-810a119b]{margin-left:1rem;font-size:1.2rem;min-width:4rem;border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;flex-direction:row!important;padding:0!important}.point .up[data-v-810a119b]{display:flex;flex-direction:column;align-items:center;justify-content:center}.point .num[data-v-810a119b]{margin-left:.2rem;font-weight:700;color:#000;user-select:none}.point svg[data-v-810a119b]{width:2rem;padding:.4rem;border-radius:.2rem}.point svg[data-v-810a119b]:hover{background:#e5e5e5}.point svg.disabled[data-v-810a119b]{cursor:not-allowed}.point svg.disabled[data-v-810a119b]:hover{background:unset!important}.Author[data-v-d8c00e09]{display:flex;align-items:center;justify-content:space-between;font-size:1.2rem;position:relative;margin-bottom:.4rem}.Author.expand[data-v-d8c00e09]{margin-bottom:0}.Author .Author-left[data-v-d8c00e09]{display:flex;align-items:center;max-width:90%}.Author .Author-left .username[data-v-d8c00e09]{font-size:1.4rem;margin-right:1rem}.Author .Author-left .expand-icon[data-v-d8c00e09]{cursor:pointer;margin-right:.8rem;width:2rem;height:2rem;transform:rotate(90deg)}.Author .Author-left .avatar[data-v-d8c00e09]{margin-right:1rem;display:flex}.Author .Author-left .avatar img[data-v-d8c00e09]{width:3.4rem;height:3.4rem;border-radius:.3rem}.Author .Author-left .texts[data-v-d8c00e09]{flex:1}.Author .Author-left .op[data-v-d8c00e09]{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;margin-right:1rem;transform:scale(.8)}.Author .Author-left .mod[data-v-d8c00e09]{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;transform:scale(.8);background:#1484cd;color:#fff;margin-right:1rem}.Author .Author-left .my-tag[data-v-d8c00e09]{font-size:1.4rem;color:red;margin-left:1rem}.Author .Author-left .my-tag:hover .remove[data-v-d8c00e09]{display:inline}.Author .Author-left .my-tag .remove[data-v-d8c00e09]{cursor:pointer;margin-left:.5rem;display:none}.Author .Author-left .add-tag[data-v-d8c00e09]{font-size:2.5rem;transform:translateY(.2rem);line-height:1rem;display:inline-block;margin-left:1rem;cursor:pointer;display:none}.Author:hover .add-tag[data-v-d8c00e09]{display:inline-block}.Author .Author-right[data-v-d8c00e09]{position:absolute;right:0;display:flex;align-items:center}.Author .Author-right .toolbar[data-v-d8c00e09]{display:flex;align-items:center;color:#929596;opacity:0}.Author .Author-right .toolbar[data-v-d8c00e09]:hover{background:white;opacity:1}.Author .Author-right .floor[data-v-d8c00e09]{margin-left:1rem;font-size:1.2rem;line-height:1rem;border-radius:1rem;display:inline-block;background-color:#f0f0f0;color:#ccc;padding:.2rem .5rem;cursor:default}.Author .Author-right .isDev[data-v-d8c00e09]{color:#000!important}.post-editor-wrapper[data-v-dc3eb8bf]{width:100%;box-sizing:border-box;position:relative;overflow:hidden;transition:all .3s}.post-editor-wrapper.reply-post .post-editor[data-v-dc3eb8bf]{border:1px solid #e2e2e2;border-radius:.4rem}.post-editor-wrapper.reply-post.isFocus .post-editor[data-v-dc3eb8bf]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment[data-v-dc3eb8bf]{border:1px solid #e2e2e2;border-radius:.4rem;overflow:hidden}.post-editor-wrapper.reply-comment.isFocus[data-v-dc3eb8bf]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment .toolbar[data-v-dc3eb8bf]{background:#f6f7f8}.post-editor-wrapper .post-editor[data-v-dc3eb8bf]{transition:border .3s;width:100%;max-width:100%;padding:.6rem 1.4rem;box-sizing:border-box;border:none;outline:none;font-family:Avenir,Helvetica,Arial,sans-serif;font-size:1.4rem;min-height:13rem;resize:none}.post-editor-wrapper .toolbar[data-v-dc3eb8bf]{box-sizing:border-box;padding:.5rem 1rem;width:100%;position:relative;display:flex;justify-content:space-between;align-items:center}.post-editor-wrapper .toolbar .left[data-v-dc3eb8bf]{display:flex;gap:1rem}.post-editor-wrapper .toolbar .left svg[data-v-dc3eb8bf]{cursor:pointer}.post-editor-wrapper .toolbar .left .upload input[data-v-dc3eb8bf]{cursor:pointer;position:absolute;width:20px;height:20px;opacity:0}.post-editor-wrapper .toolbar span[data-v-dc3eb8bf]{color:gray;font-size:1.3rem}.post-editor-wrapper .get-cursor[data-v-dc3eb8bf]{transition:border .3s;width:100%;max-width:100%;padding:.6rem 1.4rem;box-sizing:border-box;border:none;outline:none;font-family:Avenir,Helvetica,Arial,sans-serif;font-size:1.4rem;min-height:13rem;resize:none;position:absolute;top:0;z-index:-100}.post-editor-wrapper .emoticon-pack[data-v-dc3eb8bf]{z-index:999999999;border-radius:1rem;padding:1rem;width:31rem;max-width:31rem;height:30rem;max-height:30rem;overflow:auto;background:white;border:1px solid #e2e8f0;box-shadow:0 9px 24px -3px #0000000f,0 4px 8px -1px #0000001f;position:fixed;bottom:11rem;left:14rem}.post-editor-wrapper .emoticon-pack i[data-v-dc3eb8bf]{cursor:pointer;position:absolute;right:2rem;font-size:2rem;color:#e2e2e2}.post-editor-wrapper .emoticon-pack .list[data-v-dc3eb8bf]{margin:1rem 0}.post-editor-wrapper .emoticon-pack img[data-v-dc3eb8bf]{cursor:pointer;width:3rem;height:3rem;padding:.5rem}.post-editor-wrapper .emoticon-pack span[data-v-dc3eb8bf]{display:inline-block;cursor:pointer;font-size:2.3rem;padding:.5rem}.isNight .emoticon-pack[data-v-dc3eb8bf]{background:#18222d;border:1px solid #737373}.v-enter-active[data-v-a77c3d96],.v-leave-active[data-v-a77c3d96]{transition:opacity .3s ease}.v-enter-from[data-v-a77c3d96],.v-leave-to[data-v-a77c3d96]{opacity:0}.username[data-v-a77c3d96]{font-weight:700;font-size:1.4rem;margin-right:1rem}.op[data-v-a77c3d96]{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;margin-right:1rem;transform:scale(.8)}.mod[data-v-a77c3d96]{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;transform:scale(.8);background:#1484cd;color:#fff;margin-right:1rem}.my-tag[data-v-a77c3d96]{font-size:1.4rem;color:red;margin-left:1rem}.my-tag:hover .remove[data-v-a77c3d96]{display:inline}.my-tag .remove[data-v-a77c3d96]{cursor:pointer;margin-left:.5rem;display:none}.floor[data-v-a77c3d96]{margin-left:1rem;font-size:1.2rem;line-height:1rem;border-radius:1rem;display:inline-block;background-color:#f0f0f0;color:#ccc;padding:.2rem .5rem;cursor:default}html[data-v-a77c3d96],body[data-v-a77c3d96]{font-size:62.5%}.flex[data-v-a77c3d96]{display:flex;align-items:center;justify-content:space-between}.flex-end[data-v-a77c3d96]{justify-content:flex-end}.flex-center[data-v-a77c3d96]{justify-content:center}.p1[data-v-a77c3d96]{padding:1rem}.p0[data-v-a77c3d96]{padding:0!important}.post-author[data-v-a77c3d96]{display:flex;align-items:center;position:relative;color:#ccc!important}.post-author>.username[data-v-a77c3d96]{font-size:1.2rem}.sticky[data-v-a77c3d96]{position:sticky;bottom:0}.sticky[stuck][data-v-a77c3d96]{box-shadow:0 2px 20px #00000059}a[data-v-a77c3d96]{color:#778087;text-decoration:none;cursor:pointer}a[data-v-a77c3d96]:hover{text-decoration:underline}.base-loading[data-v-a77c3d96]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-a77c3d96 infinite 1s linear}.loading-c[data-v-a77c3d96]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-a77c3d96 infinite 1s linear;width:3rem;height:3rem}.loading-b[data-v-a77c3d96]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-a77c3d96 infinite 1s linear;border-color:#ffffff rgba(178,177,177,.2) rgba(178,177,177,.2) rgba(178,177,177,.2);width:3rem;height:3rem}@keyframes circle-a77c3d96{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.button[data-v-a77c3d96]{cursor:pointer;padding:.4rem 2.4rem;border-radius:5px;display:inline-flex;justify-content:center;align-items:center;font-weight:700;font-size:1.2rem;color:#fff;background:#40a9ff;border:1px solid #40a9ff;user-select:none}.button[data-v-a77c3d96]:hover{opacity:.9}.button.info[data-v-a77c3d96]{color:#000;border:1px solid #40a9ff;background:white}.button.gray[data-v-a77c3d96]{color:#f5f5f5;border:1px solid #b6b6b6;background:#b6b6b6}.button.light[data-v-a77c3d96]{color:gray;border:1px solid #e2e2e2;background:#e2e2e2}.button[data-v-a77c3d96]:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-a77c3d96 infinite 1s linear;border-color:#fff transparent transparent transparent;width:1rem;height:1rem;margin-right:1rem;display:none}.button.loading[data-v-a77c3d96]{cursor:not-allowed;opacity:.5}.button.loading[data-v-a77c3d96]:before{display:block}.button.disabled[data-v-a77c3d96]{cursor:not-allowed;color:#c6c6c6;background:#8d8d8d;border:1px solid transparent}.button.isNight[data-v-a77c3d96]{color:#c6c6c6;background:#2b4054;border:1px solid transparent}.tool[data-v-a77c3d96]{position:relative;margin-left:1rem;display:flex;align-items:center;font-size:1.2rem;font-weight:700;border-radius:.2rem;cursor:pointer;height:3rem;padding:0 .5rem}.tool[data-v-a77c3d96]:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-a77c3d96 infinite 1s linear;border-color:transparent #929596 #929596 #929596;width:1rem;height:1rem;margin-left:1rem;display:none}.tool.loading[data-v-a77c3d96]{cursor:not-allowed;opacity:.5}.tool.loading[data-v-a77c3d96]:before{display:block}.tool.loading[data-v-a77c3d96]:hover{background:unset}.tool>svg[data-v-a77c3d96]{width:1.6rem!important;height:1.6rem!important;margin-right:.4rem;box-sizing:border-box;border-radius:.2rem}.tool[data-v-a77c3d96]:hover{background:#e8e8e8}.tool.no-hover[data-v-a77c3d96]{cursor:default}.tool.no-hover[data-v-a77c3d96]:hover{background:unset}.my-node[data-v-a77c3d96]{border-radius:.2rem;padding:.4rem;font-size:1rem;color:#999;background:#f5f5f5;cursor:pointer}.my-node[data-v-a77c3d96]:hover{text-decoration:none;background:#e2e2e2}.msgs[data-v-a77c3d96]{position:fixed;margin-left:calc(50% - 25rem);width:50rem;z-index:9999;bottom:0;left:0;right:0}.msg[data-v-a77c3d96]{cursor:default;margin-bottom:2rem;background:white;display:flex;color:#000;font-size:1.4rem;box-sizing:border-box;border-radius:.4rem;box-shadow:0 0 1rem 1px silver}.msg.success .left[data-v-a77c3d96]{background:#40a9ff}.msg.warning .left[data-v-a77c3d96]{background:#c8c002}.msg.error .left[data-v-a77c3d96]{background:red}.msg .left[data-v-a77c3d96]{border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;background:#40a9ff}.msg .left svg[data-v-a77c3d96]{margin:0 .3rem;cursor:pointer}.msg .right[data-v-a77c3d96]{flex:1;padding:1rem 2rem;display:flex;justify-content:space-between;align-items:center}.line[data-v-a77c3d96]{border-bottom:1px solid #e2e2e2}.my-box[data-v-a77c3d96]{box-shadow:0 2px 3px #0000001a;border-radius:.4rem;background:white;margin-bottom:2rem;width:100%;overflow:hidden;box-sizing:border-box}.my-cell[data-v-a77c3d96]{padding:1rem;font-size:1.4rem;line-height:150%;text-align:left;border-bottom:1px solid #e2e2e2}.f14[data-v-a77c3d96]{font-size:1.4rem}.switch[data-v-a77c3d96]{width:4.5rem;height:2rem;border-radius:2rem;position:relative;display:flex;align-items:center;transition:all .3s}.switch.light[data-v-a77c3d96]{border:1px solid #e2e2e2}.switch.light.active[data-v-a77c3d96]{background:#e2e2e2}.switch.light.active[data-v-a77c3d96]:before{right:.2rem;background:white}.switch.light[data-v-a77c3d96]:before{background:#e2e2e2}.switch.gray[data-v-a77c3d96]{border:1px solid #ccc}.switch.gray.active[data-v-a77c3d96]{background:#ccc}.switch.gray.active[data-v-a77c3d96]:before{right:.2rem;background:white}.switch.gray[data-v-a77c3d96]:before{background:#ccc}.switch.isNight[data-v-a77c3d96]{border:1px solid #31475e}.switch.isNight.active[data-v-a77c3d96]{background:#31475e}.switch.isNight.active[data-v-a77c3d96]:before{right:.2rem;background:gray}.switch.isNight[data-v-a77c3d96]:before{background:#31475e}.switch[data-v-a77c3d96]:before{position:absolute;content:" ";transition:all .3s;right:calc(100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%}.modal[data-v-a77c3d96]{position:fixed;z-index:100;width:100vw;height:100vh;left:0;top:0;display:flex;justify-content:center;align-items:center}.modal .title[data-v-a77c3d96]{font-size:2.4rem;margin-bottom:1rem;text-align:center}.modal .option[data-v-a77c3d96]{display:flex;justify-content:space-between;align-items:center;padding:.6rem 0}.modal .mask[data-v-a77c3d96]{position:fixed;width:100vw;height:100vh;left:0;top:0;background:rgba(0,0,0,.3)}.radio-group2[data-v-a77c3d96]{display:inline-flex;border-radius:.5rem;overflow:hidden;border:1px solid #e2e2e2}.radio-group2 .radio[data-v-a77c3d96]{cursor:pointer;background:transparent;padding:.4rem 1rem;border-left:1px solid #e2e2e2;color:#9ca1a4;font-size:1.2rem}.radio-group2 .radio[data-v-a77c3d96]:first-child{border-left:none}.radio-group2 .active[data-v-a77c3d96]{background:#e2e2e2;color:gray}.radio-group2.isNight[data-v-a77c3d96]{border:1px solid #454847}.radio-group2.isNight .radio[data-v-a77c3d96]{border-left:1px solid #454847;color:#fff}.radio-group2.isNight .active[data-v-a77c3d96]{background:#31475e}.pop-confirm[data-v-a77c3d96]{position:relative;display:inline-flex;justify-content:center}.tip[data-v-a77c3d96]{position:fixed;background:black;color:#fff;max-width:10rem;padding:.7rem 1rem;border-radius:.5rem;transform:translate(-50%);z-index:999}input[data-v-a77c3d96]{height:3rem;outline:unset;border:1px solid #e1e1e1;padding:0 .5rem;border-radius:5px;box-sizing:border-box}.html-wrapper[data-v-a77c3d96]{position:relative}.html-wrapper .mask[data-v-a77c3d96]{max-height:90rem;overflow:hidden;-webkit-mask-image:linear-gradient(180deg,#000 80%,transparent)}.html-wrapper .expand[data-v-a77c3d96]{position:absolute;z-index:1;bottom:2rem;padding:.2rem 1.5rem;border-radius:2rem;border:1px solid gray;background:white;color:gray;left:50%;transform:translate(-50%);cursor:pointer}.comment[data-v-a0031aa2]{width:100%;box-sizing:border-box;margin-top:1rem}.comment.isLevelOne[data-v-a0031aa2]{border-bottom:1px solid #ececec;padding:1rem;margin-top:0}.comment.ding[data-v-a0031aa2]{background:rgba(255,255,0,.3)!important}.comment .comment-content-w .more[data-v-a0031aa2]{text-align:center;margin:2rem 0}.comment .comment-content[data-v-a0031aa2]{display:flex;position:relative}.comment .comment-content .expand-line[data-v-a0031aa2]{cursor:pointer;width:3rem;min-width:3rem;position:relative}.comment .comment-content .expand-line[data-v-a0031aa2]:after{position:absolute;left:calc(60% - 1px);content:" ";height:100%;width:0;border-right:1px solid #ececec}.comment .comment-content .expand-line[data-v-a0031aa2]:hover:after{border-right:2px solid #0079D3}.comment .comment-content .right[data-v-a0031aa2]{flex:1;width:calc(100% - 3rem)}.comment .comment-content .right .w[data-v-a0031aa2]{padding-left:1.7rem}.comment .comment-content .right .w .post-editor-wrapper[data-v-a0031aa2]{margin-top:1rem}.wrong-wrapper[data-v-a0031aa2]{font-size:1.4rem;margin-bottom:1rem}.wrong-wrapper span[data-v-a0031aa2]{cursor:pointer}.wrong-wrapper .del-line[data-v-a0031aa2]{text-decoration:line-through}.wrong-wrapper .wrong-icon[data-v-a0031aa2]{margin-left:.5rem}.wrong-wrapper .warning[data-v-a0031aa2]{border-top:1px solid #e1e1e1;border-bottom:1px solid #e1e1e1;padding:1rem 0;margin-top:1rem;font-size:1.2rem;color:red}.toolbar[data-v-07fa3ae8]{display:flex;align-items:center;color:#929596}.comment[data-v-3eb530b9]{width:100%;box-sizing:border-box;display:flex;gap:1rem;padding:1rem;border-bottom:1px solid #e2e2e2}.comment .avatar[data-v-3eb530b9]{display:flex}.comment .avatar img[data-v-3eb530b9]{width:3.8rem;height:3.8rem;border-radius:.3rem}.comment .comment-body[data-v-3eb530b9]{flex:1;display:flex;flex-direction:column}.comment .comment-body .texts[data-v-3eb530b9]{display:flex;align-items:center}.comment .comment-body .reply_content[data-v-3eb530b9]{margin-top:1rem;max-width:calc(100% - 5rem)}.comment .isRight[data-v-3eb530b9]{align-items:flex-end}.comment .isRight .op[data-v-3eb530b9],.comment .isRight .mod[data-v-3eb530b9],.comment .isRight .username[data-v-3eb530b9]{margin:0 0 0 1rem}.comment .Author-right[data-v-3eb530b9]{display:flex;flex-direction:column;align-items:center}.comment .Author-right .floor[data-v-3eb530b9]{margin-left:0}.comment .Author-right .jump[data-v-3eb530b9]{color:#929596;margin-left:0}.comment .point[data-v-3eb530b9]{margin:0 .5rem;font-size:1.4rem;display:flex;gap:.5rem;align-items:center;font-weight:700;color:#000}.sticky{position:sticky;bottom:-2px;z-index:2}.sticky[stuck]{box-shadow:0 2px 20px #00000059!important}.Post[data-v-4038172d]{position:unset!important;background:transparent!important;overflow:unset!important}.Post .main[data-v-4038172d]{background:transparent!important;padding:unset!important;width:100%!important}.Post .close-btn[data-v-4038172d]{display:none}.post-detail[data-v-4038172d]{text-align:start;position:fixed;z-index:99;left:0;right:0;bottom:0;top:0;background:rgba(46,47,48,.8);overflow:auto;font-size:1.4rem;display:flex;justify-content:center;flex-wrap:wrap}.post-detail.isNight[data-v-4038172d]{background:rgba(46,47,48,.8)}.post-detail.isNight .main[data-v-4038172d]{background:#22303f}.post-detail.isNight .main .toolbar-wrapper[data-v-4038172d]{border-top:unset!important}.post-detail.isNight .main .button.gray[data-v-4038172d]{background:#18222d!important;border:1px solid #18222d!important}.post-detail.isNight .main .relationReply[data-v-4038172d]{color:#fff}.post-detail.isNight .main .relationReply .comments[data-v-4038172d],.post-detail.isNight .main .relationReply .my-cell[data-v-4038172d]{background:#18222d}.post-detail.isNight .main .relationReply .comment[data-v-4038172d]{border-bottom:1px solid #22303f}.post-detail.isNight .main .my-box[data-v-4038172d]{color:#fff;background:#18222d}.post-detail.isNight .main .my-box .title[data-v-4038172d],.post-detail.isNight .main .my-box .content[data-v-4038172d]{color:#d1d5d9!important}.post-detail.isNight .main .my-box .base-info[data-v-4038172d],.post-detail.isNight .main .my-box .content[data-v-4038172d]{border:1px solid #22303f!important}.post-detail.isNight .main[data-v-4038172d] .subtle .fade{color:#b2c3d4!important}.post-detail.isNight .main[data-v-4038172d] .subtle .topic_content{color:#d1d5d9!important}.post-detail.isNight .main .my-cell[data-v-4038172d]{border-bottom:1px solid #22303f!important}.post-detail.isNight .main[data-v-4038172d] .isLevelOne{border-bottom:1px solid #22303f}.post-detail.isNight .main[data-v-4038172d] .comment .expand-line:after{border-right:1px solid #22303f!important}.post-detail.isNight .main[data-v-4038172d] .comment .expand-line:hover:after{border-right:2px solid #0079D3!important}.post-detail.isNight .main[data-v-4038172d] .comment .comment-content .w>.text{color:#d1d5d9!important}.post-detail.isNight .main[data-v-4038172d] .Author-right .toolbar:hover{background:#18222d!important}.post-detail.isNight .main[data-v-4038172d] .Author-right .tool{background:#22303f!important}.post-detail.isNight .main[data-v-4038172d] .point svg:hover{background:#22303f}.post-detail.isNight .main[data-v-4038172d] .point .num{color:#d1d5d9!important}.post-detail.isNight .main[data-v-4038172d] .floor{background:#393f4e!important;color:#d1d5d9!important}.post-detail.isNight .main .editor-wrapper[data-v-4038172d]{background:#393f4e!important}.post-detail.isNight .main[data-v-4038172d] .post-editor-wrapper .post-editor{background:#18222d;border:transparent;color:#fff}.post-detail.isNight .main[data-v-4038172d] .post-editor-wrapper .toolbar{background:#393f4e!important}.post-detail.isNight .main .call-list[data-v-4038172d]{background:#22303f}.post-detail.isNight .main .call-list .call-item[data-v-4038172d]{border-top:1px solid #18222d}.post-detail.isNight .main .call-list .call-item .select[data-v-4038172d],.post-detail.isNight .main .call-list .call-item[data-v-4038172d]:hover,.post-detail.isNight .main .call-list .call-item.select[data-v-4038172d]{background-color:#393f4e;text-decoration:none}.post-detail.isNight .main .scroll-to[data-v-4038172d],.post-detail.isNight .main .close-btn[data-v-4038172d],.post-detail.isNight .main .scroll-top[data-v-4038172d],.post-detail.isNight .main .top-reply[data-v-4038172d]{color:#9caec7}.post-detail .main[data-v-4038172d]{display:flex;justify-content:flex-end;padding:3rem 8rem 15rem;background:#e2e2e2;position:relative}.post-detail .main .main-wrapper[data-v-4038172d]{width:77rem;padding-bottom:2rem;display:flex;flex-direction:column;align-items:center;position:relative}.post-detail .main .main-wrapper .post-wrapper .toolbar-wrapper[data-v-4038172d]{border-top:1px solid #e2e2e2;height:4rem;padding-left:.6rem;display:flex;align-items:center}.post-detail .main .main-wrapper .editor-wrapper .float[data-v-4038172d]{margin-right:2rem}.post-detail .main .main-wrapper .editor-wrapper .w[data-v-4038172d]{padding:1.2rem}.post-detail .main .main-wrapper .comment-wrapper .comments[data-v-4038172d]{width:100%;box-sizing:border-box}.post-detail .main .main-wrapper .loading-wrapper[data-v-4038172d]{height:20rem;display:flex;justify-content:center;align-items:center}.post-detail .main .main-wrapper #no-comments-yet[data-v-4038172d]{color:#a9a9a9;font-weight:700;text-align:center;width:100%;margin-bottom:2rem;box-sizing:border-box}.post-detail .main .relationReply[data-v-4038172d]{position:fixed;width:25vw;top:6.5rem;bottom:15rem;z-index:99;transform:translate(calc(100% + 2rem));font-size:2rem;overflow:hidden}.post-detail .main .relationReply .my-cell[data-v-4038172d]{background:white;border-radius:.5rem .5rem 0 0}.post-detail .main .relationReply .comments[data-v-4038172d]{max-height:calc(100% - 4.2rem);overflow:auto;background:white;border-radius:0 0 .5rem .5rem}.post-detail .main .call-list[data-v-4038172d]{z-index:9;position:absolute;top:12rem;border:1px solid #ccc;background-color:#fff;box-shadow:0 5px 15px #0000001a;overflow:hidden;max-height:30rem;min-width:8rem;box-sizing:content-box}.post-detail .main .call-list .call-item[data-v-4038172d]{border-top:1px solid #ccc;height:3rem;display:flex;padding:0 1rem;align-items:center;cursor:pointer;font-size:14px;box-sizing:border-box}.post-detail .main .call-list .call-item .select[data-v-4038172d],.post-detail .main .call-list .call-item[data-v-4038172d]:hover,.post-detail .main .call-list .call-item.select[data-v-4038172d]{background-color:#f0f0f0;text-decoration:none}.post-detail .main .call-list .call-item[data-v-4038172d]:nth-child(1){border-top:1px solid transparent}@media screen and (max-width: 1500px){.post-detail .main-wrapper[data-v-4038172d]{width:65vw!important}}@media screen and (max-width: 1280px){.post-detail .main-wrapper[data-v-4038172d]{width:75vw!important}}.post-detail .scroll-top[data-v-4038172d]{position:fixed;bottom:10rem;z-index:99;padding:.6rem .2rem;width:3.5rem;transform:translate(6rem);font-size:2rem;background:#f1f1f1;border:none;color:#a9a9a9}.post-detail .scroll-to[data-v-4038172d]{position:fixed;bottom:10rem;z-index:99;padding:.6rem .2rem;width:3.5rem;transform:translate(6rem);font-size:2rem;background:#f1f1f1;border:none;color:#a9a9a9;bottom:15rem;display:flex;flex-direction:column}.post-detail .scroll-to input[data-v-4038172d]{margin-top:.5rem;height:2rem;width:3.3rem;font-size:1.4rem;text-align:center;color:gray}.post-detail .read-notice[data-v-4038172d]{display:flex;align-items:center;color:gray}.post-detail .read-notice .jump[data-v-4038172d]{background:#f1f1f1;color:gray;padding:.3rem 1rem;border-radius:.4rem;margin:0 1rem;cursor:pointer}.post-detail .close-btn[data-v-4038172d]{color:#b6b6b6;cursor:pointer;position:fixed;top:3rem;transform:translate(4rem);font-size:2rem}.post-detail .top-reply[data-v-4038172d]{color:#e2e2e2;cursor:pointer;font-size:2rem;display:flex}.post-detail .top-reply i[data-v-4038172d]{padding:0 1rem}.isNight[data-v-19fe372d]{background:#22303f!important;color:#ccc!important}.base64_tooltip[data-v-19fe372d]{box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;background:white;min-height:2.2rem;max-width:20rem;padding:.8rem;position:fixed;z-index:9998;display:flex;align-items:center;border-radius:.5rem;cursor:pointer;line-break:anywhere;font-size:1.4rem;color:#000}.base64_tooltip svg[data-v-19fe372d]{margin-left:1rem;min-width:1.8rem}.base64_tooltip .button[data-v-19fe372d]{margin-top:1rem;margin-left:2rem}.isNight .wrapper[data-v-b28a2e5e]{background:#22303f!important}.isNight .wrapper .title[data-v-b28a2e5e]{color:gray}.isNight .wrapper .option[data-v-b28a2e5e]{color:#fff!important}.isNight .wrapper .option span[data-v-b28a2e5e]{color:gray!important}.isNight .wrapper .white[data-v-b28a2e5e]{color:#fff!important}.tag-modal .wrapper[data-v-b28a2e5e]{z-index:9;background:#f1f1f1;border-radius:.8rem;font-size:1.4rem;padding:2rem 6rem 4rem;width:25rem}.tag-modal .wrapper .btns[data-v-b28a2e5e]{margin-top:1.5rem;display:flex;justify-content:flex-end;align-items:center;gap:1.5rem;font-size:1rem}.tag-modal .wrapper .btns div[data-v-b28a2e5e]{cursor:pointer}.tag-modal .wrapper .btns .main[data-v-b28a2e5e]{color:gray;background:#e2e2e2;padding:.5rem 1.2rem;border-radius:.4rem}.msgs[data-v-95974c3e]{position:fixed;margin-left:calc(50% - 25rem);width:50rem;z-index:9999;bottom:0;left:0;right:0}.isNight .open-post[data-v-f9a9d2e9],.isNight .nav[data-v-f9a9d2e9]{color:#fff;background:#18222d;border-bottom:1px solid #22303f}.card[data-v-f9a9d2e9]{border-radius:0 0 .4rem .4rem;overflow:hidden}.nav[data-v-f9a9d2e9]{font-size:1.4rem;background:white;padding:1rem;border-bottom:1px solid #e2e2e2} ');
  26.  
  27. (function (vue) {
  28. 'use strict';
  29.  
  30. var PageType = /* @__PURE__ */ ((PageType2) => {
  31. PageType2["Home"] = "Home";
  32. PageType2["Node"] = "Node";
  33. PageType2["Post"] = "Post";
  34. return PageType2;
  35. })(PageType || {});
  36. const _export_sfc = (sfc, props) => {
  37. const target = sfc.__vccOpts || sfc;
  38. for (const [key, val] of props) {
  39. target[key] = val;
  40. }
  41. return target;
  42. };
  43. const _sfc_main$f = {
  44. name: "Setting",
  45. inject: ["isNight"],
  46. props: {
  47. modelValue: {
  48. type: Object,
  49. default() {
  50. return {};
  51. }
  52. },
  53. show: {
  54. type: Boolean,
  55. default() {
  56. return false;
  57. }
  58. }
  59. },
  60. data() {
  61. return {
  62. config: window.clone(this.modelValue)
  63. };
  64. },
  65. watch: {
  66. config: {
  67. handler(n) {
  68. n.topReplyLoveMinCount = Math.trunc(n.topReplyLoveMinCount);
  69. if (n.topReplyLoveMinCount < 0) {
  70. n.topReplyLoveMinCount = 1;
  71. }
  72. this.$emit("update:modelValue", n);
  73. },
  74. deep: true
  75. }
  76. },
  77. created() {
  78. }
  79. };
  80. const _withScopeId$8 = (n) => (vue.pushScopeId("data-v-2c468bc2"), n = n(), vue.popScopeId(), n);
  81. const _hoisted_1$f = { class: "wrapper" };
  82. const _hoisted_2$d = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "title" }, " 脚本设置 ", -1));
  83. const _hoisted_3$a = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "sub-title" }, " 设置自动保存到本地,下次打开依然生效 ", -1));
  84. const _hoisted_4$8 = { class: "body" };
  85. const _hoisted_5$7 = { class: "option-list" };
  86. const _hoisted_6$7 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "option-title" }, "列表:", -1));
  87. const _hoisted_7$6 = { class: "option" };
  88. const _hoisted_8$6 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "列表帖子展示方式:", -1));
  89. const _hoisted_9$6 = { class: "option" };
  90. const _hoisted_10$6 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "列表hover时显示预览按钮:", -1));
  91. const _hoisted_11$6 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " 此项需要刷新页面才能生效 ", -1));
  92. const _hoisted_12$6 = { class: "option" };
  93. const _hoisted_13$6 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "点击列表的帖子,打开详情弹框 :", -1));
  94. const _hoisted_14$6 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " 若关闭此项,点击列表的帖子时,不会打开弹框,会跳转网页 ", -1));
  95. const _hoisted_15$6 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "option-title" }, "帖子:", -1));
  96. const _hoisted_16$4 = { class: "option" };
  97. const _hoisted_17$4 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "回复展示方式:", -1));
  98. const _hoisted_18$4 = { class: "option" };
  99. const _hoisted_19$4 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "单独打开帖子时默认显示楼中楼 :", -1));
  100. const _hoisted_20$4 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " 单独打开这种地址 https://v2ex.com/t/xxxx 时,是否默认显示楼中楼 ", -1));
  101. const _hoisted_21$3 = { class: "option" };
  102. const _hoisted_22$3 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "点击左右两侧透明处关闭帖子详情弹框:", -1));
  103. const _hoisted_23$2 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "option-title" }, "点赞:", -1));
  104. const _hoisted_24$3 = { class: "option" };
  105. const _hoisted_25$2 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "显示高赞回复:", -1));
  106. const _hoisted_26$2 = { class: "option" };
  107. const _hoisted_27$2 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "最多显示多少个高赞回复:", -1));
  108. const _hoisted_28$1 = { class: "option" };
  109. const _hoisted_29$1 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "最少需要多少赞才能被判定为高赞:", -1));
  110. const _hoisted_30$1 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "option-title" }, "记忆阅读:", -1));
  111. const _hoisted_31$1 = { class: "option" };
  112. const _hoisted_32$1 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "记录上次阅读楼层(误差1层左右):", -1));
  113. const _hoisted_33$1 = { class: "option" };
  114. const _hoisted_34$1 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "打开帖子自动跳转到上次阅读楼层:", -1));
  115. const _hoisted_35$1 = { class: "option-list" };
  116. const _hoisted_36$1 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "option-title" }, "其他:", -1));
  117. const _hoisted_37 = { class: "option" };
  118. const _hoisted_38 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "显示工具栏:", -1));
  119. const _hoisted_39 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, [
  120. /* @__PURE__ */ vue.createTextVNode(" 关闭此项会隐藏以下三个工具栏 "),
  121. /* @__PURE__ */ vue.createElementVNode("div", null, " 1. 首页”卡片/表格“ "),
  122. /* @__PURE__ */ vue.createElementVNode("div", null, " 2. 详情页”楼中楼/只看楼主/感谢/V2原版“ "),
  123. /* @__PURE__ */ vue.createElementVNode("div", null, " 3. 单独打开帖子时”点击显示楼中楼“ ")
  124. ], -1));
  125. const _hoisted_40 = { class: "option" };
  126. const _hoisted_41 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "新标签页打开链接 :", -1));
  127. const _hoisted_42 = { class: "option" };
  128. const _hoisted_43 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "用户打标签(跨平台,数据保存在自己的记事本):", -1));
  129. const _hoisted_44 = { class: "option" };
  130. const _hoisted_45 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "正文超长自动折叠:", -1));
  131. const _hoisted_46 = { class: "option" };
  132. const _hoisted_47 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "划词显示Base64解码框:", -1));
  133. const _hoisted_48 = { class: "option" };
  134. const _hoisted_49 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "使用 SOV2EX 搜索:", -1));
  135. const _hoisted_50 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " 此项需要刷新页面才能生效 ", -1));
  136. const _hoisted_51 = { class: "option" };
  137. const _hoisted_52 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "帖子宽度:", -1));
  138. const _hoisted_53 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, [
  139. /* @__PURE__ */ vue.createTextVNode(" 默认为77rem。接受合法的width值: "),
  140. /* @__PURE__ */ vue.createElementVNode("a", {
  141. href: "https://vue3js.cn/interview/css/em_px_rem_vh_vw.html#%E4%BA%8C%E3%80%81%E5%8D%95%E4%BD%8D",
  142. target: "_blank"
  143. }, "rem、px、vw、vh"),
  144. /* @__PURE__ */ vue.createTextVNode("。 vw代表屏幕百分比,如想要屏幕的66%,请填写66vw ")
  145. ], -1));
  146. const _hoisted_54 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " 提示:此项设置以后,单独打开详情页时会出现帖子突然变宽(窄)的问题,暂时无解 ", -1));
  147. const _hoisted_55 = { class: "option" };
  148. const _hoisted_56 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "自动签到:", -1));
  149. const _hoisted_57 = { class: "option" };
  150. const _hoisted_58 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "自定义背景:", -1));
  151. const _hoisted_59 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, [
  152. /* @__PURE__ */ vue.createTextVNode(" 接受一个合法的css color值:例如"),
  153. /* @__PURE__ */ vue.createElementVNode("a", {
  154. href: "https://developer.mozilla.org/zh-CN/docs/Web/CSS/color_value",
  155. target: "_blank"
  156. }, "red、#ffffff、rgb(222,222,22)"),
  157. /* @__PURE__ */ vue.createTextVNode("等等。 没图片时的背景默认为 #e2e2e2。 ")
  158. ], -1));
  159. const _hoisted_60 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " 此项需要刷新页面才能生效 ", -1));
  160. const _hoisted_61 = { class: "option" };
  161. const _hoisted_62 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("span", null, "收藏时提醒添加到书签:", -1));
  162. const _hoisted_63 = /* @__PURE__ */ _withScopeId$8(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "notice" }, " V站的帐号一旦被封了,就无法登录了,账号里的收藏也就看不到了 ", -1));
  163. function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
  164. return vue.openBlock(), vue.createBlock(vue.Transition, null, {
  165. default: vue.withCtx(() => [
  166. $props.show ? (vue.openBlock(), vue.createElementBlock("div", {
  167. key: 0,
  168. class: vue.normalizeClass(["setting-modal modal", { isNight: $options.isNight }])
  169. }, [
  170. vue.createElementVNode("div", {
  171. class: "mask",
  172. onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:show", false))
  173. }),
  174. vue.createElementVNode("div", _hoisted_1$f, [
  175. _hoisted_2$d,
  176. _hoisted_3$a,
  177. vue.createElementVNode("div", _hoisted_4$8, [
  178. vue.createElementVNode("div", _hoisted_5$7, [
  179. _hoisted_6$7,
  180. vue.createElementVNode("div", _hoisted_7$6, [
  181. _hoisted_8$6,
  182. vue.createElementVNode("div", {
  183. class: vue.normalizeClass(["radio-group2", { isNight: $options.isNight }])
  184. }, [
  185. vue.createElementVNode("div", {
  186. class: vue.normalizeClass(["radio", $data.config.viewType === "table" ? "active" : ""]),
  187. onClick: _cache[1] || (_cache[1] = ($event) => $data.config.viewType = "table")
  188. }, "表格 ", 2),
  189. vue.createElementVNode("div", {
  190. class: vue.normalizeClass(["radio", $data.config.viewType === "card" ? "active" : ""]),
  191. onClick: _cache[2] || (_cache[2] = ($event) => $data.config.viewType = "card")
  192. }, "卡片 ", 2)
  193. ], 2)
  194. ]),
  195. vue.createElementVNode("div", _hoisted_9$6, [
  196. _hoisted_10$6,
  197. vue.createElementVNode("div", {
  198. class: vue.normalizeClass(["switch gray", { active: $data.config.showPreviewBtn, isNight: $options.isNight }]),
  199. onClick: _cache[3] || (_cache[3] = ($event) => $data.config.showPreviewBtn = !$data.config.showPreviewBtn)
  200. }, null, 2)
  201. ]),
  202. _hoisted_11$6,
  203. vue.createElementVNode("div", _hoisted_12$6, [
  204. _hoisted_13$6,
  205. vue.createElementVNode("div", {
  206. class: vue.normalizeClass(["switch gray", { active: $data.config.clickPostItemOpenDetail, isNight: $options.isNight }]),
  207. onClick: _cache[4] || (_cache[4] = ($event) => $data.config.clickPostItemOpenDetail = !$data.config.clickPostItemOpenDetail)
  208. }, null, 2)
  209. ]),
  210. _hoisted_14$6,
  211. _hoisted_15$6,
  212. vue.createElementVNode("div", _hoisted_16$4, [
  213. _hoisted_17$4,
  214. vue.createElementVNode("div", {
  215. class: vue.normalizeClass(["radio-group2", { isNight: $options.isNight }])
  216. }, [
  217. vue.createElementVNode("div", {
  218. class: vue.normalizeClass(["radio", $data.config.commentDisplayType === 0 ? "active" : ""]),
  219. onClick: _cache[5] || (_cache[5] = ($event) => $data.config.commentDisplayType = 0)
  220. }, "楼中楼 ", 2),
  221. vue.createElementVNode("div", {
  222. class: vue.normalizeClass(["radio", $data.config.commentDisplayType === 1 ? "active" : ""]),
  223. onClick: _cache[6] || (_cache[6] = ($event) => $data.config.commentDisplayType = 1)
  224. }, "感谢 ", 2),
  225. vue.createElementVNode("div", {
  226. class: vue.normalizeClass(["radio", $data.config.commentDisplayType === 3 ? "active" : ""]),
  227. onClick: _cache[7] || (_cache[7] = ($event) => $data.config.commentDisplayType = 3)
  228. }, "只看楼主 ", 2),
  229. vue.createElementVNode("div", {
  230. class: vue.normalizeClass(["radio", $data.config.commentDisplayType === 2 ? "active" : ""]),
  231. onClick: _cache[8] || (_cache[8] = ($event) => $data.config.commentDisplayType = 2)
  232. }, "V2原版 ", 2)
  233. ], 2)
  234. ]),
  235. vue.createElementVNode("div", _hoisted_18$4, [
  236. _hoisted_19$4,
  237. vue.createElementVNode("div", {
  238. class: vue.normalizeClass(["switch gray", { active: $data.config.autoOpenDetail, isNight: $options.isNight }]),
  239. onClick: _cache[9] || (_cache[9] = ($event) => $data.config.autoOpenDetail = !$data.config.autoOpenDetail)
  240. }, null, 2)
  241. ]),
  242. _hoisted_20$4,
  243. vue.createElementVNode("div", _hoisted_21$3, [
  244. _hoisted_22$3,
  245. vue.createElementVNode("div", {
  246. class: vue.normalizeClass(["switch gray", { active: $data.config.closePostDetailBySpace, isNight: $options.isNight }]),
  247. onClick: _cache[10] || (_cache[10] = ($event) => $data.config.closePostDetailBySpace = !$data.config.closePostDetailBySpace)
  248. }, null, 2)
  249. ]),
  250. _hoisted_23$2,
  251. vue.createElementVNode("div", _hoisted_24$3, [
  252. _hoisted_25$2,
  253. vue.createElementVNode("div", {
  254. class: vue.normalizeClass(["switch gray", { active: $data.config.showTopReply, isNight: $options.isNight }]),
  255. onClick: _cache[11] || (_cache[11] = ($event) => $data.config.showTopReply = !$data.config.showTopReply)
  256. }, null, 2)
  257. ]),
  258. vue.createElementVNode("div", _hoisted_26$2, [
  259. _hoisted_27$2,
  260. vue.withDirectives(vue.createElementVNode("input", {
  261. type: "number",
  262. min: "1",
  263. "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => $data.config.topReplyCount = $event)
  264. }, null, 512), [
  265. [vue.vModelText, $data.config.topReplyCount]
  266. ])
  267. ]),
  268. vue.createElementVNode("div", _hoisted_28$1, [
  269. _hoisted_29$1,
  270. vue.withDirectives(vue.createElementVNode("input", {
  271. type: "number",
  272. min: "1",
  273. "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => $data.config.topReplyLoveMinCount = $event)
  274. }, null, 512), [
  275. [vue.vModelText, $data.config.topReplyLoveMinCount]
  276. ])
  277. ]),
  278. _hoisted_30$1,
  279. vue.createElementVNode("div", _hoisted_31$1, [
  280. _hoisted_32$1,
  281. vue.createElementVNode("div", {
  282. class: vue.normalizeClass(["switch gray", { active: $data.config.rememberLastReadFloor, isNight: $options.isNight }]),
  283. onClick: _cache[14] || (_cache[14] = ($event) => {
  284. $data.config.rememberLastReadFloor = !$data.config.rememberLastReadFloor;
  285. $data.config.autoJumpLastReadFloor = false;
  286. })
  287. }, null, 2)
  288. ]),
  289. vue.createElementVNode("div", _hoisted_33$1, [
  290. _hoisted_34$1,
  291. vue.createElementVNode("div", {
  292. class: vue.normalizeClass(["switch gray", { active: $data.config.autoJumpLastReadFloor, isNight: $options.isNight }]),
  293. onClick: _cache[15] || (_cache[15] = ($event) => $data.config.autoJumpLastReadFloor = !$data.config.autoJumpLastReadFloor)
  294. }, null, 2)
  295. ])
  296. ]),
  297. vue.createElementVNode("div", _hoisted_35$1, [
  298. _hoisted_36$1,
  299. vue.createElementVNode("div", _hoisted_37, [
  300. _hoisted_38,
  301. vue.createElementVNode("div", {
  302. class: vue.normalizeClass(["switch gray", { active: $data.config.showToolbar, isNight: $options.isNight }]),
  303. onClick: _cache[16] || (_cache[16] = ($event) => $data.config.showToolbar = !$data.config.showToolbar)
  304. }, null, 2)
  305. ]),
  306. _hoisted_39,
  307. vue.createElementVNode("div", _hoisted_40, [
  308. _hoisted_41,
  309. vue.createElementVNode("div", {
  310. class: vue.normalizeClass(["switch gray", { active: $data.config.newTabOpen, isNight: $options.isNight }]),
  311. onClick: _cache[17] || (_cache[17] = ($event) => {
  312. $data.config.newTabOpen = !$data.config.newTabOpen;
  313. $data.config.clickPostItemOpenDetail = !$data.config.newTabOpen;
  314. })
  315. }, null, 2)
  316. ]),
  317. vue.createElementVNode("div", _hoisted_42, [
  318. _hoisted_43,
  319. vue.createElementVNode("div", {
  320. class: vue.normalizeClass(["switch gray", { active: $data.config.openTag, isNight: $options.isNight }]),
  321. onClick: _cache[18] || (_cache[18] = ($event) => $data.config.openTag = !$data.config.openTag)
  322. }, null, 2)
  323. ]),
  324. vue.createElementVNode("div", _hoisted_44, [
  325. _hoisted_45,
  326. vue.createElementVNode("div", {
  327. class: vue.normalizeClass(["switch gray", { active: $data.config.contentAutoCollapse, isNight: $options.isNight }]),
  328. onClick: _cache[19] || (_cache[19] = ($event) => $data.config.contentAutoCollapse = !$data.config.contentAutoCollapse)
  329. }, null, 2)
  330. ]),
  331. vue.createElementVNode("div", _hoisted_46, [
  332. _hoisted_47,
  333. vue.createElementVNode("div", {
  334. class: vue.normalizeClass(["switch gray", { active: $data.config.base64, isNight: $options.isNight }]),
  335. onClick: _cache[20] || (_cache[20] = ($event) => $data.config.base64 = !$data.config.base64)
  336. }, null, 2)
  337. ]),
  338. vue.createElementVNode("div", _hoisted_48, [
  339. _hoisted_49,
  340. vue.createElementVNode("div", {
  341. class: vue.normalizeClass(["switch gray", { active: $data.config.sov2ex, isNight: $options.isNight }]),
  342. onClick: _cache[21] || (_cache[21] = ($event) => $data.config.sov2ex = !$data.config.sov2ex)
  343. }, null, 2)
  344. ]),
  345. _hoisted_50,
  346. vue.createElementVNode("div", _hoisted_51, [
  347. _hoisted_52,
  348. vue.withDirectives(vue.createElementVNode("input", {
  349. type: "text",
  350. "onUpdate:modelValue": _cache[22] || (_cache[22] = ($event) => $data.config.postWidth = $event)
  351. }, null, 512), [
  352. [vue.vModelText, $data.config.postWidth]
  353. ])
  354. ]),
  355. _hoisted_53,
  356. _hoisted_54,
  357. vue.createElementVNode("div", _hoisted_55, [
  358. _hoisted_56,
  359. vue.createElementVNode("div", {
  360. class: vue.normalizeClass(["switch gray", { active: $data.config.autoSignin, isNight: $options.isNight }]),
  361. onClick: _cache[23] || (_cache[23] = ($event) => $data.config.autoSignin = !$data.config.autoSignin)
  362. }, null, 2)
  363. ]),
  364. vue.createElementVNode("div", _hoisted_57, [
  365. _hoisted_58,
  366. vue.withDirectives(vue.createElementVNode("input", {
  367. type: "text",
  368. "onUpdate:modelValue": _cache[24] || (_cache[24] = ($event) => $data.config.customBgColor = $event)
  369. }, null, 512), [
  370. [vue.vModelText, $data.config.customBgColor]
  371. ])
  372. ]),
  373. _hoisted_59,
  374. _hoisted_60,
  375. vue.createElementVNode("div", _hoisted_61, [
  376. _hoisted_62,
  377. vue.createElementVNode("div", {
  378. class: vue.normalizeClass(["switch gray", { active: $data.config.collectBrowserNotice, isNight: $options.isNight }]),
  379. onClick: _cache[25] || (_cache[25] = ($event) => $data.config.collectBrowserNotice = !$data.config.collectBrowserNotice)
  380. }, null, 2)
  381. ]),
  382. _hoisted_63
  383. ])
  384. ])
  385. ])
  386. ], 2)) : vue.createCommentVNode("", true)
  387. ]),
  388. _: 1
  389. });
  390. }
  391. const Setting = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$9], ["__scopeId", "data-v-2c468bc2"]]);
  392. const eventBus = {
  393. eventMap: /* @__PURE__ */ new Map(),
  394. on(eventType, cb) {
  395. let cbs = this.eventMap.get(eventType);
  396. if (cbs) {
  397. cbs.push(cb);
  398. } else {
  399. cbs = [cb];
  400. }
  401. this.eventMap.set(eventType, cbs);
  402. },
  403. emit(eventType, val) {
  404. let cbs = this.eventMap.get(eventType);
  405. if (cbs) {
  406. cbs.map((cb) => cb(val));
  407. }
  408. },
  409. off(eventType) {
  410. let cbs = this.eventMap.has(eventType);
  411. if (cbs) {
  412. this.eventMap.delete(eventType);
  413. }
  414. },
  415. clear() {
  416. this.eventMap = /* @__PURE__ */ new Map();
  417. }
  418. };
  419. const CMD = {
  420. SHOW_TOOLTIP: "SHOW_TOOLTIP",
  421. SHOW_MSG: "SHOW_MSG",
  422. SET_CALL: "SET_CALL",
  423. SHOW_CALL: "SHOW_CALL",
  424. REFRESH_ONCE: "REFRESH_ONCE",
  425. ADD_REPLY: "ADD_REPLY",
  426. IGNORE: "IGNORE",
  427. MERGE: "MERGE",
  428. REMOVE: "REMOVE",
  429. CHANGE_COMMENT_THANK: "CHANGE_COMMENT_THANK",
  430. CHANGE_POST_THANK: "CHANGE_POST_THANK",
  431. ADD_TAG: "ADD_TAG",
  432. REMOVE_TAG: "REMOVE_TAG",
  433. RELATION_REPLY: "RELATION_REPLY",
  434. JUMP: "JUMP",
  435. ADD_READ: "ADD_READ"
  436. };
  437. const _sfc_main$e = {
  438. name: "PopConfirm",
  439. props: {
  440. title: {
  441. type: String,
  442. default() {
  443. return "";
  444. }
  445. },
  446. disabled: {
  447. type: Boolean,
  448. default() {
  449. return false;
  450. }
  451. }
  452. },
  453. data() {
  454. return {
  455. show: false
  456. };
  457. },
  458. methods: {
  459. showPop(e) {
  460. if (this.disabled)
  461. return;
  462. let rect = e.target.getBoundingClientRect();
  463. this.show = true;
  464. vue.nextTick(() => {
  465. this.$refs.tip.style.top = rect.top + "px";
  466. this.$refs.tip.style.left = rect.left + rect.width / 2 - 50 + "px";
  467. });
  468. },
  469. confirm() {
  470. this.show = false;
  471. this.$emit("confirm");
  472. }
  473. }
  474. };
  475. const _hoisted_1$e = { class: "pop-confirm" };
  476. const _hoisted_2$c = {
  477. key: 0,
  478. ref: "tip",
  479. class: "pop-confirm-content"
  480. };
  481. const _hoisted_3$9 = { class: "text" };
  482. const _hoisted_4$7 = { class: "options" };
  483. function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
  484. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
  485. (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
  486. vue.createVNode(vue.Transition, null, {
  487. default: vue.withCtx(() => [
  488. $data.show ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$c, [
  489. vue.createElementVNode("div", _hoisted_3$9, vue.toDisplayString($props.title), 1),
  490. vue.createElementVNode("div", _hoisted_4$7, [
  491. vue.createElementVNode("div", {
  492. onClick: _cache[0] || (_cache[0] = ($event) => $data.show = false)
  493. }, "取消"),
  494. vue.createElementVNode("div", {
  495. class: "main",
  496. onClick: _cache[1] || (_cache[1] = (...args) => $options.confirm && $options.confirm(...args))
  497. }, "确认")
  498. ])
  499. ], 512)) : vue.createCommentVNode("", true)
  500. ]),
  501. _: 1
  502. })
  503. ])),
  504. vue.createElementVNode("span", {
  505. onClick: _cache[2] || (_cache[2] = (...args) => $options.showPop && $options.showPop(...args))
  506. }, [
  507. vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
  508. ])
  509. ]);
  510. }
  511. const PopConfirm = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$8], ["__scopeId", "data-v-8df5d12b"]]);
  512. const loveColor = "rgb(224,42,42)";
  513. const _sfc_main$d = {
  514. name: "Point",
  515. components: { PopConfirm },
  516. inject: ["post", "isLogin"],
  517. props: {
  518. item: {
  519. type: Object,
  520. default() {
  521. return {};
  522. }
  523. },
  524. full: {
  525. type: Boolean,
  526. default() {
  527. return true;
  528. }
  529. },
  530. apiUrl: ""
  531. },
  532. computed: {
  533. disabled() {
  534. return this.item.username === window.user.username || this.item.isThanked || !this.isLogin;
  535. }
  536. },
  537. methods: {
  538. getColor() {
  539. if (this.item.isThanked)
  540. return loveColor;
  541. return this.full ? loveColor : "#929596";
  542. },
  543. getIsFull() {
  544. if (this.item.isThanked)
  545. return loveColor;
  546. return this.full ? loveColor : "none";
  547. },
  548. thankError() {
  549. if (this.item.username === window.user.username) {
  550. return eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "不能感谢自己" });
  551. }
  552. if (this.item.isThanked) {
  553. return eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "已经感谢过了" });
  554. }
  555. if (!this.isLogin) {
  556. return eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "请先登录!" });
  557. }
  558. },
  559. async thank() {
  560. this.$emit("addThank");
  561. let url = `${window.baseUrl}/thank/${this.apiUrl}?once=${this.post.once}`;
  562. $.post(url).then((res) => {
  563. if (!res.success) {
  564. this.$emit("recallThank");
  565. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: res.message });
  566. }
  567. eventBus.emit(CMD.REFRESH_ONCE, res.once);
  568. }, (err) => {
  569. this.$emit("recallThank");
  570. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "感谢失败" });
  571. eventBus.emit(CMD.REFRESH_ONCE);
  572. });
  573. }
  574. }
  575. };
  576. const _hoisted_1$d = { class: "point" };
  577. const _hoisted_2$b = ["fill", "stroke"];
  578. const _hoisted_3$8 = { class: "num" };
  579. function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
  580. const _component_PopConfirm = vue.resolveComponent("PopConfirm");
  581. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, [
  582. vue.createVNode(_component_PopConfirm, {
  583. disabled: $options.disabled,
  584. title: `确认花费 10 个铜币向 @${$props.item.username} 的这条回复发送感谢?`,
  585. onConfirm: $options.thank
  586. }, {
  587. default: vue.withCtx(() => [
  588. vue.createElementVNode("div", {
  589. class: "up",
  590. onClick: _cache[0] || (_cache[0] = (...args) => $options.thankError && $options.thankError(...args))
  591. }, [
  592. (vue.openBlock(), vue.createElementBlock("svg", {
  593. class: vue.normalizeClass({ disabled: $options.disabled }),
  594. width: "19",
  595. height: "19",
  596. viewBox: "0 0 48 48",
  597. fill: "none",
  598. xmlns: "http://www.w3.org/2000/svg"
  599. }, [
  600. vue.createElementVNode("path", {
  601. d: "M15 8C8.92487 8 4 12.9249 4 19C4 30 17 40 24 42.3262C31 40 44 30 44 19C44 12.9249 39.0751 8 33 8C29.2797 8 25.9907 9.8469 24 12.6738C22.0093 9.8469 18.7203 8 15 8Z",
  602. fill: $options.getIsFull(),
  603. stroke: $options.getColor(),
  604. "stroke-width": "2",
  605. "stroke-linecap": "round",
  606. "stroke-linejoin": "round"
  607. }, null, 8, _hoisted_2$b)
  608. ], 2))
  609. ])
  610. ]),
  611. _: 1
  612. }, 8, ["disabled", "title", "onConfirm"]),
  613. vue.createElementVNode("div", _hoisted_3$8, vue.toDisplayString($props.item.thankCount ? $props.item.thankCount : "感谢"), 1)
  614. ]);
  615. }
  616. const Point = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$7], ["__scopeId", "data-v-810a119b"]]);
  617. const _sfc_main$c = {
  618. name: "Author",
  619. components: { PopConfirm, Point },
  620. inject: ["isLogin", "tags", "config"],
  621. props: {
  622. modelValue: false,
  623. comment: {
  624. type: Object,
  625. default() {
  626. return {};
  627. }
  628. },
  629. type: {
  630. type: String,
  631. default() {
  632. return "list";
  633. }
  634. }
  635. },
  636. computed: {
  637. isDev() {
  638. return false;
  639. },
  640. pointInfo() {
  641. return {
  642. isThanked: this.comment.isThanked,
  643. thankCount: this.comment.thankCount,
  644. username: this.comment.username
  645. };
  646. },
  647. myTags() {
  648. return this.tags[this.comment.username] ?? [];
  649. },
  650. context() {
  651. return this.comment.replyUsers.length;
  652. }
  653. },
  654. methods: {
  655. jump() {
  656. eventBus.emit(CMD.JUMP, this.comment.floor);
  657. },
  658. showRelationReply() {
  659. if (!this.comment.replyUsers.length) {
  660. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "该回复无上下文" });
  661. return;
  662. }
  663. eventBus.emit(CMD.RELATION_REPLY, {
  664. left: this.comment.replyUsers,
  665. right: this.comment.username,
  666. rightFloor: this.comment.floor
  667. });
  668. },
  669. addTag() {
  670. eventBus.emit(CMD.ADD_TAG, this.comment.username);
  671. },
  672. removeTag(tag) {
  673. eventBus.emit(CMD.REMOVE_TAG, { username: this.comment.username, tag });
  674. },
  675. checkIsLogin(emitName = "") {
  676. if (!this.isLogin) {
  677. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "请先登录!" });
  678. return false;
  679. }
  680. this.$emit(emitName);
  681. return true;
  682. },
  683. addThank() {
  684. eventBus.emit(CMD.CHANGE_COMMENT_THANK, { id: this.comment.id, type: "add" });
  685. },
  686. recallThank() {
  687. eventBus.emit(CMD.CHANGE_COMMENT_THANK, { id: this.comment.id, type: "recall" });
  688. }
  689. }
  690. };
  691. const _withScopeId$7 = (n) => (vue.pushScopeId("data-v-d8c00e09"), n = n(), vue.popScopeId(), n);
  692. const _hoisted_1$c = { class: "Author-left" };
  693. const _hoisted_2$a = /* @__PURE__ */ _withScopeId$7(() => /* @__PURE__ */ vue.createElementVNode("path", {
  694. d: "M22 42H6V26",
  695. stroke: "#177EC9",
  696. "stroke-width": "4",
  697. "stroke-linecap": "round",
  698. "stroke-linejoin": "round"
  699. }, null, -1));
  700. const _hoisted_3$7 = /* @__PURE__ */ _withScopeId$7(() => /* @__PURE__ */ vue.createElementVNode("path", {
  701. d: "M26 6H42V22",
  702. stroke: "#177EC9",
  703. "stroke-width": "4",
  704. "stroke-linecap": "round",
  705. "stroke-linejoin": "round"
  706. }, null, -1));
  707. const _hoisted_4$6 = [
  708. _hoisted_2$a,
  709. _hoisted_3$7
  710. ];
  711. const _hoisted_5$6 = ["href"];
  712. const _hoisted_6$6 = ["src"];
  713. const _hoisted_7$5 = { class: "texts" };
  714. const _hoisted_8$5 = ["href"];
  715. const _hoisted_9$5 = {
  716. key: 0,
  717. class: "op"
  718. };
  719. const _hoisted_10$5 = {
  720. key: 1,
  721. class: "mod"
  722. };
  723. const _hoisted_11$5 = { class: "ago" };
  724. const _hoisted_12$5 = { class: "my-tag" };
  725. const _hoisted_13$5 = /* @__PURE__ */ _withScopeId$7(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-tag" }, null, -1));
  726. const _hoisted_14$5 = ["onClick"];
  727. const _hoisted_15$5 = { class: "Author-right" };
  728. const _hoisted_16$3 = {
  729. key: 0,
  730. class: "toolbar"
  731. };
  732. const _hoisted_17$3 = /* @__PURE__ */ _withScopeId$7(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "tool" }, [
  733. /* @__PURE__ */ vue.createElementVNode("span", null, "隐藏")
  734. ], -1));
  735. const _hoisted_18$3 = /* @__PURE__ */ _withScopeId$7(() => /* @__PURE__ */ vue.createElementVNode("span", null, "上下文", -1));
  736. const _hoisted_19$3 = [
  737. _hoisted_18$3
  738. ];
  739. const _hoisted_20$3 = /* @__PURE__ */ _withScopeId$7(() => /* @__PURE__ */ vue.createElementVNode("span", null, "跳转", -1));
  740. const _hoisted_21$2 = [
  741. _hoisted_20$3
  742. ];
  743. const _hoisted_22$2 = /* @__PURE__ */ vue.createStaticVNode('<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-d8c00e09><path d="M4 6H44V36H29L24 41L19 36H4V6Z" fill="none" stroke="#929596" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-d8c00e09></path><path d="M23 21H25.0025" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-d8c00e09></path><path d="M33.001 21H34.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-d8c00e09></path><path d="M13.001 21H14.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-d8c00e09></path></svg><span data-v-d8c00e09>回复</span>', 2);
  744. const _hoisted_24$2 = [
  745. _hoisted_22$2
  746. ];
  747. function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
  748. const _component_PopConfirm = vue.resolveComponent("PopConfirm");
  749. const _component_Point = vue.resolveComponent("Point");
  750. return vue.openBlock(), vue.createElementBlock("div", {
  751. class: vue.normalizeClass(["Author", { expand: !$props.modelValue }])
  752. }, [
  753. vue.createElementVNode("div", _hoisted_1$c, [
  754. !$props.modelValue ? (vue.openBlock(), vue.createElementBlock("svg", {
  755. key: 0,
  756. class: "expand-icon",
  757. onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:modelValue", true)),
  758. width: "24",
  759. height: "24",
  760. viewBox: "0 0 48 48",
  761. fill: "none",
  762. xmlns: "http://www.w3.org/2000/svg"
  763. }, _hoisted_4$6)) : vue.createCommentVNode("", true),
  764. vue.createElementVNode("a", {
  765. class: "avatar",
  766. href: `/member/${$props.comment.username}`
  767. }, [
  768. vue.createElementVNode("img", {
  769. src: $props.comment.avatar,
  770. alt: ""
  771. }, null, 8, _hoisted_6$6)
  772. ], 8, _hoisted_5$6),
  773. vue.createElementVNode("span", _hoisted_7$5, [
  774. vue.createElementVNode("strong", null, [
  775. vue.createElementVNode("a", {
  776. href: `/member/${$props.comment.username}`,
  777. class: "username"
  778. }, vue.toDisplayString($props.comment.username), 9, _hoisted_8$5)
  779. ]),
  780. $props.comment.isOp ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_9$5, "OP")) : vue.createCommentVNode("", true),
  781. $props.comment.isMod ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10$5, "MOD")) : vue.createCommentVNode("", true),
  782. vue.createElementVNode("span", _hoisted_11$5, vue.toDisplayString($props.comment.date), 1),
  783. $options.isLogin && $options.config.openTag ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
  784. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($options.myTags, (i) => {
  785. return vue.openBlock(), vue.createElementBlock("span", _hoisted_12$5, [
  786. _hoisted_13$5,
  787. vue.createElementVNode("span", null, vue.toDisplayString(i), 1),
  788. vue.createElementVNode("i", {
  789. class: "fa fa-trash-o remove",
  790. onClick: ($event) => $options.removeTag(i)
  791. }, null, 8, _hoisted_14$5)
  792. ]);
  793. }), 256)),
  794. vue.createElementVNode("span", {
  795. class: "add-tag ago",
  796. onClick: _cache[1] || (_cache[1] = (...args) => $options.addTag && $options.addTag(...args)),
  797. title: "添加标签"
  798. }, "+")
  799. ], 64)) : vue.createCommentVNode("", true)
  800. ])
  801. ]),
  802. vue.createElementVNode("div", _hoisted_15$5, [
  803. $options.isLogin ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_16$3, [
  804. vue.createVNode(_component_PopConfirm, {
  805. title: "确认隐藏这条回复?",
  806. onConfirm: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("hide"))
  807. }, {
  808. default: vue.withCtx(() => [
  809. _hoisted_17$3
  810. ]),
  811. _: 1
  812. }),
  813. $options.context ? (vue.openBlock(), vue.createElementBlock("div", {
  814. key: 0,
  815. class: "tool",
  816. onClick: _cache[3] || (_cache[3] = (...args) => $options.showRelationReply && $options.showRelationReply(...args))
  817. }, _hoisted_19$3)) : vue.createCommentVNode("", true),
  818. $props.type === "top" ? (vue.openBlock(), vue.createElementBlock("div", {
  819. key: 1,
  820. class: "tool",
  821. onClick: _cache[4] || (_cache[4] = (...args) => $options.jump && $options.jump(...args))
  822. }, _hoisted_21$2)) : vue.createCommentVNode("", true),
  823. vue.createElementVNode("div", {
  824. class: "tool",
  825. onClick: _cache[5] || (_cache[5] = ($event) => $options.checkIsLogin("reply"))
  826. }, _hoisted_24$2),
  827. vue.withDirectives(vue.createVNode(_component_Point, {
  828. item: $options.pointInfo,
  829. onAddThank: $options.addThank,
  830. onRecallThank: $options.recallThank,
  831. "api-url": "reply/" + $props.comment.id
  832. }, null, 8, ["item", "onAddThank", "onRecallThank", "api-url"]), [
  833. [vue.vShow, !$props.comment.thankCount]
  834. ])
  835. ])) : vue.createCommentVNode("", true),
  836. vue.withDirectives(vue.createVNode(_component_Point, {
  837. item: $options.pointInfo,
  838. onAddThank: $options.addThank,
  839. onRecallThank: $options.recallThank,
  840. "api-url": "reply/" + $props.comment.id
  841. }, null, 8, ["item", "onAddThank", "onRecallThank", "api-url"]), [
  842. [vue.vShow, $props.comment.thankCount]
  843. ]),
  844. vue.createElementVNode("div", {
  845. class: vue.normalizeClass(["floor", { isDev: $options.isDev }])
  846. }, vue.toDisplayString($options.isDev ? `a${$props.comment.floor}-` : $props.comment.floor), 3)
  847. ])
  848. ], 2);
  849. }
  850. const Author = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$6], ["__scopeId", "data-v-d8c00e09"]]);
  851. const _withScopeId$6 = (n) => (vue.pushScopeId("data-v-dc3eb8bf"), n = n(), vue.popScopeId(), n);
  852. const _hoisted_1$b = { class: "get-cursor" };
  853. const _hoisted_2$9 = ["innerHTML"];
  854. const _hoisted_3$6 = { class: "toolbar" };
  855. const _hoisted_4$5 = { class: "left" };
  856. const _hoisted_5$5 = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.createElementVNode("path", {
  857. d: "M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",
  858. fill: "none",
  859. stroke: "#929596",
  860. "stroke-width": "2",
  861. "stroke-linejoin": "round"
  862. }, null, -1));
  863. const _hoisted_6$5 = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.createElementVNode("path", {
  864. d: "M24 35C29 35 31 31 31 31H17C17 31 19 35 24 35Z",
  865. stroke: "#929596",
  866. "stroke-width": "2",
  867. "stroke-linecap": "round",
  868. "stroke-linejoin": "round"
  869. }, null, -1));
  870. const _hoisted_7$4 = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.createElementVNode("path", {
  871. d: "M31 18V22",
  872. stroke: "#929596",
  873. "stroke-width": "2",
  874. "stroke-linecap": "round",
  875. "stroke-linejoin": "round"
  876. }, null, -1));
  877. const _hoisted_8$4 = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.createElementVNode("path", {
  878. d: "M17 18V22",
  879. stroke: "#929596",
  880. "stroke-width": "2",
  881. "stroke-linecap": "round",
  882. "stroke-linejoin": "round"
  883. }, null, -1));
  884. const _hoisted_9$4 = [
  885. _hoisted_5$5,
  886. _hoisted_6$5,
  887. _hoisted_7$4,
  888. _hoisted_8$4
  889. ];
  890. const _hoisted_10$4 = { class: "upload" };
  891. const _hoisted_11$4 = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.createElementVNode("svg", {
  892. width: "20",
  893. height: "20",
  894. viewBox: "0 0 48 48",
  895. fill: "none",
  896. xmlns: "http://www.w3.org/2000/svg"
  897. }, [
  898. /* @__PURE__ */ vue.createElementVNode("path", {
  899. "fill-rule": "evenodd",
  900. "clip-rule": "evenodd",
  901. d: "M5 10C5 8.89543 5.89543 8 7 8L41 8C42.1046 8 43 8.89543 43 10V38C43 39.1046 42.1046 40 41 40H7C5.89543 40 5 39.1046 5 38V10Z",
  902. stroke: "#929596",
  903. "stroke-width": "2",
  904. "stroke-linecap": "round",
  905. "stroke-linejoin": "round"
  906. }),
  907. /* @__PURE__ */ vue.createElementVNode("path", {
  908. "fill-rule": "evenodd",
  909. "clip-rule": "evenodd",
  910. d: "M14.5 18C15.3284 18 16 17.3284 16 16.5C16 15.6716 15.3284 15 14.5 15C13.6716 15 13 15.6716 13 16.5C13 17.3284 13.6716 18 14.5 18Z",
  911. stroke: "#929596",
  912. "stroke-width": "2",
  913. "stroke-linecap": "round",
  914. "stroke-linejoin": "round"
  915. }),
  916. /* @__PURE__ */ vue.createElementVNode("path", {
  917. d: "M15 24L20 28L26 21L43 34V38C43 39.1046 42.1046 40 41 40H7C5.89543 40 5 39.1046 5 38V34L15 24Z",
  918. fill: "none",
  919. stroke: "#929596",
  920. "stroke-width": "2",
  921. "stroke-linejoin": "round"
  922. })
  923. ], -1));
  924. const _hoisted_12$4 = {
  925. key: 0,
  926. style: { "color": "black", "font-size": "1.4rem" }
  927. };
  928. const _hoisted_13$4 = { class: "right" };
  929. const _hoisted_14$4 = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "title" }, "经典表情", -1));
  930. const _hoisted_15$4 = { class: "list" };
  931. const _hoisted_16$2 = ["src", "onClick"];
  932. const _hoisted_17$2 = { class: "emoji" };
  933. const _hoisted_18$2 = { class: "title" };
  934. const _hoisted_19$2 = { class: "list" };
  935. const _hoisted_20$2 = ["onClick"];
  936. const _sfc_main$b = {
  937. __name: "PostEditor",
  938. props: {
  939. replyUser: null,
  940. replyFloor: null,
  941. useType: {
  942. type: String,
  943. default() {
  944. return "reply-comment";
  945. }
  946. }
  947. },
  948. emits: ["close"],
  949. setup(__props, { expose, emit: emits }) {
  950. const props = __props;
  951. const { replyUser, replyFloor, useType } = props;
  952. const replyInfo = replyUser ? `@${replyUser} #${replyFloor} ` : "";
  953. const post = vue.inject("post");
  954. const show = vue.inject("show");
  955. const isNight = vue.inject("isNight");
  956. vue.inject("pageType");
  957. const allReplyUsers = vue.inject("allReplyUsers");
  958. let isFocus = vue.ref(false);
  959. const loading = vue.ref(false);
  960. const uploadLoading = vue.ref(false);
  961. const isShowEmoticons = vue.ref(false);
  962. const editorId = vue.ref("editorId_" + Date.now());
  963. const content = vue.ref(replyInfo);
  964. const txtRef = vue.ref(null);
  965. const cursorRef = vue.ref(null);
  966. const emoticonsRef = vue.ref(null);
  967. const none = vue.ref('<span style="white-space:pre-wrap;"> </span>');
  968. const emojiEmoticons = [
  969. {
  970. title: "小黄脸",
  971. list: [
  972. "😀",
  973. "😁",
  974. "😂",
  975. "🤣",
  976. "😅",
  977. "😊",
  978. "😋",
  979. "😘",
  980. "🥰",
  981. "😗",
  982. "🤩",
  983. "🤔",
  984. "🤨",
  985. "😐",
  986. "😑",
  987. "🙄",
  988. "😏",
  989. "😪",
  990. "😫",
  991. "🥱",
  992. "😜",
  993. "😒",
  994. "😔",
  995. "😨",
  996. "😰",
  997. "😱",
  998. "🥵",
  999. "😡",
  1000. "🥳",
  1001. "🥺",
  1002. "🤭",
  1003. "🧐",
  1004. "😎",
  1005. "🤓",
  1006. "😭",
  1007. "🤑",
  1008. "🤮"
  1009. ]
  1010. },
  1011. {
  1012. title: "手势",
  1013. list: [
  1014. "🙋",
  1015. "🙎",
  1016. "🙅",
  1017. "🙇",
  1018. "🤷",
  1019. "🤏",
  1020. "👉",
  1021. "✌️",
  1022. "🤘",
  1023. "🤙",
  1024. "👌",
  1025. "🤌",
  1026. "👍",
  1027. "👎",
  1028. "👋",
  1029. "🤝",
  1030. "🙏",
  1031. "👏"
  1032. ]
  1033. },
  1034. {
  1035. title: "庆祝",
  1036. list: ["✨", "🎉", "🎊"]
  1037. },
  1038. {
  1039. title: "其他",
  1040. list: ["👻", "🤡", "🐔", "👀", "💩", "🐴", "🦄", "🐧", "🐶", "🐒", "🙈", "🙉", "🙊", "🐵"]
  1041. }
  1042. ];
  1043. const classicsEmoticons = [
  1044. {
  1045. name: "[狗头]",
  1046. low: "https://i.imgur.com/io2SM1h.png",
  1047. high: "https://i.imgur.com/0icl60r.png"
  1048. },
  1049. {
  1050. name: "[马]",
  1051. low: "https://i.imgur.com/8EKZv7I.png",
  1052. high: "https://i.imgur.com/ANFUX52.png"
  1053. },
  1054. {
  1055. name: "[不高兴]",
  1056. low: "https://i.imgur.com/huX6coX.png",
  1057. high: "https://i.imgur.com/N7JEuvc.png"
  1058. },
  1059. {
  1060. name: "[呵呵]",
  1061. low: "https://i.imgur.com/RvoLAbX.png",
  1062. high: "https://i.imgur.com/xSzIqrK.png"
  1063. },
  1064. {
  1065. name: "[真棒]",
  1066. low: "https://i.imgur.com/xr1UOz1.png",
  1067. high: "https://i.imgur.com/w8YEw9Q.png"
  1068. },
  1069. {
  1070. name: "[鄙视]",
  1071. low: "https://i.imgur.com/u6jlqVq.png",
  1072. high: "https://i.imgur.com/8JFNANq.png"
  1073. },
  1074. {
  1075. name: "[疑问]",
  1076. low: "https://i.imgur.com/F29pmQ6.png",
  1077. high: "https://i.imgur.com/EbbTQAR.png"
  1078. },
  1079. {
  1080. name: "[吐舌]",
  1081. low: "https://i.imgur.com/InmIzl9.png",
  1082. high: "https://i.imgur.com/Ovj56Cd.png"
  1083. },
  1084. // {
  1085. // name: '[嘲笑]',
  1086. // low: 'https://i.imgur.com/BaWcsMR.png',
  1087. // high: 'https://i.imgur.com/0OGfJw4.png'
  1088. // },
  1089. // {
  1090. // name: '[滑稽]',
  1091. // low: 'https://i.imgur.com/lmbN0yI.png',
  1092. // high: 'https://i.imgur.com/Pc0wH85.png'
  1093. // },
  1094. {
  1095. name: "[笑眼]",
  1096. low: "https://i.imgur.com/ZveiiGy.png",
  1097. high: "https://i.imgur.com/PI1CfEr.png"
  1098. },
  1099. {
  1100. name: "[狂汗]",
  1101. low: "https://i.imgur.com/veWihk6.png",
  1102. high: "https://i.imgur.com/3LtHdQv.png"
  1103. },
  1104. {
  1105. name: "[大哭]",
  1106. low: "https://i.imgur.com/hu4oR6C.png",
  1107. high: "https://i.imgur.com/b4X9XLE.png"
  1108. },
  1109. {
  1110. name: "[喷]",
  1111. low: "https://i.imgur.com/bkw3VRr.png",
  1112. high: "https://i.imgur.com/wnZL13L.png"
  1113. },
  1114. {
  1115. name: "[苦笑]",
  1116. low: "https://i.imgur.com/VUWFktU.png",
  1117. high: "https://i.imgur.com/NAfspZ1.png"
  1118. },
  1119. {
  1120. name: "[喝酒]",
  1121. low: "https://i.imgur.com/2ZZSapE.png",
  1122. high: "https://i.imgur.com/rVbSVak.png"
  1123. },
  1124. {
  1125. name: "[吃瓜]",
  1126. low: "https://i.imgur.com/ee8Lq7H.png",
  1127. high: "https://i.imgur.com/0L26og9.png"
  1128. },
  1129. {
  1130. name: "[捂脸]",
  1131. low: "https://i.imgur.com/krir4IG.png",
  1132. high: "https://i.imgur.com/qqBqgVm.png"
  1133. },
  1134. {
  1135. name: "[呕]",
  1136. low: "https://i.imgur.com/6CUiUxv.png",
  1137. high: "https://i.imgur.com/kgdxRsG.png"
  1138. },
  1139. {
  1140. name: "[阴险]",
  1141. low: "https://i.imgur.com/MA8YqTP.png",
  1142. high: "https://i.imgur.com/e94jbaT.png"
  1143. },
  1144. {
  1145. name: "[怒]",
  1146. low: "https://i.imgur.com/n4kWfGB.png",
  1147. high: "https://i.imgur.com/iMXxNxh.png"
  1148. },
  1149. {
  1150. name: "[衰]",
  1151. low: "https://i.imgur.com/voHFDyQ.png",
  1152. high: "https://i.imgur.com/XffE6gu.png"
  1153. },
  1154. {
  1155. name: "[合十]",
  1156. low: "https://i.imgur.com/I8x3ang.png",
  1157. high: "https://i.imgur.com/T4rJVee.png"
  1158. },
  1159. {
  1160. name: "[赞]",
  1161. low: "https://i.imgur.com/lG44yUl.png",
  1162. high: "https://i.imgur.com/AoF5PLp.png"
  1163. },
  1164. {
  1165. name: "[踩]",
  1166. low: "https://i.imgur.com/cJp0uKZ.png",
  1167. high: "https://i.imgur.com/1XYGfXj.png"
  1168. },
  1169. {
  1170. name: "[爱心]",
  1171. low: "https://i.imgur.com/sLENaF5.png",
  1172. high: "https://i.imgur.com/dND56oX.png"
  1173. },
  1174. {
  1175. name: "[心碎]",
  1176. low: "https://i.imgur.com/AZxJzve.png",
  1177. high: "https://i.imgur.com/RiUsPci.png"
  1178. }
  1179. ];
  1180. const imgurClientIdPool = [
  1181. "3107b9ef8b316f3",
  1182. "442b04f26eefc8a",
  1183. "59cfebe717c09e4",
  1184. "60605aad4a62882",
  1185. "6c65ab1d3f5452a",
  1186. "83e123737849aa9",
  1187. "9311f6be1c10160",
  1188. "c4a4a563f698595",
  1189. "81be04b9e4a08ce"
  1190. ];
  1191. expose({ content });
  1192. const editorClass = vue.computed(() => {
  1193. return [useType, isFocus.value ? "isFocus" : "", isNight.value ? "isNight" : ""];
  1194. });
  1195. const cursorHtml = vue.computed(() => {
  1196. var _a;
  1197. if (!txtRef.value || !content.value)
  1198. return "";
  1199. let index2 = ((_a = txtRef.value) == null ? void 0 : _a.selectionStart) || 0;
  1200. return content.value.substring(0, index2).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, "<br/>").replace(/\s/g, none.value);
  1201. });
  1202. const disabled = vue.computed(() => {
  1203. if (content.value) {
  1204. return content.value === replyInfo;
  1205. } else {
  1206. return true;
  1207. }
  1208. });
  1209. function drop(e) {
  1210. e.preventDefault();
  1211. upload(e.dataTransfer.files[0]);
  1212. }
  1213. async function upload(file) {
  1214. if (!file)
  1215. return;
  1216. if (uploadLoading.value)
  1217. return;
  1218. uploadLoading.value = true;
  1219. const formData = new FormData();
  1220. formData.append("image", file);
  1221. const randomIndex = Math.floor(Math.random() * imgurClientIdPool.length);
  1222. const clidenId = imgurClientIdPool[randomIndex];
  1223. const res = await fetch("https://api.imgur.com/3/upload", {
  1224. method: "POST",
  1225. headers: { Authorization: `Client-ID ${clidenId}` },
  1226. body: formData
  1227. });
  1228. uploadLoading.value = false;
  1229. if (res.ok) {
  1230. const resData = await res.json();
  1231. if (resData.success) {
  1232. return insert(" " + resData.data.link + " ");
  1233. }
  1234. }
  1235. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "上传失败" });
  1236. }
  1237. async function submit() {
  1238. if (disabled.value || loading.value)
  1239. return;
  1240. loading.value = true;
  1241. let submit_content = content.value.replace(/\[((?!\[).)+\]/g, function(match) {
  1242. let item2 = classicsEmoticons.find((v) => v.name === match);
  1243. if (item2) {
  1244. return item2.low + " ";
  1245. }
  1246. return match;
  1247. });
  1248. let show_content = content.value.replace(/https?:\/\/(i\.)?imgur\.com\/((?!http).)+\.(gif|png|jpg|jpeg|GIF|PNG|JPG|JPEG)/g, function(match) {
  1249. return `<img src="${match}" data-originUrl="${match}" data-notice="这个img标签由v2ex-超级增强脚本解析" style="max-width: 100%">`;
  1250. });
  1251. show_content = show_content.replace(/\[((?!\[).)+\]/g, function(match) {
  1252. let item2 = classicsEmoticons.find((v) => v.name === match);
  1253. if (item2) {
  1254. return `<a target="_blank" href="${item2.low}" rel="nofollow noopener"><img src="${item2.low}" class="embedded_image" rel="noreferrer"></a> `;
  1255. }
  1256. return match;
  1257. });
  1258. let matchUsers = show_content.match(/@([\w]+?[\s])/g);
  1259. if (matchUsers) {
  1260. matchUsers.map((i) => {
  1261. let username = i.replace("@", "").replace(" ", "");
  1262. show_content = show_content.replace(username, `<a href="/member/${username}">${username}</a>`);
  1263. });
  1264. }
  1265. show_content = show_content.replaceAll("\n", "<br/>");
  1266. let item = {
  1267. thankCount: 0,
  1268. isThanked: false,
  1269. isOp: post.value.username === window.user.username,
  1270. id: Date.now(),
  1271. username: window.user.username,
  1272. avatar: window.user.avatar,
  1273. date: "几秒前",
  1274. floor: post.value.replyCount + 1,
  1275. reply_content: show_content ?? "",
  1276. children: [],
  1277. replyUsers: replyUser ? [replyUser] : [],
  1278. replyFloor: replyFloor || -1,
  1279. level: useType === "reply-comment" ? 1 : 0
  1280. };
  1281. let url = `${window.baseUrl}/t/${post.value.id}`;
  1282. $.post(url, { content: submit_content, once: post.value.once }).then(
  1283. (res) => {
  1284. loading.value = false;
  1285. let r = res.search("你上一条回复的内容和这条相同");
  1286. if (r > -1)
  1287. return eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "你上一条回复的内容和这条相同" });
  1288. r = res.search("请不要在每一个回复中都包括外链,这看起来像是在 spamming");
  1289. if (r > -1)
  1290. return eventBus.emit(CMD.SHOW_MSG, {
  1291. type: "error",
  1292. text: "请不要在每一个回复中都包括外链,这看起来像是在 spamming"
  1293. });
  1294. let r2 = res.search("创建新回复");
  1295. if (r2 > -1) {
  1296. eventBus.emit(CMD.REFRESH_ONCE, res);
  1297. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "回复失败" });
  1298. let clientWidth = window.win().document.body.clientWidth;
  1299. let windowWidth = 1200;
  1300. let left = clientWidth / 2 - windowWidth / 2;
  1301. let newWin = window.win().open("about:blank", "hello", `width=${windowWidth},height=600,left=${left},top=100`);
  1302. newWin.document.write(res);
  1303. return;
  1304. }
  1305. content.value = replyInfo;
  1306. emits("close");
  1307. eventBus.emit(CMD.REFRESH_ONCE, res);
  1308. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: "回复成功" });
  1309. eventBus.emit(CMD.ADD_REPLY, item);
  1310. },
  1311. (err) => {
  1312. console.log("err", err);
  1313. loading.value = false;
  1314. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "回复失败" });
  1315. }
  1316. ).catch((r) => {
  1317. console.log("cathc", r);
  1318. });
  1319. }
  1320. function showEmoticons(e) {
  1321. if (isShowEmoticons.value) {
  1322. return isShowEmoticons.value = false;
  1323. }
  1324. let rect = e.currentTarget.getBoundingClientRect();
  1325. emoticonsRef.value.style.left = rect.left + 30 + "px";
  1326. emoticonsRef.value.style.bottom = window.innerHeight - rect.top - 20 + "px";
  1327. isShowEmoticons.value = true;
  1328. }
  1329. function off() {
  1330. eventBus.emit(CMD.SHOW_CALL, { show: false });
  1331. eventBus.off(CMD.SET_CALL);
  1332. }
  1333. function checkHeight() {
  1334. txtRef.value.style.height = 0;
  1335. txtRef.value.style.height = txtRef.value.scrollHeight + "px";
  1336. }
  1337. function insert(str) {
  1338. let cursorPos = txtRef.value.selectionStart;
  1339. let start = content.value.slice(0, cursorPos);
  1340. let end = content.value.slice(cursorPos, content.value.length);
  1341. content.value = start + str + end;
  1342. let moveCursorPos = start.length + str.length;
  1343. setTimeout(() => {
  1344. txtRef.value.focus();
  1345. txtRef.value.setSelectionRange(moveCursorPos, moveCursorPos);
  1346. checkHeight();
  1347. });
  1348. }
  1349. function showCallPopover(text) {
  1350. let r = cursorRef.value.getBoundingClientRect();
  1351. eventBus.emit(CMD.SHOW_CALL, { show: true, top: r.top, left: r.left, text });
  1352. eventBus.off(CMD.SET_CALL);
  1353. eventBus.on(CMD.SET_CALL, (e) => {
  1354. let cursorPos = txtRef.value.selectionStart;
  1355. let start = content.value.slice(0, cursorPos);
  1356. let end = content.value.slice(cursorPos, content.value.length);
  1357. let lastCallPos = start.lastIndexOf("@");
  1358. start = content.value.slice(0, lastCallPos + 1);
  1359. if (e === "管理员") {
  1360. e = "Livid @Kai @Olivia @GordianZ @sparanoid";
  1361. }
  1362. if (e === "所有人") {
  1363. e = allReplyUsers.value.map((v, i) => {
  1364. if (i)
  1365. return "@" + v;
  1366. else
  1367. return v;
  1368. }).join(" ");
  1369. }
  1370. content.value = start + e + " " + end;
  1371. let moveCursorPos = start.length + e.length + 1;
  1372. setTimeout(() => {
  1373. txtRef.value.setSelectionRange(moveCursorPos, moveCursorPos);
  1374. checkHeight();
  1375. });
  1376. eventBus.off(CMD.SET_CALL);
  1377. });
  1378. }
  1379. function onKeydown(e) {
  1380. let code = e.keyCode;
  1381. switch (code) {
  1382. case 8:
  1383. if (content.value === "@") {
  1384. off();
  1385. }
  1386. break;
  1387. case 37:
  1388. case 38:
  1389. case 39:
  1390. case 40:
  1391. setTimeout(() => onInput({ data: "" }), 100);
  1392. break;
  1393. case 27:
  1394. e.preventDefault();
  1395. e.stopPropagation();
  1396. e.stopImmediatePropagation();
  1397. return false;
  1398. case 13:
  1399. if (e.ctrlKey)
  1400. submit();
  1401. break;
  1402. }
  1403. }
  1404. function onInput(e) {
  1405. let cursorPos = txtRef.value.selectionStart;
  1406. if (!content.value)
  1407. return;
  1408. if (e.data === " ") {
  1409. return off();
  1410. }
  1411. if (e.data === "@") {
  1412. if (content.value.length !== 1) {
  1413. if (content.value[cursorPos - 2] === " " || content.value[cursorPos - 2] === "\n") {
  1414. return showCallPopover("");
  1415. }
  1416. } else {
  1417. return showCallPopover("");
  1418. }
  1419. off();
  1420. } else {
  1421. let judgeStr = content.value.slice(0, cursorPos);
  1422. let lastCallPos = judgeStr.lastIndexOf("@");
  1423. if (lastCallPos === -1) {
  1424. return off();
  1425. }
  1426. let callStr = judgeStr.slice(lastCallPos, cursorPos);
  1427. let hasSpace = callStr.includes(" ");
  1428. if (hasSpace) {
  1429. off();
  1430. } else {
  1431. if (lastCallPos === 0) {
  1432. return showCallPopover(callStr.replace("@", ""));
  1433. }
  1434. if (content.value.length !== 1) {
  1435. if (content.value[lastCallPos - 1] === " " || content.value[lastCallPos - 1] === "\n") {
  1436. return showCallPopover(callStr.replace("@", ""));
  1437. }
  1438. } else {
  1439. return showCallPopover(callStr.replace("@", ""));
  1440. }
  1441. off();
  1442. }
  1443. }
  1444. }
  1445. function onPaste(e) {
  1446. const dataTransferItemList = e.clipboardData.items;
  1447. const items = [].slice.call(dataTransferItemList).filter(function(item) {
  1448. return item.type.indexOf("image") !== -1;
  1449. });
  1450. if (items.length === 0) {
  1451. return;
  1452. }
  1453. const dataTransferItem = items[0];
  1454. const blob = dataTransferItem.getAsFile();
  1455. upload(blob);
  1456. }
  1457. function onBlur() {
  1458. document.removeEventListener("paste", onPaste);
  1459. isFocus.value = false;
  1460. }
  1461. function onFocusin() {
  1462. console.log("onFocusin");
  1463. document.addEventListener("paste", onPaste);
  1464. }
  1465. vue.watch(() => show, (n) => {
  1466. if (n.value)
  1467. isShowEmoticons.value = false;
  1468. }, { deep: true });
  1469. vue.onMounted(() => {
  1470. $(`.${editorId.value}`).each(function() {
  1471. this.setAttribute("style", "height:" + this.scrollHeight + "px;overflow-y:hidden;");
  1472. }).on("input", function() {
  1473. this.style.height = 0;
  1474. this.style.height = this.scrollHeight + "px";
  1475. });
  1476. if (useType === "reply-comment") {
  1477. txtRef.value && txtRef.value.focus();
  1478. }
  1479. });
  1480. vue.onBeforeUnmount(() => {
  1481. $(`.${editorId.value}`).off();
  1482. });
  1483. return (_ctx, _cache) => {
  1484. return vue.openBlock(), vue.createElementBlock("div", {
  1485. class: vue.normalizeClass(["post-editor-wrapper", vue.unref(editorClass)])
  1486. }, [
  1487. vue.withDirectives(vue.createElementVNode("textarea", {
  1488. class: vue.normalizeClass(["post-editor", editorId.value]),
  1489. ref_key: "txtRef",
  1490. ref: txtRef,
  1491. onFocus: _cache[0] || (_cache[0] = ($event) => vue.isRef(isFocus) ? isFocus.value = true : isFocus = true),
  1492. onBlur,
  1493. onFocusin,
  1494. placeholder: "请尽量让自己的回复能够对别人有帮助",
  1495. onInput,
  1496. onKeydown,
  1497. onDrop: drop,
  1498. "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => content.value = $event)
  1499. }, null, 34), [
  1500. [vue.vModelText, content.value]
  1501. ]),
  1502. vue.createElementVNode("div", _hoisted_1$b, [
  1503. vue.createElementVNode("span", { innerHTML: vue.unref(cursorHtml) }, null, 8, _hoisted_2$9),
  1504. vue.createElementVNode("span", {
  1505. class: "cursor",
  1506. ref_key: "cursorRef",
  1507. ref: cursorRef
  1508. }, "|", 512)
  1509. ]),
  1510. vue.createElementVNode("div", _hoisted_3$6, [
  1511. vue.createElementVNode("div", _hoisted_4$5, [
  1512. (vue.openBlock(), vue.createElementBlock("svg", {
  1513. onClick: showEmoticons,
  1514. width: "20",
  1515. height: "20",
  1516. viewBox: "0 0 48 48",
  1517. fill: "none",
  1518. xmlns: "http://www.w3.org/2000/svg"
  1519. }, _hoisted_9$4)),
  1520. vue.createElementVNode("div", _hoisted_10$4, [
  1521. vue.createElementVNode("input", {
  1522. type: "file",
  1523. accept: "image/*",
  1524. onChange: _cache[2] || (_cache[2] = (e) => upload(e.currentTarget.files[0]))
  1525. }, null, 32),
  1526. _hoisted_11$4
  1527. ]),
  1528. uploadLoading.value ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_12$4, "上传中.....")) : vue.createCommentVNode("", true)
  1529. ]),
  1530. vue.createElementVNode("div", _hoisted_13$4, [
  1531. vue.unref(useType) === "reply-comment" ? (vue.openBlock(), vue.createElementBlock("span", {
  1532. key: 0,
  1533. style: { "margin-right": "1rem", "cursor": "pointer" },
  1534. onClick: _cache[3] || (_cache[3] = ($event) => emits("close"))
  1535. }, "关闭")) : vue.createCommentVNode("", true),
  1536. vue.createElementVNode("div", {
  1537. class: vue.normalizeClass(["button", { disabled: vue.unref(disabled), loading: loading.value }]),
  1538. onClick: submit
  1539. }, "回复 ", 2)
  1540. ])
  1541. ]),
  1542. vue.withDirectives(vue.createElementVNode("div", {
  1543. class: "emoticon-pack",
  1544. ref_key: "emoticonsRef",
  1545. ref: emoticonsRef
  1546. }, [
  1547. vue.createElementVNode("i", {
  1548. class: "fa fa-times",
  1549. "aria-hidden": "true",
  1550. onClick: _cache[4] || (_cache[4] = ($event) => isShowEmoticons.value = false)
  1551. }),
  1552. _hoisted_14$4,
  1553. vue.createElementVNode("div", _hoisted_15$4, [
  1554. (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(classicsEmoticons, (item) => {
  1555. return vue.createElementVNode("img", {
  1556. src: item.high,
  1557. onClick: ($event) => {
  1558. insert(item.name);
  1559. isShowEmoticons.value = false;
  1560. }
  1561. }, null, 8, _hoisted_16$2);
  1562. }), 64))
  1563. ]),
  1564. vue.createElementVNode("div", _hoisted_17$2, [
  1565. (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(emojiEmoticons, (item) => {
  1566. return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
  1567. vue.createElementVNode("div", _hoisted_18$2, vue.toDisplayString(item.title), 1),
  1568. vue.createElementVNode("div", _hoisted_19$2, [
  1569. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item.list, (emoji) => {
  1570. return vue.openBlock(), vue.createElementBlock("span", {
  1571. onClick: ($event) => {
  1572. insert(emoji);
  1573. isShowEmoticons.value = false;
  1574. }
  1575. }, vue.toDisplayString(emoji), 9, _hoisted_20$2);
  1576. }), 256))
  1577. ])
  1578. ], 64);
  1579. }), 64))
  1580. ])
  1581. ], 512), [
  1582. [vue.vShow, isShowEmoticons.value]
  1583. ])
  1584. ], 2);
  1585. };
  1586. }
  1587. };
  1588. const PostEditor = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-dc3eb8bf"]]);
  1589. const _hoisted_1$a = {
  1590. key: 0,
  1591. class: "html-wrapper"
  1592. };
  1593. const _hoisted_2$8 = ["innerHTML"];
  1594. const _sfc_main$a = {
  1595. __name: "BaseHtmlRender",
  1596. props: ["html"],
  1597. setup(__props) {
  1598. const props = __props;
  1599. const config2 = vue.inject("config");
  1600. const contentRef = vue.ref(null);
  1601. const checkHeight = 900;
  1602. const mask = vue.ref(false);
  1603. const handOpen = vue.ref(false);
  1604. function mouseup(e) {
  1605. if (!config2.value.base64)
  1606. return;
  1607. let selectionText = window.win().getSelection().toString();
  1608. if (selectionText) {
  1609. let r = selectionText.match(/([A-Za-z0-9+/=]+)/g);
  1610. if (r) {
  1611. if (r[0].length < 4)
  1612. return;
  1613. eventBus.emit(CMD.SHOW_TOOLTIP, { text: r[0], e });
  1614. }
  1615. }
  1616. }
  1617. vue.watch(config2.value, (newVale) => {
  1618. if (!newVale.contentAutoCollapse) {
  1619. mask.value = false;
  1620. }
  1621. });
  1622. vue.watch([() => contentRef.value, () => props.html], () => {
  1623. if (!contentRef.value || !props.html)
  1624. return;
  1625. if (!config2.value.contentAutoCollapse)
  1626. return;
  1627. contentRef.value.querySelectorAll("img").forEach((item) => {
  1628. item.removeEventListener("load", checkContentHeight);
  1629. item.addEventListener("load", checkContentHeight);
  1630. });
  1631. checkContentHeight();
  1632. }, { immediate: true, flush: "post" });
  1633. function checkContentHeight() {
  1634. if (handOpen.value)
  1635. return;
  1636. let rect = contentRef.value.getBoundingClientRect();
  1637. mask.value = rect.height >= checkHeight;
  1638. }
  1639. return (_ctx, _cache) => {
  1640. return props.html ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
  1641. vue.createElementVNode("div", {
  1642. class: vue.normalizeClass({ mask: mask.value })
  1643. }, [
  1644. vue.createElementVNode("div", vue.mergeProps({
  1645. ref_key: "contentRef",
  1646. ref: contentRef
  1647. }, _ctx.$attrs, {
  1648. innerHTML: props.html,
  1649. onMouseup: mouseup
  1650. }), null, 16, _hoisted_2$8)
  1651. ], 2),
  1652. mask.value ? (vue.openBlock(), vue.createElementBlock("div", {
  1653. key: 0,
  1654. class: "expand",
  1655. onClick: _cache[0] || (_cache[0] = ($event) => {
  1656. mask.value = false;
  1657. handOpen.value = true;
  1658. })
  1659. }, "展开")) : vue.createCommentVNode("", true)
  1660. ])) : vue.createCommentVNode("", true);
  1661. };
  1662. }
  1663. };
  1664. const BaseHtmlRender = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-a77c3d96"]]);
  1665. const _sfc_main$9 = {
  1666. name: "Comment",
  1667. components: { BaseHtmlRender, Author, PostEditor, Point },
  1668. inject: ["post", "postDetailWidth", "show", "isNight"],
  1669. props: {
  1670. modelValue: {
  1671. reply_content: ""
  1672. },
  1673. type: {
  1674. type: String,
  1675. default() {
  1676. return "list";
  1677. }
  1678. }
  1679. },
  1680. data() {
  1681. return {
  1682. edit: false,
  1683. ding: false,
  1684. expand: true,
  1685. expandWrong: false,
  1686. replyInfo: `@${this.modelValue.username} #${this.modelValue.floor} `,
  1687. cssStyle: null,
  1688. floor: this.modelValue.floor
  1689. };
  1690. },
  1691. watch: {
  1692. show(e) {
  1693. if (e) {
  1694. this.edit = false;
  1695. }
  1696. },
  1697. postDetailWidth(n, o) {
  1698. this.checkIsTooLong(n);
  1699. }
  1700. },
  1701. computed: {
  1702. myClass() {
  1703. return {
  1704. isOp: this.modelValue.isOp,
  1705. ding: this.ding,
  1706. isLevelOne: this.modelValue.level === 0,
  1707. ["c_" + this.floor]: this.type !== "top"
  1708. };
  1709. }
  1710. },
  1711. mounted() {
  1712. this.checkIsTooLong(this.postDetailWidth);
  1713. },
  1714. methods: {
  1715. checkIsTooLong(postDetailWidth) {
  1716. if (postDetailWidth !== 0) {
  1717. let rect = this.$refs.comment.getBoundingClientRect();
  1718. let ban = postDetailWidth / 2;
  1719. console.log("ban", ban);
  1720. if (ban < rect.width && rect.width < ban + 25 && this.modelValue.children.length) {
  1721. this.expand = false;
  1722. let padding = 2;
  1723. this.cssStyle = {
  1724. padding: "1rem 0",
  1725. width: `calc(${postDetailWidth}px - ${padding}rem)`,
  1726. transform: `translateX(calc(${rect.width - postDetailWidth}px + ${padding}rem))`,
  1727. background: this.isNight ? "#18222d" : "white"
  1728. };
  1729. }
  1730. }
  1731. },
  1732. //高亮一下
  1733. showDing() {
  1734. this.ding = true;
  1735. setTimeout(() => {
  1736. this.ding = false;
  1737. }, 2e3);
  1738. },
  1739. hide() {
  1740. let url = `${window.baseUrl}/ignore/reply/${this.modelValue.id}?once=${this.post.once}`;
  1741. eventBus.emit(CMD.REMOVE, this.modelValue.floor);
  1742. $.post(url).then((res) => {
  1743. eventBus.emit(CMD.REFRESH_ONCE);
  1744. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: "隐藏成功" });
  1745. }, (err) => {
  1746. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "隐藏成功,仅本次有效(接口调用失败!)" });
  1747. });
  1748. },
  1749. toggle() {
  1750. this.expand = !this.expand;
  1751. }
  1752. }
  1753. };
  1754. const _withScopeId$5 = (n) => (vue.pushScopeId("data-v-a0031aa2"), n = n(), vue.popScopeId(), n);
  1755. const _hoisted_1$9 = ["data-floor"];
  1756. const _hoisted_2$7 = { class: "comment-content" };
  1757. const _hoisted_3$5 = { class: "right" };
  1758. const _hoisted_4$4 = { class: "w" };
  1759. const _hoisted_5$4 = {
  1760. key: 0,
  1761. class: "wrong-wrapper"
  1762. };
  1763. const _hoisted_6$4 = ["href"];
  1764. const _hoisted_7$3 = { class: "del-line" };
  1765. const _hoisted_8$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("i", {
  1766. class: "fa fa-question-circle-o wrong-icon",
  1767. "aria-hidden": "true"
  1768. }, null, -1));
  1769. const _hoisted_9$3 = {
  1770. key: 0,
  1771. class: "warning"
  1772. };
  1773. const _hoisted_10$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  1774. const _hoisted_11$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  1775. const _hoisted_12$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  1776. const _hoisted_13$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  1777. const _hoisted_14$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
  1778. const _hoisted_15$3 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ vue.createElementVNode("a", {
  1779. href: "https://github.com/zyronon/v2ex-script/discussions/7",
  1780. target: "_blank"
  1781. }, "这里", -1));
  1782. function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
  1783. const _component_Author = vue.resolveComponent("Author");
  1784. const _component_BaseHtmlRender = vue.resolveComponent("BaseHtmlRender");
  1785. const _component_PostEditor = vue.resolveComponent("PostEditor");
  1786. const _component_Comment = vue.resolveComponent("Comment", true);
  1787. return vue.openBlock(), vue.createElementBlock("div", {
  1788. class: vue.normalizeClass(["comment", $options.myClass]),
  1789. ref: "comment",
  1790. "data-floor": $data.floor
  1791. }, [
  1792. vue.createVNode(_component_Author, {
  1793. modelValue: $data.expand,
  1794. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.expand = $event),
  1795. comment: $props.modelValue,
  1796. onReply: _cache[1] || (_cache[1] = ($event) => $data.edit = !$data.edit),
  1797. type: $props.type,
  1798. onHide: $options.hide
  1799. }, null, 8, ["modelValue", "comment", "type", "onHide"]),
  1800. $data.cssStyle && !$data.expand ? (vue.openBlock(), vue.createElementBlock("div", {
  1801. key: 0,
  1802. class: "more ago",
  1803. onClick: _cache[2] || (_cache[2] = ($event) => $data.expand = !$data.expand)
  1804. }, " 由于嵌套回复层级太深,自动将后续回复隐藏 ")) : vue.createCommentVNode("", true),
  1805. $data.expand ? (vue.openBlock(), vue.createElementBlock("div", {
  1806. key: 1,
  1807. class: "comment-content-w",
  1808. style: vue.normalizeStyle($data.cssStyle)
  1809. }, [
  1810. $data.cssStyle ? (vue.openBlock(), vue.createElementBlock("div", {
  1811. key: 0,
  1812. class: "more ago",
  1813. onClick: _cache[3] || (_cache[3] = ($event) => $data.expand = !$data.expand)
  1814. }, " 由于嵌套回复层级太深,自动将以下回复移至可见范围 ")) : vue.createCommentVNode("", true),
  1815. vue.createElementVNode("div", _hoisted_2$7, [
  1816. vue.createElementVNode("div", {
  1817. class: "left expand-line",
  1818. onClick: _cache[4] || (_cache[4] = (...args) => $options.toggle && $options.toggle(...args))
  1819. }),
  1820. vue.createElementVNode("div", _hoisted_3$5, [
  1821. vue.createElementVNode("div", _hoisted_4$4, [
  1822. $props.modelValue.isWrong ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$4, [
  1823. vue.createElementVNode("span", {
  1824. onClick: _cache[5] || (_cache[5] = ($event) => $data.expandWrong = !$data.expandWrong),
  1825. title: "点击楼层号查看提示"
  1826. }, [
  1827. vue.createElementVNode("a", {
  1828. href: "/member/" + $props.modelValue.replyUsers[0]
  1829. }, "@" + vue.toDisplayString($props.modelValue.replyUsers[0]) + "  ", 9, _hoisted_6$4),
  1830. vue.createElementVNode("span", _hoisted_7$3, "#" + vue.toDisplayString($props.modelValue.replyFloor), 1),
  1831. _hoisted_8$3
  1832. ]),
  1833. $data.expandWrong ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_9$3, [
  1834. vue.createTextVNode(" 这条回复似乎有点问题,指定的楼层号与@的人对应不上 "),
  1835. _hoisted_10$3,
  1836. vue.createTextVNode(" 原因可能有下面几种: "),
  1837. _hoisted_11$3,
  1838. vue.createTextVNode(" 一、屏蔽用户导致楼层塌陷:你屏蔽了A,自A以后的回复的楼层号都会减1 "),
  1839. _hoisted_12$3,
  1840. vue.createTextVNode(" 二、忽略回复导致楼层塌陷:原理同上 "),
  1841. _hoisted_13$3,
  1842. vue.createTextVNode(" 三、层主回复时指定错了楼层号(同一,层主屏蔽了别人,导致楼层塌陷) "),
  1843. _hoisted_14$3,
  1844. vue.createTextVNode(" 四、脚本解析错误,请在"),
  1845. _hoisted_15$3,
  1846. vue.createTextVNode("反馈 ")
  1847. ])) : vue.createCommentVNode("", true)
  1848. ])) : vue.createCommentVNode("", true),
  1849. vue.createVNode(_component_BaseHtmlRender, {
  1850. class: "reply_content",
  1851. html: $props.modelValue.reply_content
  1852. }, null, 8, ["html"]),
  1853. $data.edit ? (vue.openBlock(), vue.createBlock(_component_PostEditor, {
  1854. key: 1,
  1855. onClose: _cache[6] || (_cache[6] = ($event) => $data.edit = false),
  1856. replyInfo: $data.replyInfo,
  1857. replyUser: $props.modelValue.username,
  1858. replyFloor: $props.modelValue.floor
  1859. }, null, 8, ["replyInfo", "replyUser", "replyFloor"])) : vue.createCommentVNode("", true)
  1860. ]),
  1861. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($props.modelValue.children, (item, index2) => {
  1862. return vue.openBlock(), vue.createBlock(_component_Comment, {
  1863. modelValue: $props.modelValue.children[index2],
  1864. "onUpdate:modelValue": ($event) => $props.modelValue.children[index2] = $event,
  1865. key: index2
  1866. }, null, 8, ["modelValue", "onUpdate:modelValue"]);
  1867. }), 128))
  1868. ])
  1869. ]),
  1870. $data.cssStyle ? (vue.openBlock(), vue.createElementBlock("div", {
  1871. key: 1,
  1872. class: "more ago",
  1873. onClick: _cache[7] || (_cache[7] = ($event) => $data.expand = !$data.expand)
  1874. }, " 由于嵌套回复层级太深,自动将以上回复移至可见范围 ")) : vue.createCommentVNode("", true)
  1875. ], 4)) : vue.createCommentVNode("", true)
  1876. ], 10, _hoisted_1$9);
  1877. }
  1878. const Comment = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5], ["__scopeId", "data-v-a0031aa2"]]);
  1879. const _sfc_main$8 = {
  1880. name: "Toolbar",
  1881. inject: [
  1882. "isLogin",
  1883. "post",
  1884. "pageType"
  1885. ],
  1886. data() {
  1887. return {
  1888. timer: null,
  1889. loading: false,
  1890. loading2: false,
  1891. loading3: false
  1892. };
  1893. },
  1894. methods: {
  1895. checkIsLogin(emitName = "") {
  1896. if (!this.isLogin) {
  1897. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "请先登录!" });
  1898. return false;
  1899. }
  1900. this.$emit(emitName);
  1901. return true;
  1902. },
  1903. getColor(val) {
  1904. return val ? "#ff4500" : "#929596";
  1905. },
  1906. getIsFull(val) {
  1907. return val ? "#ff4500" : "none";
  1908. },
  1909. tweet() {
  1910. if (!this.checkIsLogin())
  1911. return;
  1912. let username = window.user.username;
  1913. let url = `https://twitter.com/intent/tweet?url=${window.baseUrl}/t/${this.post.id}?r=${username}&related=v2ex&text=${this.post.title}`;
  1914. window.win().open(url, "_blank", "width=550,height=370");
  1915. },
  1916. report() {
  1917. if (!this.checkIsLogin())
  1918. return;
  1919. if (!this.isLogin)
  1920. return;
  1921. if (this.post.isReport)
  1922. return;
  1923. let username = window.user.username;
  1924. let url = `https://twitter.com/share?url=${window.baseUrl}/t/${this.post.id}?r=${username}&amp;related=v2ex&amp;hashtags=apple&amp;text=${this.post.title}`;
  1925. window.win().open(url, "_blank", "width=550,height=370");
  1926. },
  1927. async toggleIgnore() {
  1928. if (!this.checkIsLogin())
  1929. return;
  1930. let url = `${window.baseUrl}/${this.post.isIgnore ? "unignore" : "ignore"}/topic/${this.post.id}?once=${this.post.once}`;
  1931. if (this.pageType === "post") {
  1932. this.loading2 = true;
  1933. let apiRes = await window.win().fetch(url);
  1934. if (apiRes.redirected) {
  1935. if (!this.post.isIgnore) {
  1936. window.win().location = window.baseUrl;
  1937. }
  1938. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: this.post.isIgnore ? "取消成功" : "忽略成功" });
  1939. eventBus.emit(CMD.MERGE, { isIgnore: !this.post.isIgnore });
  1940. } else {
  1941. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "忽略失败" });
  1942. }
  1943. this.loading2 = false;
  1944. } else {
  1945. if (this.post.isIgnore) {
  1946. this.loading2 = true;
  1947. } else {
  1948. eventBus.emit(CMD.IGNORE);
  1949. }
  1950. let apiRes = await window.win().fetch(url);
  1951. if (apiRes.redirected) {
  1952. if (this.post.isIgnore) {
  1953. eventBus.emit(CMD.REFRESH_ONCE);
  1954. }
  1955. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: this.post.isIgnore ? "取消成功" : "忽略成功" });
  1956. eventBus.emit(CMD.MERGE, { isIgnore: !this.post.isIgnore });
  1957. } else {
  1958. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "忽略成功,仅本次有效(接口调用失败!)" });
  1959. }
  1960. this.loading2 = false;
  1961. }
  1962. },
  1963. async toggleFavorite() {
  1964. if (!this.post.isFavorite && config.collectBrowserNotice) {
  1965. alert("请按Command/Cmd/CTRL + D添加到书签");
  1966. }
  1967. if (!this.checkIsLogin())
  1968. return;
  1969. this.loading = true;
  1970. let url = `${window.baseUrl}/${this.post.isFavorite ? "unfavorite" : "favorite"}/topic/${this.post.id}?once=${this.post.once}`;
  1971. let apiRes = await window.win().fetch(url);
  1972. this.loading = false;
  1973. if (apiRes.redirected) {
  1974. let htmlText = await apiRes.text();
  1975. if (htmlText.search(this.post.isFavorite ? "加入收藏" : "取消收藏")) {
  1976. eventBus.emit(CMD.MERGE, { collectCount: this.post.isFavorite ? this.post.collectCount - 1 : this.post.collectCount + 1 });
  1977. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: this.post.isFavorite ? "取消成功" : "收藏成功" });
  1978. eventBus.emit(CMD.REFRESH_ONCE, htmlText);
  1979. eventBus.emit(CMD.MERGE, { isFavorite: !this.post.isFavorite });
  1980. return;
  1981. }
  1982. }
  1983. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "操作失败" });
  1984. }
  1985. }
  1986. };
  1987. const _withScopeId$4 = (n) => (vue.pushScopeId("data-v-07fa3ae8"), n = n(), vue.popScopeId(), n);
  1988. const _hoisted_1$8 = { class: "toolbar" };
  1989. const _hoisted_2$6 = /* @__PURE__ */ vue.createStaticVNode('<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-07fa3ae8><path d="M4 6H44V36H29L24 41L19 36H4V6Z" fill="none" stroke="#929596" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-07fa3ae8></path><path d="M23 21H25.0025" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-07fa3ae8></path><path d="M33.001 21H34.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-07fa3ae8></path><path d="M13.001 21H14.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-07fa3ae8></path></svg><span data-v-07fa3ae8>回复</span>', 2);
  1990. const _hoisted_4$3 = [
  1991. _hoisted_2$6
  1992. ];
  1993. const _hoisted_5$3 = {
  1994. viewBox: "0 0 48 48",
  1995. fill: "none",
  1996. xmlns: "http://www.w3.org/2000/svg"
  1997. };
  1998. const _hoisted_6$3 = ["fill", "stroke"];
  1999. const _hoisted_7$2 = {
  2000. key: 1,
  2001. class: "tool no-hover"
  2002. };
  2003. const _hoisted_8$2 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("svg", {
  2004. viewBox: "0 0 48 48",
  2005. fill: "none",
  2006. xmlns: "http://www.w3.org/2000/svg"
  2007. }, [
  2008. /* @__PURE__ */ vue.createElementVNode("path", {
  2009. d: "M28 6H42V20",
  2010. stroke: "#929596",
  2011. "stroke-width": "2",
  2012. "stroke-linecap": "round",
  2013. "stroke-linejoin": "round"
  2014. }),
  2015. /* @__PURE__ */ vue.createElementVNode("path", {
  2016. d: "M42 29.4737V39C42 40.6569 40.6569 42 39 42H9C7.34315 42 6 40.6569 6 39V9C6 7.34315 7.34315 6 9 6L18 6",
  2017. stroke: "#929596",
  2018. "stroke-width": "2",
  2019. "stroke-linecap": "round",
  2020. "stroke-linejoin": "round"
  2021. }),
  2022. /* @__PURE__ */ vue.createElementVNode("path", {
  2023. d: "M25.7998 22.1999L41.0998 6.8999",
  2024. stroke: "#929596",
  2025. "stroke-width": "2",
  2026. "stroke-linecap": "round",
  2027. "stroke-linejoin": "round"
  2028. })
  2029. ], -1));
  2030. const _hoisted_9$2 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ vue.createElementVNode("span", null, "Tweet", -1));
  2031. const _hoisted_10$2 = [
  2032. _hoisted_8$2,
  2033. _hoisted_9$2
  2034. ];
  2035. const _hoisted_11$2 = {
  2036. viewBox: "0 0 48 48",
  2037. fill: "none",
  2038. xmlns: "http://www.w3.org/2000/svg"
  2039. };
  2040. const _hoisted_12$2 = ["fill", "stroke"];
  2041. const _hoisted_13$2 = ["fill", "stroke"];
  2042. const _hoisted_14$2 = ["fill", "stroke"];
  2043. const _hoisted_15$2 = /* @__PURE__ */ vue.createStaticVNode('<svg width="19" height="19" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-07fa3ae8><path d="M36 35H12V21C12 14.3726 17.3726 9 24 9C30.6274 9 36 14.3726 36 21V35Z" fill="#929596" stroke="#929596" stroke-width="4" stroke-linejoin="round" data-v-07fa3ae8></path><path d="M8 42H40" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-07fa3ae8></path><path d="M4 13L7 14" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-07fa3ae8></path><path d="M13 3.9999L14 6.9999" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-07fa3ae8></path><path d="M10.0001 9.99989L7.00009 6.99989" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-07fa3ae8></path></svg>', 1);
  2044. function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
  2045. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
  2046. vue.createElementVNode("div", {
  2047. class: "tool",
  2048. onClick: _cache[0] || (_cache[0] = ($event) => $options.checkIsLogin("reply"))
  2049. }, _hoisted_4$3),
  2050. $options.post.once ? (vue.openBlock(), vue.createElementBlock("div", {
  2051. key: 0,
  2052. class: vue.normalizeClass(["tool", { loading: $data.loading }]),
  2053. onClick: _cache[1] || (_cache[1] = (...args) => $options.toggleFavorite && $options.toggleFavorite(...args))
  2054. }, [
  2055. (vue.openBlock(), vue.createElementBlock("svg", _hoisted_5$3, [
  2056. vue.createElementVNode("path", {
  2057. d: "M23.9986 5L17.8856 17.4776L4 19.4911L14.0589 29.3251L11.6544 43L23.9986 36.4192L36.3454 43L33.9586 29.3251L44 19.4911L30.1913 17.4776L23.9986 5Z",
  2058. fill: $options.getIsFull($options.post.isFavorite),
  2059. stroke: $options.getColor($options.post.isFavorite),
  2060. "stroke-width": "2",
  2061. "stroke-linejoin": "round"
  2062. }, null, 8, _hoisted_6$3)
  2063. ])),
  2064. vue.createElementVNode("span", null, vue.toDisplayString($options.post.isFavorite ? "取消收藏" : "加入收藏"), 1)
  2065. ], 2)) : vue.createCommentVNode("", true),
  2066. $options.post.once && $options.post.collectCount !== 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7$2, [
  2067. vue.createElementVNode("span", null, vue.toDisplayString($options.post.collectCount + "人收藏"), 1)
  2068. ])) : vue.createCommentVNode("", true),
  2069. vue.createElementVNode("div", {
  2070. class: "tool",
  2071. onClick: _cache[2] || (_cache[2] = (...args) => $options.tweet && $options.tweet(...args))
  2072. }, _hoisted_10$2),
  2073. $options.post.once ? (vue.openBlock(), vue.createElementBlock("div", {
  2074. key: 2,
  2075. class: vue.normalizeClass(["tool", { "loading": $data.loading2 }]),
  2076. onClick: _cache[3] || (_cache[3] = (...args) => $options.toggleIgnore && $options.toggleIgnore(...args))
  2077. }, [
  2078. (vue.openBlock(), vue.createElementBlock("svg", _hoisted_11$2, [
  2079. vue.createElementVNode("path", {
  2080. fill: $options.getIsFull($options.post.isIgnore),
  2081. stroke: $options.getColor($options.post.isIgnore),
  2082. d: "M9.85786 18C6.23858 21 4 24 4 24C4 24 12.9543 36 24 36C25.3699 36 26.7076 35.8154 28 35.4921M20.0318 12.5C21.3144 12.1816 22.6414 12 24 12C35.0457 12 44 24 44 24C44 24 41.7614 27 38.1421 30",
  2083. "stroke-width": "2",
  2084. "stroke-linecap": "round",
  2085. "stroke-linejoin": "round"
  2086. }, null, 8, _hoisted_12$2),
  2087. vue.createElementVNode("path", {
  2088. fill: $options.getIsFull($options.post.isIgnore),
  2089. d: "M20.3142 20.6211C19.4981 21.5109 19 22.6972 19 23.9998C19 26.7612 21.2386 28.9998 24 28.9998C25.3627 28.9998 26.5981 28.4546 27.5 27.5705",
  2090. stroke: $options.getColor($options.post.isIgnore),
  2091. "stroke-width": "2",
  2092. "stroke-linecap": "round",
  2093. "stroke-linejoin": "round"
  2094. }, null, 8, _hoisted_13$2),
  2095. vue.createElementVNode("path", {
  2096. d: "M42 42L6 6",
  2097. fill: $options.getIsFull($options.post.isIgnore),
  2098. stroke: $options.getColor($options.post.isIgnore),
  2099. "stroke-width": "2",
  2100. "stroke-linecap": "round",
  2101. "stroke-linejoin": "round"
  2102. }, null, 8, _hoisted_14$2)
  2103. ])),
  2104. vue.createElementVNode("span", null, vue.toDisplayString($options.post.isIgnore ? "取消忽略" : "忽略主题"), 1)
  2105. ], 2)) : vue.createCommentVNode("", true),
  2106. $options.post.once && $options.post.isLogin ? (vue.openBlock(), vue.createElementBlock("div", {
  2107. key: 3,
  2108. class: vue.normalizeClass(["tool", { "loading": $data.loading3, "no-hover": $options.post.isLogin }]),
  2109. onClick: _cache[4] || (_cache[4] = (...args) => $options.report && $options.report(...args))
  2110. }, [
  2111. _hoisted_15$2,
  2112. vue.createElementVNode("span", null, vue.toDisplayString($options.post.isReport ? "你已对本主题进行了报告" : "报告这个主题"), 1)
  2113. ], 2)) : vue.createCommentVNode("", true)
  2114. ]);
  2115. }
  2116. const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4], ["__scopeId", "data-v-07fa3ae8"]]);
  2117. const _sfc_main$7 = {
  2118. name: "Tooltip",
  2119. props: {
  2120. title: {
  2121. type: String,
  2122. default() {
  2123. return "";
  2124. }
  2125. }
  2126. },
  2127. data() {
  2128. return {
  2129. show: false
  2130. };
  2131. },
  2132. methods: {
  2133. hoverIn(e) {
  2134. let rect = e.target.getBoundingClientRect();
  2135. this.show = true;
  2136. vue.nextTick(() => {
  2137. let tip = this.$refs.tip.getBoundingClientRect();
  2138. this.$refs.tip.style.top = rect.top - tip.height - 5 + "px";
  2139. this.$refs.tip.style.left = rect.left + rect.width / 2 + "px";
  2140. });
  2141. }
  2142. }
  2143. };
  2144. const _hoisted_1$7 = { class: "pop-confirm" };
  2145. function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  2146. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
  2147. (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
  2148. vue.createVNode(vue.Transition, null, {
  2149. default: vue.withCtx(() => [
  2150. $data.show ? (vue.openBlock(), vue.createElementBlock("div", {
  2151. key: 0,
  2152. class: "tip",
  2153. ref: "tip"
  2154. }, vue.toDisplayString($props.title), 513)) : vue.createCommentVNode("", true)
  2155. ]),
  2156. _: 1
  2157. })
  2158. ])),
  2159. vue.createElementVNode("span", {
  2160. onMouseenter: _cache[0] || (_cache[0] = (...args) => $options.hoverIn && $options.hoverIn(...args)),
  2161. onMouseleave: _cache[1] || (_cache[1] = ($event) => $data.show = false)
  2162. }, [
  2163. vue.renderSlot(_ctx.$slots, "default")
  2164. ], 32)
  2165. ]);
  2166. }
  2167. const Tooltip = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
  2168. const _withScopeId$3 = (n) => (vue.pushScopeId("data-v-3eb530b9"), n = n(), vue.popScopeId(), n);
  2169. const _hoisted_1$6 = {
  2170. class: "comment",
  2171. ref: "comment"
  2172. };
  2173. const _hoisted_2$5 = ["href"];
  2174. const _hoisted_3$4 = ["src"];
  2175. const _hoisted_4$2 = { class: "texts" };
  2176. const _hoisted_5$2 = {
  2177. key: 0,
  2178. class: "point"
  2179. };
  2180. const _hoisted_6$2 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("svg", {
  2181. width: "19",
  2182. height: "19",
  2183. viewBox: "0 0 48 48",
  2184. fill: "none"
  2185. }, [
  2186. /* @__PURE__ */ vue.createElementVNode("path", {
  2187. d: "M15 8C8.92487 8 4 12.9249 4 19C4 30 17 40 24 42.3262C31 40 44 30 44 19C44 12.9249 39.0751 8 33 8C29.2797 8 25.9907 9.8469 24 12.6738C22.0093 9.8469 18.7203 8 15 8Z",
  2188. fill: "#E02A2A",
  2189. stroke: "#E02A2A",
  2190. "stroke-width": "2",
  2191. "stroke-linecap": "round",
  2192. "stroke-linejoin": "round"
  2193. })
  2194. ], -1));
  2195. const _hoisted_7$1 = { class: "num" };
  2196. const _hoisted_8$1 = { class: "my-tag" };
  2197. const _hoisted_9$1 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-tag" }, null, -1));
  2198. const _hoisted_10$1 = {
  2199. key: 2,
  2200. class: "ago"
  2201. };
  2202. const _hoisted_11$1 = {
  2203. key: 3,
  2204. class: "mod"
  2205. };
  2206. const _hoisted_12$1 = {
  2207. key: 4,
  2208. class: "op"
  2209. };
  2210. const _hoisted_13$1 = ["href"];
  2211. const _hoisted_14$1 = {
  2212. key: 5,
  2213. class: "op"
  2214. };
  2215. const _hoisted_15$1 = {
  2216. key: 6,
  2217. class: "mod"
  2218. };
  2219. const _hoisted_16$1 = {
  2220. key: 7,
  2221. class: "ago"
  2222. };
  2223. const _hoisted_17$1 = { class: "my-tag" };
  2224. const _hoisted_18$1 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-tag" }, null, -1));
  2225. const _hoisted_19$1 = {
  2226. key: 9,
  2227. class: "point"
  2228. };
  2229. const _hoisted_20$1 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("svg", {
  2230. width: "19",
  2231. height: "19",
  2232. viewBox: "0 0 48 48",
  2233. fill: "none"
  2234. }, [
  2235. /* @__PURE__ */ vue.createElementVNode("path", {
  2236. d: "M15 8C8.92487 8 4 12.9249 4 19C4 30 17 40 24 42.3262C31 40 44 30 44 19C44 12.9249 39.0751 8 33 8C29.2797 8 25.9907 9.8469 24 12.6738C22.0093 9.8469 18.7203 8 15 8Z",
  2237. fill: "#E02A2A",
  2238. stroke: "#E02A2A",
  2239. "stroke-width": "2",
  2240. "stroke-linecap": "round",
  2241. "stroke-linejoin": "round"
  2242. })
  2243. ], -1));
  2244. const _hoisted_21$1 = { class: "num" };
  2245. const _hoisted_22$1 = ["href"];
  2246. const _hoisted_23$1 = ["src"];
  2247. const _hoisted_24$1 = { class: "Author-right" };
  2248. const _hoisted_25$1 = { class: "floor" };
  2249. const _hoisted_26$1 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ vue.createElementVNode("span", null, "跳转", -1));
  2250. const _hoisted_27$1 = [
  2251. _hoisted_26$1
  2252. ];
  2253. const _sfc_main$6 = {
  2254. __name: "SingleComment",
  2255. props: {
  2256. comment: {
  2257. reply_content: ""
  2258. },
  2259. isRight: {
  2260. type: Boolean,
  2261. default() {
  2262. return false;
  2263. }
  2264. }
  2265. },
  2266. setup(__props) {
  2267. const props = __props;
  2268. const config2 = vue.inject("config");
  2269. const isLogin = vue.inject("isLogin");
  2270. const tags = vue.inject("tags");
  2271. const myTags = vue.computed(() => {
  2272. return tags[props.comment.username] ?? [];
  2273. });
  2274. function jump() {
  2275. eventBus.emit(CMD.JUMP, props.comment.floor);
  2276. }
  2277. return (_ctx, _cache) => {
  2278. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
  2279. !__props.isRight ? (vue.openBlock(), vue.createElementBlock("a", {
  2280. key: 0,
  2281. class: "avatar",
  2282. href: `/member/${__props.comment.username}`
  2283. }, [
  2284. vue.createElementVNode("img", {
  2285. src: __props.comment.avatar,
  2286. alt: ""
  2287. }, null, 8, _hoisted_3$4)
  2288. ], 8, _hoisted_2$5)) : vue.createCommentVNode("", true),
  2289. vue.createElementVNode("div", {
  2290. class: vue.normalizeClass(["comment-body", { isRight: __props.isRight }])
  2291. }, [
  2292. vue.createElementVNode("div", _hoisted_4$2, [
  2293. __props.comment.thankCount && __props.isRight ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$2, [
  2294. _hoisted_6$2,
  2295. vue.createElementVNode("div", _hoisted_7$1, vue.toDisplayString(__props.comment.thankCount), 1)
  2296. ])) : vue.createCommentVNode("", true),
  2297. vue.unref(isLogin) && vue.unref(config2).openTag && __props.isRight ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(vue.unref(myTags), (i) => {
  2298. return vue.openBlock(), vue.createElementBlock("span", _hoisted_8$1, [
  2299. _hoisted_9$1,
  2300. vue.createElementVNode("span", null, vue.toDisplayString(i), 1)
  2301. ]);
  2302. }), 256)) : vue.createCommentVNode("", true),
  2303. __props.isRight ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_10$1, vue.toDisplayString(__props.comment.date), 1)) : vue.createCommentVNode("", true),
  2304. __props.comment.isMod && __props.isRight ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11$1, "MOD")) : vue.createCommentVNode("", true),
  2305. __props.comment.isOp && __props.isRight ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12$1, "OP")) : vue.createCommentVNode("", true),
  2306. vue.createElementVNode("a", {
  2307. href: `/member/${__props.comment.username}`,
  2308. class: "username"
  2309. }, vue.toDisplayString(__props.comment.username), 9, _hoisted_13$1),
  2310. __props.comment.isOp && !__props.isRight ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_14$1, "OP")) : vue.createCommentVNode("", true),
  2311. __props.comment.isMod && !__props.isRight ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_15$1, "MOD")) : vue.createCommentVNode("", true),
  2312. !__props.isRight ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_16$1, vue.toDisplayString(__props.comment.date), 1)) : vue.createCommentVNode("", true),
  2313. vue.unref(isLogin) && vue.unref(config2).openTag && !__props.isRight ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 8 }, vue.renderList(vue.unref(myTags), (i) => {
  2314. return vue.openBlock(), vue.createElementBlock("span", _hoisted_17$1, [
  2315. _hoisted_18$1,
  2316. vue.createElementVNode("span", null, vue.toDisplayString(i), 1)
  2317. ]);
  2318. }), 256)) : vue.createCommentVNode("", true),
  2319. __props.comment.thankCount && !__props.isRight ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_19$1, [
  2320. _hoisted_20$1,
  2321. vue.createElementVNode("div", _hoisted_21$1, vue.toDisplayString(__props.comment.thankCount), 1)
  2322. ])) : vue.createCommentVNode("", true)
  2323. ]),
  2324. vue.createVNode(vue.unref(BaseHtmlRender), {
  2325. class: "reply_content",
  2326. html: __props.comment.reply_content
  2327. }, null, 8, ["html"])
  2328. ], 2),
  2329. __props.isRight ? (vue.openBlock(), vue.createElementBlock("a", {
  2330. key: 1,
  2331. class: "avatar",
  2332. href: `/member/${__props.comment.username}`
  2333. }, [
  2334. vue.createElementVNode("img", {
  2335. src: __props.comment.avatar,
  2336. alt: ""
  2337. }, null, 8, _hoisted_23$1)
  2338. ], 8, _hoisted_22$1)) : vue.createCommentVNode("", true),
  2339. vue.createElementVNode("div", _hoisted_24$1, [
  2340. vue.createElementVNode("div", _hoisted_25$1, vue.toDisplayString(__props.comment.floor), 1),
  2341. vue.createElementVNode("div", {
  2342. class: "tool jump",
  2343. onClick: jump
  2344. }, _hoisted_27$1)
  2345. ])
  2346. ], 512);
  2347. };
  2348. }
  2349. };
  2350. const SingleComment = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-3eb530b9"]]);
  2351. function debounce(fn, delay, scope) {
  2352. let timer = null;
  2353. return function() {
  2354. let context = scope || this, args = arguments;
  2355. clearTimeout(timer);
  2356. timer = setTimeout(function() {
  2357. fn.apply(context, args);
  2358. timer = null;
  2359. }, delay);
  2360. };
  2361. }
  2362. const _sfc_main$5 = {
  2363. name: "detail",
  2364. components: {
  2365. SingleComment,
  2366. PopConfirm,
  2367. Comment,
  2368. PostEditor,
  2369. Point,
  2370. Toolbar,
  2371. BaseHtmlRender,
  2372. Tooltip
  2373. },
  2374. inject: ["allReplyUsers", "post", "isLogin", "config", "pageType", "isNight", "showConfig"],
  2375. provide() {
  2376. return {
  2377. postDetailWidth: vue.computed(() => this.postDetailWidth)
  2378. };
  2379. },
  2380. props: {
  2381. modelValue: {
  2382. type: Boolean,
  2383. default() {
  2384. return false;
  2385. }
  2386. },
  2387. loading: {
  2388. type: Boolean,
  2389. default() {
  2390. return false;
  2391. }
  2392. },
  2393. displayType: 0
  2394. },
  2395. data() {
  2396. return {
  2397. isSticky: false,
  2398. selectCallIndex: 0,
  2399. postDetailWidth: 0,
  2400. showCallList: false,
  2401. showRelationReply: false,
  2402. replyText: "",
  2403. callStyle: {
  2404. top: 0,
  2405. left: 0
  2406. },
  2407. targetUser: {
  2408. left: [],
  2409. right: "",
  2410. rightFloor: -1
  2411. },
  2412. debounceScroll: () => {
  2413. },
  2414. read: {
  2415. floor: 0,
  2416. total: 0
  2417. },
  2418. currentFloor: 1
  2419. };
  2420. },
  2421. computed: {
  2422. isPost() {
  2423. return this.pageType === PageType.Post;
  2424. },
  2425. filterCallList() {
  2426. if (this.showCallList) {
  2427. let list = ["管理员", "所有人"].concat(this.allReplyUsers);
  2428. if (this.replyText)
  2429. return list.filter((i) => i.search(this.replyText) > -1);
  2430. return list;
  2431. }
  2432. return [];
  2433. },
  2434. topReply() {
  2435. return this.post.replyList.filter((v) => v.thankCount >= this.config.topReplyLoveMinCount).sort((a, b) => b.thankCount - a.thankCount).slice(0, this.config.topReplyCount);
  2436. },
  2437. replyList() {
  2438. if (this.displayType === 0)
  2439. return this.post.nestedReplies;
  2440. if (this.displayType === 1) {
  2441. return window.clone(this.post.nestedReplies).sort((a, b) => b.thankCount - a.thankCount);
  2442. }
  2443. if (this.displayType === 2)
  2444. return this.post.replyList;
  2445. if (this.displayType === 3)
  2446. return this.post.replyList.filter((v) => {
  2447. var _a;
  2448. return v.username === ((_a = this.post.member) == null ? void 0 : _a.username);
  2449. });
  2450. return [];
  2451. },
  2452. //关联回复
  2453. relationReply() {
  2454. if (this.targetUser.left.length && this.targetUser.right) {
  2455. return this.post.replyList.filter((v) => {
  2456. if (this.targetUser.left.includes(v.username)) {
  2457. if (v.floor > this.targetUser.rightFloor) {
  2458. if (v.replyUsers.includes(this.targetUser.right)) {
  2459. return true;
  2460. }
  2461. } else {
  2462. return true;
  2463. }
  2464. }
  2465. if (v.username === this.targetUser.right) {
  2466. for (let i = 0; i < this.targetUser.left.length; i++) {
  2467. if (v.replyUsers.includes(this.targetUser.left[i])) {
  2468. return true;
  2469. }
  2470. }
  2471. }
  2472. });
  2473. }
  2474. return [];
  2475. }
  2476. },
  2477. watch: {
  2478. "post.id"(n, o) {
  2479. if (this.$refs["post-editor"]) {
  2480. this.$refs["post-editor"].content = "";
  2481. }
  2482. },
  2483. modelValue: {
  2484. handler(newVal) {
  2485. if (this.isPost)
  2486. return;
  2487. if (newVal) {
  2488. document.body.style.overflow = "hidden";
  2489. this.read = this.post.read;
  2490. this.currentFloor = 1;
  2491. vue.nextTick(() => {
  2492. var _a, _b, _c, _d;
  2493. (_b = (_a = this.$refs) == null ? void 0 : _a.main) == null ? void 0 : _b.focus();
  2494. (_d = (_c = this.$refs) == null ? void 0 : _c.detail) == null ? void 0 : _d.scrollTo({ top: 0 });
  2495. });
  2496. } else {
  2497. this.$emit("saveReadList");
  2498. document.body.style.overflow = "unset";
  2499. this.isSticky = false;
  2500. this.showRelationReply = false;
  2501. if ((this.pageType === PageType.Home || this.pageType === PageType.Node) && window.location.pathname !== "/") {
  2502. window.history.back();
  2503. }
  2504. }
  2505. }
  2506. }
  2507. },
  2508. mounted() {
  2509. setTimeout(() => {
  2510. var _a;
  2511. this.postDetailWidth = ((_a = this.$refs.mainWrapper) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
  2512. });
  2513. this.debounceScroll = debounce(this.scroll, 300, false);
  2514. if (this.isLogin) {
  2515. const observer = new IntersectionObserver(
  2516. ([e]) => e.target.toggleAttribute("stuck", e.intersectionRatio < 1),
  2517. { threshold: [1] }
  2518. );
  2519. observer.observe(this.$refs.replyBox);
  2520. window.addEventListener("keydown", this.onKeyDown);
  2521. }
  2522. eventBus.on(CMD.SHOW_CALL, (val) => {
  2523. if (val.show) {
  2524. this.showCallList = true;
  2525. this.replyText = val.text;
  2526. if (this.isPost) {
  2527. this.callStyle.top = val.top + $(window.win()).scrollTop() + -40 + "px";
  2528. } else {
  2529. this.callStyle.top = val.top + $(".post-detail").scrollTop() + 15 + "px";
  2530. }
  2531. this.callStyle.left = val.left - $(".main")[0].getBoundingClientRect().left + 10 + "px";
  2532. if (this.selectCallIndex >= this.filterCallList.length) {
  2533. this.selectCallIndex = 0;
  2534. }
  2535. } else {
  2536. this.replyText = "";
  2537. this.showCallList = false;
  2538. this.selectCallIndex = 0;
  2539. }
  2540. });
  2541. eventBus.on(CMD.RELATION_REPLY, (val) => {
  2542. this.targetUser = val;
  2543. this.showRelationReply = true;
  2544. });
  2545. eventBus.on(CMD.JUMP, this.jump);
  2546. if (this.isPost) {
  2547. window.addEventListener("scroll", this.debounceScroll);
  2548. }
  2549. },
  2550. beforeUnmount() {
  2551. window.removeEventListener("keydown", this.onKeyDown);
  2552. eventBus.off(CMD.SHOW_CALL);
  2553. },
  2554. methods: {
  2555. scroll() {
  2556. if (!this.config.rememberLastReadFloor)
  2557. return;
  2558. let height = window.innerHeight * 0.3;
  2559. let comments = $(".comments .comment");
  2560. let forCount = 0;
  2561. for (let i = 0; i < comments.length; i++) {
  2562. forCount++;
  2563. let ins = comments[i];
  2564. let rect = ins.getBoundingClientRect();
  2565. if (rect.top > height) {
  2566. let lastReadFloor = Number(ins.dataset["floor"]);
  2567. console.log("当前阅读楼层", lastReadFloor);
  2568. eventBus.emit(CMD.ADD_READ, {
  2569. floor: lastReadFloor > 3 ? lastReadFloor : 0,
  2570. total: this.post.replyList.length
  2571. });
  2572. if (lastReadFloor > 3) {
  2573. this.read.floor = 0;
  2574. }
  2575. break;
  2576. }
  2577. }
  2578. if (forCount === comments.length) {
  2579. console.log("看到最后了");
  2580. eventBus.emit(CMD.ADD_READ, {
  2581. floor: forCount,
  2582. total: this.post.replyList.length
  2583. });
  2584. }
  2585. },
  2586. stop(e) {
  2587. },
  2588. jump(floor) {
  2589. try {
  2590. floor = Number(floor);
  2591. } catch (e) {
  2592. }
  2593. if (!floor)
  2594. return;
  2595. if (!this.post.replyList.length) {
  2596. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "没有回复可跳转!" });
  2597. this.read.floor = 0;
  2598. return;
  2599. }
  2600. if (floor > this.post.replyList.length) {
  2601. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "没有找到对应回复!" });
  2602. this.read.floor = 0;
  2603. return;
  2604. }
  2605. let comment = $(`.c_${floor}`);
  2606. if (!comment.length) {
  2607. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "没有找到对应回复!" });
  2608. this.read.floor = 0;
  2609. return;
  2610. }
  2611. comment[0].scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
  2612. comment.addClass("ding");
  2613. this.read.floor = 0;
  2614. this.currentFloor = floor + 1;
  2615. setTimeout(() => {
  2616. comment.removeClass("ding");
  2617. }, 2e3);
  2618. },
  2619. jumpLastRead(floor) {
  2620. if (this.config.autoJumpLastReadFloor) {
  2621. if (!floor)
  2622. return;
  2623. setTimeout(() => {
  2624. console.log("上次跳转", floor);
  2625. this.jump(floor);
  2626. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: "已跳转到上次阅读位置" });
  2627. }, 300);
  2628. }
  2629. },
  2630. collapseTopReplyList() {
  2631. $(this.$refs.topReply).slideToggle("fast");
  2632. },
  2633. goBottom() {
  2634. this.isSticky = false;
  2635. setTimeout(() => {
  2636. if (this.isPost) {
  2637. let body = $("body , html");
  2638. let scrollHeight = body.prop("scrollHeight");
  2639. body.animate({ scrollTop: scrollHeight - 850 }, 300);
  2640. } else {
  2641. this.$refs.detail.scrollTo({ top: this.$refs.detail.scrollHeight, behavior: "smooth" });
  2642. }
  2643. });
  2644. },
  2645. close(from) {
  2646. if (this.isPost)
  2647. return;
  2648. if (from === "space") {
  2649. if (this.config.closePostDetailBySpace) {
  2650. this.$emit("update:modelValue", false);
  2651. }
  2652. } else {
  2653. this.$emit("update:modelValue", false);
  2654. }
  2655. },
  2656. setCall(e) {
  2657. eventBus.emit(CMD.SET_CALL, e);
  2658. this.showCallList = false;
  2659. },
  2660. onKeyDown(e) {
  2661. if (!this.modelValue)
  2662. return;
  2663. if (!this.showCallList)
  2664. return;
  2665. let length = this.filterCallList.slice(0, 10).length;
  2666. if (e.keyCode === 13) {
  2667. this.setCall(this.filterCallList[this.selectCallIndex]);
  2668. e.preventDefault();
  2669. }
  2670. if (e.keyCode === 38) {
  2671. this.selectCallIndex--;
  2672. if (this.selectCallIndex < 0) {
  2673. this.selectCallIndex = length - 1;
  2674. }
  2675. e.preventDefault();
  2676. }
  2677. if (e.keyCode === 40) {
  2678. this.selectCallIndex++;
  2679. if (this.selectCallIndex > length - 1) {
  2680. this.selectCallIndex = 0;
  2681. }
  2682. e.preventDefault();
  2683. }
  2684. },
  2685. changeOption(item) {
  2686. this.$emit("update:displayType", item);
  2687. },
  2688. addThank() {
  2689. eventBus.emit(CMD.CHANGE_POST_THANK, { id: this.post.id, type: "add" });
  2690. },
  2691. recallThank() {
  2692. eventBus.emit(CMD.CHANGE_POST_THANK, { id: this.post.id, type: "recall" });
  2693. },
  2694. scrollTop() {
  2695. if (this.isPost) {
  2696. $("body , html").animate({ scrollTop: 0 }, 300);
  2697. } else {
  2698. this.$refs.detail.scrollTo({ top: 0, behavior: "smooth" });
  2699. }
  2700. }
  2701. }
  2702. };
  2703. const _withScopeId$2 = (n) => (vue.pushScopeId("data-v-4038172d"), n = n(), vue.popScopeId(), n);
  2704. const _hoisted_1$5 = { class: "my-box post-wrapper" };
  2705. const _hoisted_2$4 = { class: "toolbar-wrapper" };
  2706. const _hoisted_3$3 = {
  2707. key: 0,
  2708. class: "my-box"
  2709. };
  2710. const _hoisted_4$1 = { class: "my-cell flex" };
  2711. const _hoisted_5$1 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("span", { class: "gray" }, "高赞回复", -1));
  2712. const _hoisted_6$1 = { class: "top-reply" };
  2713. const _hoisted_7 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-times" }, null, -1));
  2714. const _hoisted_8 = { ref: "topReply" };
  2715. const _hoisted_9 = { class: "my-box comment-wrapper" };
  2716. const _hoisted_10 = {
  2717. key: 0,
  2718. class: "my-cell flex"
  2719. };
  2720. const _hoisted_11 = {
  2721. key: 0,
  2722. class: "read-notice"
  2723. };
  2724. const _hoisted_12 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("span", null, "上次打开:", -1));
  2725. const _hoisted_13 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-long-arrow-down" }, null, -1));
  2726. const _hoisted_14 = [
  2727. _hoisted_13
  2728. ];
  2729. const _hoisted_15 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-long-arrow-down" }, null, -1));
  2730. const _hoisted_16 = [
  2731. _hoisted_15
  2732. ];
  2733. const _hoisted_17 = { class: "my-cell flex" };
  2734. const _hoisted_18 = { class: "gray" };
  2735. const _hoisted_19 = { key: 0 };
  2736. const _hoisted_20 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("strong", { class: "snow" }, "•", -1));
  2737. const _hoisted_21 = ["innerHTML"];
  2738. const _hoisted_22 = {
  2739. key: 0,
  2740. class: "loading-wrapper"
  2741. };
  2742. const _hoisted_23 = {
  2743. key: 1,
  2744. class: "comments"
  2745. };
  2746. const _hoisted_24 = {
  2747. key: 1,
  2748. id: "no-comments-yet"
  2749. };
  2750. const _hoisted_25 = { class: "my-cell flex" };
  2751. const _hoisted_26 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("span", null, "添加一条新回复", -1));
  2752. const _hoisted_27 = { class: "notice-right" };
  2753. const _hoisted_28 = { class: "w" };
  2754. const _hoisted_29 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("span", { class: "gray" }, "上下文", -1));
  2755. const _hoisted_30 = { class: "top-reply" };
  2756. const _hoisted_31 = ["onClick"];
  2757. const _hoisted_32 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("i", {
  2758. class: "fa fa-times",
  2759. "aria-hidden": "true"
  2760. }, null, -1));
  2761. const _hoisted_33 = [
  2762. _hoisted_32
  2763. ];
  2764. const _hoisted_34 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("i", {
  2765. class: "fa fa-long-arrow-up",
  2766. "aria-hidden": "true"
  2767. }, null, -1));
  2768. const _hoisted_35 = [
  2769. _hoisted_34
  2770. ];
  2771. const _hoisted_36 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ vue.createElementVNode("i", { class: "fa fa-long-arrow-down" }, null, -1));
  2772. function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  2773. const _component_BaseHtmlRender = vue.resolveComponent("BaseHtmlRender");
  2774. const _component_Point = vue.resolveComponent("Point");
  2775. const _component_Toolbar = vue.resolveComponent("Toolbar");
  2776. const _component_Tooltip = vue.resolveComponent("Tooltip");
  2777. const _component_PopConfirm = vue.resolveComponent("PopConfirm");
  2778. const _component_Comment = vue.resolveComponent("Comment");
  2779. const _component_PostEditor = vue.resolveComponent("PostEditor");
  2780. const _component_SingleComment = vue.resolveComponent("SingleComment");
  2781. return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
  2782. class: vue.normalizeClass(["post-detail", [$options.isNight ? "isNight" : "", $options.pageType]]),
  2783. ref: "detail",
  2784. onKeydown: _cache[23] || (_cache[23] = vue.withKeys(($event) => $options.close(), ["esc"])),
  2785. onScroll: _cache[24] || (_cache[24] = (...args) => $data.debounceScroll && $data.debounceScroll(...args)),
  2786. onClick: _cache[25] || (_cache[25] = ($event) => $options.close("space"))
  2787. }, [
  2788. vue.createElementVNode("div", {
  2789. ref: "main",
  2790. class: "main",
  2791. tabindex: "1",
  2792. onClick: _cache[22] || (_cache[22] = vue.withModifiers((...args) => $options.stop && $options.stop(...args), ["stop"]))
  2793. }, [
  2794. vue.createElementVNode("div", {
  2795. class: "main-wrapper",
  2796. ref: "mainWrapper",
  2797. style: vue.normalizeStyle({ width: $options.config.postWidth })
  2798. }, [
  2799. vue.createElementVNode("div", _hoisted_1$5, [
  2800. vue.createVNode(_component_BaseHtmlRender, {
  2801. html: $options.post.headerTemplate
  2802. }, null, 8, ["html"]),
  2803. vue.createElementVNode("div", _hoisted_2$4, [
  2804. vue.createVNode(_component_Point, {
  2805. onAddThank: $options.addThank,
  2806. onRecallThank: $options.recallThank,
  2807. full: false,
  2808. item: {
  2809. isThanked: $options.post.isThanked,
  2810. thankCount: $options.post.thankCount,
  2811. username: $options.post.username
  2812. },
  2813. "api-url": "topic/" + $options.post.id
  2814. }, null, 8, ["onAddThank", "onRecallThank", "item", "api-url"]),
  2815. vue.createVNode(_component_Toolbar, {
  2816. onReply: _cache[0] || (_cache[0] = ($event) => $data.isSticky = !$data.isSticky)
  2817. })
  2818. ])
  2819. ]),
  2820. $options.topReply.length && $options.config.showTopReply ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$3, [
  2821. vue.createElementVNode("div", _hoisted_4$1, [
  2822. _hoisted_5$1,
  2823. vue.createElementVNode("div", _hoisted_6$1, [
  2824. vue.createVNode(_component_Tooltip, {
  2825. title: `统计点赞数大于等于${$options.config.topReplyLoveMinCount}个的回复,可在设置中调整`
  2826. }, {
  2827. default: vue.withCtx(() => [
  2828. vue.createElementVNode("i", {
  2829. class: "fa fa-info",
  2830. onClick: _cache[1] || (_cache[1] = ($event) => $options.showConfig())
  2831. })
  2832. ]),
  2833. _: 1
  2834. }, 8, ["title"]),
  2835. vue.createVNode(_component_PopConfirm, {
  2836. title: "关闭后不再默认显示,可在设置里重新打开,确认关闭?",
  2837. onConfirm: _cache[2] || (_cache[2] = ($event) => $options.config.showTopReply = false)
  2838. }, {
  2839. default: vue.withCtx(() => [
  2840. _hoisted_7
  2841. ]),
  2842. _: 1
  2843. }),
  2844. vue.createVNode(_component_Tooltip, { title: "收起高赞回复" }, {
  2845. default: vue.withCtx(() => [
  2846. vue.createElementVNode("i", {
  2847. class: "fa fa-compress",
  2848. onClick: _cache[3] || (_cache[3] = (...args) => $options.collapseTopReplyList && $options.collapseTopReplyList(...args))
  2849. })
  2850. ]),
  2851. _: 1
  2852. })
  2853. ])
  2854. ]),
  2855. vue.createElementVNode("div", _hoisted_8, [
  2856. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($options.topReply, (item, index2) => {
  2857. return vue.openBlock(), vue.createBlock(_component_Comment, {
  2858. key: item.floor,
  2859. type: "top",
  2860. modelValue: $options.topReply[index2],
  2861. "onUpdate:modelValue": ($event) => $options.topReply[index2] = $event
  2862. }, null, 8, ["modelValue", "onUpdate:modelValue"]);
  2863. }), 128))
  2864. ], 512)
  2865. ])) : vue.createCommentVNode("", true),
  2866. vue.createElementVNode("div", _hoisted_9, [
  2867. $options.post.replyList.length || $props.loading ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
  2868. $options.config.showToolbar ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [
  2869. vue.createElementVNode("div", {
  2870. class: vue.normalizeClass(["radio-group2", { isNight: $options.isNight }])
  2871. }, [
  2872. vue.createElementVNode("div", {
  2873. class: vue.normalizeClass(["radio", $props.displayType === 0 ? "active" : ""]),
  2874. onClick: _cache[4] || (_cache[4] = ($event) => $options.changeOption(0))
  2875. }, "楼中楼 ", 2),
  2876. vue.createElementVNode("div", {
  2877. class: vue.normalizeClass(["radio", $props.displayType === 1 ? "active" : ""]),
  2878. onClick: _cache[5] || (_cache[5] = ($event) => $options.changeOption(1))
  2879. }, "感谢 ", 2),
  2880. vue.createElementVNode("div", {
  2881. class: vue.normalizeClass(["radio", $props.displayType === 3 ? "active" : ""]),
  2882. onClick: _cache[6] || (_cache[6] = ($event) => $options.changeOption(3))
  2883. }, "只看楼主 ", 2),
  2884. vue.createElementVNode("div", {
  2885. class: vue.normalizeClass(["radio", $props.displayType === 2 ? "active" : ""]),
  2886. onClick: _cache[7] || (_cache[7] = ($event) => $options.changeOption(2))
  2887. }, "V2原版 ", 2)
  2888. ], 2),
  2889. $data.read.floor || $data.read.total ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11, [
  2890. _hoisted_12,
  2891. $data.read.floor ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
  2892. vue.createElementVNode("span", null, [
  2893. vue.createTextVNode("阅读到"),
  2894. vue.createElementVNode("b", null, vue.toDisplayString($data.read.floor), 1),
  2895. vue.createTextVNode("楼")
  2896. ]),
  2897. vue.createElementVNode("div", {
  2898. class: "jump jump1",
  2899. onClick: _cache[8] || (_cache[8] = ($event) => $options.jump($data.read.floor))
  2900. }, _hoisted_14)
  2901. ], 64)) : vue.createCommentVNode("", true),
  2902. vue.createElementVNode("span", null, [
  2903. vue.createTextVNode("总楼层"),
  2904. vue.createElementVNode("b", null, vue.toDisplayString($data.read.total), 1)
  2905. ]),
  2906. vue.createElementVNode("div", {
  2907. class: "jump",
  2908. onClick: _cache[9] || (_cache[9] = ($event) => $options.jump($data.read.total))
  2909. }, _hoisted_16)
  2910. ])) : vue.createCommentVNode("", true)
  2911. ])) : vue.createCommentVNode("", true),
  2912. vue.createElementVNode("div", _hoisted_17, [
  2913. vue.createElementVNode("span", _hoisted_18, [
  2914. vue.createTextVNode(vue.toDisplayString($options.post.replyCount) + " 条回复 ", 1),
  2915. $options.post.createDate ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_19, [
  2916. vue.createTextVNode("  "),
  2917. _hoisted_20,
  2918. vue.createTextVNode("  " + vue.toDisplayString($options.post.createDate), 1)
  2919. ])) : vue.createCommentVNode("", true)
  2920. ]),
  2921. vue.createElementVNode("div", {
  2922. class: "fr",
  2923. innerHTML: $options.post.fr
  2924. }, null, 8, _hoisted_21)
  2925. ])
  2926. ], 64)) : vue.createCommentVNode("", true),
  2927. $options.replyList.length || $props.loading ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
  2928. $props.loading ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_22, [
  2929. vue.createElementVNode("div", {
  2930. class: vue.normalizeClass([$options.isNight ? "loading-b" : "loading-c"])
  2931. }, null, 2)
  2932. ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_23, [
  2933. $props.modelValue ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList($options.replyList, (item, index2) => {
  2934. return vue.openBlock(), vue.createBlock(_component_Comment, {
  2935. key: item.floor,
  2936. modelValue: $options.replyList[index2],
  2937. "onUpdate:modelValue": ($event) => $options.replyList[index2] = $event
  2938. }, null, 8, ["modelValue", "onUpdate:modelValue"]);
  2939. }), 128)) : vue.createCommentVNode("", true)
  2940. ]))
  2941. ], 64)) : vue.createCommentVNode("", true)
  2942. ]),
  2943. !($options.replyList.length || $props.loading) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_24, "目前尚无回复")) : vue.createCommentVNode("", true),
  2944. $options.isLogin ? (vue.openBlock(), vue.createElementBlock("div", {
  2945. key: 2,
  2946. class: vue.normalizeClass(["my-box editor-wrapper", { "sticky": $data.isSticky }]),
  2947. ref: "replyBox"
  2948. }, [
  2949. vue.createElementVNode("div", _hoisted_25, [
  2950. _hoisted_26,
  2951. vue.createElementVNode("div", _hoisted_27, [
  2952. $data.isSticky ? (vue.openBlock(), vue.createElementBlock("a", {
  2953. key: 0,
  2954. class: "float",
  2955. onClick: _cache[10] || (_cache[10] = ($event) => $data.isSticky = false)
  2956. }, "取消回复框停靠")) : vue.createCommentVNode("", true),
  2957. vue.createElementVNode("a", {
  2958. onClick: _cache[11] || (_cache[11] = (...args) => $options.scrollTop && $options.scrollTop(...args))
  2959. }, "回到顶部")
  2960. ])
  2961. ]),
  2962. vue.createElementVNode("div", _hoisted_28, [
  2963. vue.createVNode(_component_PostEditor, {
  2964. onClose: $options.goBottom,
  2965. ref: "post-editor",
  2966. useType: "reply-post",
  2967. onClick: _cache[12] || (_cache[12] = ($event) => $data.isSticky = true)
  2968. }, null, 8, ["onClose"])
  2969. ])
  2970. ], 2)) : vue.createCommentVNode("", true)
  2971. ], 4),
  2972. $data.showRelationReply ? (vue.openBlock(), vue.createElementBlock("div", {
  2973. key: 0,
  2974. class: "relationReply",
  2975. onClick: _cache[16] || (_cache[16] = ($event) => $options.close("space"))
  2976. }, [
  2977. vue.createElementVNode("div", {
  2978. class: "my-cell flex",
  2979. onClick: _cache[14] || (_cache[14] = vue.withModifiers((...args) => $options.stop && $options.stop(...args), ["stop"]))
  2980. }, [
  2981. _hoisted_29,
  2982. vue.createElementVNode("div", _hoisted_30, [
  2983. vue.createElementVNode("i", {
  2984. class: "fa fa-times",
  2985. onClick: _cache[13] || (_cache[13] = ($event) => $data.showRelationReply = false)
  2986. })
  2987. ])
  2988. ]),
  2989. vue.createElementVNode("div", {
  2990. class: "comments",
  2991. onClick: _cache[15] || (_cache[15] = vue.withModifiers((...args) => $options.stop && $options.stop(...args), ["stop"]))
  2992. }, [
  2993. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($options.relationReply, (item, index2) => {
  2994. return vue.openBlock(), vue.createBlock(_component_SingleComment, {
  2995. "is-right": item.username === $data.targetUser.right,
  2996. key: item.floor,
  2997. comment: item
  2998. }, null, 8, ["is-right", "comment"]);
  2999. }), 128))
  3000. ])
  3001. ])) : vue.createCommentVNode("", true),
  3002. $data.showCallList && $options.filterCallList.length ? (vue.openBlock(), vue.createElementBlock("div", {
  3003. key: 1,
  3004. class: "call-list",
  3005. style: vue.normalizeStyle($data.callStyle)
  3006. }, [
  3007. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($options.filterCallList.slice(0, 10), (item, index2) => {
  3008. return vue.openBlock(), vue.createElementBlock("div", {
  3009. class: vue.normalizeClass(["call-item", { select: index2 === $data.selectCallIndex }]),
  3010. onClick: ($event) => $options.setCall(item)
  3011. }, [
  3012. vue.createElementVNode("a", null, vue.toDisplayString(item), 1)
  3013. ], 10, _hoisted_31);
  3014. }), 256))
  3015. ], 4)) : vue.createCommentVNode("", true),
  3016. $options.config.closePostDetailBySpace ? (vue.openBlock(), vue.createElementBlock("div", {
  3017. key: 2,
  3018. class: "close-btn",
  3019. onClick: _cache[17] || (_cache[17] = ($event) => $options.close("btn"))
  3020. }, _hoisted_33)) : vue.createCommentVNode("", true),
  3021. vue.createElementVNode("div", {
  3022. class: "scroll-top button",
  3023. onClick: _cache[18] || (_cache[18] = vue.withModifiers((...args) => $options.scrollTop && $options.scrollTop(...args), ["stop"]))
  3024. }, _hoisted_35),
  3025. vue.createElementVNode("div", {
  3026. class: "scroll-to button",
  3027. onClick: _cache[21] || (_cache[21] = vue.withModifiers(($event) => $options.jump($data.currentFloor), ["stop"]))
  3028. }, [
  3029. _hoisted_36,
  3030. vue.withDirectives(vue.createElementVNode("input", {
  3031. type: "text",
  3032. "onUpdate:modelValue": _cache[19] || (_cache[19] = ($event) => $data.currentFloor = $event),
  3033. onClick: _cache[20] || (_cache[20] = vue.withModifiers((...args) => $options.stop && $options.stop(...args), ["stop"]))
  3034. }, null, 512), [
  3035. [vue.vModelText, $data.currentFloor]
  3036. ])
  3037. ])
  3038. ], 512)
  3039. ], 34)), [
  3040. [vue.vShow, $props.modelValue]
  3041. ]);
  3042. }
  3043. const PostDetail = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$2], ["__scopeId", "data-v-4038172d"]]);
  3044. const _withScopeId$1 = (n) => (vue.pushScopeId("data-v-19fe372d"), n = n(), vue.popScopeId(), n);
  3045. const _hoisted_1$4 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ vue.createElementVNode("svg", {
  3046. width: "24",
  3047. height: "24",
  3048. viewBox: "0 0 48 48",
  3049. fill: "none",
  3050. xmlns: "http://www.w3.org/2000/svg"
  3051. }, [
  3052. /* @__PURE__ */ vue.createElementVNode("path", {
  3053. d: "M17 32L19.1875 27M31 32L28.8125 27M19.1875 27L24 16L28.8125 27M19.1875 27H28.8125",
  3054. stroke: "#929596",
  3055. "stroke-width": "4",
  3056. "stroke-linecap": "round",
  3057. "stroke-linejoin": "round"
  3058. }),
  3059. /* @__PURE__ */ vue.createElementVNode("path", {
  3060. d: "M43.1999 20C41.3468 10.871 33.2758 4 23.5999 4C13.9241 4 5.85308 10.871 4 20L10 18",
  3061. stroke: "#929596",
  3062. "stroke-width": "4",
  3063. "stroke-linecap": "round",
  3064. "stroke-linejoin": "round"
  3065. }),
  3066. /* @__PURE__ */ vue.createElementVNode("path", {
  3067. d: "M4 28C5.85308 37.129 13.9241 44 23.5999 44C33.2758 44 41.3468 37.129 43.1999 28L38 30",
  3068. stroke: "#929596",
  3069. "stroke-width": "4",
  3070. "stroke-linecap": "round",
  3071. "stroke-linejoin": "round"
  3072. })
  3073. ], -1));
  3074. const _hoisted_2$3 = { key: 1 };
  3075. const _sfc_main$4 = {
  3076. __name: "Base64Tooltip",
  3077. setup(__props) {
  3078. const tooltip = vue.ref(null);
  3079. const show = vue.ref(false);
  3080. const originalText = vue.ref("");
  3081. const decodeText = vue.ref("");
  3082. const styleObject = vue.reactive({
  3083. left: "-100vw",
  3084. top: "-100vh"
  3085. });
  3086. vue.onMounted(() => {
  3087. eventBus.on(CMD.SHOW_TOOLTIP, ({ text, e }) => {
  3088. setTimeout(() => show.value = true);
  3089. originalText.value = text;
  3090. decodeText.value = "";
  3091. styleObject.left = e.clientX + "px";
  3092. styleObject.top = e.clientY + 20 + "px";
  3093. });
  3094. window.addEventListener("click", (e) => {
  3095. if (!tooltip.value)
  3096. return;
  3097. if (!tooltip.value.contains(e.target) && show.value) {
  3098. show.value = false;
  3099. }
  3100. }, { capture: true });
  3101. const fn = () => show.value && (show.value = false);
  3102. $(".post-detail", window.win().doc).on("scroll", fn);
  3103. });
  3104. function copy() {
  3105. if (window.win().navigator.clipboard) {
  3106. window.win().navigator.clipboard.writeText(decodeText.value);
  3107. eventBus.emit(CMD.SHOW_MSG, { type: "success", text: "复制成功" });
  3108. } else {
  3109. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "复制失败!浏览器不支持!" });
  3110. }
  3111. }
  3112. function base64ToArrayBuffer(base64) {
  3113. let binary_string = window.atob(base64);
  3114. let len = binary_string.length;
  3115. let bytes = new Uint8Array(len);
  3116. for (let i = 0; i < len; i++) {
  3117. bytes[i] = binary_string.charCodeAt(i);
  3118. }
  3119. return bytes.buffer;
  3120. }
  3121. function decode() {
  3122. try {
  3123. new Blob([base64ToArrayBuffer(originalText.value)]).text().then((r) => {
  3124. decodeText.value = r;
  3125. });
  3126. } catch (e) {
  3127. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "Base64解码失败!不是标准数据!" });
  3128. }
  3129. }
  3130. return (_ctx, _cache) => {
  3131. return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
  3132. class: "base64_tooltip",
  3133. style: vue.normalizeStyle(styleObject),
  3134. onClick: decode,
  3135. ref_key: "tooltip",
  3136. ref: tooltip
  3137. }, [
  3138. !decodeText.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
  3139. vue.createTextVNode(" Base64解码:" + vue.toDisplayString(originalText.value) + " ", 1),
  3140. _hoisted_1$4
  3141. ], 64)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
  3142. vue.createElementVNode("span", null, vue.toDisplayString(decodeText.value), 1),
  3143. vue.createElementVNode("div", {
  3144. class: "button",
  3145. onClick: copy
  3146. }, "点击复制")
  3147. ]))
  3148. ], 4)), [
  3149. [vue.vShow, show.value]
  3150. ]);
  3151. };
  3152. }
  3153. };
  3154. const Base64Tooltip = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-19fe372d"]]);
  3155. const _sfc_main$3 = {
  3156. name: "Msg",
  3157. props: {
  3158. type: "",
  3159. text: ""
  3160. },
  3161. created() {
  3162. setTimeout(() => {
  3163. this.$emit("close");
  3164. }, 3e3);
  3165. }
  3166. };
  3167. const _hoisted_1$3 = /* @__PURE__ */ vue.createElementVNode("svg", {
  3168. width: "24",
  3169. height: "24",
  3170. viewBox: "0 0 48 48",
  3171. fill: "none",
  3172. xmlns: "http://www.w3.org/2000/svg"
  3173. }, [
  3174. /* @__PURE__ */ vue.createElementVNode("path", {
  3175. d: "M14 14L34 34",
  3176. stroke: "#ffffff",
  3177. "stroke-width": "4",
  3178. "stroke-linecap": "round",
  3179. "stroke-linejoin": "round"
  3180. }),
  3181. /* @__PURE__ */ vue.createElementVNode("path", {
  3182. d: "M14 34L34 14",
  3183. stroke: "#ffffff",
  3184. "stroke-width": "4",
  3185. "stroke-linecap": "round",
  3186. "stroke-linejoin": "round"
  3187. })
  3188. ], -1);
  3189. const _hoisted_2$2 = [
  3190. _hoisted_1$3
  3191. ];
  3192. const _hoisted_3$2 = { class: "right" };
  3193. function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  3194. return vue.openBlock(), vue.createElementBlock("div", {
  3195. class: vue.normalizeClass(["msg", $props.type])
  3196. }, [
  3197. vue.createElementVNode("div", {
  3198. class: "left",
  3199. onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
  3200. }, _hoisted_2$2),
  3201. vue.createElementVNode("div", _hoisted_3$2, vue.toDisplayString($props.text), 1)
  3202. ], 2);
  3203. }
  3204. const Msg = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$1]]);
  3205. const _withScopeId = (n) => (vue.pushScopeId("data-v-b28a2e5e"), n = n(), vue.popScopeId(), n);
  3206. const _hoisted_1$2 = { class: "wrapper" };
  3207. const _hoisted_2$1 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("div", { class: "title" }, " 添加标签 ", -1));
  3208. const _hoisted_3$1 = { class: "option" };
  3209. const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("span", null, "用户:", -1));
  3210. const _hoisted_5 = ["onKeydown"];
  3211. const _hoisted_6 = { class: "btns" };
  3212. const _sfc_main$2 = {
  3213. __name: "TagModal",
  3214. props: ["tags"],
  3215. emits: ["update:tags"],
  3216. setup(__props, { emit }) {
  3217. const props = __props;
  3218. const tagModal = vue.reactive({
  3219. show: false,
  3220. currentUsername: "",
  3221. tag: ""
  3222. });
  3223. const isNight = vue.inject("isNight");
  3224. const input = vue.ref < HTMLInputElement > null;
  3225. vue.onMounted(() => {
  3226. eventBus.on(CMD.ADD_TAG, (username) => {
  3227. tagModal.currentUsername = username;
  3228. tagModal.show = true;
  3229. vue.nextTick(() => {
  3230. input.value.focus();
  3231. });
  3232. });
  3233. });
  3234. async function addTag() {
  3235. let oldTag = window.clone(props.tags);
  3236. let tempTag = window.clone(props.tags);
  3237. let userTags = tempTag[tagModal.currentUsername] ?? [];
  3238. let rIndex = userTags.findIndex((v) => v === tagModal.tag);
  3239. if (rIndex > -1) {
  3240. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "标签已存在!" });
  3241. return;
  3242. } else {
  3243. userTags.push(tagModal.tag);
  3244. }
  3245. tempTag[tagModal.currentUsername] = userTags;
  3246. emit("update:tags", tempTag);
  3247. tagModal.tag = "";
  3248. tagModal.show = false;
  3249. let res = await window.parse.saveTags(tempTag);
  3250. if (!res) {
  3251. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "标签添加失败!" });
  3252. emit("update:tags", oldTag);
  3253. }
  3254. }
  3255. return (_ctx, _cache) => {
  3256. return vue.openBlock(), vue.createBlock(vue.Transition, null, {
  3257. default: vue.withCtx(() => [
  3258. tagModal.show ? (vue.openBlock(), vue.createElementBlock("div", {
  3259. key: 0,
  3260. class: vue.normalizeClass(["tag-modal modal", { isNight: vue.unref(isNight) }])
  3261. }, [
  3262. vue.createElementVNode("div", {
  3263. class: "mask",
  3264. onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => tagModal.show = false, ["stop"]))
  3265. }),
  3266. vue.createElementVNode("div", _hoisted_1$2, [
  3267. _hoisted_2$1,
  3268. vue.createElementVNode("div", _hoisted_3$1, [
  3269. _hoisted_4,
  3270. vue.createElementVNode("div", null, vue.toDisplayString(tagModal.currentUsername), 1)
  3271. ]),
  3272. vue.withDirectives(vue.createElementVNode("input", {
  3273. type: "text",
  3274. ref: "input",
  3275. style: { "width": "100%" },
  3276. autofocus: "",
  3277. "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => tagModal.tag = $event),
  3278. onKeydown: vue.withKeys(addTag, ["enter"])
  3279. }, null, 40, _hoisted_5), [
  3280. [vue.vModelText, tagModal.tag]
  3281. ]),
  3282. vue.createElementVNode("div", _hoisted_6, [
  3283. vue.createElementVNode("div", {
  3284. class: "white",
  3285. onClick: _cache[2] || (_cache[2] = ($event) => tagModal.show = false)
  3286. }, "取消"),
  3287. vue.createElementVNode("div", {
  3288. class: "main",
  3289. onClick: addTag
  3290. }, "确定")
  3291. ])
  3292. ])
  3293. ], 2)) : vue.createCommentVNode("", true)
  3294. ]),
  3295. _: 1
  3296. });
  3297. };
  3298. }
  3299. };
  3300. const TagModal = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-b28a2e5e"]]);
  3301. const _hoisted_1$1 = { class: "msgs" };
  3302. const _sfc_main$1 = {
  3303. __name: "MsgModal",
  3304. setup(__props) {
  3305. const msgList = vue.reactive([
  3306. // {type: 'success', text: '123', id: Date.now()}
  3307. ]);
  3308. vue.onMounted(() => {
  3309. eventBus.on(CMD.SHOW_MSG, (val) => {
  3310. msgList.push({ ...val, id: Date.now() });
  3311. });
  3312. });
  3313. function removeMsg(id) {
  3314. let rIndex = msgList.findIndex((item) => item.id === id);
  3315. if (rIndex > -1) {
  3316. msgList.splice(rIndex, 1);
  3317. }
  3318. }
  3319. return (_ctx, _cache) => {
  3320. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
  3321. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(msgList, (v) => {
  3322. return vue.openBlock(), vue.createBlock(Msg, {
  3323. key: v.id,
  3324. type: v.type,
  3325. text: v.text,
  3326. onClose: ($event) => removeMsg(v.id)
  3327. }, null, 8, ["type", "text", "onClose"]);
  3328. }), 128))
  3329. ]);
  3330. };
  3331. }
  3332. };
  3333. const MsgModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-95974c3e"]]);
  3334. const _sfc_main = {
  3335. components: { MsgModal, TagModal, Tooltip, Setting, PostDetail, Base64Tooltip, Msg },
  3336. provide() {
  3337. return {
  3338. isLogin: vue.computed(() => this.isLogin),
  3339. isNight: vue.computed(() => this.isNight),
  3340. pageType: vue.computed(() => this.pageType),
  3341. tags: vue.computed(() => this.tags),
  3342. show: vue.computed(() => this.show),
  3343. post: vue.computed(() => this.current),
  3344. config: vue.computed(() => this.config),
  3345. allReplyUsers: vue.computed(() => {
  3346. var _a, _b, _c;
  3347. if ((_a = this.current) == null ? void 0 : _a.replyList) {
  3348. return Array.from(new Set(((_c = (_b = this.current) == null ? void 0 : _b.replyList) == null ? void 0 : _c.map((v) => v.username)) ?? []));
  3349. }
  3350. return [];
  3351. }),
  3352. showConfig: this.showConfig
  3353. };
  3354. },
  3355. data() {
  3356. return {
  3357. loading: window.pageType === PageType.Post,
  3358. loadMore: false,
  3359. isLogin: !!window.user.username,
  3360. pageType: window.pageType,
  3361. isNight: window.isNight,
  3362. stopMe: false,
  3363. //停止使用脚本
  3364. show: false,
  3365. current: window.clone(window.initPost),
  3366. list: [],
  3367. config: window.clone(window.config),
  3368. tags: window.user.tags,
  3369. readList: window.user.readList,
  3370. configModal: {
  3371. show: false
  3372. },
  3373. tagModal: {
  3374. show: false,
  3375. currentUsername: "",
  3376. tag: ""
  3377. }
  3378. };
  3379. },
  3380. computed: {
  3381. isList() {
  3382. return this.pageType !== PageType.Post;
  3383. },
  3384. isPost() {
  3385. return this.pageType === PageType.Post;
  3386. }
  3387. },
  3388. watch: {
  3389. "current.replyList": {
  3390. handler(newVal, oldVal) {
  3391. if (newVal.length) {
  3392. this.current.replyCount = newVal.length;
  3393. let res = window.parse.createNestedList(newVal, this.current.allReplyUsers);
  3394. if (res) {
  3395. this.current.nestedReplies = res;
  3396. }
  3397. } else {
  3398. this.current.replyCount = 0;
  3399. this.current.nestedReplies = [];
  3400. }
  3401. if (this.list) {
  3402. let rIndex = this.list.findIndex((i) => i.id === this.current.id);
  3403. if (rIndex > -1) {
  3404. this.list[rIndex].replyCount = newVal.length;
  3405. }
  3406. }
  3407. },
  3408. deep: true
  3409. },
  3410. config: {
  3411. handler(newVal) {
  3412. let config2 = { [window.user.username ?? "default"]: newVal };
  3413. localStorage.setItem("v2ex-config", JSON.stringify(config2));
  3414. window.config = newVal;
  3415. },
  3416. deep: true
  3417. },
  3418. tags(newVal) {
  3419. window.user.tags = newVal;
  3420. },
  3421. "config.viewType"(newVal) {
  3422. if (!newVal)
  3423. return;
  3424. if (newVal === "card") {
  3425. $(".post-item").each(function() {
  3426. $(this).addClass("preview");
  3427. });
  3428. } else {
  3429. $(".post-item").each(function() {
  3430. $(this).removeClass("preview");
  3431. });
  3432. }
  3433. }
  3434. },
  3435. created() {
  3436. window.cb = this.winCb;
  3437. if (window.win().canParseV2exPage) {
  3438. if (this.isList)
  3439. ;
  3440. }
  3441. $(document).on("click", "a", (e) => {
  3442. if (this.stopMe)
  3443. return true;
  3444. let { href, id, title } = window.parse.parseA(e.currentTarget);
  3445. if (this.clickPost(e, id, href, title)) {
  3446. return false;
  3447. }
  3448. });
  3449. let that = this;
  3450. $(document).on("click", ".post-item", function(e) {
  3451. if (this.classList.contains("preview")) {
  3452. if (e.target.tagName !== "A" && e.target.tagName !== "IMG" && !e.target.classList.contains("toggle")) {
  3453. console.log("点空白处");
  3454. let id = this.dataset["id"];
  3455. let href = this.dataset["href"];
  3456. if (that.clickPost(e, id, href)) {
  3457. return false;
  3458. } else {
  3459. location.href = href;
  3460. }
  3461. }
  3462. }
  3463. });
  3464. $(document).on("click", ".toggle", (e) => {
  3465. let id = e.currentTarget.dataset["id"];
  3466. let itemDom = window.win().query(`.id_${id}`);
  3467. if (itemDom.classList.contains("preview")) {
  3468. itemDom.classList.remove("preview");
  3469. } else {
  3470. itemDom.classList.add("preview");
  3471. }
  3472. });
  3473. window.onpopstate = (event) => {
  3474. if (event.state) {
  3475. if (!this.show)
  3476. this.show = true;
  3477. } else {
  3478. if (this.show)
  3479. this.show = false;
  3480. }
  3481. };
  3482. window.onbeforeunload = () => {
  3483. this.saveReadList();
  3484. };
  3485. this.initEvent();
  3486. },
  3487. beforeUnmount() {
  3488. eventBus.clear();
  3489. },
  3490. methods: {
  3491. saveReadList() {
  3492. window.parse.saveReadList(this.readList);
  3493. },
  3494. clickPost(e, id, href, title = "") {
  3495. var _a, _b, _c, _d, _e, _f;
  3496. if (id) {
  3497. if (this.config.clickPostItemOpenDetail) {
  3498. let index2 = this.list.findIndex((v) => v.id == id);
  3499. let postItem = this.clone(window.initPost);
  3500. if (index2 > -1) {
  3501. postItem = this.list[index2];
  3502. } else {
  3503. postItem.title = title ?? "加载中";
  3504. }
  3505. postItem.id = id;
  3506. postItem.href = href;
  3507. if (!postItem.headerTemplate) {
  3508. let template = `
  3509. <div class="header">
  3510. <div class="fr">
  3511. <a href="/member/${((_a = postItem == null ? void 0 : postItem.member) == null ? void 0 : _a.username) ?? ""}">
  3512. <img src="${((_b = postItem == null ? void 0 : postItem.member) == null ? void 0 : _b.avatar_large) ?? ""}" class="avatar"
  3513. border="0"
  3514. align="default" width="73" style="width: 73px; max-height: 73px;" alt="${((_c = postItem == null ? void 0 : postItem.member) == null ? void 0 : _c.username) ?? ""}">
  3515. </a>
  3516. </div>
  3517. <a href="/public">V2EX</a> <span class="chevron">&nbsp;›&nbsp;</span> <a href="${((_d = postItem == null ? void 0 : postItem.node) == null ? void 0 : _d.url) ?? ""}">${((_e = postItem == null ? void 0 : postItem.node) == null ? void 0 : _e.title) ?? ""}</a>
  3518. <div class="sep10"></div>
  3519. <h1>${(postItem == null ? void 0 : postItem.title) || "加载中..."}</h1>
  3520. <div id="topic_930514_votes" class="votes">
  3521. <a href="javascript:" onclick="null" class="vote">
  3522. <li class="fa fa-chevron-up"></li>
  3523. &nbsp;
  3524. </a> &nbsp;
  3525. <a href="javascript:" onclick="null" class="vote">
  3526. <li class="fa fa-chevron-down"></li>
  3527. </a>
  3528. </div> &nbsp;
  3529. <small class="gray">
  3530. <a href="/member/zyronon">${((_f = postItem == null ? void 0 : postItem.member) == null ? void 0 : _f.username) ?? ""}</a> ·
  3531. <span title="2023-04-07 11:32:28 +08:00">1 天前</span> · 0 次点击
  3532. </small>
  3533. </div>
  3534. <div class="cell">
  3535. <div class="topic_content">
  3536. <div class="markdown_body">
  3537. ${(postItem == null ? void 0 : postItem.content_rendered) ?? ""}
  3538. </div>
  3539. </div>
  3540. </div>
  3541. `;
  3542. postItem.headerTemplate = template;
  3543. }
  3544. this.getPostDetail(postItem);
  3545. e.preventDefault();
  3546. return true;
  3547. }
  3548. if (this.config.newTabOpen) {
  3549. let tempId = "a_blank_" + Date.now();
  3550. let a = win().doc.createElement("a");
  3551. a.setAttribute("href", href);
  3552. a.setAttribute("target", "_blank");
  3553. a.setAttribute("id", tempId);
  3554. if (!win().doc.getElementById(tempId)) {
  3555. win().doc.body.appendChild(a);
  3556. }
  3557. a.click();
  3558. return true;
  3559. }
  3560. }
  3561. },
  3562. showPost() {
  3563. this.show = true;
  3564. $(`#Wrapper #Main .box:lt(3)`).each(function() {
  3565. $(this).hide();
  3566. });
  3567. },
  3568. showConfig() {
  3569. this.configModal.show = true;
  3570. },
  3571. async winCb({ type, value }) {
  3572. if (type === "openSetting") {
  3573. this.configModal.show = true;
  3574. }
  3575. if (type === "restorePost") {
  3576. if (this.stopMe)
  3577. return;
  3578. this.stopMe = true;
  3579. this.show = false;
  3580. this.loading = false;
  3581. eventBus.emit(CMD.SHOW_MSG, { type: "warning", text: "脚本无法查看此页面!" });
  3582. $(`#Wrapper #Main .box:lt(3)`).each(function() {
  3583. $(this).show();
  3584. });
  3585. }
  3586. if (type === "postContent") {
  3587. if (this.stopMe)
  3588. return;
  3589. this.current = Object.assign(this.clone(this.current), this.clone(value));
  3590. if (this.config.autoOpenDetail) {
  3591. this.showPost();
  3592. }
  3593. }
  3594. if (type === "postReplies") {
  3595. if (this.stopMe)
  3596. return;
  3597. this.current = Object.assign(this.clone(this.current), this.clone(value));
  3598. console.log("当前帖子", this.current);
  3599. this.loading = false;
  3600. }
  3601. if (type === "syncData") {
  3602. this.list = window.postList;
  3603. this.config = window.config;
  3604. this.tags = window.user.tags;
  3605. this.readList = window.user.readList;
  3606. this.current.read = this.readList[this.current.id] ?? {};
  3607. if (this.show && this.isPost && this.current.read.floor) {
  3608. this.$refs.postDetail.read = this.current.read;
  3609. }
  3610. console.log("this.readList", this.readList);
  3611. }
  3612. },
  3613. clone(val) {
  3614. return window.clone(val);
  3615. },
  3616. initEvent() {
  3617. eventBus.on(CMD.CHANGE_COMMENT_THANK, (val) => {
  3618. console.log("CHANGE_COMMENT_THANK", val);
  3619. const { id, type } = val;
  3620. let currentI = this.current.replyList.findIndex((i) => i.id === id);
  3621. if (currentI > -1) {
  3622. this.current.replyList[currentI].isThanked = type === "add";
  3623. if (type === "add") {
  3624. this.current.replyList[currentI].thankCount++;
  3625. } else {
  3626. this.current.replyList[currentI].thankCount--;
  3627. }
  3628. }
  3629. });
  3630. eventBus.on(CMD.CHANGE_POST_THANK, (val) => {
  3631. const { id, type } = val;
  3632. this.current.isThanked = type === "add";
  3633. if (type === "add") {
  3634. this.current.thankCount++;
  3635. } else {
  3636. this.current.thankCount--;
  3637. }
  3638. let currentI = this.list.findIndex((i) => i.id === id);
  3639. if (currentI > -1) {
  3640. this.list[currentI].isThanked = type === "add";
  3641. if (type === "add") {
  3642. this.list[currentI].thankCount++;
  3643. } else {
  3644. this.list[currentI].thankCount++;
  3645. }
  3646. }
  3647. });
  3648. eventBus.on(CMD.REMOVE, (val) => {
  3649. let removeIndex = this.current.replyList.findIndex((i) => i.floor === val);
  3650. if (removeIndex > -1) {
  3651. this.current.replyList.splice(removeIndex, 1);
  3652. }
  3653. let rIndex = this.list.findIndex((i) => i.id === this.current.id);
  3654. if (rIndex > -1) {
  3655. this.list[rIndex] = Object.assign(this.list[rIndex], val);
  3656. }
  3657. });
  3658. eventBus.on(CMD.IGNORE, () => {
  3659. this.show = false;
  3660. let rIndex = this.list.findIndex((i) => i.id === this.current.id);
  3661. if (rIndex > -1) {
  3662. this.list.splice(rIndex, 1);
  3663. }
  3664. this.current = this.clone(window.initPost);
  3665. });
  3666. eventBus.on(CMD.MERGE, (val) => {
  3667. this.current = Object.assign(this.current, val);
  3668. let rIndex = this.list.findIndex((i) => i.id === this.current.id);
  3669. if (rIndex > -1) {
  3670. this.list[rIndex] = Object.assign(this.list[rIndex], val);
  3671. }
  3672. });
  3673. eventBus.on(CMD.ADD_READ, (val) => {
  3674. this.readList[this.current.id] = val;
  3675. });
  3676. eventBus.on(CMD.ADD_REPLY, (item) => {
  3677. this.current.replyList.push(item);
  3678. });
  3679. eventBus.on(CMD.REFRESH_ONCE, async (once) => {
  3680. if (once) {
  3681. if (typeof once === "string") {
  3682. let res = once.match(/var once = "([\d]+)";/);
  3683. if (res && res[1]) {
  3684. this.current.once = Number(res[1]);
  3685. return;
  3686. }
  3687. }
  3688. if (typeof once === "number") {
  3689. this.current.once = once;
  3690. return;
  3691. }
  3692. }
  3693. window.fetchOnce().then((r) => {
  3694. this.current.once = r;
  3695. });
  3696. });
  3697. eventBus.on(CMD.REMOVE_TAG, async ({ username, tag }) => {
  3698. let oldTag = this.clone(this.tags);
  3699. let tags = this.tags[username] ?? [];
  3700. let rIndex = tags.findIndex((v) => v === tag);
  3701. if (rIndex > -1) {
  3702. tags.splice(rIndex, 1);
  3703. }
  3704. this.tags[username] = tags;
  3705. let res = await window.parse.saveTags(this.tags);
  3706. if (!res) {
  3707. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "标签删除失败!" });
  3708. this.tags = oldTag;
  3709. }
  3710. });
  3711. },
  3712. async getPostDetail(post, event) {
  3713. this.current = Object.assign({}, window.initPost, post);
  3714. this.current.read = this.readList[this.current.id] ?? { floor: 0, total: 0 };
  3715. this.show = true;
  3716. let url = window.baseUrl + "/t/" + post.id;
  3717. document.body.style.overflow = "hidden";
  3718. window.history.pushState({}, 0, post.href ?? url);
  3719. window.document.title = post.title ?? "V2EX";
  3720. let alreadyHasReply = this.current.replyList.length;
  3721. if (alreadyHasReply) {
  3722. this.$refs.postDetail.jumpLastRead(this.current.read.floor);
  3723. } else {
  3724. this.loading = true;
  3725. }
  3726. let apiRes = await window.fetch(url + "?p=1");
  3727. if (apiRes.status === 404) {
  3728. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "主题未找到" });
  3729. return this.loading = false;
  3730. }
  3731. if (apiRes.status === 403) {
  3732. this.loading = false;
  3733. this.show = false;
  3734. window.open(`https://www.v2ex.com/t/${post.id}?p=1&script=0`, "_black");
  3735. return;
  3736. }
  3737. if (apiRes.redirected) {
  3738. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "没有权限" });
  3739. return this.loading = false;
  3740. }
  3741. let htmlText = await apiRes.text();
  3742. let hasPermission = htmlText.search("你要查看的页面需要先登录");
  3743. if (hasPermission > -1) {
  3744. eventBus.emit(CMD.SHOW_MSG, { type: "error", text: "你要查看的页面需要先登录" });
  3745. return this.loading = false;
  3746. }
  3747. let bodyText = htmlText.match(/<body[^>]*>([\s\S]+?)<\/body>/g);
  3748. let body = $(bodyText[0]);
  3749. this.current = await window.parse.getPostDetail(this.current, body, htmlText);
  3750. if (this.current.replyList.length) {
  3751. let index2 = this.list.findIndex((v) => v.id == post.id);
  3752. if (index2 > -1) {
  3753. this.list[index2].replyList = this.current.replyList;
  3754. this.list[index2].nestedReplies = this.current.nestedReplies;
  3755. this.list[index2].once = this.current.once;
  3756. this.list[index2].createDate = this.current.createDate;
  3757. } else {
  3758. this.list.push(this.clone(this.current));
  3759. }
  3760. }
  3761. this.loading = false;
  3762. if (!alreadyHasReply) {
  3763. vue.nextTick(() => {
  3764. this.$refs.postDetail.jumpLastRead(this.current.read.floor);
  3765. });
  3766. }
  3767. console.log("当前帖子", this.current);
  3768. }
  3769. }
  3770. };
  3771. const _hoisted_1 = {
  3772. key: 0,
  3773. class: "nav flex flex-end"
  3774. };
  3775. const _hoisted_2 = {
  3776. key: 1,
  3777. class: "my-box flex f14 open-post",
  3778. style: { "margin": "2rem 0 0 0", "padding": "1rem" }
  3779. };
  3780. const _hoisted_3 = { class: "flex" };
  3781. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  3782. const _component_Setting = vue.resolveComponent("Setting");
  3783. const _component_TagModal = vue.resolveComponent("TagModal");
  3784. const _component_PostDetail = vue.resolveComponent("PostDetail");
  3785. const _component_Base64Tooltip = vue.resolveComponent("Base64Tooltip");
  3786. const _component_MsgModal = vue.resolveComponent("MsgModal");
  3787. return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
  3788. vue.createVNode(_component_Setting, {
  3789. modelValue: $data.config,
  3790. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.config = $event),
  3791. show: $data.configModal.show,
  3792. "onUpdate:show": _cache[1] || (_cache[1] = ($event) => $data.configModal.show = $event)
  3793. }, null, 8, ["modelValue", "show"]),
  3794. vue.createVNode(_component_TagModal, {
  3795. tags: $data.tags,
  3796. "onUpdate:tags": _cache[2] || (_cache[2] = ($event) => $data.tags = $event)
  3797. }, null, 8, ["tags"]),
  3798. vue.createVNode(_component_PostDetail, {
  3799. modelValue: $data.show,
  3800. "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $data.show = $event),
  3801. ref: "postDetail",
  3802. displayType: $data.config.commentDisplayType,
  3803. "onUpdate:displayType": _cache[4] || (_cache[4] = ($event) => $data.config.commentDisplayType = $event),
  3804. onSaveReadList: $options.saveReadList,
  3805. loading: $data.loading
  3806. }, null, 8, ["modelValue", "displayType", "onSaveReadList", "loading"]),
  3807. vue.createVNode(_component_Base64Tooltip),
  3808. vue.createVNode(_component_MsgModal),
  3809. !$data.stopMe && $data.config.showToolbar ? (vue.openBlock(), vue.createElementBlock("div", {
  3810. key: 0,
  3811. class: vue.normalizeClass(["toolbar", [$data.isNight ? "isNight" : "", $data.config["viewType"]]])
  3812. }, [
  3813. $options.isList ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
  3814. vue.createElementVNode("div", {
  3815. class: vue.normalizeClass(["radio-group2", { isNight: $data.isNight }])
  3816. }, [
  3817. vue.createElementVNode("div", {
  3818. class: vue.normalizeClass(["radio", $data.config.viewType === "table" ? "active" : ""]),
  3819. onClick: _cache[5] || (_cache[5] = ($event) => $data.config.viewType = "table")
  3820. }, "表格 ", 2),
  3821. vue.createElementVNode("div", {
  3822. class: vue.normalizeClass(["radio", $data.config.viewType === "card" ? "active" : ""]),
  3823. onClick: _cache[6] || (_cache[6] = ($event) => $data.config.viewType = "card")
  3824. }, "卡片 ", 2)
  3825. ], 2)
  3826. ])) : vue.createCommentVNode("", true),
  3827. !$options.isList && !$data.show ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
  3828. vue.createElementVNode("div", _hoisted_3, [
  3829. vue.createTextVNode(" 默认显示楼中楼 : "),
  3830. vue.createElementVNode("div", {
  3831. class: vue.normalizeClass(["switch light", { active: $data.config.autoOpenDetail }]),
  3832. onClick: _cache[7] || (_cache[7] = ($event) => $data.config.autoOpenDetail = !$data.config.autoOpenDetail)
  3833. }, null, 2)
  3834. ]),
  3835. vue.createElementVNode("div", {
  3836. class: vue.normalizeClass(["button light", { loading: $data.loading, isNight: $data.isNight }]),
  3837. onClick: _cache[8] || (_cache[8] = (...args) => $options.showPost && $options.showPost(...args))
  3838. }, " 点击显示楼中楼 ", 2)
  3839. ])) : vue.createCommentVNode("", true)
  3840. ], 2)) : vue.createCommentVNode("", true)
  3841. ], 64);
  3842. }
  3843. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-f9a9d2e9"]]);
  3844. var _GM_notification = /* @__PURE__ */ (() => typeof GM_notification != "undefined" ? GM_notification : void 0)();
  3845. var _GM_openInTab = /* @__PURE__ */ (() => typeof GM_openInTab != "undefined" ? GM_openInTab : void 0)();
  3846. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  3847. let $section = document.createElement("section");
  3848. $section.id = "app";
  3849. function run() {
  3850. window.baseUrl = location.origin;
  3851. window.initPost = {
  3852. allReplyUsers: [],
  3853. content_rendered: "",
  3854. createDate: "",
  3855. fr: "",
  3856. replyList: [],
  3857. nestedReplies: [],
  3858. username: "",
  3859. member: {},
  3860. node: {},
  3861. headerTemplate: "",
  3862. title: "",
  3863. id: "",
  3864. type: "post",
  3865. once: "",
  3866. replyCount: 0,
  3867. clickCount: 0,
  3868. thankCount: 0,
  3869. collectCount: 0,
  3870. lastReadFloor: 0,
  3871. isFavorite: false,
  3872. isIgnore: false,
  3873. isThanked: false,
  3874. isReport: false
  3875. };
  3876. window.win = function() {
  3877. return window;
  3878. };
  3879. window.win().doc = window.win().document;
  3880. window.win().query = (v) => window.win().document.querySelector(v);
  3881. window.query = (v) => window.win().document.querySelector(v);
  3882. window.clone = (val) => JSON.parse(JSON.stringify(val));
  3883. window.user = {
  3884. tagPrefix: "--用户标签--",
  3885. tags: {},
  3886. tagsId: "",
  3887. username: "",
  3888. avatar: "",
  3889. readPrefix: "--已读楼层--",
  3890. readNoteItemId: "",
  3891. readList: {}
  3892. };
  3893. window.pageType = void 0;
  3894. window.pageData = { pageNo: 1 };
  3895. window.config = {
  3896. showToolbar: true,
  3897. showPreviewBtn: true,
  3898. autoOpenDetail: true,
  3899. openTag: true,
  3900. //给用户打标签
  3901. clickPostItemOpenDetail: true,
  3902. closePostDetailBySpace: true,
  3903. //点击空白处关闭详情
  3904. contentAutoCollapse: true,
  3905. //正文超长自动折叠
  3906. viewType: "table",
  3907. commentDisplayType: 0,
  3908. newTabOpen: false,
  3909. //新标签打开
  3910. base64: true,
  3911. //base功能
  3912. sov2ex: false,
  3913. postWidth: "",
  3914. showTopReply: true,
  3915. topReplyLoveMinCount: 3,
  3916. topReplyCount: 3,
  3917. autoJumpLastReadFloor: false,
  3918. rememberLastReadFloor: true,
  3919. autoSignin: true,
  3920. customBgColor: "",
  3921. version: 1,
  3922. collectBrowserNotice: false
  3923. };
  3924. window.isNight = $(".Night").length === 1;
  3925. window.cb = null;
  3926. window.postList = [];
  3927. window.parse = {
  3928. //解析帖子内容
  3929. async parsePostContent(post, body, htmlText) {
  3930. let once = htmlText.match(/var once = "([\d]+)";/);
  3931. if (once && once[1]) {
  3932. post.once = once[1];
  3933. }
  3934. post.isReport = htmlText.includes("你已对本主题进行了报告");
  3935. if (!post.title || !post.content_rendered) {
  3936. let main = body.find("#Main");
  3937. let aName = main.find(".header small.gray a:nth-child(1)");
  3938. if (aName) {
  3939. post.member.username = aName[0].innerText;
  3940. }
  3941. }
  3942. let topic_buttons = body.find(".topic_buttons");
  3943. if (topic_buttons.length) {
  3944. let favoriteNode = topic_buttons.find(".tb:first");
  3945. if (favoriteNode.length) {
  3946. post.isFavorite = favoriteNode[0].innerText === "取消收藏";
  3947. }
  3948. let ignoreNode = topic_buttons.find(".tb:nth-child(3)");
  3949. if (ignoreNode.length) {
  3950. post.isIgnore = ignoreNode[0].innerText === "取消忽略";
  3951. }
  3952. let thankNode = topic_buttons.find("#topic_thank .tb");
  3953. if (!thankNode.length) {
  3954. post.isThanked = true;
  3955. }
  3956. let topic_stats = topic_buttons.find(".topic_stats");
  3957. if (topic_stats.length) {
  3958. let text = topic_stats[0].innerText;
  3959. let reg1 = text.matchAll(/([\d]+)[\s]*人收藏/g);
  3960. let collectCountReg = [...reg1];
  3961. if (collectCountReg.length) {
  3962. post.collectCount = Number(collectCountReg[0][1]);
  3963. }
  3964. reg1 = text.matchAll(/([\d]+)[\s]*likes/g);
  3965. collectCountReg = [...reg1];
  3966. if (collectCountReg.length) {
  3967. post.collectCount = Number(collectCountReg[0][1]);
  3968. }
  3969. let reg2 = text.matchAll(/([\d]+)[\s]*人感谢/g);
  3970. let thankCountReg = [...reg2];
  3971. if (thankCountReg.length) {
  3972. post.thankCount = Number(thankCountReg[0][1]);
  3973. }
  3974. let reg3 = text.matchAll(/([\d]+)[\s]*次点击/g);
  3975. let clickCountReg = [...reg3];
  3976. if (clickCountReg.length) {
  3977. post.clickCount = Number(clickCountReg[0][1]);
  3978. }
  3979. reg3 = text.matchAll(/([\d]+)[\s]*views/g);
  3980. clickCountReg = [...reg3];
  3981. if (clickCountReg.length) {
  3982. post.clickCount = Number(clickCountReg[0][1]);
  3983. }
  3984. }
  3985. }
  3986. let header = body.find("#Main .box").first();
  3987. let temp = header.clone();
  3988. temp.find(".topic_buttons").remove();
  3989. let html = temp.html();
  3990. html = this.checkPhotoLink2Img(html);
  3991. post.headerTemplate = html;
  3992. return post;
  3993. },
  3994. //获取帖子所有回复
  3995. async getPostAllReplies(post, body, htmlText, pageNo = 1) {
  3996. var _a, _b;
  3997. if (body.find("#no-comments-yet").length) {
  3998. return post;
  3999. }
  4000. let box = body.find("#Main > .box")[1];
  4001. let cells = box.querySelectorAll(".cell");
  4002. if (cells && cells.length) {
  4003. post.fr = cells[0].querySelector(".cell .fr").innerHTML;
  4004. cells = Array.from(cells);
  4005. }
  4006. let snow = cells[0].querySelector(".snow");
  4007. post.createDate = ((_b = (_a = snow == null ? void 0 : snow.nextSibling) == null ? void 0 : _a.nodeValue) == null ? void 0 : _b.trim()) || "";
  4008. let repliesMap = [];
  4009. if (cells[1].id) {
  4010. repliesMap.push({ i: pageNo, replyList: this.parsePageReplies(cells.slice(1)) });
  4011. let replyList = this.getAllReply(repliesMap);
  4012. post.replyList = replyList;
  4013. post.replyCount = replyList.length;
  4014. post.allReplyUsers = Array.from(new Set(replyList.map((v) => v.username)));
  4015. let nestedList = this.createNestedList(replyList, post.allReplyUsers);
  4016. if (nestedList)
  4017. post.nestedReplies = nestedList;
  4018. return post;
  4019. } else {
  4020. let promiseList = [];
  4021. return new Promise((resolve, reject) => {
  4022. repliesMap.push({ i: pageNo, replyList: this.parsePageReplies(cells.slice(2, cells.length - 1)) });
  4023. let pages = cells[1].querySelectorAll("a");
  4024. pages = Array.from(pages);
  4025. let url = window.baseUrl + "/t/" + post.id;
  4026. for (let i = 0; i < pages.length; i++) {
  4027. let currentPageNo = Number(pages[i].innerText);
  4028. if (currentPageNo == pageNo)
  4029. continue;
  4030. promiseList.push(this.fetchPostOtherPageReplies(url + "?p=" + currentPageNo, currentPageNo));
  4031. }
  4032. Promise.allSettled(promiseList).then(
  4033. (results) => {
  4034. results.filter((result) => result.status === "fulfilled").map((v) => repliesMap.push(v.value));
  4035. let replyList = this.getAllReply(repliesMap);
  4036. post.replyList = replyList;
  4037. post.replyCount = replyList.length;
  4038. post.allReplyUsers = Array.from(new Set(replyList.map((v) => v.username)));
  4039. let nestedList = this.createNestedList(replyList, post.allReplyUsers);
  4040. if (nestedList)
  4041. post.nestedReplies = nestedList;
  4042. resolve(post);
  4043. }
  4044. );
  4045. });
  4046. }
  4047. },
  4048. //请求帖子其他页的回复
  4049. fetchPostOtherPageReplies(href, pageNo) {
  4050. return new Promise((resolve) => {
  4051. $.get(href).then((res) => {
  4052. let s = res.match(/<body[^>]*>([\s\S]+?)<\/body>/g);
  4053. let box = $(s[0]).find("#Main .box")[1];
  4054. let cells = box.querySelectorAll(".cell");
  4055. cells = Array.from(cells);
  4056. resolve({ i: pageNo, replyList: this.parsePageReplies(cells.slice(2, cells.length - 1)) });
  4057. }).catch((r) => {
  4058. if (r.status === 403) {
  4059. cbChecker({ type: "restorePost", value: null });
  4060. }
  4061. });
  4062. });
  4063. },
  4064. //解析页面的回复
  4065. parsePageReplies(nodes) {
  4066. let replyList = [];
  4067. nodes.forEach((node, index2) => {
  4068. if (!node.id)
  4069. return;
  4070. let item = {
  4071. level: 0,
  4072. thankCount: 0,
  4073. isThanked: false,
  4074. isOp: false,
  4075. id: node.id.replace("r_", "")
  4076. };
  4077. let reply_content = node.querySelector(".reply_content");
  4078. item.reply_content = this.checkPhotoLink2Img(reply_content.innerHTML);
  4079. item.reply_text = reply_content.textContent;
  4080. let { users, floor } = this.parseReplyContent(item.reply_content);
  4081. item.replyUsers = users;
  4082. item.replyFloor = floor;
  4083. let ago = node.querySelector(".ago");
  4084. item.date = ago.textContent;
  4085. let userNode = node.querySelector("strong a");
  4086. item.username = userNode.textContent;
  4087. let avatar = node.querySelector("td img");
  4088. item.avatar = avatar.src;
  4089. let no = node.querySelector(".no");
  4090. item.floor = Number(no.textContent);
  4091. let thank_area = node.querySelector(".thank_area");
  4092. if (thank_area) {
  4093. item.isThanked = thank_area.classList.contains("thanked");
  4094. }
  4095. let small = node.querySelector(".small");
  4096. if (small) {
  4097. item.thankCount = Number(small.textContent);
  4098. }
  4099. let op = node.querySelector(".op");
  4100. if (op) {
  4101. item.isOp = true;
  4102. }
  4103. let mod = node.querySelector(".mod");
  4104. if (mod) {
  4105. item.isMod = true;
  4106. }
  4107. replyList.push(item);
  4108. });
  4109. return replyList;
  4110. },
  4111. //解析回复内容,解析出@用户,回复楼层。用于后续生成嵌套楼层
  4112. parseReplyContent(str) {
  4113. if (!str)
  4114. return;
  4115. let users = [];
  4116. let getUsername = (userStr) => {
  4117. let endIndex = userStr.indexOf('">');
  4118. if (endIndex > -1) {
  4119. let user = userStr.substring(0, endIndex);
  4120. if (!users.find((i) => i === user)) {
  4121. users.push(user);
  4122. }
  4123. }
  4124. };
  4125. let userReg = /@<a href="\/member\/([\s\S]+?)<\/a>/g;
  4126. let has = str.matchAll(userReg);
  4127. let res2 = [...has];
  4128. if (res2.length > 1) {
  4129. res2.map((item) => {
  4130. getUsername(item[1]);
  4131. });
  4132. }
  4133. if (res2.length === 1) {
  4134. getUsername(res2[0][1]);
  4135. }
  4136. let floor = -1;
  4137. if (users.length === 1) {
  4138. let floorReg = /@<a href="\/member\/[\s\S]+?<\/a>[\s]+#([\d]+)/g;
  4139. let hasFloor = str.matchAll(floorReg);
  4140. let res = [...hasFloor];
  4141. if (res.length) {
  4142. floor = Number(res[0][1]);
  4143. }
  4144. }
  4145. return { users, floor };
  4146. },
  4147. //获取帖子详情
  4148. async getPostDetail(post, body, htmlText, pageNo = 1) {
  4149. post = await this.parsePostContent(post, body, htmlText);
  4150. return await this.getPostAllReplies(post, body, htmlText, pageNo);
  4151. },
  4152. getAllReply(repliesMap = []) {
  4153. return repliesMap.sort((a, b) => a.i - b.i).reduce((pre, i) => {
  4154. pre = pre.concat(i.replyList);
  4155. return pre;
  4156. }, []);
  4157. },
  4158. //生成嵌套回复
  4159. createNestedList(allList = []) {
  4160. if (!allList.length)
  4161. return [];
  4162. if (Date.now() - window.win().lastCallDate < 1e3) {
  4163. return false;
  4164. }
  4165. let list = window.clone(allList);
  4166. let nestedList = [];
  4167. list.map((item, index2) => {
  4168. let startList = list.slice(0, index2);
  4169. let startReplyUsers = Array.from(new Set(startList.map((v) => v.username)));
  4170. let endList = list.slice(index2 + 1);
  4171. if (index2 === 0) {
  4172. nestedList.push(this.findChildren(item, endList, list));
  4173. } else {
  4174. if (!item.isUse) {
  4175. let isOneLevelReply = false;
  4176. if (item.replyUsers.length) {
  4177. if (item.replyUsers.length > 1) {
  4178. isOneLevelReply = true;
  4179. } else {
  4180. isOneLevelReply = !startReplyUsers.find((v) => v === item.replyUsers[0]);
  4181. }
  4182. } else {
  4183. isOneLevelReply = true;
  4184. }
  4185. if (isOneLevelReply) {
  4186. item.level === 0;
  4187. nestedList.push(this.findChildren(item, endList, list));
  4188. }
  4189. }
  4190. }
  4191. });
  4192. window.win().lastCallDate = Date.now();
  4193. return nestedList;
  4194. },
  4195. //查找子回复
  4196. findChildren(item, endList, all) {
  4197. var _a;
  4198. const fn = (child, endList2, parent) => {
  4199. child.level = parent.level + 1;
  4200. let rIndex = all.findIndex((v) => v.floor === child.floor);
  4201. if (rIndex > -1) {
  4202. all[rIndex].isUse = true;
  4203. }
  4204. parent.children.push(this.findChildren(child, endList2, all));
  4205. };
  4206. item.children = [];
  4207. let floorReplyList = [];
  4208. for (let i = 0; i < endList.length; i++) {
  4209. let currentItem = endList[i];
  4210. if (currentItem.isUse)
  4211. continue;
  4212. if (currentItem.replyFloor === item.floor) {
  4213. if (currentItem.replyUsers.length === 1 && currentItem.replyUsers[0] === item.username) {
  4214. currentItem.isUse = true;
  4215. floorReplyList.push({ endList: endList.slice(i + 1), currentItem });
  4216. } else {
  4217. currentItem.isWrong = true;
  4218. }
  4219. }
  4220. }
  4221. floorReplyList.reverse().map(({ currentItem, endList: endList2 }) => {
  4222. fn(currentItem, endList2, item);
  4223. });
  4224. let nextMeIndex = endList.findIndex((v) => {
  4225. var _a2;
  4226. return v.username === item.username && ((_a2 = v.replyUsers) == null ? void 0 : _a2[0]) !== item.username;
  4227. });
  4228. let findList = nextMeIndex > -1 ? endList.slice(0, nextMeIndex) : endList;
  4229. for (let i = 0; i < findList.length; i++) {
  4230. let currentItem = findList[i];
  4231. if (currentItem.isUse)
  4232. continue;
  4233. if (currentItem.replyUsers.length === 1) {
  4234. if (currentItem.replyFloor !== -1) {
  4235. if (((_a = all[currentItem.replyFloor - 1]) == null ? void 0 : _a.username) === currentItem.replyUsers[0]) {
  4236. continue;
  4237. }
  4238. }
  4239. let endList2 = endList.slice(i + 1);
  4240. if (currentItem.username === item.username) {
  4241. if (currentItem.replyUsers[0] === item.username) {
  4242. fn(currentItem, endList2, item);
  4243. }
  4244. break;
  4245. } else {
  4246. if (currentItem.replyUsers[0] === item.username) {
  4247. fn(currentItem, endList2, item);
  4248. }
  4249. }
  4250. } else {
  4251. if (currentItem.username === item.username)
  4252. break;
  4253. }
  4254. }
  4255. item.children = item.children.sort((a, b) => a.floor - b.floor);
  4256. return item;
  4257. },
  4258. //解析页面帖子列表
  4259. parsePagePostList(list, box) {
  4260. list.forEach((itemDom) => {
  4261. let item = window.clone(window.initPost);
  4262. let item_title = itemDom.querySelector(".item_title a");
  4263. let { href, id } = window.parse.parseA(item_title);
  4264. item.id = id;
  4265. item.href = href;
  4266. item.url = location.origin + "/api/topics/show.json?id=" + item.id;
  4267. itemDom.classList.add("post-item");
  4268. itemDom.classList.add(`id_${id}`);
  4269. itemDom.dataset["href"] = href;
  4270. itemDom.dataset["id"] = id;
  4271. window.postList.push(item);
  4272. });
  4273. Promise.allSettled(window.postList.map((item) => $.get(item.url))).then((res) => {
  4274. let ok = res.filter((r) => r.status === "fulfilled").map((v) => v.value[0]);
  4275. box.style.boxShadow = "unset";
  4276. box.style.background = "unset";
  4277. if (window.config.viewType === "card") {
  4278. list.forEach((itemDom) => itemDom.classList.add("preview"));
  4279. }
  4280. ok.map((postItem) => {
  4281. if (postItem == null ? void 0 : postItem.id) {
  4282. let itemDom = box.querySelector(`.id_${postItem.id}`);
  4283. if (window.config.showPreviewBtn) {
  4284. let td = itemDom.querySelector("td:nth-child(4)");
  4285. td.style.position = "relative";
  4286. let toggle = document.createElement("div");
  4287. toggle.dataset["id"] = postItem.id;
  4288. toggle.classList.add("toggle");
  4289. toggle.innerText = "点击展开/收起";
  4290. td.append(toggle);
  4291. }
  4292. let index2 = window.postList.findIndex((v) => v.id == postItem.id);
  4293. if (index2 > -1) {
  4294. let obj = window.postList[index2];
  4295. window.postList[index2] = Object.assign({}, obj, postItem);
  4296. if (postItem.content_rendered) {
  4297. let a = document.createElement("a");
  4298. a.href = obj.href;
  4299. a.classList.add("post-content");
  4300. let div = document.createElement("div");
  4301. div.innerHTML = postItem.content_rendered;
  4302. a.append(div);
  4303. itemDom.append(a);
  4304. }
  4305. }
  4306. }
  4307. });
  4308. cbChecker({ type: "syncData" });
  4309. });
  4310. },
  4311. parseA(a) {
  4312. let href = a.href;
  4313. let id;
  4314. if (href.includes("/t/")) {
  4315. id = href.substring(href.indexOf("/t/") + 3, href.indexOf("/t/") + 9);
  4316. }
  4317. return { href, id, title: a.innerText };
  4318. },
  4319. //创建记事本子条目
  4320. async createNoteItem(itemName) {
  4321. return new Promise(async (resolve) => {
  4322. let data = new FormData();
  4323. data.append("content", itemName);
  4324. data.append("parent_id", 0);
  4325. data.append("syntax", 0);
  4326. let apiRes = await window.win().fetch(`${window.baseUrl}/notes/new`, { method: "post", body: data });
  4327. console.log(apiRes);
  4328. if (apiRes.redirected && apiRes.status === 200) {
  4329. resolve(apiRes.url.substr(-5));
  4330. return;
  4331. }
  4332. resolve(null);
  4333. });
  4334. },
  4335. //编辑记事本子条目
  4336. async editNoteItem(val, id) {
  4337. let data = new FormData();
  4338. data.append("content", val);
  4339. data.append("syntax", 0);
  4340. let apiRes = await window.fetch(`${window.baseUrl}/notes/edit/${id}`, {
  4341. method: "post",
  4342. body: data
  4343. });
  4344. return apiRes.redirected && apiRes.status === 200;
  4345. },
  4346. //标签操作
  4347. async saveTags(val) {
  4348. return await this.editNoteItem(window.user.tagPrefix + JSON.stringify(val), window.user.tagsId);
  4349. },
  4350. //已读楼层操作
  4351. async saveReadList(val) {
  4352. return await this.editNoteItem(window.user.readPrefix + JSON.stringify(val), window.user.readNoteItemId);
  4353. },
  4354. //图片链接转Img标签
  4355. checkPhotoLink2Img(str) {
  4356. if (!str)
  4357. return;
  4358. try {
  4359. let imgWebs = [
  4360. /<a((?!<a).)*href="https?:\/\/((?!<a).)*imgur.com((?!<a).)*>(((?!<a).)*)<\/a>/g,
  4361. /<a((?!<a).)*href="https?:\/\/((?!<a).)*\.(gif|png|jpg|jpeg|GIF|PNG|JPG|JPEG)((?!<a).)*>(((?!<a).)*)<\/a>/g
  4362. ];
  4363. imgWebs.map((v, i) => {
  4364. let has = str.matchAll(v);
  4365. let res2 = [...has];
  4366. res2.map((r) => {
  4367. let p = i === 0 ? r[4] : r[5];
  4368. if (p) {
  4369. let link = p.toLowerCase();
  4370. let src = p;
  4371. if (link.includes(".png") || link.includes(".jpg") || link.includes(".jpeg") || link.includes(".gif")) {
  4372. } else {
  4373. src = p + ".png";
  4374. }
  4375. str = str.replace(r[0], `<img src="${src}" data-originUrl="${p}" data-notice="这个img标签由v2ex-超级增强脚本解析" style="max-width: 100%">`);
  4376. }
  4377. });
  4378. });
  4379. } catch (e) {
  4380. console.log("正则解析html里面的a标签的图片链接出错了");
  4381. }
  4382. return str;
  4383. }
  4384. };
  4385. async function sleep(time) {
  4386. return new Promise((resolve) => {
  4387. setTimeout(resolve, time);
  4388. });
  4389. }
  4390. async function cbChecker(val, count = 0) {
  4391. if (window.cb) {
  4392. window.cb(val);
  4393. } else {
  4394. while (!window.cb && count < 20) {
  4395. await sleep(500);
  4396. count++;
  4397. }
  4398. window.cb && window.cb(val);
  4399. }
  4400. }
  4401. function feedback() {
  4402. _GM_openInTab("https://github.com/zyronon/v2ex-script/discussions/", {
  4403. active: true,
  4404. insert: true,
  4405. setParent: true
  4406. });
  4407. }
  4408. function initMonkeyMenu() {
  4409. try {
  4410. _GM_registerMenuCommand("脚本设置", function(event) {
  4411. cbChecker({ type: "openSetting" });
  4412. });
  4413. _GM_registerMenuCommand("💬 反馈 & 建议", feedback);
  4414. } catch (e) {
  4415. console.error("无法使用Tampermonkey");
  4416. }
  4417. }
  4418. function initStyle() {
  4419. let style2 = `
  4420. html, body {
  4421. font-size: 62.5%;
  4422. }
  4423.  
  4424. #Wrapper {
  4425. height: unset !important;
  4426. width: unset !important;
  4427. }
  4428.  
  4429. #Wrapper > .content {
  4430. height: unset !important;
  4431. width: unset !important;
  4432. }
  4433.  
  4434. .post-item {
  4435. background: white;
  4436. }
  4437.  
  4438. .post-item > .post-content {
  4439. height: 0;
  4440. margin-top: 0;
  4441. }
  4442.  
  4443. .post-item:hover .toggle {
  4444. display: flex;
  4445. }
  4446.  
  4447. .toggle {
  4448. position: absolute;
  4449. right: 0;
  4450. top: 0.5rem;
  4451. width: 9rem;
  4452. height: 100%;
  4453. display: flex;
  4454. justify-content: flex-end;
  4455. align-items: flex-end;
  4456. cursor: pointer;
  4457. font-size: 1.2rem;
  4458. color: #ccc;
  4459. display: none;
  4460. }
  4461.  
  4462. .preview {
  4463. margin: 1rem 0;
  4464. border: 1px solid #c8c8c8;
  4465. border-radius: 0.4rem;
  4466. cursor: pointer;
  4467. }
  4468.  
  4469. .preview:hover {
  4470. border: 1px solid #968b8b;
  4471. }
  4472.  
  4473. .preview > .post-content {
  4474. height: unset !important;
  4475. margin-top: 0.5rem !important;
  4476. }
  4477.  
  4478. .preview .topic-link:link {
  4479. color: black !important;
  4480. }
  4481.  
  4482. .post-content {
  4483. margin-top: 0.5rem;
  4484. display: block;
  4485. max-height: 20rem;
  4486. overflow: hidden;
  4487. text-decoration: unset !important;
  4488. line-break: anywhere;
  4489. -webkit-mask-image: linear-gradient(180deg,#000 60%,transparent);
  4490. }
  4491.  
  4492. .post-content:link {
  4493. color: #494949;
  4494. }
  4495.  
  4496.  
  4497. .post-content:visited {
  4498. color: #afb9c1 !important;
  4499. }
  4500.  
  4501. .Night .post-item {
  4502. background: #18222d !important;
  4503. }
  4504.  
  4505. .Night .preview {
  4506. border: 1px solid #3b536e;
  4507. }
  4508.  
  4509. .Night .preview > .post-content:link {
  4510. color: #d1d5d9;
  4511. }
  4512.  
  4513. .Night .preview > .post-content:visited {
  4514. color: #393f4e !important;
  4515. }
  4516.  
  4517. .Night .preview .topic-link:link {
  4518. color: #c0dbff !important;
  4519. }
  4520.  
  4521. `;
  4522. let addStyle2 = document.createElement("style");
  4523. addStyle2.rel = "stylesheet";
  4524. addStyle2.type = "text/css";
  4525. addStyle2.innerHTML = style2;
  4526. $(window.win().doc.head).append(addStyle2);
  4527. }
  4528. function qianDao() {
  4529. let timeNow = (/* @__PURE__ */ new Date()).getUTCFullYear() + "/" + ((/* @__PURE__ */ new Date()).getUTCMonth() + 1) + "/" + (/* @__PURE__ */ new Date()).getUTCDate();
  4530. if (window.pageType === PageType.Home) {
  4531. let qiandao = window.query('.box .inner a[href="/mission/daily"]');
  4532. if (qiandao) {
  4533. qianDao_(qiandao, timeNow);
  4534. } else if (window.win().doc.getElementById("gift_v2excellent")) {
  4535. window.win().doc.getElementById("gift_v2excellent").click();
  4536. localStorage.setItem("menu_clockInTime", timeNow);
  4537. console.info("[V2EX - 超级增强] 自动签到完成!");
  4538. } else {
  4539. console.info("[V2EX - 超级增强] 自动签到完成!");
  4540. }
  4541. } else {
  4542. let timeOld = localStorage.getItem("menu_clockInTime");
  4543. if (!timeOld || timeOld != timeNow) {
  4544. qianDaoStatus_(timeNow);
  4545. } else {
  4546. console.info("[V2EX - 超级增强] 自动签到完成!");
  4547. }
  4548. }
  4549. }
  4550. function qianDao_(qiandao, timeNow) {
  4551. let url = window.baseUrl + "/mission/daily/redeem?" + RegExp("once\\=(\\d+)").exec(document.querySelector("div#Top .tools, #menu-body").innerHTML)[0];
  4552. console.log("url", url);
  4553. $.get(url).then((r) => {
  4554. let bodyText = r.match(/<body[^>]*>([\s\S]+?)<\/body>/g);
  4555. let html = $(bodyText[0]);
  4556. if (html.find("li.fa.fa-ok-sign").length) {
  4557. html = html.find("#Main").text().match(/已连续登录 (\d+?) 天/)[0];
  4558. localStorage.setItem("menu_clockInTime", timeNow);
  4559. console.info("[V2EX - 超级增强] 自动签到完成!");
  4560. if (qiandao) {
  4561. qiandao.textContent = `自动签到完成!${html}`;
  4562. qiandao.href = "javascript:void(0);";
  4563. }
  4564. } else {
  4565. _GM_notification({
  4566. text: "自动签到失败!请访问 V2EX 首页试试。\n如果连续几天都签到失败,请联系作者解决!",
  4567. timeout: 4e3,
  4568. onclick() {
  4569. feedback();
  4570. }
  4571. });
  4572. console.warn("[V2EX 增强] 自动签到失败!请访问 V2EX 首页试试。如果连续几天都签到失败,请联系作者解决!");
  4573. if (qiandao)
  4574. qiandao.textContent = "自动签到失败!请尝试手动签到!";
  4575. }
  4576. });
  4577. }
  4578. function qianDaoStatus_(timeNow) {
  4579. $.get(window.baseUrl + "/mission/daily").then((r) => {
  4580. let bodyText = r.match(/<body[^>]*>([\s\S]+?)<\/body>/g);
  4581. let html = $(bodyText[0]);
  4582. if (html.find('input[value^="领取"]').length) {
  4583. qianDao_(null, timeNow);
  4584. } else {
  4585. console.info("[V2EX 增强] 已经签过到了。");
  4586. localStorage.setItem("menu_clockInTime", timeNow);
  4587. }
  4588. });
  4589. }
  4590. function checkPageType() {
  4591. let location2 = window.win().location;
  4592. if (location2.pathname === "/") {
  4593. window.pageType = PageType.Home;
  4594. } else if (location2.href.match(/.com\/?tab=/)) {
  4595. window.pageType = PageType.Home;
  4596. } else if (location2.href.match(/.com\/go\//)) {
  4597. if (!location2.href.includes("/links")) {
  4598. window.pageType = PageType.Node;
  4599. }
  4600. } else if (location2.href.match(/.com\/recent/)) {
  4601. window.pageType = PageType.Home;
  4602. } else {
  4603. let r = location2.href.match(/.com\/t\/([\d]+)/);
  4604. if (r) {
  4605. window.pageType = PageType.Post;
  4606. window.pageData.id = r[1];
  4607. if (location2.search) {
  4608. let pr = location2.href.match(/\?p=([\d]+)/);
  4609. if (pr)
  4610. window.pageData.pageNo = Number(pr[1]);
  4611. }
  4612. }
  4613. }
  4614. }
  4615. function getNoteItemContent(id, prefix) {
  4616. return new Promise((resolve, reject) => {
  4617. $.get(window.baseUrl + "/notes/edit/" + id).then((r2) => {
  4618. let bodyText = r2.match(/<body[^>]*>([\s\S]+?)<\/body>/g);
  4619. let body = $(bodyText[0]);
  4620. let text = body.find(".note_editor").text();
  4621. if (text === prefix) {
  4622. resolve({});
  4623. } else {
  4624. let tagJson = text.substring(prefix.length);
  4625. try {
  4626. resolve(JSON.parse(tagJson));
  4627. } catch (e) {
  4628. console.log("tage", tagJson);
  4629. resolve({});
  4630. }
  4631. }
  4632. });
  4633. });
  4634. }
  4635. async function initNoteData() {
  4636. $.get(window.baseUrl + "/notes").then(async (r) => {
  4637. let bodyText = r.match(/<body[^>]*>([\s\S]+?)<\/body>/g);
  4638. let body = $(bodyText[0]);
  4639. let items = body.find("#Main .box .note_item_title a");
  4640. if (items.length) {
  4641. let tagItem = Array.from(items).find((v) => v.innerText.includes(window.user.tagPrefix));
  4642. if (tagItem) {
  4643. window.user.tagsId = tagItem.href.substr(-5);
  4644. window.user.tags = await getNoteItemContent(window.user.tagsId, window.user.tagPrefix);
  4645. } else {
  4646. let r2 = await window.parse.createNoteItem(window.user.tagPrefix);
  4647. r2 && (window.user.tagsId = r2);
  4648. }
  4649. let readItem = Array.from(items).find((v) => v.innerText.includes(window.user.readPrefix));
  4650. if (readItem) {
  4651. window.user.readNoteItemId = readItem.href.substr(-5);
  4652. window.user.readList = await getNoteItemContent(window.user.readNoteItemId, window.user.readPrefix);
  4653. } else {
  4654. let r2 = await window.parse.createNoteItem(window.user.readPrefix);
  4655. r2 && (window.user.readNoteItemId = r2);
  4656. }
  4657. cbChecker({ type: "syncData" });
  4658. }
  4659. });
  4660. }
  4661. function initConfig() {
  4662. return new Promise((resolve) => {
  4663. let configStr = window.win().localStorage.getItem("v2ex-config");
  4664. if (configStr) {
  4665. let configObj = JSON.parse(configStr);
  4666. configObj = configObj[window.user.username ?? "default"];
  4667. if (configObj) {
  4668. window.config = Object.assign(window.config, configObj);
  4669. }
  4670. }
  4671. resolve(window.config);
  4672. });
  4673. }
  4674. function initSoV2ex() {
  4675. var $search = $("#search");
  4676. var searchEvents = $._data($search[0], "events");
  4677. console.log($search, searchEvents);
  4678. var oKeydownEvent = searchEvents["keydown"][0]["handler"];
  4679. var oInputEvent = searchEvents["input"][0]["handler"];
  4680. $search.attr("placeholder", "sov2ex");
  4681. $search.unbind("keydown", oKeydownEvent);
  4682. $search.unbind("input", oInputEvent);
  4683. $search.on("input", function(e) {
  4684. oInputEvent(e);
  4685. $(".search-item:last").attr("href", "https://www.sov2ex.com/?q=" + $search.val()).text("sov2ex " + $search.val());
  4686. });
  4687. $search.keydown(function(e) {
  4688. if (e.code == "Enter" || e.code == "NumpadEnter" || e.keyCode === 13) {
  4689. if ($(".search-item:last").is(".active")) {
  4690. $(this).val($(this).val().replace(/[#%&]/g, ""));
  4691. window.open("https://www.sov2ex.com/?q=" + $(this).val());
  4692. return 0;
  4693. }
  4694. }
  4695. oKeydownEvent(e);
  4696. });
  4697. }
  4698. function addSettingText() {
  4699. let setting = $(`<a href="javascript:void 0;" class="top">脚本设置</a>`);
  4700. setting.on("click", () => {
  4701. cbChecker({ type: "openSetting" });
  4702. });
  4703. $(".tools").prepend(setting);
  4704. }
  4705. function initCustomBgColor() {
  4706. let style2 = `#Wrapper {
  4707. background-color: ${window.config.customBgColor} !important;
  4708. background-image: unset !important;
  4709. }`;
  4710. let addStyle2 = document.createElement("style");
  4711. addStyle2.rel = "stylesheet";
  4712. addStyle2.type = "text/css";
  4713. addStyle2.innerHTML = style2;
  4714. $(window.win().doc.head).append(addStyle2);
  4715. }
  4716. function init() {
  4717. checkPageType();
  4718. initMonkeyMenu();
  4719. initStyle();
  4720. let top2 = document.querySelector(".tools .top:nth-child(2)");
  4721. if (top2 && top2.textContent !== "注册") {
  4722. window.user.username = top2.textContent;
  4723. window.user.avatar = $("#Rightbar .box .avatar").attr("src");
  4724. initNoteData();
  4725. }
  4726. addSettingText();
  4727. initConfig().then((r) => {
  4728. if (window.config.sov2ex) {
  4729. setTimeout(initSoV2ex, 1e3);
  4730. }
  4731. if (window.config.customBgColor) {
  4732. initCustomBgColor();
  4733. }
  4734. try {
  4735. if (window.config.autoSignin && window.user.username) {
  4736. qianDao();
  4737. }
  4738. } catch (e) {
  4739. console.log("签到失败");
  4740. }
  4741. });
  4742. let box;
  4743. let list;
  4744. switch (window.pageType) {
  4745. case PageType.Node:
  4746. box = window.win().doc.querySelectorAll("#Wrapper #Main .box");
  4747. let topics = box[1].querySelector("#TopicsNode");
  4748. list = topics.querySelectorAll(".cell");
  4749. list[0].before($section);
  4750. window.parse.parsePagePostList(list, box[1]);
  4751. break;
  4752. case PageType.Home:
  4753. box = document.querySelector("#Wrapper #Main .box");
  4754. list = box.querySelectorAll(".item");
  4755. list[0].before($section);
  4756. window.parse.parsePagePostList(list, box);
  4757. break;
  4758. case PageType.Post:
  4759. if (window.config.postWidth) {
  4760. let Main = $("#Main");
  4761. Main.css({
  4762. "width": window.config.postWidth,
  4763. margin: "unset"
  4764. });
  4765. $("#Wrapper > .content").css({
  4766. "max-width": "unset",
  4767. display: "flex",
  4768. "justify-content": "center",
  4769. gap: "20px"
  4770. });
  4771. Main.after($("#Rightbar"));
  4772. }
  4773. box = document.querySelector("#Wrapper #Main .box");
  4774. box.after($section);
  4775. let post = Object.assign({}, window.clone(window.initPost), { id: window.pageData.id });
  4776. let body = $(window.win().doc.body);
  4777. let htmlText = window.win().doc.documentElement.outerHTML;
  4778. window.parse.parsePostContent(
  4779. post,
  4780. body,
  4781. htmlText
  4782. ).then(async (res) => {
  4783. await cbChecker({ type: "postContent", value: res }, 0);
  4784. });
  4785. window.parse.getPostAllReplies(
  4786. post,
  4787. body,
  4788. htmlText,
  4789. window.pageData.pageNo
  4790. ).then(async (res) => {
  4791. await cbChecker({ type: "postReplies", value: res }, 0);
  4792. });
  4793. break;
  4794. default:
  4795. console.error("未知页面");
  4796. break;
  4797. }
  4798. }
  4799. window.canParseV2exPage = !window.location.href.includes("script=0");
  4800. if (window.canParseV2exPage) {
  4801. init();
  4802. } else {
  4803. alert("脚本无法查看此主题,已为您单独打开此主题");
  4804. }
  4805. }
  4806. run();
  4807. let vueApp = vue.createApp(App);
  4808. vueApp.config.unwrapInjectedRef = true;
  4809. vueApp.mount($section);
  4810.  
  4811. })(Vue);