V2EX - 超级增强

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

当前为 2023-06-11 提交的版本,查看 最新版本

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