article-detail.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  1. <template>
  2. <view class="app-page">
  3. <view v-if="loading !== 'success'" class="loading-wrap">
  4. <tm-skeleton model="card"></tm-skeleton>
  5. <tm-skeleton model="card"></tm-skeleton>
  6. <tm-skeleton model="card"></tm-skeleton>
  7. </view>
  8. <block v-else>
  9. <!-- 顶部信息 -->
  10. <view class="head ma-24">
  11. <view class="title">{{ result.spec.title }}</view>
  12. <view class="detail">
  13. <view class="author">
  14. <text class="author-name">作者:{{ result.owner.displayName }}</text>
  15. <text class="author-time">时间:{{ { d: result.spec.publishTime, f: 'yyyy年MM月dd日 星期w' } | formatTime }}</text>
  16. </view>
  17. <view class="cover" v-if="result.spec.cover">
  18. <image class="cover-img" mode="aspectFill" :src="calcUrl(result.spec.cover)" @click="handlePreview(0, [{ url: calcUrl(result.spec.cover) }])"></image>
  19. </view>
  20. <view class="count" :class="{ 'no-thumbnail': !result.spec.cover }">
  21. <view class="count-item">
  22. <text class="value">{{ result.stats.visit }}</text>
  23. <text class="label">阅读</text>
  24. </view>
  25. <view class="count-item">
  26. <text class="value">{{ result.stats.upvote }}</text>
  27. <text class="label">喜欢</text>
  28. </view>
  29. <view v-if="postDetailConfig && postDetailConfig.showComment" class="count-item">
  30. <text class="value">{{ result.stats.comment }}</text>
  31. <text class="label">评论</text>
  32. </view>
  33. <view class="count-item">
  34. <text class="value">{{ result.content.raw.length }}</text>
  35. <text class="label">字数</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 分类 -->
  41. <view class="category">
  42. <view class="category-type">
  43. <text class="text-weight-b">分类:</text>
  44. <text v-if="result.categories.length === 0" class="category-tag is-empty">未选择分类</text>
  45. <block v-else>
  46. <text class="category-tag" v-for="(item, index) in result.categories" :key="index" @click="fnToCate(item)">
  47. {{ item.spec.displayName }}
  48. </text>
  49. </block>
  50. </view>
  51. <view class="mt-18 category-type">
  52. <text class="text-weight-b">标签:</text>
  53. <text v-if="result.tags.length === 0" class="category-tag is-empty">未选择标签</text>
  54. <block v-else>
  55. <text class="category-tag" :style="{ backgroundColor: item.color }" v-for="(item, index) in result.tags" :key="index" @click="fnToTag(item)">
  56. {{ item.spec.displayName }}
  57. </text>
  58. </block>
  59. </view>
  60. <view v-if="originalURL" class="mt-18 category-type original-url">
  61. <view class="original-url_left text-weight-b">原文:</view>
  62. <view class="original-url_right text-grey">
  63. <text class="original-url_right__link" @click.stop="fnToOriginal(originalURL)">{{ originalURL }}</text>
  64. <text class="original-url_right__btn" @click.stop="fnToOriginal(originalURL)">
  65. 阅读原文
  66. <text class="iconfont icon-angle-right ml-5 text-size-s"></text>
  67. </text>
  68. </view>
  69. </view>
  70. </view>
  71. <view v-if="!calcAuditModeEnabled && result._doubanUrls.length !== 0 && doubanPluginConfig.position === 'top'" class="pa-24 pb-0">
  72. <view class="vote-wrap copyright-wrap bg-white pa-24 round-4">
  73. <view class="copyright-title text-weight-b flex items-center justify-between">
  74. <text>豆瓣资源</text>
  75. <text class="vote-opra" @click="doubanIsOpen = !doubanIsOpen">
  76. {{ doubanIsOpen ? '收起' : '展开' }}
  77. </text>
  78. </view>
  79. <view v-show="doubanIsOpen" class="flex flex-col uh-gap-8 uh-mt-8">
  80. <ArticleDouban
  81. v-for="(doubanUrl, doubanIndex) in result._doubanUrls"
  82. :key="doubanIndex"
  83. :url="doubanUrl"
  84. :article="result"
  85. :index="doubanIndex"
  86. ></ArticleDouban>
  87. </view>
  88. <view v-show="uniHaloPluginAvailable && !doubanIsOpen" class="vote-tip" @click="doubanIsOpen = !doubanIsOpen">豆瓣内容已收起,点击展开</view>
  89. <view v-show="!uniHaloPluginAvailable && !doubanIsOpen" class="vote-tip" @click="doubanIsOpen = !doubanIsOpen">提示区域已收起,点击显示</view>
  90. </view>
  91. </view>
  92. <!-- 内容区域 -->
  93. <view class="content ml-24 mr-24">
  94. <!-- markdown渲染 -->
  95. <view class="markdown-wrap">
  96. <view v-if="checkPostRestrictRead(result)">
  97. <view v-if="showContentArr.length == 0">
  98. <restrict-read-skeleton
  99. :loading="true"
  100. :lines="3"
  101. :tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`"
  102. :button-text="`${getRestrictReadTypeName(result)}`"
  103. button-color="#1890ff"
  104. skeleton-color="#f0f0f0"
  105. skeleton-highlight="#e0e0e0"
  106. animation-duration="2"
  107. @refresh="readMore"
  108. />
  109. </view>
  110. <view v-else v-for="showContent in showContentArr">
  111. <mp-html
  112. class="evan-markdown"
  113. lazy-load
  114. :domain="markdownConfig.domain"
  115. :loading-img="markdownConfig.loadingGif"
  116. :scroll-table="true"
  117. :selectable="true"
  118. :tag-style="markdownConfig.tagStyle"
  119. :container-style="markdownConfig.containStyle"
  120. :content="showContent"
  121. :markdown="true"
  122. :showLineNumber="true"
  123. :showLanguageName="true"
  124. :copyByLongPress="true"
  125. />
  126. <restrict-read-skeleton
  127. :loading="true"
  128. :lines="3"
  129. :tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`"
  130. :button-text="`${getRestrictReadTypeName(result)}`"
  131. button-color="#1890ff"
  132. skeleton-color="#f0f0f0"
  133. skeleton-highlight="#e0e0e0"
  134. animation-duration="2"
  135. @refresh="readMore"
  136. />
  137. </view>
  138. </view>
  139. <view v-else>
  140. <mp-html
  141. class="evan-markdown"
  142. lazy-load
  143. :domain="markdownConfig.domain"
  144. :loading-img="markdownConfig.loadingGif"
  145. :scroll-table="true"
  146. :selectable="true"
  147. :tag-style="markdownConfig.tagStyle"
  148. :container-style="markdownConfig.containStyle"
  149. :content="result.content.raw"
  150. :markdown="true"
  151. :showLineNumber="true"
  152. :showLanguageName="true"
  153. :copyByLongPress="true"
  154. />
  155. </view>
  156. </view>
  157. <!-- 豆瓣 -->
  158. <view
  159. v-if="!calcAuditModeEnabled && result._doubanUrls.length !== 0 && doubanPluginConfig.position === 'bottom'"
  160. class="vote-wrap copyright-wrap bg-white mt-24 pa-24 round-4"
  161. >
  162. <view class="copyright-title text-weight-b flex items-center justify-between">
  163. <text>豆瓣资源</text>
  164. <text class="vote-opra" @click="doubanIsOpen = !doubanIsOpen">
  165. {{ doubanIsOpen ? '收起' : '展开' }}
  166. </text>
  167. </view>
  168. <view v-show="doubanIsOpen" class="flex flex-col uh-gap-8 uh-mt-8">
  169. <ArticleDouban
  170. v-for="(doubanUrl, doubanIndex) in result._doubanUrls"
  171. :key="doubanIndex"
  172. :url="doubanUrl"
  173. :article="result"
  174. :index="doubanIndex"
  175. ></ArticleDouban>
  176. </view>
  177. <view v-show="uniHaloPluginAvailable && !doubanIsOpen" class="vote-tip" @click="doubanIsOpen = !doubanIsOpen">豆瓣内容已收起,点击展开</view>
  178. <view v-show="!uniHaloPluginAvailable && !doubanIsOpen" class="vote-tip" @click="doubanIsOpen = !doubanIsOpen">提示区域已收起,点击显示</view>
  179. </view>
  180. <!-- 投票 -->
  181. <view v-if="!calcAuditModeEnabled && result._voteIds.length !== 0" class="vote-wrap copyright-wrap bg-white mt-24 pa-24 round-4">
  182. <view class="copyright-title text-weight-b flex items-center justify-between">
  183. <text>相关投票</text>
  184. <text class="vote-opra" @click="voteIsOpen = !voteIsOpen">
  185. {{ voteIsOpen ? '收起' : '展开' }}
  186. </text>
  187. </view>
  188. <template v-if="reloadVote">
  189. <view v-show="voteIsOpen" class="flex flex-col uh-gap-8 uh-mt-8">
  190. <PluginUnavailable
  191. v-if="!uniHaloPluginAvailable"
  192. :pluginId="uniHaloPluginId"
  193. :error-text="uniHaloPluginAvailableError"
  194. :useDecoration="false"
  195. :customStyle="{
  196. width: '100%',
  197. borderRadius: '16rpx'
  198. }"
  199. />
  200. <template v-else>
  201. <ArticleVote v-for="(voteId, voteIdIndex) in result._voteIds" :key="voteId" :voteId="voteId" :article="result" :index="voteIdIndex"></ArticleVote>
  202. </template>
  203. </view>
  204. <view v-show="uniHaloPluginAvailable && !voteIsOpen" class="vote-tip" @click="voteIsOpen = !voteIsOpen">
  205. 投票已收起,点击展开 {{ result._voteIds.length }} 个投票项
  206. </view>
  207. <view v-show="!uniHaloPluginAvailable && !voteIsOpen" class="vote-tip" @click="voteIsOpen = !voteIsOpen">提示区域已收起,点击显示</view>
  208. </template>
  209. </view>
  210. <!-- 版权声明 -->
  211. <view v-if="postDetailConfig && postDetailConfig.copyrightEnabled" class="copyright-wrap bg-white mt-24 pa-24 round-4">
  212. <view class="copyright-title text-weight-b">版权声明</view>
  213. <view class="copyright-content mt-12 grey-lighten-5 text-grey-darken-2 round-4 pt-12 pb-12 pl-24 pr-24">
  214. <view v-if="postDetailConfig.copyrightAuthor" class="copyright-text text-size-s">版权归属:{{ postDetailConfig.copyrightAuthor }}</view>
  215. <view v-if="postDetailConfig.copyrightDesc" class="copyright-text text-size-s mt-12">版权说明:{{ postDetailConfig.copyrightDesc }}</view>
  216. <view v-if="postDetailConfig.copyrightViolation" class="copyright-text text-size-s mt-12 text-red">
  217. 侵权处理:{{ postDetailConfig.copyrightViolation }}
  218. </view>
  219. </view>
  220. </view>
  221. <!-- 评论展示区域 -->
  222. <block v-if="postDetailConfig && postDetailConfig.showComment">
  223. <view v-if="result" id="CommentList" class="comment-wrap bg-white mt-24 pa-24 round-4">
  224. <commentList
  225. ref="commentListRef"
  226. :disallowComment="!result.spec.allowComment"
  227. :postName="result.metadata.name"
  228. :post="result"
  229. @on-comment="fnOnComment"
  230. @on-comment-detail="fnOnShowCommentDetail"
  231. @on-loaded="fnOnCommentLoaded"
  232. ></commentList>
  233. </view>
  234. </block>
  235. </view>
  236. <!-- 弹幕效果 -->
  237. <barrage ref="barrage" :maxTop="240" :type="globalAppSettings.barrage.type"></barrage>
  238. <!-- 返回顶部 -->
  239. <tm-flotbutton :width="90" :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent" @click="fnToTopPage()"></tm-flotbutton>
  240. <tm-flotbutton
  241. :width="90"
  242. :actions="flotButtonActions"
  243. :click-actions-hiden="false"
  244. actions-pos="left"
  245. :show-text="true"
  246. color="bg-gradient-orange-accent"
  247. @change="fnOnFlotButtonChange"
  248. ></tm-flotbutton>
  249. </block>
  250. <!-- 评论详情 -->
  251. <tm-poup v-model="commentDetail.show" height="auto" :round="6" :over-close="true" position="bottom">
  252. <view v-if="commentDetail.show && result" class="pa-24">
  253. <view class="poup-head pb-24">
  254. <view class="poup-title text-align-center text-size-g text-weight-b mb-32">评论详情</view>
  255. <comment-item :useContentBg="false" :useActions="false" :isChild="false" :comment="commentDetail.comment" :postName="result.metadata.name"></comment-item>
  256. </view>
  257. <scroll-view :scroll-y="true" class="poup-body">
  258. <view v-if="commentDetail.loading !== 'success'" class="poup-loading-wrap flex flex-center">
  259. <view v-if="commentDetail.loading === 'loading'" class="loading flex flex-center flex-col">
  260. <text class="e-loading-icon iconfont icon-loading text-blue"></text>
  261. <view class="text-size-n text-grey-lighten-1 py-12 mt-12">加载中,请稍等...</view>
  262. </view>
  263. <view v-else-if="commentDetail.loading === 'error'" class="error">
  264. <tm-empty icon="icon-wind-cry" label="加载失败">
  265. <tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnGetChildComments()">刷新试试</tm-button>
  266. </tm-empty>
  267. </view>
  268. </view>
  269. <block v-else>
  270. <view v-if="commentDetail.list.length === 0" class="poup-empty flex flex-center">
  271. <tm-empty icon="icon-shiliangzhinengduixiang-" label="没有更多评论啦~"></tm-empty>
  272. </view>
  273. <block v-else>
  274. <comment-item
  275. v-for="(comment, index) in commentDetail.list"
  276. :useContentBg="false"
  277. :useSolid="false"
  278. :useActions="false"
  279. :key="index"
  280. :isChild="false"
  281. :comment="comment"
  282. :postName="result.metadata.name"
  283. ></comment-item>
  284. </block>
  285. </block>
  286. </scroll-view>
  287. </view>
  288. </tm-poup>
  289. <tm-poup v-model="poster.show" width="90vw" height="auto" :round="6" :over-close="true" position="center">
  290. <view class="poster-content pt-12 bg-white">
  291. <liu-poster ref="liuPoster" :width="674" :height="940" @change="handleOnPosterChange"></liu-poster>
  292. <view v-if="poster.loading" class="poster-loading flex flex-center text-grey-darken-1">
  293. <text class="e-loading-icon iconfont icon-loading"></text>
  294. <text class="ml-6">海报正在生成...</text>
  295. </view>
  296. <block v-if="!poster.loading">
  297. <image
  298. :style="{
  299. width: '100%',
  300. height: '940rpx'
  301. }"
  302. :src="poster.url"
  303. ></image>
  304. <view class="poster-save ma-24 mt-0 pt-20 flex flex-center">
  305. <tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnSavePoster()">保存到相册</tm-button>
  306. <tm-button v-if="false" theme="bg-gradient-orange-accent" size="m" @click="fnShareTo()">分享给好友</tm-button>
  307. <tm-button theme="bg-gradient-blue-grey-accent" size="m" @click="fnOnPosterClose()">关 闭</tm-button>
  308. </view>
  309. </block>
  310. </view>
  311. </tm-poup>
  312. <!-- 验证码弹窗 -->
  313. <tm-dialog
  314. v-model="verificationCodeModal.show"
  315. :disabled="true"
  316. title="验证提示"
  317. :confirmText="verificationCodeModal.confirmText"
  318. :showCancel="true"
  319. model="verificationCodeModal.model"
  320. theme="split"
  321. confirmColor="blue shadow-blue-0"
  322. @cancel="verificationCodeModal.show = false"
  323. @confirm="restrictReadCheckOrViewVideo"
  324. >
  325. <template #default>
  326. <view class="pa-20">
  327. <!-- 扫码验证模式 -->
  328. <view v-if="verificationCodeModal.type === 'scan'" class="flex flex-col flex-center">
  329. <text class="mb-20">请扫描下方二维码获取验证码</text>
  330. <tm-images :width="180" :height="180" :src="verificationCodeModal.imgUrl" preview round="5"></tm-images>
  331. <tm-input bg-color="grey-lighten-5" required v-model="restrictReadInputCode" placeholder="请输入验证码" :border-bottom="false" :flat="true"></tm-input>
  332. </view>
  333. <!-- 观看视频模式 -->
  334. <view v-else class="flex flex-col flex-center">
  335. <text class="mb-20">点击观看视频之后,可访问</text>
  336. </view>
  337. </view>
  338. </template>
  339. </tm-dialog>
  340. <!-- 密码弹窗 -->
  341. <tm-dialog
  342. v-model="passwordModal.show"
  343. :disabled="true"
  344. title="验证提示"
  345. confirmText="确定"
  346. content="请输入密码"
  347. :showCancel="true"
  348. model="confirm"
  349. theme="split"
  350. confirmColor="blue shadow-blue-0"
  351. :input-val.sync="restrictReadInputCode"
  352. @cancel="passwordModal.show = false"
  353. @confirm="restrictReadCheck"
  354. ></tm-dialog>
  355. <!-- 评论弹窗 -->
  356. <block v-if="calcIsShowComment">
  357. <comment-modal
  358. :show="commentModal.show"
  359. :title="commentModal.title"
  360. :postName="commentModal.postName"
  361. :isComment="commentModal.isComment"
  362. @on-close="fnOnCommentModalClose"
  363. ></comment-modal>
  364. </block>
  365. </view>
  366. </template>
  367. <script>
  368. import MarkdownConfig from '@/common/markdown/markdown.config.js';
  369. import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
  370. import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
  371. import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
  372. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  373. import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
  374. import tmDialog from '@/tm-vuetify/components/tm-dialog/tm-dialog.vue';
  375. import tmMore from '@/tm-vuetify/components/tm-more/tm-more.vue';
  376. import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
  377. import commentList from '@/components/comment-list/comment-list.vue';
  378. import commentItem from '@/components/comment-item/comment-item.vue';
  379. import commentModal from '@/components/comment-modal/comment-modal.vue';
  380. import ArticleVote from '@/components/article-vote/article-vote.vue';
  381. import ArticleDouban from '@/components/article-douban/article-douban.vue';
  382. import barrage from '@/components/barrage/barrage.vue';
  383. import { getAppConfigs } from '@/config/index.js';
  384. import { upvote } from '@/utils/upvote.js';
  385. import { checkPostRestrictRead, copyToClipboard, getRestrictReadTypeName, getShowableContent } from '@/utils/restrictRead';
  386. import HaloTokenConfig from '@/config/uhalo.config';
  387. import RestrictReadSkeleton from '@/components/restrict-read-skeleton/restrict-read-skeleton.vue';
  388. import TmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
  389. import TmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
  390. import pluginAvailableMixin from '@/common/mixins/pluginAvailable.js';
  391. import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue';
  392. let videoAd = null;
  393. export default {
  394. mixins: [pluginAvailableMixin],
  395. components: {
  396. TmInput,
  397. TmImages,
  398. RestrictReadSkeleton,
  399. tmSkeleton,
  400. tmPoup,
  401. tmFlotbutton,
  402. tmButton,
  403. tmEmpty,
  404. tmDialog,
  405. tmMore,
  406. mpHtml,
  407. commentList,
  408. commentItem,
  409. barrage,
  410. commentModal,
  411. ArticleVote,
  412. PluginUnavailable,
  413. ArticleDouban
  414. },
  415. data() {
  416. return {
  417. loading: 'loading',
  418. markdownConfig: MarkdownConfig,
  419. flotButtonActions: [],
  420. queryParams: {
  421. name: null
  422. },
  423. result: null,
  424. commentDetail: {
  425. loading: 'loading',
  426. show: false,
  427. comment: {},
  428. postName: undefined,
  429. list: []
  430. },
  431. poster: {
  432. show: false,
  433. showCanvas: false,
  434. loading: true,
  435. res: null,
  436. url: '',
  437. configs: []
  438. },
  439. metas: [], // 自定义元数据
  440. showContentArr: [],
  441. restrictReadInputCode: '',
  442. verificationCodeModal: {
  443. show: false,
  444. model: 'confirm',
  445. confirmText: '确定',
  446. type: '',
  447. imgUrl: '',
  448. adId: ''
  449. },
  450. passwordModal: {
  451. show: false
  452. },
  453. commentModal: {
  454. show: false,
  455. isComment: false,
  456. postName: '',
  457. title: ''
  458. },
  459. commentListScrollTop: 0,
  460. voteIsOpen: true,
  461. reloadVote: false,
  462. doubanIsOpen: true,
  463. appAuthorize: {
  464. writePhotosAlbum: ''
  465. }
  466. };
  467. },
  468. computed: {
  469. haloConfigs() {
  470. return this.$tm.vx.getters().getConfigs;
  471. },
  472. postDetailConfig() {
  473. return this.haloConfigs.basicConfig.postDetailConfig;
  474. },
  475. calcUrl() {
  476. return (url) => {
  477. if (this.$utils.checkIsUrl(url)) {
  478. return url;
  479. }
  480. return getApp().globalData.baseApiUrl + url;
  481. };
  482. },
  483. // 获取博主信息
  484. bloggerInfo() {
  485. const blogger = this.$tm.vx.getters().getConfigs.authorConfig.blogger;
  486. blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
  487. return blogger;
  488. },
  489. // 原文链接:个人资质=可以打开公众号文章;非个人:任意链接地址(需在小程序后台配置)
  490. originalURL() {
  491. return this.result?.metadata?.annotations?.unihalo_originalURL || '';
  492. },
  493. calcIsShowComment() {
  494. return this.postDetailConfig.showComment;
  495. },
  496. calcUpvoted() {
  497. return upvote.has('post', this.result?.metadata?.name);
  498. },
  499. calcAuditModeEnabled() {
  500. return this.haloConfigs.auditConfig.auditModeEnabled;
  501. },
  502. pluginsConfig() {
  503. return this.haloConfigs.pluginConfig;
  504. },
  505. doubanPluginConfig() {
  506. return this.pluginsConfig.doubanPlugin;
  507. }
  508. },
  509. watch: {
  510. haloConfigs: {
  511. deep: true,
  512. immediate: true,
  513. handler: function (newVal) {
  514. if (!newVal) return;
  515. this.fnHandleSetFlotButtonItems(newVal);
  516. }
  517. }
  518. },
  519. async onLoad(e) {
  520. // 检查插件
  521. this.setPluginId(this.NeedPluginIds.PluginVote);
  522. this.setPluginError('阿偶,检测到当前插件没有安装或者启用,无法使用投票功能,请联系管理员');
  523. await this.checkPluginAvailable();
  524. this.fnSetPageTitle('文章加载中...');
  525. this.queryParams.name = e.name;
  526. this.fnGetData();
  527. },
  528. onShow() {
  529. if (this.reloadVote) {
  530. this.reloadVote = false;
  531. setTimeout(() => {
  532. this.reloadVote = true;
  533. }, 100);
  534. }
  535. },
  536. onPullDownRefresh() {
  537. this.fnGetData();
  538. },
  539. onShareAppMessage() {
  540. const cover = this.result.spec.cover ? this.calcUrl(this.result.spec.cover) : '';
  541. return {
  542. path: '/pagesA/article-detail/article-detail?name=' + this.result.metadata.name,
  543. title: this.result.spec.title,
  544. imageUrl: cover
  545. };
  546. },
  547. onShareTimeline() {
  548. const cover = this.result.spec.cover ? this.calcUrl(this.result.spec.cover) : '';
  549. return {
  550. title: this.result.spec.title,
  551. query: {
  552. name: this.result.metadata.name
  553. },
  554. imageUrl: cover
  555. };
  556. },
  557. methods: {
  558. getRestrictReadTypeName,
  559. checkPostRestrictRead,
  560. fnGetData() {
  561. this.loading = 'loading';
  562. this.$httpApi.v2
  563. .getPostByName(this.queryParams.name)
  564. .then((res) => {
  565. console.log('详情', res);
  566. const tempResult = res;
  567. tempResult._voteIds = this.extractVoteBlockIds(res.content?.raw || res.content?.content || '');
  568. tempResult._doubanUrls = this.extractDoubanBlockUrls(res.content?.raw || res.content?.content || '');
  569. const openid = uni.getStorageSync('openid');
  570. if (openid === '' || openid === null) {
  571. this.fnGetOpenid();
  572. }
  573. const toolsPluginEnabled = getAppConfigs().pluginConfig.toolsPlugin?.enabled;
  574. const restrictRead = checkPostRestrictRead(tempResult);
  575. if (restrictRead && toolsPluginEnabled) {
  576. let verifyCodeType = getAppConfigs().pluginConfig.toolsPlugin?.verifyCodeType;
  577. const postVerifyCodeType = tempResult?.metadata?.annotations?.verifyCodeType;
  578. if (postVerifyCodeType) {
  579. verifyCodeType = postVerifyCodeType;
  580. }
  581. if (verifyCodeType === 'scan') {
  582. const scanCodeUrl = getAppConfigs().pluginConfig.toolsPlugin?.scanCodeUrl;
  583. this.verificationCodeModal.type = 'scan';
  584. this.verificationCodeModal.imgUrl = this.$utils.checkImageUrl(scanCodeUrl);
  585. this.verificationCodeModal.model = 'confirm';
  586. this.verificationCodeModal.confirmText = '立即验证';
  587. } else if (verifyCodeType === 'advert') {
  588. const rewardedVideoAdId = getAppConfigs().pluginConfig.toolsPlugin?.rewardedVideoAdId;
  589. this.verificationCodeModal.type = 'advert';
  590. this.verificationCodeModal.adId = rewardedVideoAdId;
  591. this.verificationCodeModal.model = 'dialog';
  592. this.verificationCodeModal.confirmText = '观看视频';
  593. // #ifdef MP-WEIXIN
  594. this.adLoad();
  595. // #endif
  596. }
  597. const showableContentArr = getShowableContent(tempResult);
  598. this.showContentArr = showableContentArr;
  599. }
  600. this.result = tempResult;
  601. this.fnSetPageTitle('文章详情');
  602. this.loading = 'success';
  603. this.reloadVote = true;
  604. this.fnHandleSetFlotButtonItems(this.haloConfigs);
  605. this.handleQueryCommentListScrollTop();
  606. })
  607. .catch((err) => {
  608. console.log('错误', err);
  609. this.loading = 'error';
  610. })
  611. .finally(() => {
  612. uni.hideLoading();
  613. uni.stopPullDownRefresh();
  614. });
  615. },
  616. fnHandleSetFlotButtonItems(configs) {
  617. const actions = [
  618. {
  619. icon: 'icon-share1',
  620. color: 'bg-gradient-blue-accent',
  621. use: true
  622. },
  623. {
  624. icon: upvote.has('post', this.result?.metadata?.name) ? 'icon-heart-fill' : 'icon-like',
  625. color: upvote.has('post', this.result?.metadata?.name) ? 'bg-gradient-red-accent' : 'bg-gradient-orange-accent',
  626. use: true
  627. },
  628. {
  629. icon: 'icon-commentdots-fill',
  630. color: 'bg-gradient-green-accent',
  631. use: configs?.basicConfig?.postDetailConfig?.showComment
  632. }
  633. ];
  634. this.flotButtonActions = actions.filter((x) => x.use === true);
  635. },
  636. // 浮动按钮点击
  637. fnOnFlotButtonChange(index) {
  638. switch (index) {
  639. case 0:
  640. this.fnShowShare();
  641. break;
  642. case 1:
  643. this.fnDoLikes();
  644. break;
  645. case 2:
  646. this.fnToComment();
  647. break;
  648. }
  649. },
  650. fnToComment() {
  651. if (!this.calcIsShowComment) {
  652. return;
  653. }
  654. if (!this.result.spec.allowComment) {
  655. return uni.$tm.toast('文章已开启禁止评论!');
  656. }
  657. this.commentModal.isComment = true;
  658. this.commentModal.postName = this.result.metadata.name;
  659. this.commentModal.title = '新增评论';
  660. this.commentModal.show = true;
  661. setTimeout(() => {
  662. uni.pageScrollTo({
  663. scrollTop: this.commentListScrollTop,
  664. duration: 100
  665. });
  666. }, 300);
  667. },
  668. fnOnComment(data) {
  669. this.commentModal.isComment = data.isComment;
  670. this.commentModal.postName = data.postName;
  671. this.commentModal.title = data.title;
  672. this.commentModal.show = true;
  673. },
  674. fnOnCommentModalClose({ refresh, isSubmit }) {
  675. // 评论后自动刷新
  676. if (this.result?.metadata?.annotations?.restrictReadEnable === 'comment') {
  677. this.fnGetData();
  678. }
  679. if (refresh && isSubmit && this.$refs.commentListRef) {
  680. this.$refs.commentListRef.fnGetData();
  681. }
  682. this.commentModal.show = false;
  683. this.commentModal.isComment = false;
  684. this.commentModal.postName = '';
  685. this.commentModal.title = '';
  686. },
  687. fnDoLikes() {
  688. if (upvote.has('post', this.result?.metadata?.name)) {
  689. uni.$tm.toast('已经点过赞啦!');
  690. return;
  691. }
  692. this.$httpApi.v2
  693. .submitUpvote({
  694. group: 'content.halo.run',
  695. plural: 'posts',
  696. name: this.result?.metadata?.name
  697. })
  698. .then((res) => {
  699. uni.$tm.toast('点赞成功!');
  700. upvote.set('post', this.result?.metadata?.name);
  701. this.fnHandleSetFlotButtonItems(this.haloConfigs);
  702. })
  703. .catch((err) => {
  704. uni.$tm.toast('点赞失败');
  705. });
  706. },
  707. async fnShowShare() {
  708. this.poster.show = true;
  709. await this.handleCreatePoster();
  710. setTimeout(() => {
  711. this.poster.showCanvas = true;
  712. this.$nextTick(() => {
  713. this.$refs.liuPoster.init(this.poster.configs);
  714. });
  715. }, 500);
  716. },
  717. handleOnPosterChange(url) {
  718. this.poster.url = url;
  719. this.poster.loading = false;
  720. },
  721. async handleCreatePoster() {
  722. const systemInfo = await uni.getSystemInfoSync();
  723. const _bloggerAvatar = this.$utils.checkAvatarUrl(this.bloggerInfo.avatar, true);
  724. const _articleCover = this.$utils.checkThumbnailUrl(this.result.spec.cover, true);
  725. const _qrCodeImageUrl = await this.qrCodeImageUrl();
  726. this.poster.configs = [
  727. {
  728. type: 'color',
  729. width: 674,
  730. height: 940,
  731. x: 0,
  732. y: 0,
  733. radius: 24,
  734. lineWidth: 0,
  735. lineColor: '#ffffff',
  736. colorObj: {
  737. colorList: ['#FFFFFF'],
  738. direction: 2
  739. }
  740. },
  741. {
  742. type: 'image',
  743. width: 96,
  744. height: 96,
  745. x: 24,
  746. y: 24,
  747. radius: 48,
  748. lineWidth: 2,
  749. lineColor: '#FFFFFF',
  750. path: _bloggerAvatar
  751. },
  752. {
  753. type: 'text',
  754. width: 400,
  755. height: 40,
  756. x: 140,
  757. y: 42,
  758. color: '#000000',
  759. fontSize: 30,
  760. lineHeight: 30,
  761. bold: true,
  762. content: this.bloggerInfo.nickname
  763. },
  764. {
  765. type: 'text',
  766. width: 400,
  767. height: 40,
  768. x: 140,
  769. y: 90,
  770. color: '#666666',
  771. fontSize: 24,
  772. lineHeight: 24,
  773. bold: false,
  774. content: this.bloggerInfo.description
  775. },
  776. {
  777. type: 'image',
  778. width: 624,
  779. height: 360,
  780. x: 24,
  781. y: 152,
  782. radius: 12,
  783. lineWidth: 0,
  784. lineColor: '#FFFFFF',
  785. path: _articleCover
  786. },
  787. {
  788. type: 'text',
  789. width: 626,
  790. height: 40,
  791. x: 24,
  792. y: 562,
  793. color: '#333333',
  794. fontSize: 28,
  795. lineHeight: 28,
  796. bold: true,
  797. content: this.result.spec.title
  798. },
  799. {
  800. type: 'text',
  801. width: 626,
  802. height: 80,
  803. x: 24,
  804. y: 612,
  805. color: '#333333',
  806. fontSize: 24,
  807. lineHeight: 40,
  808. bold: false,
  809. content: this.result?.status?.excerpt || '文章暂无摘要信息'
  810. },
  811. {
  812. type: 'line',
  813. width: 2,
  814. color: '#999999',
  815. startX: 24,
  816. startY: 722,
  817. endX: 646,
  818. endY: 722,
  819. lineType: 'dash'
  820. },
  821. {
  822. type: 'image',
  823. width: 160,
  824. height: 160,
  825. x: 24,
  826. y: 752,
  827. radius: 12,
  828. lineWidth: 0,
  829. lineColor: '#FFFFFF',
  830. path: this.$utils.checkImageUrl(_qrCodeImageUrl)
  831. },
  832. {
  833. type: 'text',
  834. width: 300,
  835. height: 44,
  836. x: 320,
  837. y: 772,
  838. color: '#333333',
  839. fontSize: 32,
  840. lineHeight: 44,
  841. bold: true,
  842. content: '长按识别小程序'
  843. },
  844. {
  845. type: 'text',
  846. width: 442,
  847. height: 24,
  848. x: 234,
  849. y: 872,
  850. color: '#333333',
  851. fontSize: 24,
  852. lineHeight: 24,
  853. bold: false,
  854. content: '关注我,给你分享更多有趣的知识'
  855. }
  856. ];
  857. },
  858. // 绘制虚线:https://blog.csdn.net/a460550542/article/details/124821248
  859. drawDashedLine(ctx, x, y, w, h, pattern, color) {
  860. ctx.lineWidth = h;
  861. ctx.strokeStyle = color;
  862. ctx.beginPath();
  863. ctx.setLineDash(pattern);
  864. ctx.moveTo(x, y);
  865. ctx.lineTo(w, y);
  866. ctx.stroke();
  867. y += 20;
  868. },
  869. fnOnPosterClose() {
  870. this.poster.show = false;
  871. this.poster.showCanvas = false;
  872. this.poster.loading = true;
  873. },
  874. fnGetAlbumAuthorize() {
  875. return new Promise((resolve) => {
  876. uni.showModal({
  877. title: '提示',
  878. content: '保存到相册未授权,是否去授权?',
  879. success: (res) => {
  880. if (res.confirm) {
  881. uni.openSetting({
  882. success: (res) => {
  883. if (res.authSetting['scope.writePhotosAlbum'] === true) {
  884. uni.showToast({
  885. icon: 'none',
  886. title: '授权成功,请重新保存'
  887. });
  888. resolve(true);
  889. } else {
  890. uni.showToast({
  891. icon: 'none',
  892. title: '未进行授权操作'
  893. });
  894. resolve(false);
  895. }
  896. },
  897. fail: (err) => {
  898. uni.showToast({
  899. icon: 'none',
  900. title: '授权失败'
  901. });
  902. resolve(false);
  903. }
  904. });
  905. }
  906. },
  907. fail: () => {
  908. resolve(false);
  909. }
  910. });
  911. });
  912. },
  913. fnCheckAlbumAppAuthorize() {
  914. return new Promise((resolve) => {
  915. // #ifdef MP-WEIXIN
  916. uni.getSetting({
  917. success: async (res) => {
  918. if (res.authSetting['scope.writePhotosAlbum'] === false) {
  919. const authorize = await this.fnGetAlbumAuthorize();
  920. console.log('authorize1', authorize);
  921. if (!authorize) {
  922. uni.openSetting({
  923. success: (res) => {
  924. console.log('授权1', res);
  925. }
  926. });
  927. console.log('打开授权页面1');
  928. }
  929. resolve(false);
  930. } else {
  931. resolve(true);
  932. }
  933. },
  934. fail: async () => {
  935. const authorize = await this.fnGetAlbumAuthorize();
  936. console.log('authorize2', authorize);
  937. if (!authorize) {
  938. uni.openSetting({
  939. success: (res) => {
  940. console.log('授权2', res);
  941. }
  942. });
  943. console.log('打开授权页面2');
  944. }
  945. resolve(false);
  946. }
  947. });
  948. // #endif
  949. // #ifndef MP-WEIXIN
  950. resolve(true);
  951. // #endif
  952. });
  953. },
  954. async fnSavePoster() {
  955. // 检查授权
  956. const authorize = await this.fnCheckAlbumAppAuthorize();
  957. if (!authorize) return;
  958. uni.saveImageToPhotosAlbum({
  959. filePath: this.poster.url,
  960. success: () => {
  961. uni.$tm.toast('保存成功');
  962. },
  963. fail: (e) => {
  964. if(!e?.errMsg.includes('cancel')){
  965. uni.$tm.toast('保存失败,请重试');
  966. }
  967. }
  968. });
  969. },
  970. fnShareTo() {
  971. // #ifdef MP-WEIXIN
  972. uni.$tm.toast('点击右上角分享给好友!');
  973. // #endif
  974. },
  975. fnOnShowCommentDetail(data) {
  976. const { postName, comment } = data;
  977. this.commentDetail.comment = comment;
  978. this.commentDetail.postName = postName;
  979. this.commentDetail.list = [];
  980. this.commentDetail.show = true;
  981. this.fnGetChildComments();
  982. },
  983. fnGetChildComments() {
  984. this.commentDetail.loading = 'loading';
  985. this.$httpApi.v2
  986. .getPostCommentReplyList(this.commentDetail.postName, {
  987. page: 1,
  988. size: 100
  989. })
  990. .then((res) => {
  991. console.log('getPostChildrenCommentList res', res);
  992. this.commentDetail.loading = 'success';
  993. this.commentDetail.list = res.items;
  994. })
  995. .catch((err) => {
  996. console.log('getPostChildrenCommentList err', err);
  997. this.commentDetail.loading = 'error';
  998. });
  999. },
  1000. fnToCate(category) {
  1001. uni.navigateTo({
  1002. url: `/pagesA/category-detail/category-detail?name=${category.metadata.name}&title=${category.spec.displayName}`
  1003. });
  1004. },
  1005. fnToTag(tag) {
  1006. uni.navigateTo({
  1007. url: `/pagesA/tag-detail/tag-detail?name=${tag.metadata.name}&title=${tag.spec.displayName}`
  1008. });
  1009. },
  1010. async fnOnCommentLoaded(data) {
  1011. const _list = [];
  1012. const _handleData = (list) => {
  1013. return new Promise((resolve) => {
  1014. if (list.length === 0) {
  1015. resolve();
  1016. } else {
  1017. list.forEach((item) => {
  1018. _list.push(item);
  1019. if (item.replies && item.replies.length !== 0) {
  1020. _handleData(item.replies.items);
  1021. }
  1022. resolve();
  1023. });
  1024. }
  1025. });
  1026. };
  1027. await _handleData(data);
  1028. // if (this.globalAppSettings.barrage.use) {
  1029. // this.$nextTick(() => {
  1030. // if (_list.length != 0) {
  1031. // _handleAddBarrage();
  1032. // }
  1033. // });
  1034. // }
  1035. // const _handleRemove = () => {
  1036. // this.$refs['barrage'] && this.$refs['barrage'].remove({
  1037. // duration: 5000, // 延迟关闭的时间
  1038. // speed: 600 // 弹幕消失的速度
  1039. // });
  1040. // };
  1041. // let index = 0;
  1042. // const _handleAddBarrage = () => {
  1043. // setTimeout(() => {
  1044. // this.$refs['barrage'] && this.$refs['barrage'].add(_list[index]);
  1045. // index += 1;
  1046. // if (index < _list.length - 1) {
  1047. // _handleAddBarrage();
  1048. // } else {
  1049. // _handleRemove();
  1050. // }
  1051. // }, 1000);
  1052. // };
  1053. },
  1054. fnToWebview(data) {
  1055. uni.navigateTo({
  1056. url:
  1057. '/pagesC/website/website?data=' +
  1058. JSON.stringify({
  1059. title: data.title,
  1060. url: encodeURIComponent(data.url)
  1061. })
  1062. });
  1063. },
  1064. fnToOriginal(originalURL) {
  1065. this.fnToWebview({
  1066. title: this.result.title,
  1067. url: originalURL
  1068. });
  1069. },
  1070. readMore() {
  1071. const annotations = this.result?.metadata?.annotations;
  1072. const restrictReadEnable = annotations?.restrictReadEnable;
  1073. if (restrictReadEnable === 'password') {
  1074. this.passwordModal.show = true;
  1075. return;
  1076. } else if (restrictReadEnable === 'code') {
  1077. this.verificationCodeModal.show = true;
  1078. return;
  1079. } else if (restrictReadEnable === 'comment') {
  1080. this.fnToComment();
  1081. return;
  1082. } else if (restrictReadEnable === 'login') {
  1083. uni.showToast({
  1084. title: '前往web端登录后访问',
  1085. icon: 'none'
  1086. });
  1087. } else if (restrictReadEnable === 'pay') {
  1088. uni.showToast({
  1089. title: '前往web端支付后访问',
  1090. icon: 'none'
  1091. });
  1092. }
  1093. // 两秒后执行
  1094. setTimeout(() => {
  1095. copyToClipboard(`${HaloTokenConfig.BASE_API + this.result.status.permalink}`);
  1096. }, 2000);
  1097. },
  1098. // 获取openid
  1099. fnGetOpenid() {
  1100. // #ifdef MP-WEIXIN
  1101. uni.login({
  1102. provider: 'weixin',
  1103. success: function (loginRes) {
  1104. try {
  1105. // todo 因为没有获取openid,所以先使用code代替
  1106. uni.setStorageSync('openid', loginRes.code);
  1107. } catch (error) {
  1108. console.log(error);
  1109. }
  1110. }
  1111. });
  1112. // #endif
  1113. },
  1114. restrictReadCheckOrViewVideo() {
  1115. console.log('restrictReadCheckOrViewVideo', this.verificationCodeModal.type);
  1116. if (this.verificationCodeModal.type === 'advert') {
  1117. this.openVideoAd();
  1118. } else {
  1119. this.restrictReadCheck();
  1120. }
  1121. },
  1122. // 校验密码
  1123. restrictReadCheck() {
  1124. if (!this.restrictReadInputCode) {
  1125. uni.showToast({
  1126. title: '请输入内容',
  1127. icon: 'none'
  1128. });
  1129. return;
  1130. }
  1131. this.$httpApi.v2
  1132. .requestRestrictReadCheck(this.result?.metadata?.annotations?.restrictReadEnable, this.restrictReadInputCode, this.result?.metadata?.name)
  1133. .then((res) => {
  1134. if (res.code === 200) {
  1135. this.passwordModal.show = false;
  1136. this.verificationCodeModal.show = false;
  1137. this.fnGetData();
  1138. } else {
  1139. uni.showToast({
  1140. title: '密码错误',
  1141. icon: 'none'
  1142. });
  1143. }
  1144. })
  1145. .catch((err) => {
  1146. console.error(err);
  1147. });
  1148. },
  1149. adLoad() {
  1150. if (wx.createRewardedVideoAd) {
  1151. videoAd = wx.createRewardedVideoAd({
  1152. adUnitId: this.verificationCodeModal.adId
  1153. });
  1154. videoAd.onError((err) => {});
  1155. videoAd.onClose((status) => {
  1156. if ((status && status.isEnded) || status === undefined) {
  1157. //这里写广告播放完成后的事件
  1158. this.getVerificationCode();
  1159. } else {
  1160. // 广告播放未完成
  1161. }
  1162. });
  1163. }
  1164. },
  1165. openVideoAd: function () {
  1166. if (videoAd && this.verificationCodeModal.adId !== '') {
  1167. videoAd.show().catch((err) => {
  1168. // 失败重试
  1169. console.log('广告拉取失败');
  1170. videoAd.load().then(() => videoAd.show());
  1171. });
  1172. } else {
  1173. this.getVerificationCode();
  1174. }
  1175. },
  1176. getVerificationCode() {
  1177. uni.showLoading({
  1178. title: '正在获取...'
  1179. });
  1180. this.$httpApi.v2
  1181. .createVerificationCode()
  1182. .then((res) => {
  1183. if (res.code === 200) {
  1184. this.verificationCodeModal.show = false;
  1185. this.restrictReadInputCode = res.data;
  1186. this.restrictReadCheck();
  1187. } else {
  1188. uni.$tm.toast('操作失败,请重试!');
  1189. }
  1190. })
  1191. .catch((err) => {
  1192. uni.$tm.toast(err.message);
  1193. });
  1194. },
  1195. async qrCodeImageUrl() {
  1196. const useDynamicQRCode = this.haloConfigs?.appConfig?.appInfo?.useDynamicQRCode;
  1197. if (useDynamicQRCode) {
  1198. const qrCodeImg = await this.$httpApi.v2.getQRCodeImg(this.result.metadata.name);
  1199. return qrCodeImg;
  1200. } else {
  1201. return this.haloConfigs?.appConfig?.appInfo?.qrCodeImageUrl;
  1202. }
  1203. },
  1204. handleQueryCommentListScrollTop() {
  1205. if (!this.postDetailConfig) return;
  1206. if (!this.postDetailConfig.showComment) return;
  1207. this.$nextTick(() => {
  1208. setTimeout(() => {
  1209. uni.createSelectorQuery()
  1210. .in(this)
  1211. .select('#CommentList')
  1212. .boundingClientRect((res) => {
  1213. this.commentListScrollTop = res.top - 12;
  1214. })
  1215. .exec();
  1216. }, 2 * 1000);
  1217. });
  1218. },
  1219. /**
  1220. * 从HTML字符串中提取所有vote-block的id
  1221. * @param {string} html - 包含vote-block的HTML字符串
  1222. * @returns {string[]} 提取到的id数组
  1223. */
  1224. extractVoteBlockIds(html) {
  1225. // 正则表达式匹配<vote-block id="xxx">格式
  1226. // 捕获组提取id值
  1227. const regex = /<vote-block\s+id="(vote-\w+)"\s*\/?>/g;
  1228. const ids = [];
  1229. let match;
  1230. // 循环匹配所有符合条件的id
  1231. while ((match = regex.exec(html)) !== null) {
  1232. // 第一个捕获组是id值
  1233. ids.push(match[1]);
  1234. }
  1235. return ids;
  1236. },
  1237. extractDoubanBlockUrls(html) {
  1238. // 匹配<douban src="xxx">格式,仅关注标签和src属性,不限制域名
  1239. const regex = /<douban\s+src="([^"]+)"\s*\/?>/g;
  1240. const urls = [];
  1241. let match;
  1242. while ((match = regex.exec(html)) !== null) {
  1243. // 捕获src属性中双引号内的所有内容(不限制域名)
  1244. urls.push(match[1]);
  1245. }
  1246. return urls;
  1247. },
  1248. handlePreview(index, list) {
  1249. uni.previewImage({
  1250. current: index,
  1251. urls: list.map((item) => item.url)
  1252. });
  1253. }
  1254. }
  1255. };
  1256. </script>
  1257. <style lang="scss" scoped>
  1258. .app-page {
  1259. width: 100vw;
  1260. min-height: 100vh;
  1261. display: flex;
  1262. flex-direction: column;
  1263. box-sizing: border-box;
  1264. background-color: #fafafd;
  1265. padding-bottom: 24rpx;
  1266. }
  1267. .bg-image {
  1268. position: fixed;
  1269. left: 0;
  1270. top: 0;
  1271. right: 0;
  1272. bottom: 0;
  1273. width: 100vw;
  1274. height: 100vh;
  1275. z-index: 0;
  1276. }
  1277. .loading-wrap {
  1278. padding: 0 24rpx;
  1279. height: inherit;
  1280. background-color: #fff;
  1281. }
  1282. .head {
  1283. display: flex;
  1284. flex-direction: column;
  1285. align-items: center;
  1286. justify-content: center;
  1287. padding: 36rpx 24rpx;
  1288. background-color: #ffffff;
  1289. box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03);
  1290. // box-shadow: 0rpx 6rpx 30rpx rgba(182, 223, 255, 0.3);
  1291. border-radius: 12rpx;
  1292. .title {
  1293. font-size: 36rpx;
  1294. font-weight: 600;
  1295. text-align: center;
  1296. }
  1297. .detail {
  1298. width: 100%;
  1299. margin-top: 24rpx;
  1300. font-size: 26rpx;
  1301. .author {
  1302. text-align: center;
  1303. font-size: 24rpx;
  1304. color: #666;
  1305. &-name {
  1306. }
  1307. &-time {
  1308. margin-left: 36rpx;
  1309. }
  1310. }
  1311. .cover {
  1312. margin-top: 24rpx;
  1313. width: 100%;
  1314. height: 280rpx;
  1315. &-img {
  1316. width: 100%;
  1317. height: 100%;
  1318. border-radius: 12rpx;
  1319. }
  1320. }
  1321. .count {
  1322. margin-top: 24rpx;
  1323. display: flex;
  1324. justify-content: space-between;
  1325. &.no-thumbnail {
  1326. border-top: 2rpx solid #f2f2f2;
  1327. padding-top: 12rpx;
  1328. .count-item {
  1329. position: relative;
  1330. color: #666;
  1331. &::after {
  1332. content: '';
  1333. position: absolute;
  1334. right: 0;
  1335. background-color: #eee;
  1336. width: 2rpx;
  1337. height: 32rpx;
  1338. }
  1339. &:last-child {
  1340. &::after {
  1341. display: none;
  1342. }
  1343. }
  1344. }
  1345. }
  1346. &-item {
  1347. flex: 1;
  1348. display: flex;
  1349. align-items: flex-end;
  1350. justify-content: center;
  1351. color: #666;
  1352. .label {
  1353. font-size: 24rpx;
  1354. padding-left: 8rpx;
  1355. }
  1356. .value {
  1357. font-size: 32rpx;
  1358. }
  1359. }
  1360. }
  1361. }
  1362. }
  1363. .category {
  1364. margin: 0 24rpx;
  1365. padding: 24rpx;
  1366. background-color: #ffffff;
  1367. border-radius: 12rpx;
  1368. // box-shadow: 0rpx 0rpx 24rpx rgba(182, 223, 255, 0.3);
  1369. box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.03);
  1370. // border: 2rpx solid #f8f8f8;
  1371. font-size: 28rpx;
  1372. &-type {
  1373. line-height: 55rpx;
  1374. }
  1375. &-tag {
  1376. background-color: #5bb8fa;
  1377. color: #fff;
  1378. padding: 6rpx 12rpx;
  1379. border-radius: 6rpx;
  1380. font-size: 24rpx;
  1381. &.is-empty {
  1382. background-color: #607d8b;
  1383. }
  1384. }
  1385. }
  1386. .category-tag + .category-tag {
  1387. margin-left: 12rpx;
  1388. }
  1389. .content {
  1390. margin-top: 24rpx;
  1391. }
  1392. .markdown-wrap,
  1393. .evan-markdown,
  1394. .ad-wrap,
  1395. .copyright-wrap,
  1396. .comment-wrap {
  1397. box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.03);
  1398. }
  1399. .vote-wrap {
  1400. position: relative;
  1401. }
  1402. .vote-opra {
  1403. font-size: 24rpx;
  1404. font-weight: normal;
  1405. color: #999;
  1406. }
  1407. .vote-tip {
  1408. margin-top: 12rpx;
  1409. padding: 50rpx 24rpx;
  1410. background: #f1f5f9;
  1411. color: #666;
  1412. font-size: 24rpx;
  1413. border-radius: 12rpx;
  1414. text-align: center;
  1415. }
  1416. .markdown-wrap {
  1417. overflow: hidden;
  1418. border-radius: 12rpx;
  1419. }
  1420. .copyright-title {
  1421. position: relative;
  1422. box-sizing: border-box;
  1423. padding-left: 24rpx;
  1424. font-size: 30rpx;
  1425. &:before {
  1426. content: '';
  1427. position: absolute;
  1428. left: 0rpx;
  1429. top: 8rpx;
  1430. width: 8rpx;
  1431. height: 26rpx;
  1432. background-color: rgb(3, 174, 252);
  1433. border-radius: 6rpx;
  1434. }
  1435. }
  1436. .poup-head {
  1437. border-bottom: 2rpx solid #f5f5f5;
  1438. }
  1439. .poup-body {
  1440. height: 50vh;
  1441. }
  1442. .poup-empty {
  1443. width: 100%;
  1444. height: 40vh;
  1445. }
  1446. .poup-loading-wrap {
  1447. width: 100%;
  1448. height: 40vh;
  1449. .e-loading-icon {
  1450. font-size: 80rpx;
  1451. }
  1452. }
  1453. .poster-content {
  1454. width: 100%;
  1455. min-height: 60vh;
  1456. overflow: hidden;
  1457. }
  1458. .copyright-text {
  1459. line-height: 1.7;
  1460. }
  1461. .poster-loading {
  1462. width: 100%;
  1463. position: absolute;
  1464. left: 0;
  1465. top: 0;
  1466. right: 0;
  1467. bottom: 0;
  1468. // background-color: rgba(0, 0, 0, 0.1);
  1469. z-index: 666;
  1470. }
  1471. .poster-save {
  1472. box-sizing: border-box;
  1473. border-top: 2rpx dashed #eee;
  1474. }
  1475. .original-url {
  1476. display: flex;
  1477. &_left {
  1478. flex-shrink: 0;
  1479. width: 84rpx;
  1480. }
  1481. &_right {
  1482. flex-grow: 1;
  1483. display: inline-flex;
  1484. align-items: center;
  1485. &__link {
  1486. width: 410rpx;
  1487. display: inline-block;
  1488. overflow: hidden;
  1489. text-overflow: ellipsis;
  1490. white-space: nowrap;
  1491. }
  1492. &__btn {
  1493. flex-grow: 1;
  1494. flex-shrink: 0;
  1495. display: block;
  1496. text-align: right;
  1497. }
  1498. }
  1499. }
  1500. </style>