V2EX - 超级增强

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

当前为 2023-08-24 提交的版本,查看 最新版本

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