// ==UserScript==
// @name V2EX - 单页应用
// @namespace http://tampermonkey.net/
// @version 1
// @description V2EX - 单页应用,仿 Reddit 设计
// @author You
// @match https://*.v2ex.com/
// @match https://*.v2ex.com/?tab=*
// @match https://*.v2ex.com/t/*
// @match https://*.v2ex.com/recent*
// @match https://*.v2ex.com/go/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @require https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.min.js
// @grant none
// @license GPL License
// ==/UserScript==
(function () {
'use strict';
let style = `
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}.subtlesHtml {font-size:1.4rem;border-top:1px solid #e2e2e2;margin-bottom:1rem}.subtlesHtml .subtle {border-bottom:none}.subtlesHtml .subtle .fade {color:#ccc}.subtlesHtml .subtle .sep5 {height:5px}.subtlesHtml .subtle .topic_content {color:#000}.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}@keyframes circle {0%{transform:rotate (0)} to {transform:rotate (360deg)}}.button {cursor:pointer;padding:.4rem 2.4rem;border-radius:10rem;display:inline-flex;justify-content:center;align-items:center;font-weight:700;font-size:1.2rem;color:#fff;background:#0079d3;border:1px solid #0079d3;user-select:none}.button:hover {opacity:.9}.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}.tool {position:relative;margin-left:.6rem;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:#0079d3}.msg.warning .left {background:#c8c002}.msg.error .left {background:red}.msg .left {border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;background:#0079d3}.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:2.2rem;border-radius:2rem;position:relative;display:flex;align-items:center;background:#ccc;transition:all .3s}.switch.active {background:#0079d3}.switch.active:before {right:.2rem}.switch:before {position:absolute;content:" ";transition:all .3s;right:calc (100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%;background:white}.horizontal [data-v-8f98dac0]{flex-direction:row!important;padding:0!important}.horizontal .num [data-v-8f98dac0]{margin-left:.2rem}.point [data-v-8f98dac0]{font-size:1.2rem;padding:1rem 0;min-width:4rem;border-radius:.4rem 0 0 .4rem;display:flex;flex-direction:column;align-items:center}.point .up [data-v-8f98dac0]{display:flex;flex-direction:column;align-items:center;justify-content:center}.point .num [data-v-8f98dac0]{font-weight:700;color:#000;user-select:none}.point svg [data-v-8f98dac0]{width:2rem;padding:.4rem;border-radius:.2rem}.point svg [data-v-8f98dac0]:hover {background:#e5e5e5}.point .disabled [data-v-8f98dac0]:hover {background:unset}.Author [data-v-e030155e]{display:flex;align-items:center;justify-content:space-between;font-size:1.2rem;position:relative;margin-bottom:.4rem}.Author.expand [data-v-e030155e]{margin-bottom:0}.Author .Author-left [data-v-e030155e]{display:flex;align-items:center}.Author .Author-left .username [data-v-e030155e]{font-size:1.4rem}.Author .Author-left .expand-icon [data-v-e030155e]{cursor:pointer;margin-right:.8rem;width:2rem;height:2rem;transform:rotate (90deg)}.Author .Author-left .icon [data-v-e030155e]{margin-right:1rem;display:flex}.Author .Author-left .icon img [data-v-e030155e]{width:3.4rem;height:3.4rem;border-radius:.3rem}.Author .Author-left .op [data-v-e030155e]{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-right [data-v-e030155e]{position:absolute;right:0;display:flex;align-items:center}.Author .Author-right .toolbar [data-v-e030155e]{display:flex;align-items:center;color:#929596;opacity:0}.Author .Author-right .toolbar [data-v-e030155e]:hover {background:white;opacity:1}.Author .Author-right .floor [data-v-e030155e]{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-e030155e]{color:#000!important}.post-editor-wrapper [data-v-5d67ef48]{width:100%;box-sizing:border-box;position:relative;overflow:hidden;transition:all .3s}.post-editor-wrapper.reply-post .post-editor [data-v-5d67ef48]{border:1px solid #e2e2e2;border-radius:.4rem}.post-editor-wrapper.reply-post.isFocus .post-editor [data-v-5d67ef48]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment [data-v-5d67ef48]{border:1px solid #e2e2e2;border-radius:.4rem;overflow:hidden}.post-editor-wrapper.reply-comment.isFocus [data-v-5d67ef48]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment .toolbar [data-v-5d67ef48]{background:#f6f7f8}.post-editor-wrapper .post-editor [data-v-5d67ef48]{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-5d67ef48]{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-5d67ef48]{color:gray;font-size:1.3rem}.post-editor-wrapper .get-cursor [data-v-5d67ef48]{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}.comment [data-v-610ec7c1]{width:100%;box-sizing:border-box;margin-top:1rem;background:white}.comment .comment-content-w [data-v-610ec7c1]{background:white}.comment .comment-content-w .more [data-v-610ec7c1]{text-align:center;margin:2rem 0}.comment .comment-content [data-v-610ec7c1]{display:flex;position:relative}.comment .comment-content .expand-line [data-v-610ec7c1]{cursor:pointer;width:2.6rem;min-width:2.6rem;position:relative}.comment .comment-content .expand-line [data-v-610ec7c1]:after {position:absolute;left:calc (68% - 1px);content:" ";height:100%;width:0;border-right:2px solid #ddd}.comment .comment-content .expand-line [data-v-610ec7c1]:hover:after {border-right:2px solid #0079D3}.comment .comment-content .right [data-v-610ec7c1]{flex:1;width:calc (100% - 2.6rem)}.comment .comment-content .right .w [data-v-610ec7c1]{padding-left:1.7rem}.comment .comment-content .right .w .text [data-v-610ec7c1]{color:#000;word-break:break-word}.comment .comment-content .right .w .post-editor-wrapper [data-v-610ec7c1]{margin-top:1rem}.toolbar [data-v-119b6802]{display:flex;align-items:center;color:#929596}.toolbar .tooltip [data-v-119b6802]{box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;background:white;padding:1rem;top:4rem;left:-3rem;width:15rem;position:absolute;z-index:99}.toolbar .tooltip a [data-v-119b6802]{color:#0079d3!important}.htmlContent {width:100%}.htmlContent img {max-width:100%}.sticky {position:sticky;bottom:-2px}.sticky [stuck]{box-shadow:0 2px 20px #00000059!important}.post-detail [data-v-31164580]{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 .main [data-v-31164580]{display:flex;padding:6rem 12rem 15rem;background:#e2e2e2;position:relative}.post-detail .main>.left [data-v-31164580]{width:77rem}.post-detail .main>.left .left-wrapper [data-v-31164580]{width:100%;padding-bottom:2rem;display:flex;flex-direction:column;align-items:center}.post-detail .main>.left .post-wrapper .base-info [data-v-31164580]{padding:1rem;box-sizing:border-box;border-bottom:1px solid #e2e2e2}.post-detail .main>.left .post-wrapper .base-info .avatar [data-v-31164580]{float:right;border-radius:.4rem;height:7.3rem}.post-detail .main>.left .post-wrapper .base-info .post-nodes [data-v-31164580]{font-size:1.5rem;margin-bottom:.8rem;display:flex}.post-detail .main>.left .post-wrapper .base-info .title [data-v-31164580]{margin-bottom:1rem;line-height:150%;font-size:2.4rem;color:#000}.post-detail .main>.left .post-wrapper .content [data-v-31164580]{color:#000;word-break:break-word;line-height:1.6;border-bottom:1px solid #e2e2e2}.post-detail .main>.left .post-wrapper .content .baseContent [data-v-31164580]{padding:1rem}.post-detail .main>.left .post-wrapper .toolbar-wrapper [data-v-31164580]{height:4rem;padding-left:.6rem;display:flex;align-items:center}.post-detail .main>.left .editor-wrapper .float [data-v-31164580]{margin-right:2rem}.post-detail .main>.left .editor-wrapper .w [data-v-31164580]{padding:1.2rem}.post-detail .main>.left .comment-wrapper .comments [data-v-31164580]{width:100%;box-sizing:border-box}.post-detail .main>.left .sort-select [data-v-31164580]{position:relative}.post-detail .main>.left .sort-select .target [data-v-31164580]{color:#0079d3;font-size:1.2rem;font-weight:700;display:inline-flex;align-items:center;cursor:pointer}.post-detail .main>.left .sort-select .target svg [data-v-31164580]{width:1.4rem;height:1.4rem;margin-left:.5rem}.post-detail .main>.left .sort-select .options [data-v-31164580]{box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;background:white;z-index:9998;border-radius:.5rem;cursor:pointer;font-size:1.4rem;position:absolute;top:2.6rem;left:2.7rem;width:8rem;color:#778087}.post-detail .main>.left .sort-select .options .option [data-v-31164580]{padding:.8rem 1.4rem}.post-detail .main>.left .sort-select .options .option.active [data-v-31164580]{color:#0079d3}.post-detail .main>.left .sort-select .options .option [data-v-31164580]:hover {background:#e9f5fd}.post-detail .main>.left .loading-wrapper [data-v-31164580]{height:20rem;display:flex;justify-content:center;align-items:center}.post-detail .main>.left #no-comments-yet [data-v-31164580]{color:#a9a9a9;font-weight:700;text-align:center;width:100%;margin-bottom:2rem;box-sizing:border-box}.post-detail .main>.right [data-v-31164580]{margin-left:2rem;margin-top:-2rem;display:flex;flex-direction:column;align-items:center}.post-detail .main .call-list [data-v-31164580]{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-31164580]{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-31164580],.post-detail .main .call-list .call-item [data-v-31164580]:hover,.post-detail .main .call-list .call-item.select [data-v-31164580]{background-color:#f0f0f0;text-decoration:none}.post-detail .main .call-list .call-item [data-v-31164580]:nth-child (1){border-top:1px solid transparent}@media screen and (max-width: 1500px){.post-detail .main [data-v-31164580]{padding:8rem 8rem 15rem}.post-detail .main>.left [data-v-31164580]{width:65vw}.post-detail .main>.right [data-v-31164580]{display:none}}@media screen and (max-width: 1280px){.post-detail .main [data-v-31164580]{padding:5rem 5rem 15rem}.post-detail .main>.left [data-v-31164580]{width:75vw}.post-detail .main>.right [data-v-31164580]{display:none}}.post-detail .scroll-top [data-v-31164580]{position:fixed;bottom:3rem;z-index:99} p:first-child {margin-top:0} p:last-child {margin-bottom:0}.post [data-v-0bca2a61]{font-size:1.4rem;background:white;text-align:start;padding:1rem;overflow:hidden}.post.table [data-v-0bca2a61]{border-bottom:1px solid #e2e2e2}.post.table .post-content-wrapper [data-v-0bca2a61]{display:none}.post.table .title a [data-v-0bca2a61]{color:#778087;font-size:1.6rem}.post.card [data-v-0bca2a61]{margin-top:1.1rem;border:1px solid #e2e2e2;border-radius:.4rem;cursor:pointer}.post.card [data-v-0bca2a61]:hover {border:1px solid #968b8b}.post.card .title a [data-v-0bca2a61]{color:#000;font-size:1.8rem}.post.visited .title a [data-v-0bca2a61]{color:#afb9c1!important}.post.visited .post-content-wrapper [data-v-0bca2a61]{opacity:.6}.post .base-info [data-v-0bca2a61]{box-sizing:border-box;display:flex;justify-content:space-between;align-items:flex-start}.post .base-info .left [data-v-0bca2a61]{display:flex;width:95%}.post .base-info .left .avatar [data-v-0bca2a61]{margin-right:1rem}.post .base-info .left .avatar img [data-v-0bca2a61]{border-radius:.4rem;width:4.8rem;min-width:4.8rem;min-height:4.8rem}.post .base-info .left .right [data-v-0bca2a61]{display:flex;flex-direction:column;justify-content:space-between}.post .base-info .left .right .title [data-v-0bca2a61]{display:inline;align-items:center}.post .base-info .left .right .bottom [data-v-0bca2a61]{font-size:1.2rem;line-height:1.2rem;display:flex;align-items:center}.post .base-info .count [data-v-0bca2a61]{margin-top:1.8rem;line-height:12px;font-weight:700;color:#fff;background-color:#aab0c6;display:inline-block;padding:2px 10px;-moz-border-radius:12px;-webkit-border-radius:12px;border-radius:12px;text-decoration:none;cursor:pointer}.post .base-info .count [data-v-0bca2a61]:hover {background-color:#969cb1}.post .post-content-wrapper [data-v-0bca2a61]{max-height:20rem;overflow:hidden;margin-top:.6rem;color:#000;position:relative;line-break:anywhere;font-size:1.4rem}.post .post-content-wrapper.mask [data-v-0bca2a61]{-webkit-mask-image:linear-gradient (180deg,#000 60%,transparent)}.base64_tooltip [data-v-2d42a498]{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}.base64_tooltip svg [data-v-2d42a498]{margin-left:1rem;min-width:1.8rem}.base64_tooltip .button [data-v-2d42a498]{margin-top:1rem;margin-left:2rem}.app-home.home,.app-home.recent,.app-home.nodePage {background:#e2e2e2}.app-home.card {padding:1rem 0}.page.card {margin-top:1rem}.nav {font-size:1.4rem;background:white;text-align:start;padding:1rem}.nav.card {border:1px solid #e2e2e2;border-radius:.4rem}.nav.table {border-bottom:1px solid #e2e2e2}.nav .nav-item {cursor:pointer;display:flex;margin-left:2rem;padding:.6rem;border-radius:.4rem}.nav .nav-item.active {background:#40a9ff;color:#fff}.nav .nav-item.active:hover {background:#40a9ff;opacity:.8}.nav .nav-item:hover {background:#e2e2e2}.nav .nav-item span {margin-left:.4rem}
`
let addStyle = document.createElement ("style");
addStyle.rel = "stylesheet";
addStyle.type = "text/css";
addStyle.innerHTML = style
document.head.append (addStyle)
let $vue = document.createElement ('script')
$vue.src = 'https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.min.js'
document.body.appendChild ($vue);
$vue.addEventListener ('load', () => {
const G=function (){const e=document.createElement ("link").relList;if (e&&e.supports&&e.supports ("modulepreload")) return;for (const n of document.querySelectorAll ('link [rel="modulepreload"]')) u (n);new MutationObserver (n=>{for (const t of n) if (t.type==="childList") for (const d of t.addedNodes) d.tagName==="LINK"&&d.rel==="modulepreload"&&u (d)}).observe (document,{childList:!0,subtree:!0});function l (n){const t={};return n.integrity&&(t.integrity=n.integrity),n.referrerpolicy&&(t.referrerPolicy=n.referrerpolicy),n.crossorigin==="use-credentials"?t.credentials="include":n.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t} function u (n){if (n.ep) return;n.ep=!0;const t=l (n);fetch (n.href,t)}};G ();var i={eventMap:new Map,on (o,e){let l=this.eventMap.get (o);l?l.push (e):l=[e],this.eventMap.set (o,l)},emit (o,e){let l=this.eventMap.get (o);l&&l.map (u=>u (e))},off (o){this.eventMap.has (o)&&this.eventMap.delete (o)},clear (){this.eventMap=new Map}};const r={SHOW_TOOLTIP:"SHOW_TOOLTIP",SHOW_MSG:"SHOW_MSG",SET_CALL:"SET_CALL",SHOW_CALL:"SHOW_CALL",REFRESH_ONCE:"REFRESH_ONCE",ADD_REPLY:"ADD_REPLY",IGNORE:"IGNORE",MERGE:"MERGE",REMOVE:"REMOVE",CHANGE_COMMENT_THANK:"CHANGE_COMMENT_THANK",CHANGE_POST_THANK:"CHANGE_POST_THANK"};var k=(o,e)=>{const l=o.__vccOpts||o;for (const [u,n] of e) l [u]=n;return l};const W={name:"Point",inject:["post"],props:{item:{type:Object,default (){return {}}},type:{type:String,default (){return"horizontal"}},apiUrl:""},computed:{disabled (){return this.item.username===window.win ().user.username||this.item.isThanked}},methods:{getColor (o){return o?"#ff4500":"#929596"},getIsFull (o){return o?"#ff4500":"none"},async thank (){if (this.item.username===window.win ().user.username) return i.emit (r.SHOW_MSG,{type:"warning",text:"\u4E0D\u80FD\u611F\u8C22\u81EA\u5DF1"});if (this.item.isThanked) return i.emit (r.SHOW_MSG,{type:"warning",text:"\u5DF2\u7ECF\u611F\u8C22\u8FC7\u4E86"});this.$emit ("addThank");let o=`${window.win ().url}/thank/${this.apiUrl}?once=${this.post.once}`;$.post (o).then (e=>{console.log ("\u611F\u8C22",e),e.success||(this.$emit ("recallThank"),i.emit (r.SHOW_MSG,{type:"error",text:e.message})),i.emit (r.REFRESH_ONCE,e.once)},e=>{this.$emit ("recallThank"),i.emit (r.SHOW_MSG,{type:"error",text:"\u611F\u8C22\u5931\u8D25"}),i.emit (r.REFRESH_ONCE)})}}},z=["fill","stroke"],U={class:"num"};function K (o,e,l,u,n,t){return Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["point",l.type])},[Vue.createElementVNode ("div",{class:"up",onClick:e [0]||(e [0]=Vue.withModifiers ((...d)=>t.thank&&t.thank (...d),["stop"]))},[(Vue.openBlock (),Vue.createElementBlock ("svg",{class:Vue.normalizeClass ({disabled:t.disabled}),width:"19",height:"19",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{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",fill:t.getIsFull (l.item.isThanked),stroke:t.getColor (l.item.isThanked),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,z)],2))]),Vue.createElementVNode ("div",U,Vue.toDisplayString (l.item.thankCount?l.item.thankCount:"\u611F\u8C22"),1)],2)} var B=k (W,[["render",K],["__scopeId","data-v-8f98dac0"]]);const Z={name:"Author",components:{Point:B},inject:["isDev"],props:{modelValue:!1,comment:{type:Object,default (){return {}}}},data (){return {}},computed:{pointInfo (){return {isThanked:this.comment.isThanked,thankCount:this.comment.thankCount,username:this.comment.username}}},methods:{addThank (){i.emit (r.CHANGE_COMMENT_THANK,{id:this.comment.id,type:"add"})},recallThank (){i.emit (r.CHANGE_COMMENT_THANK,{id:this.comment.id,type:"recall"})}}},M=o=>(Vue.pushScopeId ("data-v-e030155e"),o=o (),Vue.popScopeId (),o),Y={class:"Author-left"},q=M (()=>Vue.createElementVNode ("path",{d:"M22 42H6V26",stroke:"#177EC9","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)),X=M (()=>Vue.createElementVNode ("path",{d:"M26 6H42V22",stroke:"#177EC9","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)),J=[q,X],Q=["href"],ee=["src"],te=["href"],oe={key:0,class:"op"},ne={class:"ago"},le={class:"Author-right"},se={class:"toolbar"},ie=Vue.createStaticVNode ('<svg viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"data-v-e030155e><path d="M4 6H44V36H29L24 41L19 36H4V6Z"fill="none"stroke="#929596"stroke-width="2"stroke-linecap="round"stroke-linejoin="round"data-v-e030155e></path><path d="M23 21H25.0025"stroke="#929596"stroke-width="2"stroke-linecap="round"data-v-e030155e></path><path d="M33.001 21H34.9999"stroke="#929596"stroke-width="2"stroke-linecap="round"data-v-e030155e></path><path d="M13.001 21H14.9999"stroke="#929596"stroke-width="2"stroke-linecap="round"data-v-e030155e></path></svg><span data-v-e030155e>\u56DE\u590D</span>',2),re=[ie],ae=M (()=>Vue.createElementVNode ("span",null,"\u9690\u85CF",-1)),ue=[ae];function de (o,e,l,u,n,t){const d=Vue.resolveComponent ("Point");return Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["Author",{expand:!l.modelValue}])},[Vue.createElementVNode ("div",Y,[l.modelValue?Vue.createCommentVNode ("",!0):(Vue.openBlock (),Vue.createElementBlock ("svg",{key:0,class:"expand-icon",onClick:e [0]||(e [0]=p=>o.$emit ("update:modelValue",!0)),width:"24",height:"24",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J)),Vue.createElementVNode ("a",{class:"icon",href:`/member/${l.comment.username}`},[Vue.createElementVNode ("img",{src:l.comment.avatar,alt:""},null,8,ee)],8,Q),Vue.createElementVNode ("span",null,[Vue.createElementVNode ("strong",null,[Vue.createElementVNode ("a",{href:`/member/${l.comment.username}`,class:"username"},Vue.toDisplayString (l.comment.username),9,te)]),Vue.createTextVNode (" \xA0\xA0\xA0 "),l.comment.isOp?(Vue.openBlock (),Vue.createElementBlock ("div",oe,"OP")):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("span",ne,Vue.toDisplayString (l.comment.date),1)])]),Vue.createElementVNode ("div",le,[Vue.createElementVNode ("div",se,[Vue.createElementVNode ("div",{class:"tool",onClick:e [1]||(e [1]=p=>o.$emit ("reply"))},re),Vue.createElementVNode ("div",{class:"tool",onClick:e [2]||(e [2]=p=>o.$emit ("hide"))},ue),l.comment.thankCount?Vue.createCommentVNode ("",!0):(Vue.openBlock (),Vue.createBlock (d,{key:0,item:t.pointInfo,onAddThank:t.addThank,onRecallThank:t.recallThank,"api-url":"reply/"+l.comment.id},null,8,["item","onAddThank","onRecallThank","api-url"]))]),l.comment.thankCount?(Vue.openBlock (),Vue.createBlock (d,{key:0,item:t.pointInfo,onAddThank:t.addThank,onRecallThank:t.recallThank,"api-url":"reply/"+l.comment.id},null,8,["item","onAddThank","onRecallThank","api-url"])):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("div",{class:Vue.normalizeClass (["floor",{isDev:t.isDev}])},Vue.toDisplayString (l.comment.floor),3)])],2)} var ce=k (Z,[["render",de],["__scopeId","data-v-e030155e"]]);const pe=o=>(Vue.pushScopeId ("data-v-5d67ef48"),o=o (),Vue.popScopeId (),o),me={class:"get-cursor"},he=["innerHTML"],Ve={class:"toolbar"},ve=pe (()=>Vue.createElementVNode ("span",null,"\u8BF7\u5C3D\u91CF\u8BA9\u81EA\u5DF1\u7684\u56DE\u590D\u80FD\u591F\u5BF9\u522B\u4EBA\u6709\u5E2E\u52A9",-1)),we={__name:"PostEditor",props:{replyInfo:null,replyFloor:null,useType:{type:String,default (){return"reply-comment"}}},emits:["close"],setup (o,{emit:e}){const {replyInfo:l,replyFloor:u,useType:n,isShow:t}=o,d=Vue.inject ("post");Vue.inject ("allReplyUsers");let p=Vue.ref (!1);const c=Vue.ref (!1),m=Vue.ref ("editorId_"+Date.now ()),s=Vue.ref (l),a=Vue.ref (null),h=Vue.ref (null),y=Vue.ref ('<span style="white-space:pre-wrap;"> </span>'),C=Vue.computed (()=>[n,p.value?"isFocus":""]),D=Vue.computed (()=>{var V;if (!a.value||!s.value) return"";let f=((V=a.value)==null?void 0:V.selectionStart)||0;return s.value.substring (0,f).replace (/</g,"<").replace (/>/g,">").replace (/\n/g,"<br/>").replace (/\s/g,y.value)}),L=Vue.computed (()=>s.value?s.value===l:!0);async function P (){if (L.value||c.value) return;c.value=!0;let f={thankCount:0,isThanked:!1,isOp:d.value.username===window.win ().user.username,id:Date.now (),username:window.win ().user.username,avatar:window.win ().user.avatar,date:"\u51E0\u79D2\u524D",floor:d.value.replyCount+1,reply_content:s.value||Date.now (),children:[],replyUsers:[],replyFloor:u||-1},V=s.value.match (/@([\w]+?[\s])/g);V&&V.map (v=>{let w=v.replace ("@","").replace (" ","");f.reply_content=f.reply_content.replace (w,`<a href="/member/${w}">${w}</a>`)});let _=`${window.win ().url}/t/${d.value.id}`;$.post (_,{content:s.value,once:d.value.once}).then (v=>{if (c.value=!1,v.search ("\u4F60\u4E0A\u4E00\u6761\u56DE\u590D\u7684\u5185\u5BB9\u548C\u8FD9\u6761\u76F8\u540C")>-1) return i.emit (r.SHOW_MSG,{type:"error",text:"\u4F60\u4E0A\u4E00\u6761\u56DE\u590D\u7684\u5185\u5BB9\u548C\u8FD9\u6761\u76F8\u540C"});if (v.search ("\u521B\u5EFA\u65B0\u56DE\u590D")>-1) return i.emit (r.SHOW_MSG,{type:"error",text:"\u56DE\u590D\u5931\u8D25"});s.value=l,e ("close"),i.emit (r.REFRESH_ONCE,v),i.emit (r.SHOW_MSG,{type:"success",text:"\u56DE\u590D\u6210\u529F"}),i.emit (r.ADD_REPLY,f)},v=>{c.value=!1,i.emit (r.SHOW_MSG,{type:"error",text:"\u56DE\u590D\u5931\u8D25"})})} function E (){i.emit (r.SHOW_CALL,{show:!1}),i.off (r.SET_CALL)} function N (f){let V=h.value.getBoundingClientRect ();i.emit (r.SHOW_CALL,{show:!0,top:V.top,left:V.left,text:f}),i.off (r.SET_CALL),i.on (r.SET_CALL,_=>{let v=a.value.selectionStart,w=s.value.slice (0,v),S=s.value.slice (v,s.value.length),F=w.lastIndexOf ("@");w=s.value.slice (0,F+1),s.value=w+_+""+S;let O=w.length+_.length+1;setTimeout (()=>{a.value.setSelectionRange (O,O)}),i.off (r.SET_CALL)})} function A (f){switch (f.keyCode){case 8:s.value==="@"&&E ();break;case 37:case 38:case 39:case 40:setTimeout (()=>H ({data:""}),100);break}} function H (f){let V=a.value.selectionStart;if (!!s.value){if (f.data==="") return E ();if (f.data==="@"){if (s.value.length!==1){if (s.value [V-2]===" "||s.value [V-2]===`
`) return N ("")} else return N ("");E ()} else {let _=s.value.slice (0,V),v=_.lastIndexOf ("@");if (v===-1) return E ();let w=_.slice (v,V);if (w.includes (" ")) E ();else {if (v===0) return N (w.replace ("@",""));if (s.value.length!==1){if (s.value [v-1]===""||s.value [v-1]===`
`) return N (w.replace ("@",""))} else return N (w.replace ("@",""));E ()}}}} function j (){p.value=!1} return Vue.onMounted (()=>{$(`.${m.value}`).each (function (){this.setAttribute ("style","height:"+this.scrollHeight+"px;overflow-y:hidden;")}).on ("input",function (){this.style.height=0,this.style.height=this.scrollHeight+"px"}),a.value&&a.value.focus ()}),Vue.onBeforeUnmount (()=>{$(`.${m.value}`).off ()}),(f,V)=>(Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["post-editor-wrapper",Vue.unref (C)])},[Vue.withDirectives (Vue.createElementVNode ("textarea",{class:Vue.normalizeClass (["post-editor",m.value]),ref_key:"txtRef",ref:a,onFocus:V [0]||(V [0]=_=>Vue.isRef (p)?p.value=!0:p=!0),onBlur:j,onInput:H,onKeydown:A,"onUpdate:modelValue":V [1]||(V [1]=_=>s.value=_)},null,34),[[Vue.vModelText,s.value]]),Vue.createElementVNode ("div",me,[Vue.createElementVNode ("span",{innerHTML:Vue.unref (D)},null,8,he),Vue.createElementVNode ("span",{class:"cursor",ref_key:"cursorRef",ref:h},"|",512)]),Vue.createElementVNode ("div",Ve,[ve,Vue.createElementVNode ("div",{class:Vue.normalizeClass (["button",{disabled:Vue.unref (L),loading:c.value}]),onClick:P},"\u56DE\u590D ",2)])],2))}};var I=k (we,[["__scopeId","data-v-5d67ef48"]]);const fe=["innerHTML"],R={__name:"BaseHtmlRender",props:["html"],setup (o){const e=o;function l (u){let n=window.win ().getSelection ().toString ();if (n){let t=n.match (/([A-Za-z0-9+/=]+)/g);if (t){if (t [0].length<4) return;i.emit (r.SHOW_TOOLTIP,{text:t [0],e:u})}}} return (u,n)=>(Vue.openBlock (),Vue.createElementBlock ("div",Vue.mergeProps (u.$attrs,{innerHTML:e.html,onMouseup:l}),null,16,fe))}};const _e={name:"Comment",components:{BaseHtmlRender:R,Author:ce,PostEditor:I,Point:B},props:{modelValue:{reply_content:""}},data (){return {edit:!1,expand:!0,replyInfo:`@${this.modelValue.username} #${this.modelValue.floor}`,cssStyle:null}},inject:["post","postDetailWidth"],watch:{},created (){},mounted (){let o=this.$refs.comment.getBoundingClientRect (),e=this.postDetailWidth/2;if (e<o.width&&o.width<e+25&&this.modelValue.children.length){this.expand=!1;let l=2;this.cssStyle={padding:"1rem 0",width:`calc (${this.postDetailWidth} px - ${l} rem)`,transform:`translateX (calc (${o.width-this.postDetailWidth} px + ${l} rem))`}}},methods:{hide (){let o=`${window.win ().url}/ignore/reply/${this.modelValue.id}?once=${this.post.once}`;i.emit (r.REMOVE,this.modelValue.floor),$.post (o).then (e=>{i.emit (r.REFRESH_ONCE),i.emit (r.SHOW_MSG,{type:"success",text:"\u9690\u85CF\u6210\u529F"})},e=>{i.emit (r.SHOW_MSG,{type:"warning",text:"\u9690\u85CF\u6210\u529F,\u4EC5\u672C\u6B21\u6709\u6548\uFF08\u63A5\u53E3\u8C03\u7528\u5931\u8D25\uFF01\uFF09"})})},toggle (){this.expand=!this.expand}}},ke={class:"comment",ref:"comment"},ge={class:"comment-content"},ye={class:"right"},Ce={class:"w"};function Ee (o,e,l,u,n,t){const d=Vue.resolveComponent ("Author"),p=Vue.resolveComponent ("BaseHtmlRender"),c=Vue.resolveComponent ("PostEditor"),m=Vue.resolveComponent ("Comment",!0);return Vue.openBlock (),Vue.createElementBlock ("div",ke,[Vue.createVNode (d,{modelValue:n.expand,"onUpdate:modelValue":e [0]||(e [0]=s=>n.expand=s),comment:l.modelValue,onReply:e [1]||(e [1]=s=>n.edit=!n.edit),onHide:t.hide},null,8,["modelValue","comment","onHide"]),n.cssStyle&&!n.expand?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:"more ago",onClick:e [2]||(e [2]=s=>n.expand=!n.expand)},"\u7531\u4E8E\u5D4C\u5957\u56DE\u590D\u5C42\u7EA7\u592A\u6DF1\uFF0C\u81EA\u52A8\u5C06\u540E\u7EED\u56DE\u590D\u9690\u85CF")):Vue.createCommentVNode ("",!0),Vue.withDirectives (Vue.createElementVNode ("div",{class:"comment-content-w",style:Vue.normalizeStyle (n.cssStyle)},[n.cssStyle?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:"more ago",onClick:e [3]||(e [3]=s=>n.expand=!n.expand)}," \u7531\u4E8E\u5D4C\u5957\u56DE\u590D\u5C42\u7EA7\u592A\u6DF1\uFF0C\u81EA\u52A8\u5C06\u4EE5\u4E0B\u56DE\u590D\u79FB\u81F3\u53EF\u89C1\u8303\u56F4 ")):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("div",ge,[Vue.createElementVNode ("div",{class:"left expand-line",onClick:e [4]||(e [4]=(...s)=>t.toggle&&t.toggle (...s))}),Vue.createElementVNode ("div",ye,[Vue.createElementVNode ("div",Ce,[Vue.createVNode (p,{class:"text",html:l.modelValue.reply_content},null,8,["html"]),n.edit?(Vue.openBlock (),Vue.createBlock (c,{key:0,onClose:e [5]||(e [5]=s=>n.edit=!1),replyInfo:n.replyInfo,replyFloor:l.modelValue.floor},null,8,["replyInfo","replyFloor"])):Vue.createCommentVNode ("",!0)]),(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (l.modelValue.children,(s,a)=>(Vue.openBlock (),Vue.createBlock (m,{modelValue:l.modelValue.children [a],"onUpdate:modelValue":h=>l.modelValue.children [a]=h,key:a},null,8,["modelValue","onUpdate:modelValue"]))),128))])]),n.cssStyle?(Vue.openBlock (),Vue.createElementBlock ("div",{key:1,class:"more ago",onClick:e [6]||(e [6]=s=>n.expand=!n.expand)}," \u7531\u4E8E\u5D4C\u5957\u56DE\u590D\u5C42\u7EA7\u592A\u6DF1\uFF0C\u81EA\u52A8\u5C06\u4EE5\u4E0A\u56DE\u590D\u79FB\u81F3\u53EF\u89C1\u8303\u56F4 ")):Vue.createCommentVNode ("",!0)],4),[[Vue.vShow,n.expand]])],512)} var Ne=k (_e,[["render",Ee],["__scopeId","data-v-610ec7c1"]]);const xe={name:"Toolbar",inject:["isLogin","post","pageType"],data (){return {timer:null,showTooltip:!1,loading:!1,loading2:!1,loading3:!1}},methods:{getColor (o){return o?"#ff4500":"#929596"},getIsFull (o){return o?"#ff4500":"none"},showTooltipHandler (){this.timer&&clearTimeout (this.timer),this.showTooltip=!0},hideTooltip (){this.timer=setTimeout (()=>{this.showTooltip=!1},500)},tweet (){let o=window.win ().user.username,e=`https://twitter.com/share?url=${window.win ().url}/t/${this.post.id}?r=${o}&related=v2ex&hashtags=apple&text=${this.post.title}`;window.win ().open (e,"_blank","width=550,height=370")},report (){if (!this.isLogin||this.post.isReport) return;let o=window.win ().user.username,e=`https://twitter.com/share?url=${window.win ().url}/t/${this.post.id}?r=${o}&related=v2ex&hashtags=apple&text=${this.post.title}`;window.win ().open (e,"_blank","width=550,height=370")},async toggleIgnore (){let o=`${window.win ().url}/${this.post.isIgnore?"unignore":"ignore"}/topic/${this.post.id}?once=${this.post.once}`;this.pageType==="post"?(this.loading2=!0,(await window.win ().fetch (o)).redirected?(this.post.isIgnore||(window.win ().location=window.win ().url),i.emit (r.SHOW_MSG,{type:"success",text:this.post.isIgnore?"\u53D6\u6D88\u6210\u529F":"\u5FFD\u7565\u6210\u529F"}),i.emit (r.MERGE,{isIgnore:!this.post.isIgnore})):i.emit (r.SHOW_MSG,{type:"warning",text:"\u5FFD\u7565\u5931\u8D25"}),this.loading2=!1):(this.post.isIgnore?this.loading2=!0:i.emit (r.IGNORE),(await window.win ().fetch (o)).redirected?(this.post.isIgnore&&i.emit (r.REFRESH_ONCE),i.emit (r.SHOW_MSG,{type:"success",text:this.post.isIgnore?"\u53D6\u6D88\u6210\u529F":"\u5FFD\u7565\u6210\u529F"}),i.emit (r.MERGE,{isIgnore:!this.post.isIgnore})):i.emit (r.SHOW_MSG,{type:"warning",text:"\u5FFD\u7565\u6210\u529F,\u4EC5\u672C\u6B21\u6709\u6548\uFF08\u63A5\u53E3\u8C03\u7528\u5931\u8D25\uFF01\uFF09"}),this.loading2=!1)},async toggleFavorite (){this.loading=!0;let o=`${window.win ().url}/${this.post.isFavorite?"unfavorite":"favorite"}/topic/${this.post.id}?once=${this.post.once}`,e=await window.win ().fetch (o);if (this.loading=!1,e.redirected){let l=await e.text ();if (l.search (this.post.isFavorite?"\u52A0\u5165\u6536\u85CF":"\u53D6\u6D88\u6536\u85CF")){i.emit (r.MERGE,{collectCount:this.post.isFavorite?this.post.collectCount-1:this.post.collectCount+1}),i.emit (r.SHOW_MSG,{type:"success",text:this.post.isFavorite?"\u53D6\u6D88\u6210\u529F":"\u6536\u85CF\u6210\u529F"}),i.emit (r.REFRESH_ONCE,l),i.emit (r.MERGE,{isFavorite:!this.post.isFavorite});return}} i.emit (r.SHOW_MSG,{type:"error",text:"\u64CD\u4F5C\u5931\u8D25"})}}},x=o=>(Vue.pushScopeId ("data-v-119b6802"),o=o (),Vue.popScopeId (),o),Te={class:"toolbar"},Se=Vue.createStaticVNode ('<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-119b6802><path d="M4 6H44V36H29L24 41L19 36H4V6Z" fill="none" stroke="#929596" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-119b6802></path><path d="M23 21H25.0025" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-119b6802></path><path d="M33.001 21H34.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-119b6802></path><path d="M13.001 21H14.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-119b6802></path></svg><span data-v-119b6802>\u56DE\u590D</span>',2),Be=[Se],Me={viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be=["fill","stroke"],Le={key:1,class:"tool no-hover"},He=x (()=>Vue.createElementVNode ("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{d:"M28 6H42V20",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{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",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{d:"M25.7998 22.1999L41.0998 6.8999",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),Oe=x (()=>Vue.createElementVNode ("span",null,"Tweet",-1)),Ie=[He,Oe],Re={viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},De=["fill","stroke"],Pe=["fill","stroke"],Ae=["fill","stroke"],je=Vue.createStaticVNode ('<svg width="19" height="19" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-119b6802><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-119b6802></path><path d="M8 42H40" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-119b6802></path><path d="M4 13L7 14" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-119b6802></path><path d="M13 3.9999L14 6.9999" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-119b6802></path><path d="M10.0001 9.99989L7.00009 6.99989" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-119b6802></path></svg>',1),Fe=x (()=>Vue.createElementVNode ("a",{target:"_blank",href:"https://github.com/zyronon/v2ex-script/issues"},"\u70B9\u51FB\u8FD9\u91CC\u63D0\u4E00\u4E2AIssue",-1)),Ge=x (()=>Vue.createElementVNode ("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{d:"M8 44H12H16",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{d:"M12 44V4",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{d:"M40 6H12V22H40L36 14L40 6Z",fill:"none",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),We=x (()=>Vue.createElementVNode ("span",null,"\u811A\u672C\u6709\u95EE\u9898\uFF1F",-1));function ze (o,e,l,u,n,t){return Vue.openBlock (),Vue.createElementBlock ("div",Te,[Vue.createElementVNode ("div",{class:"tool",onClick:e [0]||(e [0]=d=>o.$emit ("reply"))},Be),t.post.once?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:Vue.normalizeClass (["tool",{loading:n.loading}]),onClick:e [1]||(e [1]=(...d)=>t.toggleFavorite&&t.toggleFavorite (...d))},[(Vue.openBlock (),Vue.createElementBlock ("svg",Me,[Vue.createElementVNode ("path",{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",fill:t.getIsFull (t.post.isFavorite),stroke:t.getColor (t.post.isFavorite),"stroke-width":"2","stroke-linejoin":"round"},null,8,be)])),Vue.createElementVNode ("span",null,Vue.toDisplayString (t.post.isFavorite?"\u53D6\u6D88\u6536\u85CF":"\u52A0\u5165\u6536\u85CF"),1)],2)):Vue.createCommentVNode ("",!0),t.post.once&&t.post.collectCount!==0?(Vue.openBlock (),Vue.createElementBlock ("div",Le,[Vue.createElementVNode ("span",null,Vue.toDisplayString (t.post.collectCount+"\u4EBA\u6536\u85CF"),1)])):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("div",{class:"tool",onClick:e [2]||(e [2]=(...d)=>t.tweet&&t.tweet (...d))},Ie),t.post.once?(Vue.openBlock (),Vue.createElementBlock ("div",{key:2,class:Vue.normalizeClass (["tool",{loading:n.loading2}]),onClick:e [3]||(e [3]=(...d)=>t.toggleIgnore&&t.toggleIgnore (...d))},[(Vue.openBlock (),Vue.createElementBlock ("svg",Re,[Vue.createElementVNode ("path",{fill:t.getIsFull (t.post.isIgnore),stroke:t.getColor (t.post.isIgnore),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","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,De),Vue.createElementVNode ("path",{fill:t.getIsFull (t.post.isIgnore),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",stroke:t.getColor (t.post.isIgnore),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Pe),Vue.createElementVNode ("path",{d:"M42 42L6 6",fill:t.getIsFull (t.post.isIgnore),stroke:t.getColor (t.post.isIgnore),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Ae)])),Vue.createElementVNode ("span",null,Vue.toDisplayString (t.post.isIgnore?"\u53D6\u6D88\u5FFD\u7565":"\u5FFD\u7565\u4E3B\u9898"),1)],2)):Vue.createCommentVNode ("",!0),t.post.once&&t.post.isLogin?(Vue.openBlock (),Vue.createElementBlock ("div",{key:3,class:Vue.normalizeClass (["tool",{loading:n.loading3,"no-hover":t.post.isLogin}]),onClick:e [4]||(e [4]=(...d)=>t.report&&t.report (...d))},[je,Vue.createElementVNode ("span",null,Vue.toDisplayString (t.post.isReport?"\u4F60\u5DF2\u5BF9\u672C\u4E3B\u9898\u8FDB\u884C\u4E86\u62A5\u544A":"\u62A5\u544A\u8FD9\u4E2A\u4E3B\u9898"),1)],2)):Vue.createCommentVNode ("",!0),t.post.once?(Vue.openBlock (),Vue.createElementBlock ("div",{key:4,class:"tool no-hover",onMouseenter:e [7]||(e [7]=(...d)=>t.showTooltipHandler&&t.showTooltipHandler (...d)),onMouseleave:e [8]||(e [8]=(...d)=>t.hideTooltip&&t.hideTooltip (...d))},[n.showTooltip?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:"tooltip",onMouseenter:e [5]||(e [5]=(...d)=>t.showTooltipHandler&&t.showTooltipHandler (...d)),onMouseleave:e [6]||(e [6]=(...d)=>t.hideTooltip&&t.hideTooltip (...d))},[Vue.createTextVNode ("\u811A\u672C\u6709\u95EE\u9898\uFF1F"),Fe],32)):Vue.createCommentVNode ("",!0),Ge,We],32)):Vue.createCommentVNode ("",!0)])} var Ue=k (xe,[["render",ze],["__scopeId","data-v-119b6802"]]);const Ke={name:"detail",components:{Comment:Ne,PostEditor:I,Point:B,Toolbar:Ue,BaseHtmlRender:R},inject:["allReplyUsers","post","clone"],provide (){return {postDetailWidth:Vue.computed (()=>{var o;return ((o=this.$refs.comments)==null?void 0:o.getBoundingClientRect ().width)||0})}},props:{modelValue:!1,loading:!1},data (){return {showSortOption:!1,isSticky:!1,target:0,sortOptions:[{value:0,label:"\u697C\u4E2D\u697C"},{value:1,label:"\u611F\u8C22"},{value:2,label:"V2\u539F\u7248"}],selectCallIndex:0,postDetailWidth:0,showCallList:!1,replyText:"",callStyle:{top:0,left:0}}},computed:{filterCallList (){return this.showCallList?this.replyText?this.allReplyUsers.filter (o=>o.search (this.replyText)>-1):this.allReplyUsers:[]},replies (){if (this.target===0) return this.post.nestedReplies;if (this.target===1) return this.clone (this.post.nestedReplies).sort ((o,e)=>e.thankCount-o.thankCount);if (this.target===2) return this.post.replies}},watch:{modelValue (o){o||(this.$nextTick (()=>{this.$refs.detail.scrollTo ({top:0})}),window.win ().doc.body.style.overflow="unset",this.isSticky=!1,window.win ().pageType)}},mounted (){new IntersectionObserver (([e])=>e.target.toggleAttribute ("stuck",e.intersectionRatio<1),{threshold:[1]}).observe (this.$refs.replyBox),window.win ().addEventListener ("keydown",this.onKeyDown),i.on (r.SHOW_CALL,e=>{e.show?(this.showCallList=!0,this.replyText=e.text,this.callStyle.top=e.top+$(".post-detail").scrollTop ()+15+"px",this.callStyle.left=e.left-$(".main")[0].getBoundingClientRect ().left+10+"px",this.selectCallIndex>=this.filterCallList.length&&(this.selectCallIndex=0)):(this.replyText="",this.showCallList=!1,this.selectCallIndex=0)})},beforeUnmount (){this.$refs.right.innerHTML="",window.win ().removeEventListener ("keydown",this.onKeyDown),i.off (r.SHOW_CALL)},methods:{setCall (o){i.emit (r.SET_CALL,o),this.showCallList=!1},onKeyDown (o){if (!this.modelValue||!this.showCallList) return;let e=this.filterCallList.slice (0,10).length;o.keyCode===13&&(this.setCall (this.filterCallList [this.selectCallIndex]),o.preventDefault ()),o.keyCode===38&&(this.selectCallIndex--,this.selectCallIndex<0&&(this.selectCallIndex=e-1),o.preventDefault ()),o.keyCode===40&&(this.selectCallIndex++,this.selectCallIndex>e-1&&(this.selectCallIndex=0),o.preventDefault ())},changeOption (o){this.showSortOption=!1,this.target=o.value},stop (){this.showSortOption=!1},scroll (){this.showSortOption=!1},addThank (){i.emit (r.CHANGE_POST_THANK,{id:this.post.id,type:"add"})},recallThank (){i.emit (r.CHANGE_POST_THANK,{id:this.post.id,type:"recall"})},scrollTop (){this.$refs.detail.scrollTo ({top:0,behavior:"smooth"})}}},g=o=>(Vue.pushScopeId ("data-v-31164580"),o=o (),Vue.popScopeId (),o),Ze={class:"left"},$e={class:"left-wrapper"},Ye={class:"my-box post-wrapper"},qe={class:"base-info"},Xe=["href"],Je=["src"],Qe={class:"post-nodes"},et=g (()=>Vue.createElementVNode ("a",{href:"/"},"V2EX",-1)),tt=g (()=>Vue.createElementVNode ("span",{class:"chevron"},"\xA0\xA0\u203A\xA0\xA0",-1)),ot=["href"],nt=["innerHTML"],lt={class:"post-author"},st={class:"username"},it=["href"],rt={class:"date"},at={class:"date"},ut={key:0,class:"content"},dt={class:"toolbar-wrapper"},ct={key:0,class:"my-box"},pt={class:"my-cell flex"},mt={class:"gray"},ht={key:0},Vt=g (()=>Vue.createElementVNode ("strong",{class:"snow"},"\u2022",-1)),vt={class:"sort-select"},wt=g (()=>Vue.createElementVNode ("svg",{width:"20",height:"20",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{d:"M36 19L24 31L12 19H36Z",fill:"#0079d3",stroke:"#0079d3","stroke-width":"2","stroke-linejoin":"round"})],-1)),ft={key:0,class:"options"},_t=["onClick"],kt=g (()=>Vue.createElementVNode ("div",{class:"loading-wrapper"},[Vue.createElementVNode ("div",{class:"loading-c"})],-1)),gt={key:0,class:"my-box comment-wrapper"},yt={class:"my-cell flex"},Ct={class:"gray"},Et={key:0},Nt=g (()=>Vue.createElementVNode ("strong",{class:"snow"},"\u2022",-1)),xt={class:"sort-select"},Tt=g (()=>Vue.createElementVNode ("svg",{width:"20",height:"20",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{d:"M36 19L24 31L12 19H36Z",fill:"#0079d3",stroke:"#0079d3","stroke-width":"2","stroke-linejoin":"round"})],-1)),St={key:0,class:"options"},Bt=["onClick"],Mt={class:"comments",ref:"comments"},bt={key:1,id:"no-comments-yet"},Lt={class:"my-cell flex"},Ht=g (()=>Vue.createElementVNode ("span",null,"\u6DFB\u52A0\u4E00\u6761\u65B0\u56DE\u590D",-1)),Ot={class:"notice-right"},It={class:"w"},Rt={class:"right",ref:"right"},Dt=["innerHTML"],Pt=["onClick"];function At (o,e,l,u,n,t){const d=Vue.resolveComponent ("BaseHtmlRender"),p=Vue.resolveComponent ("Point"),c=Vue.resolveComponent ("Toolbar"),m=Vue.resolveComponent ("Comment"),s=Vue.resolveComponent ("PostEditor");return Vue.withDirectives ((Vue.openBlock (),Vue.createElementBlock ("div",{class:"post-detail",ref:"detail",onScroll:e [8]||(e [8]=(...a)=>t.scroll&&t.scroll (...a)),onClick:e [9]||(e [9]=a=>o.$emit ("update:modelValue",!1))},[Vue.createElementVNode ("div",{class:"main",onClick:e [7]||(e [7]=Vue.withModifiers ((...a)=>t.stop&&t.stop (...a),["stop"]))},[Vue.createElementVNode ("div",Ze,[Vue.createElementVNode ("div",$e,[Vue.createElementVNode ("div",Ye,[Vue.createElementVNode ("div",qe,[Vue.createElementVNode ("a",{href:`/member/${t.post.username}`},[Vue.createElementVNode ("img",{class:"avatar",src:t.post.avatar,alt:""},null,8,Je)],8,Xe),Vue.createElementVNode ("div",Qe,[et,tt,Vue.createElementVNode ("a",{href:t.post.nodeUrl},Vue.toDisplayString (t.post.node),9,ot)]),Vue.createElementVNode ("div",{class:"title",innerHTML:t.post.title},null,8,nt),Vue.createElementVNode ("div",lt,[Vue.createElementVNode ("div",st,[Vue.createElementVNode ("a",{href:`/member/${t.post.username}`},Vue.toDisplayString (t.post.username),9,it)]),Vue.createTextVNode ("\xA0\xA0\xB7\xA0\xA0"),Vue.createElementVNode ("div",rt,Vue.toDisplayString (t.post.date),1),Vue.createTextVNode ("\xA0\xA0\xB7\xA0\xA0"),Vue.createElementVNode ("div",at,Vue.toDisplayString (t.post.clickCount)+"\u6B21\u70B9\u51FB",1)])]),t.post.content_rendered||t.post.subtlesHtml?(Vue.openBlock (),Vue.createElementBlock ("div",ut,[Vue.createVNode (d,{html:t.post.content_rendered,class:"baseContent"},null,8,["html"]),Vue.createVNode (d,{html:t.post.subtlesHtml},null,8,["html"])])):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("div",dt,[Vue.createVNode (p,{onAddThank:t.addThank,onRecallThank:t.recallThank,item:{isThanked:t.post.isThanked,thankCount:t.post.thankCount,username:t.post.username},"api-url":"topic/"+t.post.id},null,8,["onAddThank","onRecallThank","item","api-url"]),Vue.createVNode (c,{onReply:e [0]||(e [0]=a=>n.isSticky=!n.isSticky)})])]),l.loading?(Vue.openBlock (),Vue.createElementBlock ("div",ct,[Vue.createElementVNode ("div",pt,[Vue.createElementVNode ("span",mt,[Vue.createTextVNode (Vue.toDisplayString (t.post.replyCount)+" \u6761\u56DE\u590D ",1),t.post.createDate?(Vue.openBlock (),Vue.createElementBlock ("span",ht,[Vue.createTextVNode (" \xA0"),Vt,Vue.createTextVNode (" \xA0"+Vue.toDisplayString (t.post.createDate),1)])):Vue.createCommentVNode ("",!0)]),Vue.createElementVNode ("div",vt,[Vue.createElementVNode ("div",{class:"target",onClick:e [1]||(e [1]=Vue.withModifiers (a=>n.showSortOption=!0,["stop"]))},[Vue.createElementVNode ("span",null,"\u6392\u5E8F\uFF1A"+Vue.toDisplayString (n.sortOptions.find (a=>a.value===n.target).label),1),wt]),n.showSortOption?(Vue.openBlock (),Vue.createElementBlock ("div",ft,[(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (n.sortOptions,a=>(Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["option",{active:n.target===a.value}]),onClick:h=>t.changeOption (a)},Vue.toDisplayString (a.label),11,_t))),256))])):Vue.createCommentVNode ("",!0)])]),kt])):(Vue.openBlock (),Vue.createElementBlock (Vue.Fragment,{key:1},[t.replies.length?(Vue.openBlock (),Vue.createElementBlock ("div",gt,[Vue.createElementVNode ("div",yt,[Vue.createElementVNode ("span",Ct,[Vue.createTextVNode (Vue.toDisplayString (t.post.replyCount)+" \u6761\u56DE\u590D ",1),t.post.createDate?(Vue.openBlock (),Vue.createElementBlock ("span",Et,[Vue.createTextVNode (" \xA0"),Nt,Vue.createTextVNode (" \xA0"+Vue.toDisplayString (t.post.createDate),1)])):Vue.createCommentVNode ("",!0)]),Vue.createElementVNode ("div",xt,[Vue.createElementVNode ("div",{class:"target",onClick:e [2]||(e [2]=Vue.withModifiers (a=>n.showSortOption=!0,["stop"]))},[Vue.createElementVNode ("span",null,"\u6392\u5E8F\uFF1A"+Vue.toDisplayString (n.sortOptions.find (a=>a.value===n.target).label),1),Tt]),n.showSortOption?(Vue.openBlock (),Vue.createElementBlock ("div",St,[(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (n.sortOptions,a=>(Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["option",{active:n.target===a.value}]),onClick:h=>t.changeOption (a)},Vue.toDisplayString (a.label),11,Bt))),256))])):Vue.createCommentVNode ("",!0)])]),Vue.createElementVNode ("div",Mt,[(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (t.replies,(a,h)=>(Vue.openBlock (),Vue.createBlock (m,{key:a.floor,style:{"border-bottom":"1px solid #e2e2e2",padding:"1rem","margin-top":"0"},modelValue:t.replies [h],"onUpdate:modelValue":y=>t.replies [h]=y},null,8,["modelValue","onUpdate:modelValue"]))),128))],512)])):(Vue.openBlock (),Vue.createElementBlock ("div",bt,"\u76EE\u524D\u5C1A\u65E0\u56DE\u590D"))],64)),Vue.createElementVNode ("div",{class:Vue.normalizeClass (["my-box editor-wrapper",{sticky:n.isSticky}]),ref:"replyBox"},[Vue.createElementVNode ("div",Lt,[Ht,Vue.createElementVNode ("div",Ot,[n.isSticky?(Vue.openBlock (),Vue.createElementBlock ("a",{key:0,class:"float",onClick:e [3]||(e [3]=a=>n.isSticky=!1)},"\u53D6\u6D88\u56DE\u590D\u6846\u505C\u9760")):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("a",{onClick:e [4]||(e [4]=(...a)=>t.scrollTop&&t.scrollTop (...a))},"\u56DE\u5230\u9876\u90E8")])]),Vue.createElementVNode ("div",It,[Vue.createVNode (s,{useType:"reply-post",onClick:e [5]||(e [5]=a=>n.isSticky=!0)})])],2)])]),Vue.createElementVNode ("div",Rt,[Vue.createElementVNode ("div",{id:"Rightbar",innerHTML:t.post.RightbarHTML},null,8,Dt),Vue.createElementVNode ("div",{class:"scroll-top button",onClick:e [6]||(e [6]=Vue.withModifiers ((...a)=>t.scrollTop&&t.scrollTop (...a),["stop"]))},"\u56DE\u5230\u9876\u90E8")],512),n.showCallList&&t.filterCallList.length?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:"call-list",style:Vue.normalizeStyle (n.callStyle)},[(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (t.filterCallList.slice (0,10),(a,h)=>(Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["call-item",{select:h===n.selectCallIndex}]),onClick:y=>t.setCall (a)},[Vue.createElementVNode ("a",null,Vue.toDisplayString (a),1)],10,Pt))),256))],4)):Vue.createCommentVNode ("",!0)])],544)),[[Vue.vShow,l.modelValue]])} var jt=k (Ke,[["render",At],["__scopeId","data-v-31164580"]]);const Ft={class:"base-info"},Gt={class:"left"},Wt=["href"],zt={class:"avatar"},Ut=["src"],Kt={class:"right"},Zt=["href"],$t={class:"bottom"},Yt=["href"],qt=["href"],Xt={class:"date"},Jt=["innerHTML"],Qt={__name:"Post",props:["post","viewType"],setup (o){const e=o,l=200,u=Vue.ref (!1),n=Vue.ref (null),t=Vue.computed (()=>e.post.bg?{backgroundImage:e.post.bg,backgroundRepeat:"no-repeat",backgroundSize:"20px 20px",backgroundPosition:"right top"}:{});Vue.watch ([()=>e.post,()=>n.value,()=>e.viewType],()=>{if (!n.value||e.viewType==="table") return;let p=n.value.getBoundingClientRect ();n.value.querySelectorAll ("img").forEach (c=>{c.addEventListener ("load",d)}),u.value=p.height>=l},{immediate:!0,flush:"post"});function d (){if (u.value) return;let p=n.value.getBoundingClientRect ();u.value=p.height>=l} return (p,c)=>(Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["post",e.viewType]),style:Vue.normalizeStyle (Vue.unref (t))},[Vue.createElementVNode ("div",Ft,[Vue.createElementVNode ("div",Gt,[Vue.createElementVNode ("a",{href:`/member/${e.post.username}`},[Vue.createElementVNode ("div",zt,[Vue.createElementVNode ("img",{src:e.post.avatar,alt:""},null,8,Ut)])],8,Wt),Vue.createElementVNode ("div",Kt,[Vue.createElementVNode ("div",{class:"title",onClick:c [0]||(c [0]=m=>p.$emit ("show",m))},[Vue.createElementVNode ("a",{href:`t/${e.post.id}`},Vue.toDisplayString (e.post.title),9,Zt)]),Vue.createElementVNode ("div",$t,[e.post.node?(Vue.openBlock (),Vue.createElementBlock (Vue.Fragment,{key:0},[Vue.createElementVNode ("a",{href:e.post.nodeUrl,class:"my-node"},Vue.toDisplayString (e.post.node),9,Yt),Vue.createTextVNode ("\xA0\xA0\xB7\xA0\xA0")],64)):Vue.createCommentVNode ("",!0),Vue.createElementVNode ("strong",null,[Vue.createElementVNode ("a",{class:"username",href:`/member/${e.post.username}`},Vue.toDisplayString (e.post.username),9,qt)]),Vue.createTextVNode (" \xA0\xA0\xB7\xA0\xA0 "),Vue.createElementVNode ("span",Xt,Vue.toDisplayString (e.post.date),1)])])]),e.post.replyCount?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:"count",onClick:c [1]||(c [1]=m=>p.$emit ("show"))},Vue.toDisplayString (e.post.replyCount),1)):Vue.createCommentVNode ("",!0)]),e.post.content_rendered?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:Vue.normalizeClass (["post-content-wrapper",{mask:u.value}])},[Vue.createElementVNode ("div",{innerHTML:e.post.content_rendered,ref_key:"content",ref:n,onClick:c [2]||(c [2]=m=>p.$emit ("show",m))},null,8,Jt)],2)):Vue.createCommentVNode ("",!0)],6))}};var eo=k (Qt,[["__scopeId","data-v-0bca2a61"]]);const to={name:"Msg",props:{type:"",text:""},created (){setTimeout (()=>{this.$emit ("close")},3e3)}},oo=Vue.createElementVNode ("svg",{width:"24",height:"24",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{d:"M14 14L34 34",stroke:"#ffffff","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{d:"M14 34L34 14",stroke:"#ffffff","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"})],-1),no=[oo],lo={class:"right"};function so (o,e,l,u,n,t){return Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["msg",l.type])},[Vue.createElementVNode ("div",{class:"left",onClick:e [0]||(e [0]=d=>o.$emit ("close"))},no),Vue.createElementVNode ("div",lo,Vue.toDisplayString (l.text),1)],2)} var io=k (to,[["render",so]]),ro=[{avatar:"https://cdn.v2ex.com/avatar/cdca/41db/41900_normal.png?m=1644293935",id:"887913",content_rendered:"",thankCount:0,title:"\u6B63\u6587\u663E\u793A\u5F02\u5E3812123",node:"\u7ECF\u5178\u56DE\u987E",username:"\u7ECF\u5178\u56DE\u987E",date:"\u51E0\u5C0F\u65F6\u524D"},{avatar:"https://cdn.v2ex.com/avatar/cdca/41db/41900_normal.png?m=1644293935",id:"667520",content_rendered:"",thankCount:0,title:"\u5D4C\u5957\u6709\u95EE\u9898",node:"\u7ECF\u5178\u56DE\u987E",username:"\u7ECF\u5178\u56DE\u987E",date:"\u51E0\u5C0F\u65F6\u524D"},{avatar:"https://cdn.v2ex.com/avatar/cdca/41db/41900_normal.png?m=1644293935",id:"724408",content_rendered:"",thankCount:0,title:"\u5185\u5BB9\u8D85\u7EA7\u591A",node:"\u7ECF\u5178\u56DE\u987E",username:"\u7ECF\u5178\u56DE\u987E",date:"\u51E0\u5C0F\u65F6\u524D"},{avatar:"https://cdn.v2ex.com/avatar/cdca/41db/41900_normal.png?m=1644293935",id:"886622",thankCount:0,title:"\u56DE\u590D\u91CC\u9762\u5982\u679C\u662F \u672C\u7AD9\u5E16\u5B50\uFF0C\u90A3\u4E48\u4E0D\u6253\u5F00\u65B0\u7684\u9875\u9762",node:"\u7ECF\u5178\u56DE\u987E",username:"\u7ECF\u5178\u56DE\u987E",date:"\u51E0\u5C0F\u65F6\u524D"}];const ao=o=>(Vue.pushScopeId ("data-v-2d42a498"),o=o (),Vue.popScopeId (),o),uo=ao (()=>Vue.createElementVNode ("svg",{width:"24",height:"24",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode ("path",{d:"M17 32L19.1875 27M31 32L28.8125 27M19.1875 27L24 16L28.8125 27M19.1875 27H28.8125",stroke:"#929596","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{d:"M43.1999 20C41.3468 10.871 33.2758 4 23.5999 4C13.9241 4 5.85308 10.871 4 20L10 18",stroke:"#929596","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode ("path",{d:"M4 28C5.85308 37.129 13.9241 44 23.5999 44C33.2758 44 41.3468 37.129 43.1999 28L38 30",stroke:"#929596","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),co={key:1},po={__name:"Base64Tooltip",setup (o){const e=Vue.ref (null),l=Vue.ref (!1),u=Vue.ref (""),n=Vue.ref (""),t=Vue.reactive ({left:"-100vw",top:"-100vh"});Vue.onMounted (()=>{i.on (r.SHOW_TOOLTIP,({text:m,e:s})=>{setTimeout (()=>l.value=!0),u.value=m,n.value="",t.left=s.clientX+"px",t.top=s.clientY+20+"px"}),window.win ().addEventListener ("click",m=>{!e.value||!e.value.contains (m.target)&&l.value&&(l.value=!1)},{capture:!0});const c=()=>l.value&&(l.value=!1);$(".post-detail",window.win ().doc).on ("scroll",c)});function d (){window.win ().navigator.clipboard?(window.win ().navigator.clipboard.writeText (n.value),i.emit (r.SHOW_MSG,{type:"success",text:"\u590D\u5236\u6210\u529F"})):i.emit (r.SHOW_MSG,{type:"error",text:"\u590D\u5236\u5931\u8D25\uFF01\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\uFF01"})} function p (){try {n.value=window.atob (u.value)} catch {i.emit (r.SHOW_MSG,{type:"error",text:"Base64\u89E3\u7801\u5931\u8D25\uFF01\u4E0D\u662F\u6807\u51C6\u6570\u636E\uFF01"})}} return (c,m)=>Vue.withDirectives ((Vue.openBlock (),Vue.createElementBlock ("div",{class:"base64_tooltip",style:Vue.normalizeStyle (t),onClick:p,ref_key:"tooltip",ref:e},[n.value?(Vue.openBlock (),Vue.createElementBlock ("div",co,[Vue.createElementVNode ("span",null,Vue.toDisplayString (n.value),1),Vue.createElementVNode ("div",{class:"button",onClick:d},"\u70B9\u51FB\u590D\u5236")])):(Vue.openBlock (),Vue.createElementBlock (Vue.Fragment,{key:0},[Vue.createTextVNode (" Base64\u89E3\u7801\uFF1A"+Vue.toDisplayString (u.value)+" ",1),uo],64))],4)),[[Vue.vShow,l.value]])}};var mo=k (po,[["__scopeId","data-v-2d42a498"]]);const ho={name:"home",provide (){return {isDev:Vue.computed (()=>!1),isLogin:Vue.computed (()=>!!window.win ().user.username),pageType:Vue.computed (()=>this.pageType),clone:window.win ().clone,post:Vue.computed (()=>this.current),allReplyUsers:Vue.computed (()=>Array.from (new Set (this.current.replies.map (o=>o.username))))}},components:{PostDetail:jt,Post:eo,Msg:io,Base64Tooltip:mo},data (){return {viewType:"card",loading:window.win ().pageType==="post",loadMore:!1,pageType:window.win ().pageType,msgList:[],show:!1,autoOpenDetail:!1,current:window.win ().initPost,list:[],readList:new Set}},computed:{isDev (){return!1},showList (){return this.pageType==="home"||this.pageType==="recent"||this.pageType==="nodePage"}},watch:{"current.replies":{handler (o){if (console.log ("watch"),o.length){this.current.replyCount=o.length;let e=window.parse.getNestedList (o);e&&(this.current.nestedReplies=e)} else this.current.replyCount=0,this.current.nestedReplies=[];if (this.list){let e=this.list.findIndex (l=>l.id===this.current.id);e>-1&&(this.list [e].replyCount=o.length)}},deep:!0}},created (){console.log ("create"),window.win ().cb=this.winCb,window.win ().vue;let o=window.win ().localStorage.getItem ("v2ex-config");if (o){let e=JSON.parse (o);e.username===window.win ().user.username&&(this.readList=new Set (e.readList),this.viewType=e.viewType,this.autoOpenDetail=e.autoOpenDetail||!1,this.autoOpenDetail&&this.pageType==="post"&&(this.show=!0,window.win ().doc.body.style.overflow="hidden"))} if (window.win ().onbeforeunload=this.saveConfig,window.win ().isFrame){if (this.list=window.win ().postList,this.showList){let e=window.win ().appNode.nextElementSibling,l=1e3;if (this.pageType!=="home"){let t=e.querySelectorAll ("a");l=Number (t [t.length-1].innerText)} let u=window.win ().IntersectionObserver;new u (async t=>{if (t [0].isIntersecting){if (this.loadMore) return;console.log ("\u52A0\u8F7D\u66F4\u591A"),this.loadMore=!0;let d;if (this.pageType==="home") d=window.win ().url+"/recent?p=1",this.pageType="recent";else {let {href:s,search:a,origin:h,pathname:y}=window.win ().location;d=s+"?p=2";let C=a.match (/p=([\d]+)/);if (C){if (Number (C [1])>=l) return i.emit (r.SHOW_MSG,{type:"success",text:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u9875\u4E86"}),this.loadMore=!1;d=h+y+a.replace (C [1],Number (C [1])+1)}} console.log ("url",d),window.win ().history.pushState ({},0,d);let c=await (await window.win ().fetch (d)).text (),m=window.parse.parsePage (c,this.pageType);console.log ("res",m),e.innerHTML=m.page,this.list.push ({id:"page",innerHTML:e.innerHTML}),m.postList.map (s=>{this.list.findIndex (h=>h.id==s.id)===-1&&this.list.push (s)}),this.loadMore=!1,Promise.allSettled (m.apiList.map (s=>$.get (s))).then (async s=>{let a=s.filter (h=>h.status==="fulfilled").map (h=>h.value [0]);this.winCb ({type:"list",value:a})})}}).observe (e)}} else this.list=ro;this.initEvent ()},beforeUnmount (){console.log ("unmounted"),i.clear ()},methods:{winCb ({type:o,value:e}){o==="list"&&(e.map (l=>{let u=this.list.findIndex (n=>n.id==l.id);u>-1&&(this.list [u]=Object.assign (this.list [u],{content_rendered:l.content_rendered,nodeUrl:l.node.url,avatar:l.member.avatar_large}))}),window.win ().vueCb&&window.win ().vueCb ()),o==="postContent"&&(this.saveConfig (this.readList.add (e.id)),this.current=Object.assign (this.clone (window.win ().initPost),this.clone (e))),o==="postReplies"&&(this.current=Object.assign (this.current,this.clone (e)),this.loading=!1)},saveConfig (){var e;let o={username:(e=window.win ().user.username)!=null?e:"",viewType:this.viewType,readList:Array.from (this.readList),autoOpenDetail:this.autoOpenDetail};window.win ().localStorage.setItem ("v2ex-config",JSON.stringify (o))},clone (o){return window.win ().clone (o)},initEvent (){i.on (r.CHANGE_COMMENT_THANK,o=>{const {id:e,type:l}=o;let u=this.current.replies.findIndex (n=>n.id===e);u>-1&&(this.current.replies [u].isThanked=l==="add",l==="add"?this.current.replies [u].thankCount++:this.current.replies [u].thankCount--)}),i.on (r.CHANGE_POST_THANK,o=>{const {id:e,type:l}=o;this.current.isThanked=l==="add",l==="add"?this.current.thankCount++:this.current.thankCount--;let u=this.list.findIndex (n=>n.id===e);u>-1&&(this.list [u].isThanked=l==="add",l==="add"?this.list [u].thankCount++:this.list [u].thankCount++)}),i.on (r.REMOVE,o=>{let e=this.current.replies.findIndex (u=>u.floor===o);e>-1&&this.current.replies.splice (e,1);let l=this.list.findIndex (u=>u.id===this.current.id);l>-1&&(this.list [l]=Object.assign (this.list [l],o))}),i.on (r.SHOW_MSG,o=>{this.msgList.push ({...o,id:Date.now ()})}),i.on (r.IGNORE,()=>{this.show=!1;let o=this.list.findIndex (e=>e.id===this.current.id);o>-1&&this.list.splice (o,1),this.current=this.clone (window.win ().initPost)}),i.on (r.MERGE,o=>{this.current=Object.assign (this.current,o);let e=this.list.findIndex (l=>l.id===this.current.id);e>-1&&(this.list [e]=Object.assign (this.list [e],o))}),i.on (r.ADD_REPLY,o=>{this.current.replies.push (o)}),i.on (r.REFRESH_ONCE,async o=>{if (o){if (typeof o=="string"){let e=o.match (/var once = "([\d]+)";/);if (e&&e [1]){this.current.once=Number (e [1]);return}} if (typeof o=="number"){this.current.once=o;return}} window.win ().fetchOnce ().then (e=>{this.current.once=e})})},svgColor (o){return o===this.viewType?"white":"#929596"},removeMsg (o){let e=this.msgList.findIndex (l=>l.id===o);e>-1&&this.msgList.splice (e,1)},openPostDetail (){this.show=!0,window.win ().doc.body.style.overflow="hidden"},async getPostDetail (o,e){if (e){let c=e.target||e.srcElement;if (c.nodeName.toLocaleLowerCase ()==="a"){e.preventDefault ();let s=c.innerText.match (/t\/([\d]+)/);s&&(o={id:s [1]})}} this.saveConfig (this.readList.add (o.id)),this.current=Object.assign (window.win ().clone (window.win ().initPost),window.win ().clone (o)),this.show=!0,this.loading=!0,window.win ().doc.body.style.overflow="hidden";let l=window.win ().url+"/t/"+o.id,u=await window.win ().fetch (l+"?p=1");if (u.redirected) return i.emit (r.SHOW_MSG,{type:"error",text:"\u6CA1\u6709\u6743\u9650"}),this.loading=!1;let n=await u.text ();if (n.search ("\u4F60\u8981\u67E5\u770B\u7684\u9875\u9762\u9700\u8981\u5148\u767B\u5F55")>-1) return i.emit (r.SHOW_MSG,{type:"error",text:"\u4F60\u8981\u67E5\u770B\u7684\u9875\u9762\u9700\u8981\u5148\u767B\u5F55"}),this.loading=!1;let d=n.match (/<body [^>]*>([\s\S]+?)<\/body>/g),p=$(d [0]);this.current=await window.parse.parsePostDetail (this.current,p,n),this.loading=!1,console.log ("\u5F53\u524D\u5E16\u5B50",this.current)}}},Vo={width:"19",height:"19",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},vo=["stroke"],wo=["stroke"],fo=["stroke"],_o=Vue.createElementVNode ("span",null,"\u8868\u683C",-1),ko={width:"19",height:"19",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},go=["stroke"],yo=["stroke"],Co=["fill"],Eo=["fill"],No=["fill"],xo=Vue.createElementVNode ("span",null,"\u5361\u7247",-1),To={class:"posts"},So=["innerHTML"],Bo={key:0,class:"flex flex-center p1"},Mo=Vue.createElementVNode ("div",{class:"loading-c"},null,-1),bo=[Mo],Lo={key:1,class:"my-box flex f14",style:{margin:"1rem 0 0 0",padding:"1rem"}},Ho={class:"flex"},Oo={class:"msgs"};function Io (o,e,l,u,n,t){const d=Vue.resolveComponent ("Post"),p=Vue.resolveComponent ("PostDetail"),c=Vue.resolveComponent ("Msg"),m=Vue.resolveComponent ("Base64Tooltip");return Vue.openBlock (),Vue.createElementBlock ("div",{class:Vue.normalizeClass (["app-home",[n.viewType,n.pageType]])},[t.showList?(Vue.openBlock (),Vue.createElementBlock (Vue.Fragment,{key:0},[Vue.createElementVNode ("div",{class:Vue.normalizeClass (["nav flex flex-end",n.viewType])},[Vue.createElementVNode ("div",{class:Vue.normalizeClass (["nav-item",{active:n.viewType==="table"}]),onClick:e [0]||(e [0]=s=>t.saveConfig (n.viewType="table"))},[(Vue.openBlock (),Vue.createElementBlock ("svg",Vo,[Vue.createElementVNode ("path",{d:"M42 5H6V13H42V5Z",fill:"none",stroke:t.svgColor ("table"),"stroke-width":"4","stroke-linejoin":"round"},null,8,vo),Vue.createElementVNode ("path",{d:"M42 20H6V28H42V20Z",fill:"none",stroke:t.svgColor ("table"),"stroke-width":"4","stroke-linejoin":"round"},null,8,wo),Vue.createElementVNode ("path",{d:"M42 35H6V43H42V35Z",fill:"none",stroke:t.svgColor ("table"),"stroke-width":"4","stroke-linejoin":"round"},null,8,fo)])),_o],2),Vue.createElementVNode ("div",{class:Vue.normalizeClass (["nav-item",{active:n.viewType==="card"}]),onClick:e [1]||(e [1]=s=>t.saveConfig (n.viewType="card"))},[(Vue.openBlock (),Vue.createElementBlock ("svg",ko,[Vue.createElementVNode ("path",{d:"M42 18V40C42 41.1046 41.1046 42 40 42H8C6.89543 42 6 41.1046 6 40V18",stroke:t.svgColor ("card"),"stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,8,go),Vue.createElementVNode ("path",{d:"M6 8C6 6.89543 6.89543 6 8 6H40C41.1046 6 42 6.89543 42 8V18H6V8Z",fill:"none",stroke:t.svgColor ("card"),"stroke-width":"4","stroke-linejoin":"round"},null,8,yo),Vue.createElementVNode ("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14Z",fill:t.svgColor ("card")},null,8,Co),Vue.createElementVNode ("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M18 14C19.1046 14 20 13.1046 20 12C20 10.8954 19.1046 10 18 10C16.8954 10 16 10.8954 16 12C16 13.1046 16.8954 14 18 14Z",fill:t.svgColor ("card")},null,8,Eo),Vue.createElementVNode ("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M24 14C25.1046 14 26 13.1046 26 12C26 10.8954 25.1046 10 24 10C22.8954 10 22 10.8954 22 12C22 13.1046 22.8954 14 24 14Z",fill:t.svgColor ("card")},null,8,No)])),xo],2)],2),Vue.createElementVNode ("div",To,[(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (n.list,s=>(Vue.openBlock (),Vue.createElementBlock (Vue.Fragment,null,[s.id==="page"?(Vue.openBlock (),Vue.createElementBlock ("div",{key:0,class:Vue.normalizeClass (["nav p0 page",n.viewType])},[Vue.createElementVNode ("div",{class:"cell",innerHTML:s.innerHTML},null,8,So)],2)):(Vue.openBlock (),Vue.createBlock (d,{key:1,viewType:n.viewType,post:s,class:Vue.normalizeClass ({visited:n.readList.has (s.id)}),onShow:a=>t.getPostDetail (s,a)},null,8,["viewType","post","class","onShow"]))],64))),256)),n.loadMore?(Vue.openBlock (),Vue.createElementBlock ("div",Bo,bo)):Vue.createCommentVNode ("",!0)])],64)):Vue.createCommentVNode ("",!0),n.pageType==="post"?(Vue.openBlock (),Vue.createElementBlock ("div",Lo,[Vue.createElementVNode ("div",Ho,[Vue.createTextVNode ("\u81EA\u52A8\u52A0\u8F7D\u8BE6\u60C5\u9875 \uFF1A"),Vue.createElementVNode ("div",{class:Vue.normalizeClass (["switch",{active:n.autoOpenDetail}]),onClick:e [2]||(e [2]=s=>t.saveConfig (n.autoOpenDetail=!n.autoOpenDetail))},null,2)]),Vue.createElementVNode ("div",{class:Vue.normalizeClass (["button",{loading:n.loading}]),onClick:e [3]||(e [3]=(...s)=>t.openPostDetail&&t.openPostDetail (...s))},"\u70B9\u51FB\u663E\u793A\u8BE6\u60C5\u9875",2)])):Vue.createCommentVNode ("",!0),Vue.createVNode (p,{modelValue:n.show,"onUpdate:modelValue":e [4]||(e [4]=s=>n.show=s),loading:n.loading},null,8,["modelValue","loading"]),Vue.createElementVNode ("div",Oo,[(Vue.openBlock (!0),Vue.createElementBlock (Vue.Fragment,null,Vue.renderList (n.msgList,s=>(Vue.openBlock (),Vue.createBlock (c,{key:s.id,type:s.type,text:s.text,onClose:a=>t.removeMsg (s.id)},null,8,["type","text","onClose"]))),128))]),Vue.createVNode (m)],2)} var Ro=k (ho,[["render",Io]]);let T;window.win ().isFrame?T=$("#app",window.win ().doc)[0]:T=$("#app")[0];window.win ().vue&&window.win ().vue.unmount ();let b=Vue.createApp (Ro);window.win ().vue=b;window.win ().appNode=T;b.config.unwrapInjectedRef=!0;b.mount (T);
//# sourceMappingURL=index.d8b50f52.js.map
})
const isDev = false
window.parse = {
async parsePostContent (post = {}, body, htmlText) {
// 如果没有正文(点的本站的 a 标签),才会解析正文
if (!post.title) {
let main = body.find ('#Main')
let topic_content = main.find ('.topic_content')
if (topic_content.length) {
post.content_rendered = topic_content.html ()
}
let title = main.find ('.header h1')
if (title.length) {
post.title = title.html ()
}
let a2 = main.find ('.header a:eq (2)')
if (a2.length) {
post.nodeUrl = a2 [0].href
post.node = a2.text ()
}
let a5 = main.find ('.header a:eq (5)')
if (a5.length) {
post.username = a5.text ()
post.date = a5.next ().text ()
}
let avatarNode = main.find ('.header .fr img')
if (avatarNode.length) {
post.avatar = avatarNode [0].src
}
}
let subtles = body.find ('.subtle')
if (subtles.length) {
post.subtlesHtml = `
<div class="subtlesHtml">${Array.from (subtles).reduce ((p, i) => {
p += `<div class="subtle">${i.innerHTML}</div>`
return p
}, '')}</div>
`
}
let once = htmlText.match (/var once = "([\d]+)";/)
//console.log (once)
if (once && once [1]) {
post.once = once [1]
}
post.isReport = htmlText.includes (' 你已对本主题进行了报告 ')
let topic_buttons = body.find ('.topic_buttons')
if (topic_buttons.length) {
let favoriteNode = topic_buttons.find ('.tb:first')
if (favoriteNode.length) {
post.isFavorite = favoriteNode [0].innerText === ' 取消收藏 '
}
let ignoreNode = topic_buttons.find ('.tb:eq (2)')
if (ignoreNode.length) {
post.isIgnore = ignoreNode [0].innerText === ' 取消忽略 '
}
//
let thankNode = topic_buttons.find ('#topic_thank .tb')
if (!thankNode.length) {
post.isThanked = true
}
let topic_stats = topic_buttons.find ('.topic_stats')
//topic_stats = $(`<div class="fr topic_stats"style="padding-top: 4px;">9569 次点击 ∙ 28 人收藏 ∙ 1 人感谢 </div>`)
// 收藏数、感谢数
if (topic_stats.length) {
let text = topic_stats [0].innerText
let reg1 = text.matchAll (/([\d]+)[\s]* 人收藏 /g)
let collectCountReg = [...reg1]
if (collectCountReg.length) {
post.collectCount = Number (collectCountReg [0][1])
}
//console.log ([...collectCountReg])
let reg2 = text.matchAll (/([\d]+)[\s]* 人感谢 /g)
let thankCountReg = [...reg2]
if (thankCountReg.length) {
post.thankCount = Number (thankCountReg [0][1])
}
//console.log ([...thankCountReg])
}
}
// 点击数
let baseInfo = body.find ('.header small.gray')
if (baseInfo.length) {
let text = baseInfo.text ()
let reg = text.matchAll (/([\d]+)[\s]* 次点击 /g)
let clickCountReg = [...reg]
if (clickCountReg.length) {
post.clickCount = Number (clickCountReg [0][1])
}
}
let Rightbar = body.find ('#Rightbar')
if (Rightbar.length) {
post.RightbarHTML = Rightbar [0].innerHTML
// 让修改背景的样式失效
post.RightbarHTML = post.RightbarHTML.replace ('type="text/css"', 'type="text/css1"')
}
//console.log (' 基本信息 ', post)
return post
},
async parsePostReplies (post = {}, body, htmlText, pageNo = 1) {
if (body.find ('#no-comments-yet').length) {
return post
}
let box = body.find ('#Main > .box')[1]
let cells = box.querySelectorAll ('.cell')
cells = Array.from (cells)
// 获取创建时间
let snow = cells [0].querySelector ('.snow')
post.createDate = snow?.nextSibling.nodeValue.trim () || ''
let repliesMap = []
if (cells [1].id) {
repliesMap.push ({i: pageNo, replyList: this.parseReplies (cells.slice (1))})
let replies = this.getAllReply (repliesMap)
post.replies = replies
post.replyCount = replies.length
post.nestedReplies = this.getNestedList (replies)
return post
} else {
let promiseList = []
//console.log (this.current.repliesMap)
return new Promise ((resolve, reject) => {
repliesMap.push ({i: pageNo, replyList: this.parseReplies (cells.slice (2, cells.length - 1))})
let pages = cells [1].querySelectorAll ('a')
//console.log (pages)
let url = window.win ().url + '/t/' + post.id
pages.forEach ((v, i) => {
let currentPageNo = Number (v.innerText)
if (currentPageNo === pageNo) return
promiseList.push (this.getOtherPage (url + '?p=' + currentPageNo, currentPageNo))
})
Promise.allSettled (promiseList).then (
(results) => {
results.filter ((result) => result.status === "fulfilled").map (v => repliesMap.push (v.value))
let replies = this.getAllReply (repliesMap)
post.replies = replies
post.replyCount = replies.length
post.nestedReplies = this.getNestedList (replies)
resolve (post)
}
);
})
}
},
async parsePostDetail (post = {}, body, htmlText, pageNo = 1) {
post = await this.parsePostContent (post, body, htmlText)
return await this.parsePostReplies (post, body, htmlText, pageNo)
},
getOtherPage (url, pageNo) {
return new Promise (resolve => {
$.get (url).then (res => {
let s = res.match (/<body [^>]*>([\s\S]+?)<\/body>/g)
let box = $(s [0]).find ('#Main .box')[1]
let cells = box.querySelectorAll ('.cell')
cells = Array.from (cells)
resolve ({i: pageNo, replyList: this.parseReplies (cells.slice (2, cells.length - 1))})
})
})
},
parseReplies (nodes) {
let replyList = []
nodes.forEach ((node, index) => {
if (!node.id) return
let item = {
thankCount: 0,
isThanked: false,
isOp: false,
id: node.id.replace ('r_', '')
}
let reply_content = node.querySelector ('.reply_content')
//console.log ('reply_content',reply_content)
item.reply_content = reply_content.innerHTML
item.reply_text = reply_content.innerText
let {users, floor} = this.parseReplyContent (item.reply_content)
item.replyUsers = users
item.replyFloor = floor
if (index === 5) {
//console.log (item)
//console.log (reply_content.innerText)
//console.log (reply_content.innerHTML)
}
let ago = node.querySelector ('.ago')
item.date = ago.innerText
let userNode = node.querySelector ('strong a')
item.username = userNode.innerText
let avatar = node.querySelector ('td img')
item.avatar = avatar.src
let no = node.querySelector ('.no')
item.floor = Number (no.innerText)
let thank_area = node.querySelector ('.thank_area')
if (thank_area) {
item.isThanked = thank_area.classList.contains ('thanked')
}
let small = node.querySelector ('.small')
if (small) {
item.thankCount = Number (small.innerText)
}
let op = node.querySelector ('.op')
if (op) {
item.isOp = true
}
//console.log ('item', item)
replyList.push (item)
})
return replyList
},
parseReplyContent (str) {
if (!str) return
let getUsername = (userStr) => {
let endIndex = userStr.indexOf ('">')
if (endIndex > -1) {
let user = userStr.substring (0, endIndex)
if (!users.find (i => i === user)) {
users.push (user)
}
}
}
//str = `@<a hr a> #4 @<a1 href="/member/Eiden1">Eiden1</a1> @<a href="/member/Eiden111">Eiden21</a> #11 这也是执行阶段,所谓的安装也是程序业务的 setup 。<br>windows 、Android 并没有系统级的 CD-KEY 。`
let floorReg = /@<a href="\/member\/[\s\S]+?<\/a>[\s]+#([\d]+)/g
let userReg = /@<a href="\/member\/([\s\S]+?)<\/a>/g
let hasFloor = str.matchAll (floorReg)
let res = [...hasFloor]
//console.log (' 总匹配 ', res)
let users = []
let floor = -1
if (res.length) {
floor = Number (res [0][1])
} else {
let has = str.matchAll (userReg)
let res2 = [...has]
//console.log (' 总匹配 ', res2)
if (res2.length > 1) {
res2.map (item => {
getUsername (item [1])
})
}
if (res2.length === 1) {
getUsername (res2 [0][1])
}
}
//console.log (' 用户 ', users)
//console.log (' 楼层 ', floor)
return {users, floor}
},
getAllReply (repliesMap = []) {
return repliesMap.sort ((a, b) => a.i - b.i).reduce ((pre, i) => {
pre = pre.concat (i.replyList)
return pre
}, [])
},
getNestedList (allList = []) {
if (!allList.length) return []
if ((Date.now () - window.win ().lastCallDate) < 1000) {
console.log (' 短时间内,重复调用 ')
//return null
}
window.win ().lastCallDate = Date.now ()
//console.log ('cal-getNestedList', Date.now ())
console.log ('getNestedList,长度 ', allList.length)
let list = JSON.parse (JSON.stringify (allList))
let nestedList = []
list.map ((item, index) => {
let forList = list.slice (index + 1)
if (index === 0) {
item.level = 0
nestedList.push (this.findChildren (item, forList, list))
} else {
// 这里判断 @人数不等于 1。那么会把 @多个人作为一级楼层,而不会作为楼中楼
// 如果要把 @多个人作为楼中楼,那么这里只需判断人数等于 0
// 然后把子方法里面 for 里面的第一个 else 里面的 if 判断 r.replyUsers.length === 1 改为 === 0。然后把逻辑和 else 对调就可以
if ((item.replyUsers.length !== 1) && item.replyFloor === -1) {
item.level = 0
nestedList.push (this.findChildren (item, forList, list))
}
}
})
return nestedList
},
findChildren (item, arr, all) {
const fn = (list, r, item2) => {
r.level = item2.level + 1
let rIndex = all.findIndex (v => v.floor === r.floor)
if (rIndex > -1) {
all [rIndex].isUse = true
}
item2.children.push (this.findChildren (r, list, all))
}
//console.log ('arr', arr)
item.children = []
//if (item.floor ==8) debugger
for (let i = 0; i < arr.length; i++) {
let r = arr [i]
// 如果已被使用,直接跳过
if (r.isUse) continue
let list = arr.slice (i + 1)
// 不知哪个 V 友的插件,回复的 #号是错误的....,所有还要加上一个用户名是不是相同的判断
//if (r.replyFloor === item.floor && r.replyUsers [0] === item.username) {
// 错的就错的吧,反正我自己的不出错就行
//todo 2022-10-26,好像回复被忽略了之后,会占据原来的楼层
// 但是,未忽略这条回复的人,看到的楼层和忽略回复的人看到的不一样,导致以楼层号来判断会出问题
if (r.replyFloor !== -1) {
if (r.replyFloor === item.floor) {
fn (list, r, item)
}
} else {
if (r.replyUsers.length === 1) {
// 找出自己最近一条正常回复,以那条为搜索终点
let rIndex = arr.findIndex (v => v.username === item.username && (r.replyUsers.length === 0 && r.replyFloor === -1))
if (rIndex > -1) {
list = arr.slice (i + 1, rIndex)
}
// 如果是下一条是同一人的回复,那么跳转循环。children 从下一条开始找
if (r.username === item.username) {
// 自己回复自己的特殊情况
if (r.replyUsers [0] === item.username) {
fn (list, r, item)
continue
}
list.map ((v, vi) => {
if (v.replyFloor === item.floor) {
fn (arr.slice (vi + 1), v, item)
}
})
break
} else {
if (r.replyUsers [0] === item.username) {
fn (list, r, item)
}
}
} else {
// 如果是下一条是同一人的回复,那么跳转循环。children 从下一条开始找
if (r.username === item.username) {
// 有种特殊情况,就是自己连着评论了两条。然后后面的人以 #号的方式 回复了自己第一条。
// 如果检测到下条是自己的回复,直接略过的话就会丢失第一条的所有楼中楼回复
// 具体如下
// 自己:1 楼,在 for 的时候,如果碰到 2 楼不能直接跳过,直接略过的话就会丢失第一条的所有楼中楼回复,即 3 楼。所以应该以 3 楼为起点
// 进行楼中楼查找,查找完了再跳过
// 自己:2 楼
// 别人:指定回复 1 楼
list.map ((v, vi) => {
if (v.replyFloor === item.floor) {
fn (arr.slice (vi + 1), v, item)
}
})
break
}
}
}
}
return item
},
parsePage (html, pageType) {
let bodyText = html.match (/<body [^>]*>([\s\S]+?)<\/body>/g)
let body = $(bodyText [0])
if (pageType === 'recent') {
let list = body.find ('.item')
let res = this.parsePostListItem (list)
let page = body.find ('.cell:last').html ()
return {...res, page}
}
if (pageType === 'nodePage') {
let topics = body.find ('#TopicsNode')
let list = topics.children ()
let res = this.parsePostListItem (list)
let page = topics.next ().html ()
return {...res, page}
}
},
parsePostListItem (list) {
let postList = []
let apiList = []
list.each (function () {
let item = window.win ().clone (window.win ().initPost)
let bg = this.style ['background-image']
item.bg = bg
let item_title = this.querySelector ('.item_title a')
let href = item_title.href
item.id = href.substring (href.indexOf ('/t/') + 3, href.indexOf ('#'))
item.title = item_title.innerText
let topic_info = this.querySelector ('.topic_info')
let userNode = topic_info.querySelector ('strong a')
item.username = userNode.innerText
let timeNode = this.querySelector ('.topic_info span')
item.date = timeNode.innerText
let tagNode = topic_info.querySelector ('.node')
if (tagNode) {
item.node = tagNode.innerText
}
let countNode = this.querySelector ('.count_livid')
item.replyCount = countNode ? countNode.innerText : 0
let url = window.win ().location.origin + '/api/topics/show.json?id=' + item.id
//console.log (url)
apiList.push (url)
postList.push (item)
this.remove ()
})
//let page = body.find ('.cell:last')
return {postList, apiList}
},
fetchPostDetail (list) {
return new Promise (resolve => {
Promise.allSettled (list.map (v => $.get (v))).then (async (res) => {
let ok = res.filter ((r) => r.status === "fulfilled").map (v => v.value [0])
let fail = res.filter ((r) => r.status === "rejected")
console.log ('fail', fail)
resolve (ok)
});
})
}
}
if (window.top [0]) {
window.win = () => window.top
window.win ().url = 'https://www.v2ex.com'
//window.win ().url = location.origin
window.win ().isFrame = true
// 直接使用 v2 的 jquery,因为 v2 对 jquery 作了修改,加了一些 header,缺少这些 header 发送请求会报 403
window.$ = window.win ().$
} else {
window.win = () => window
window.win ().url = 'https://www.v2ex.com'
//window.win ().url = location.origin
window.win ().isFrame = false
}
if (!isDev) {
window.win = () => window
window.win ().url = location.origin
window.win ().isFrame = true
}
window.win ().initPost = {
replies: [],
nestedReplies: [],
username: '',
title: '',
id: '',
once: '',
replyCount: 0,
clickCount: 0,
thankCount: 0,
collectCount: 0,
isFavorite: false,
isIgnore: false,
isThanked: false,
isReport: false,
RightbarHTML: '',
}
window.win ().doc = window.win ().document
window.win ().clone = (val) => JSON.parse (JSON.stringify (val))
window.win ().user = {}
window.win ().pageType = ''
window.win ().pageData = {pageNo: 1}
let location2 = window.win ().location
if (location2.pathname === '/') {
window.win ().pageType = 'home'
} else if (location2.href.match (/.com\/?tab=/)) {
window.win ().pageType = 'home'
} else if (location2.href.match (/.com\/go\//)) {
window.win ().pageType = 'nodePage'
} else if (location2.href.match (/.com\/recent/)) {
window.win ().pageType = 'recent'
} else {
let r = location2.href.match (/.com\/t\/([\d]+)/)
if (r) {
window.win ().pageType = 'post'
window.win ().pageData.id = r [1]
if (location2.search) {
let pr = location2.href.match (/\?p=([\d]+)/)
if (pr) window.win ().pageData.pageNo = Number (pr [1])
}
}
}
let top2 = $('.tools .top:eq (1)', window.win ().doc).text ()
if (top2 !== ' 注册 ') {
window.win ().user = {
username: top2,
avatar: $('#Rightbar .box:eq (0) .avatar', window.win ().doc).attr ('src')
}
}
//console.log ('type===', window.win ().pageType, 'pageData===', window.win ().pageData)
async function sleep (time) {
return new Promise (resolve => {
//console.log (' 等待 vue 加载完成,第 ' + count + ' 次 ', Date.now ())
setTimeout (resolve, time)
})
}
async function cbChecker (val, count = 0) {
if (window.win ().cb) {
window.win ().cb (val)
} else {
while ((!window.win ().cb) && count < 20) {
await sleep (500)
count++
}
window.win ().cb && window.win ().cb (val)
}
}
//console.log ('postList', window.win ().postList)
//console.log ('init', window.win ().init)
//let $vue = document.createElement ('iframe');$vue.src = 'http://localhost:3000/';document.body.appendChild ($vue);
if (window.win ().isFrame) {
if (!window.win ().init) {
//window.win ().init = true
window.win ().cb = null
window.win ().vueCb = null
window.win ().postList = []
let $section = document.createElement ('section')
$section.id = 'app'
let wrapper
let box
let list
let res
switch (window.win ().pageType) {
case 'nodePage':
box = $('#Wrapper #Main .box:first')
box.css ({'box-shadow': 'unset'})
let topics = $('#TopicsNode')
topics.attr ('id', 'app')
list = topics.children ()
res = window.parse.parsePostListItem (list)
window.win ().postList = res.postList
window.parse.fetchPostDetail (res.apiList).then (async r => {
await cbChecker ({type: 'list', value: r})
})
break
case 'recent':
case 'home':
box = $('#Wrapper #Main .box:first')
box.css ({'box-shadow': 'unset'})
wrapper = box.find ('.item:first')
wrapper.before ($section)
list = $('.item')
res = window.parse.parsePostListItem (list)
window.win ().postList = res.postList
window.parse.fetchPostDetail (res.apiList).then (async r => {
await cbChecker ({type: 'list', value: r})
})
break
case 'post':
box = $('#Wrapper #Main .box:first')
box.after ($section)
window.parse.parsePostContent (
{id: window.win ().pageData.id},
$(window.win ().doc.body),
window.win ().doc.documentElement.outerHTML
).then (async res => {
//console.log (' 详情页 - 基本信息解析完成 ', new Date ())
window.win ().pageData.post = res
await cbChecker ({type: 'postContent', value: res}, 0)
})
window.parse.parsePostReplies (
{id: window.win ().pageData.id},
$(window.win ().doc.body),
window.win ().doc.documentElement.outerHTML,
window.win ().pageData.pageNo
).then (async res => {
//console.log (' 详情页 - 回复解析完成 ', new Date ())
window.win ().pageData.post = Object.assign (window.win ().pageData.post, res)
await cbChecker ({type: 'postReplies', value: res}, 0)
})
break
default:
console.error (' 未知页面 ')
console.error (' 未知页面 ')
break
}
}
if (isDev) {
// 开发时自动更新 window.top head 里面添加的 vue style
function getStyle (html) {
let reg = html.match (/(<title>Vite App<\/title>[\s\S]+)/g)
if (reg) {
return reg [0]
}
return `<style></style>`
}
function removeVueStyle () {
let title = $('title:eq (1)', window.win ().doc.head)
while (title.next ().length) {
title.next ().remove ()
}
title.remove ()
}
window.onbeforeunload = removeVueStyle
let observe = new MutationObserver (() => {
removeVueStyle ()
let headHtml = window.document.head.innerHTML
let reg = getStyle (headHtml)
$(window.win ().doc.head).append ($(`<head>${reg}</head>`))
});
observe.observe (window.document.head, {
attributes: true, // 目标节点的属性变化
childList: true, // 目标节点的子节点的新增和删除
characterData: true, // 如果目标节点为 characterData 节点 (一种抽象接口,具体可以为文本节点,注释节点,以及处理指令节点) 时,也要观察该节点的文本内容是否发生变化
subtree: true, // 目标节点所有后代节点的 attributes、childList、characterData 变化
});
}
}
})();