index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <template>
  2. <view class="ac-container" :style="{ '--font-scale': fontScale }">
  3. <!-- 登录浮层(全局组件,页面内弹出底部登录) -->
  4. <login-sheet ref="loginSheet" @success="onSheetLoginSuccess" />
  5. <!-- 自定义导航栏 -->
  6. <view class="ac-nav">
  7. <view class="ac-nav-left" @click="onBack">
  8. <text class="ac-nav-back">&#x2190;</text>
  9. </view>
  10. <text class="ac-nav-title">知识分享</text>
  11. <view class="ac-nav-right">
  12. <!-- 搜索栏已常驻,此处仅作「聚焦输入框 + 回全量」快捷方式,与常驻输入框是同一入口,非独立搜索 -->
  13. <text class="ac-nav-search-icon" @click="focusSearch">搜索</text>
  14. <text class="ac-nav-add" @click="goEdit">+</text>
  15. </view>
  16. </view>
  17. <!-- 搜索栏(常驻可见):默认即展示输入框,聚焦时展开搜索历史;右上角「搜索」为聚焦快捷方式 -->
  18. <view class="ac-search-bar">
  19. <input
  20. class="ac-search-input"
  21. v-model="searchKeyword"
  22. :focus="searchFocused"
  23. placeholder="搜索文章..."
  24. confirm-type="search"
  25. @confirm="onSearch"
  26. @input="onSearchInput"
  27. @focus="onSearchFocus"
  28. @blur="onSearchBlur"
  29. />
  30. <text v-if="searchFocused || searchKeyword" class="ac-search-cancel" @click="cancelSearch">取消</text>
  31. </view>
  32. <!-- 搜索历史(聚焦且未输入时展示,上限 10 条可清空) -->
  33. <view v-if="searchFocused && !searchKeyword && searchHistory.length" class="ac-search-history">
  34. <view class="ac-history-header">
  35. <text class="ac-history-title">搜索历史</text>
  36. <text class="ac-history-clear" @click="clearSearchHistory">清除</text>
  37. </view>
  38. <view class="ac-history-tags">
  39. <text
  40. v-for="(item, idx) in searchHistory"
  41. :key="idx"
  42. class="ac-history-tag"
  43. @click="clickSearchHistory(item)"
  44. >{{ item }}</text>
  45. </view>
  46. </view>
  47. <!-- Tab 导航(药丸式) -->
  48. <view class="ac-tabs">
  49. <scroll-view scroll-x show-scrollbar="false" class="ac-tab-scroll">
  50. <view
  51. v-for="tab in tabList"
  52. :key="tab.code"
  53. :class="['ac-tab', currentTab === tab.code ? 'active' : '']"
  54. :style="currentTab === tab.code ? 'background:' + tab.color + ';color:' + whiteColor + ';border-color:' + tab.color : ''"
  55. @click="onTabChange(tab.code)"
  56. >
  57. {{ tab.name }}
  58. </view>
  59. </scroll-view>
  60. </view>
  61. <!-- 书册式推荐阅读 -->
  62. <ArticleBookshelf
  63. v-if="recommendedArticles.length > 0 || !recommendLoading"
  64. :articles="recommendedArticles"
  65. :loading="recommendLoading"
  66. :isLoggedIn="isLoggedIn"
  67. @articleClick="goDetail"
  68. @moreArticles="goExplore"
  69. />
  70. <!-- 文章列表区域 -->
  71. <scroll-view scroll-y class="ac-scroll" @scrolltolower="onLoadMore">
  72. <!-- 骨架屏 -->
  73. <view v-if="loading && articles.length === 0" class="ac-skeleton-wrap">
  74. <view v-for="n in 3" :key="n" class="sk-card">
  75. <view class="sk-cover"></view>
  76. <view class="sk-body">
  77. <view class="sk-row sk-tag"></view>
  78. <view class="sk-row sk-title"></view>
  79. <view class="sk-row sk-desc"></view>
  80. <view class="sk-row sk-footer"></view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 空状态(搜索态无命中 → 未找到相关文章;非搜索态 → 暂无文章) -->
  85. <view v-else-if="noMore && articles.length === 0" class="ac-empty">
  86. <image class="ac-empty-img" src="/static/empty-article.png" mode="aspectFit" lazy-load></image>
  87. <text class="ac-empty-text">{{ isSearchEmpty ? '未找到相关文章' : '暂无文章' }}</text>
  88. </view>
  89. <!-- 文章列表 -->
  90. <view v-else class="ac-feed">
  91. <view
  92. v-for="item in articles"
  93. :key="item.id"
  94. class="ac-card"
  95. hover-class="ac-card-pressed"
  96. @click="goDetail(item.id)"
  97. >
  98. <view class="ac-card-media">
  99. <image
  100. class="ac-card-cover"
  101. :src="getImageUrl(item.coverImage) || '/static/default-article.png'"
  102. mode="aspectFill"
  103. lazy-load />
  104. <view class="ac-card-dimension-tags" v-if="item.relatedDimensions">
  105. <view
  106. v-for="dim in parseDimensions(item.relatedDimensions)"
  107. :key="dim.code"
  108. class="ac-card-dim-tag"
  109. :style="'background:' + dim.color"
  110. >{{ dim.name }}</view>
  111. </view>
  112. </view>
  113. <view class="ac-card-body">
  114. <view class="ac-card-meta-top">
  115. <text class="ac-card-category" v-if="item.categoryName">{{ item.categoryName }}</text>
  116. <text class="ac-card-readtime">&#x1F4D6; {{ item.readTime || 3 }}分钟</text>
  117. </view>
  118. <text class="ac-card-title">{{ item.title }}</text>
  119. <text class="ac-card-summary" v-if="item.summary">{{ item.summary }}</text>
  120. <view class="ac-card-footer">
  121. <text class="ac-card-author">{{ item.author || '浠艾福' }}</text>
  122. <text class="ac-card-sep">|</text>
  123. <text class="ac-card-date">{{ formatDate(item.publishedAt) }}</text>
  124. <text class="ac-card-fav">&#x2B50; {{ item.favCount || 0 }}</text>
  125. <text class="ac-card-sep">|</text>
  126. <text class="ac-card-readcount">&#x1F441; {{ item.viewCount || 0 }}</text>
  127. <text class="ac-card-sep">|</text>
  128. <text class="ac-card-duration">&#x23F1; {{ formatDuration(item.totalDurationSeconds) }}</text>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <!-- 加载更多 / 没有更多 -->
  134. <view v-if="loadingMore" class="ac-loading-more">
  135. <text class="ac-loading-text">加载中...</text>
  136. </view>
  137. <view v-if="noMore && articles.length > 0" class="ac-no-more">
  138. <text class="ac-no-more-text">— 没有更多了 —</text>
  139. </view>
  140. <view class="ac-bottom-gap"></view>
  141. </scroll-view>
  142. <!-- 浮动发布按钮 -->
  143. <view class="ac-fab" @click="goEdit">
  144. <text class="ac-fab-icon">+</text>
  145. </view>
  146. </view>
  147. </template>
  148. <script>
  149. import { BrandColors } from '../../utils/brand-colors.js'
  150. import { getArticleList, getArticleTags, getFeaturedArticles } from '@/utils/api.js'
  151. import config from '@/config.js'
  152. import fontScaleMixin from '@/mixins/font-scale.js'
  153. export default {
  154. mixins: [fontScaleMixin],
  155. data() {
  156. return {
  157. whiteColor: BrandColors.white,
  158. tabList: [
  159. { code: '', name: '全部', color: BrandColors.primary }
  160. ],
  161. currentTab: '',
  162. articles: [],
  163. page: 1,
  164. size: 10,
  165. total: 0,
  166. loading: false,
  167. loadingMore: false,
  168. noMore: false,
  169. searchKeyword: '',
  170. searchFocused: false,
  171. searchHistory: [],
  172. isLoggedIn: false,
  173. recommendedArticles: [],
  174. recommendLoading: false
  175. }
  176. },
  177. computed: {
  178. // 搜索态判定:供空态文案区分「未找到相关文章 / 暂无文章」(契约 C5)
  179. isSearchEmpty() {
  180. return !!(this.searchKeyword && this.searchKeyword.trim())
  181. }
  182. },
  183. components: {
  184. ArticleBookshelf: () => require('@/pages/home-pages/components/ArticleBookshelf.vue')
  185. },
  186. onLoad(options) {
  187. // 兼容旧入口:外部传入 dimension(旧五维 code)时仍设置 currentTab。
  188. // 新语义下 currentTab 表示「文章标签」,若外部传的是旧五维 code,
  189. // 将命中 tag 为空的降级结果(无可匹配文章),属可接受的降级行为。
  190. if (options && options.dimension) {
  191. this.currentTab = options.dimension
  192. }
  193. this.isLoggedIn = !!uni.getStorageSync('token')
  194. this.currentChildId = uni.getStorageSync('currentChildId') || null
  195. this.loadTags()
  196. this.loadArticles()
  197. this.loadRecommendedArticles()
  198. this.loadSearchHistory()
  199. },
  200. onShow() {
  201. this.isLoggedIn = !!uni.getStorageSync('token')
  202. },
  203. onUnload() {
  204. if (this._searchTimer) {
  205. clearTimeout(this._searchTimer)
  206. this._searchTimer = null
  207. }
  208. if (this._blurTimer) {
  209. clearTimeout(this._blurTimer)
  210. this._blurTimer = null
  211. }
  212. },
  213. methods: {
  214. async loadTags() {
  215. try {
  216. var res = await getArticleTags()
  217. if (res && res.code === 200 && res.data && res.data.length) {
  218. var addList = res.data.map(function(tag) {
  219. return { code: tag, name: tag, color: BrandColors.primary }
  220. })
  221. this.tabList = [{ code: '', name: '全部', color: BrandColors.primary }].concat(addList)
  222. }
  223. } catch (e) {
  224. // 标签拉取失败时保留「全部」,文章列表仍可正常浏览
  225. }
  226. },
  227. async loadArticles(isLoadMore) {
  228. if (!isLoadMore) {
  229. if (this.loading) return
  230. this.loading = true
  231. this.page = 1
  232. this.articles = []
  233. this.noMore = false
  234. } else {
  235. if (this.loadingMore || this.noMore) return
  236. this.loadingMore = true
  237. }
  238. // 请求序号:新的搜索/刷新会使仍在途的旧响应作废,避免过期数据覆盖新结果
  239. var seq = (this._seq = (this._seq || 0) + 1)
  240. try {
  241. var params = { page: this.page, size: this.size }
  242. if (this.currentChildId) {
  243. params.memberId = parseInt(this.currentChildId)
  244. }
  245. if (this.currentTab) {
  246. params.tag = this.currentTab
  247. }
  248. if (this.searchKeyword && this.searchKeyword.trim()) {
  249. params.keyword = this.searchKeyword.trim()
  250. }
  251. var res = await getArticleList(params)
  252. if (seq !== this._seq) return
  253. if (res.code === 200 && res.data) {
  254. var list = res.data.records || []
  255. if (this.page === 1) {
  256. this.articles = list
  257. } else {
  258. this.articles = this.articles.concat(list)
  259. }
  260. this.total = res.data.total || 0
  261. this.noMore = this.articles.length >= this.total
  262. }
  263. } catch (e) {
  264. if (seq === this._seq) {
  265. uni.showToast({ title: '加载失败', icon: 'none' })
  266. }
  267. } finally {
  268. if (seq === this._seq) {
  269. this.loading = false
  270. this.loadingMore = false
  271. }
  272. }
  273. },
  274. onTabChange(code) {
  275. if (this.currentTab === code) return
  276. this.currentTab = code
  277. this.searchKeyword = ''
  278. this.searchFocused = false
  279. this.resetList()
  280. this.loadArticles()
  281. },
  282. async loadRecommendedArticles() {
  283. var self = this
  284. self.recommendLoading = true
  285. try {
  286. var res = await getFeaturedArticles({ size: 8 })
  287. if (res && res.code === 200 && res.data) {
  288. // 兼容数组 / { list } / { records } 三种响应结构,保证永远赋值数组
  289. var raw = Array.isArray(res.data) ? res.data : (res.data.list || res.data.records || [])
  290. self.recommendedArticles = Array.isArray(raw) ? raw : []
  291. }
  292. } catch (e) {
  293. // silent fail
  294. } finally {
  295. self.recommendLoading = false
  296. }
  297. },
  298. onLoadMore() {
  299. if (this.noMore || this.loading || this.loadingMore) return
  300. this.page++
  301. this.loadArticles(true)
  302. },
  303. goDetail(idOrArticle) {
  304. var id = idOrArticle && idOrArticle.id ? idOrArticle.id : idOrArticle
  305. uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
  306. },
  307. goEdit() {
  308. var isLoggedIn = !!uni.getStorageSync('token')
  309. if (isLoggedIn) {
  310. uni.navigateTo({ url: '/pages/article-center/article-edit' })
  311. } else {
  312. this.openLoginSheet({ redirect: '/pages/article-center/index' })
  313. }
  314. },
  315. goExplore() {
  316. // 筛选全部文章
  317. this.currentTab = ''
  318. this.page = 1
  319. this.articles = []
  320. this.loadArticles()
  321. },
  322. // 登录浮层成功回调:刷新文章列表(登录后可见编辑入口等)
  323. onLoginSuccess() {
  324. this.loadArticles()
  325. },
  326. formatDate(dateStr) {
  327. if (!dateStr) return ''
  328. return dateStr.slice(0, 10)
  329. },
  330. formatDuration(seconds) {
  331. if (!seconds || seconds <= 0) return '0分钟'
  332. var mins = Math.round(seconds / 60)
  333. if (mins < 60) return mins + '分钟'
  334. var hours = Math.floor(mins / 60)
  335. var restMins = mins % 60
  336. return restMins > 0 ? hours + '小时' + restMins + '分钟' : hours + '小时'
  337. },
  338. parseDimensions(str) {
  339. if (!str) return []
  340. var dimMap = {
  341. body: { code: 'body', color: BrandColors.body, name: '身' },
  342. mind: { code: 'mind', color: BrandColors.mind, name: '心' },
  343. wisdom: { code: 'wisdom', color: BrandColors.wisdom, name: '智' },
  344. action: { code: 'action', color: BrandColors.success, name: '行' },
  345. wealth: { code: 'wealth', color: BrandColors.wealth, name: '富' }
  346. }
  347. var codes = str.split(',').map(function(s) { return s.trim().toLowerCase() })
  348. return codes.filter(function(c) { return dimMap[c] }).map(function(c) { return dimMap[c] })
  349. },
  350. focusSearch() {
  351. this.searchFocused = true
  352. // 进入搜索态:清当前 Tab 回全量(搜索与标签筛选互斥,契约 C6)
  353. if (this.currentTab !== '') {
  354. this.currentTab = ''
  355. this.resetList()
  356. this.loadArticles()
  357. }
  358. },
  359. onSearch() {
  360. this.doSearch(true)
  361. },
  362. doSearch(saveHistory) {
  363. var keyword = (this.searchKeyword || '').trim()
  364. // 进入搜索态:清当前 Tab 回全量(互斥重置,契约 C6)
  365. if (this.currentTab !== '') {
  366. this.currentTab = ''
  367. }
  368. this.resetList()
  369. if (saveHistory && keyword) {
  370. this.saveSearchHistory(keyword)
  371. }
  372. this.loadArticles()
  373. },
  374. onSearchInput(e) {
  375. var value = e && e.detail ? e.detail.value : this.searchKeyword
  376. this.searchKeyword = value
  377. var self = this
  378. if (this._searchTimer) clearTimeout(this._searchTimer)
  379. // 400ms 防抖即时搜索(避免逐字请求,契约 D3a)
  380. this._searchTimer = setTimeout(function () {
  381. self._searchTimer = null
  382. self.doSearch(false)
  383. }, 400)
  384. },
  385. loadSearchHistory() {
  386. var raw = uni.getStorageSync('article_search_history')
  387. if (!raw) {
  388. this.searchHistory = []
  389. return
  390. }
  391. try {
  392. var arr = JSON.parse(raw)
  393. this.searchHistory = Array.isArray(arr) ? arr : []
  394. } catch (e) {
  395. this.searchHistory = []
  396. }
  397. },
  398. saveSearchHistory(keyword) {
  399. if (!keyword) return
  400. var list = this.searchHistory.filter(function (h) { return h !== keyword })
  401. list.unshift(keyword)
  402. if (list.length > 10) {
  403. list = list.slice(0, 10)
  404. }
  405. this.searchHistory = list
  406. uni.setStorageSync('article_search_history', JSON.stringify(list))
  407. },
  408. clearSearchHistory() {
  409. this.searchHistory = []
  410. uni.removeStorageSync('article_search_history')
  411. },
  412. clickSearchHistory(keyword) {
  413. this.searchKeyword = keyword
  414. this.onSearch()
  415. },
  416. resetList() {
  417. this.page = 1
  418. this.articles = []
  419. this.noMore = false
  420. // 作废旧请求:让新搜索/刷新取代仍在途的响应,避免旧数据覆盖新结果
  421. this._seq = (this._seq || 0) + 1
  422. this.loading = false
  423. this.loadingMore = false
  424. },
  425. // 常驻搜索框:聚焦即进入搜索态(展开历史),不重拉列表;
  426. // 与右上角「搜索」快捷方式(focusSearch,含 Tab 互斥重置)共用同一输入框
  427. onSearchFocus() {
  428. if (this._blurTimer) {
  429. clearTimeout(this._blurTimer)
  430. this._blurTimer = null
  431. }
  432. this.searchFocused = true
  433. },
  434. cancelSearch() {
  435. // 取消:清掉防抖与失焦定时器,避免取消后仍发出旧词请求或状态反复
  436. if (this._searchTimer) {
  437. clearTimeout(this._searchTimer)
  438. this._searchTimer = null
  439. }
  440. if (this._blurTimer) {
  441. clearTimeout(this._blurTimer)
  442. this._blurTimer = null
  443. }
  444. this.searchKeyword = ''
  445. this.searchFocused = false
  446. this.onSearch()
  447. },
  448. onSearchBlur() {
  449. if (this._blurTimer) clearTimeout(this._blurTimer)
  450. var self = this
  451. // 延迟收起:点击搜索历史项时 blur 先于 click 触发,
  452. // 若立即置 false,历史区 v-if 失效会导致点不中历史项
  453. this._blurTimer = setTimeout(function () {
  454. self._blurTimer = null
  455. // 焦点态与输入框实际焦点保持一致;有关键词时「取消」仍由 searchKeyword 维持显示
  456. self.searchFocused = false
  457. }, 150)
  458. },
  459. onBack() {
  460. uni.navigateBack()
  461. },
  462. getImageUrl: function(path) {
  463. if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
  464. var s = String(path).trim()
  465. if (!s || s === 'null' || s === '/null') return ''
  466. if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
  467. return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
  468. }
  469. }
  470. }
  471. </script>
  472. <style scoped lang="scss">
  473. /* ====================================
  474. 知识分享 — 重设计
  475. 白色导航 + 药丸Tab + 精装卡片
  476. ==================================== */
  477. .ac-container {
  478. min-height: 100vh;
  479. background: $app-bg;
  480. position: relative;
  481. }
  482. /* ---- 导航栏(白色简约) ---- */
  483. .ac-nav {
  484. display: flex;
  485. align-items: center;
  486. justify-content: space-between;
  487. padding: 84rpx 28rpx 20rpx;
  488. background: $app-surface;
  489. position: sticky;
  490. top: 0;
  491. z-index: 100;
  492. }
  493. .ac-nav-left {
  494. width: 60rpx;
  495. height: 48rpx;
  496. display: flex;
  497. align-items: center;
  498. justify-content: flex-start;
  499. flex-shrink: 0;
  500. }
  501. .ac-nav-back {
  502. font-size: calc(36rpx * var(--font-scale, 1));
  503. color: $facade-text-strong;
  504. font-weight: bold;
  505. }
  506. .ac-nav-title {
  507. font-size: calc(32rpx * var(--font-scale, 1));
  508. font-weight: bold;
  509. color: $text-charcoal;
  510. flex: 1;
  511. text-align: center;
  512. }
  513. .ac-nav-right {
  514. display: flex;
  515. align-items: center;
  516. gap: 20rpx;
  517. flex-shrink: 0;
  518. }
  519. .ac-nav-search-icon {
  520. font-size: calc(26rpx * var(--font-scale, 1));
  521. font-weight: 500;
  522. line-height: 1;
  523. color: $brand-primary;
  524. }
  525. .ac-nav-add {
  526. font-size: calc(40rpx * var(--font-scale, 1));
  527. color: $brand-primary;
  528. font-weight: 400;
  529. line-height: 1;
  530. }
  531. /* ---- 搜索栏(常驻可见) ---- */
  532. .ac-search-bar {
  533. display: flex;
  534. align-items: center;
  535. padding: 12rpx 28rpx 16rpx;
  536. background: $app-surface;
  537. border-bottom: 1rpx solid $facade-fill;
  538. }
  539. .ac-search-input {
  540. flex: 1;
  541. height: 60rpx;
  542. background: $facade-fill-2;
  543. border-radius: 24rpx;
  544. padding: 0 28rpx;
  545. font-size: calc(26rpx * var(--font-scale, 1));
  546. color: $facade-text-strong;
  547. }
  548. .ac-search-cancel {
  549. font-size: calc(26rpx * var(--font-scale, 1));
  550. color: $facade-text-muted;
  551. margin-left: 16rpx;
  552. flex-shrink: 0;
  553. }
  554. /* ---- 搜索历史 ---- */
  555. .ac-search-history {
  556. padding: 16rpx 28rpx;
  557. background: $app-surface;
  558. border-bottom: 1rpx solid $facade-fill;
  559. }
  560. .ac-history-header {
  561. display: flex;
  562. align-items: center;
  563. justify-content: space-between;
  564. margin-bottom: 12rpx;
  565. }
  566. .ac-history-title {
  567. font-size: calc(24rpx * var(--font-scale, 1));
  568. color: $facade-text-muted;
  569. }
  570. .ac-history-clear {
  571. font-size: calc(22rpx * var(--font-scale, 1));
  572. color: $facade-text-ghost;
  573. }
  574. .ac-history-tags {
  575. display: flex;
  576. flex-wrap: wrap;
  577. gap: 12rpx;
  578. }
  579. .ac-history-tag {
  580. padding: 6rpx 20rpx;
  581. border-radius: 20rpx;
  582. background: $facade-fill;
  583. font-size: calc(22rpx * var(--font-scale, 1));
  584. color: $facade-text-strong;
  585. }
  586. /* ---- Tab 药丸导航 ---- */
  587. .ac-tabs {
  588. padding: 16rpx 28rpx;
  589. background: $app-surface;
  590. border-bottom: 1rpx solid $facade-fill;
  591. position: sticky;
  592. z-index: 10;
  593. }
  594. .ac-tab-scroll {
  595. white-space: nowrap;
  596. display: flex;
  597. }
  598. .ac-tab {
  599. display: inline-flex;
  600. align-items: center;
  601. justify-content: center;
  602. height: 52rpx;
  603. padding: 0 28rpx;
  604. margin-right: 16rpx;
  605. font-size: calc(24rpx * var(--font-scale, 1));
  606. color: $facade-text-body;
  607. background: $facade-fill;
  608. border-radius: 24rpx;
  609. border: 2rpx solid $facade-fill;
  610. flex-shrink: 0;
  611. transition: font-weight 0.2s;
  612. }
  613. .ac-tab.active {
  614. font-weight: 600;
  615. }
  616. /* ---- 滚动列表区域 ---- */
  617. .ac-scroll {
  618. height: calc(100vh - 200rpx);
  619. }
  620. /* ---- 骨架屏 ---- */
  621. .ac-skeleton-wrap { padding: 24rpx 28rpx; }
  622. .sk-card {
  623. background: $app-surface;
  624. border-radius: 24rpx;
  625. overflow: hidden;
  626. margin-bottom: 24rpx;
  627. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  628. }
  629. .sk-cover {
  630. height: 340rpx;
  631. background: linear-gradient(90deg, $facade-fill 25%, $facade-fill-4 50%, $facade-fill 75%);
  632. background-size: 200% 100%;
  633. animation: sk-shimmer 1.5s infinite;
  634. }
  635. .sk-body { padding: 24rpx; }
  636. .sk-row {
  637. height: 22rpx;
  638. background: linear-gradient(90deg, $facade-fill 25%, $facade-fill-4 50%, $facade-fill 75%);
  639. background-size: 200% 100%;
  640. border-radius: 8rpx;
  641. margin-bottom: 14rpx;
  642. animation: sk-shimmer 1.5s infinite;
  643. }
  644. .sk-tag { width: 20%; }
  645. .sk-title { width: 65%; }
  646. .sk-desc { width: 90%; }
  647. .sk-footer { width: 40%; height: 18rpx; }
  648. @keyframes sk-shimmer {
  649. 0% { background-position: -200% 0; }
  650. 100% { background-position: 200% 0; }
  651. }
  652. /* ---- 空状态 ---- */
  653. .ac-empty {
  654. display: flex;
  655. flex-direction: column;
  656. align-items: center;
  657. padding-top: 240rpx;
  658. }
  659. .ac-empty-img {
  660. width: 200rpx;
  661. height: 200rpx;
  662. margin-bottom: 28rpx;
  663. }
  664. .ac-empty-text {
  665. font-size: calc(28rpx * var(--font-scale, 1));
  666. color: $facade-text-ghost-light;
  667. }
  668. /* ---- 文章卡片(新版) ---- */
  669. .ac-feed {
  670. padding: 24rpx 28rpx;
  671. }
  672. .ac-card {
  673. background: $app-surface;
  674. border-radius: 24rpx;
  675. overflow: hidden;
  676. margin-bottom: 24rpx;
  677. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  678. transition: transform 0.15s;
  679. }
  680. .ac-card-pressed {
  681. transform: scale(0.97);
  682. opacity: 0.9;
  683. }
  684. /* 封面 + 维度浮标 */
  685. .ac-card-media {
  686. position: relative;
  687. width: 100%;
  688. overflow: hidden;
  689. }
  690. .ac-card-cover {
  691. display: block;
  692. width: 100%;
  693. height: 340rpx;
  694. background: $facade-fill;
  695. }
  696. .ac-card-dimension-tags {
  697. position: absolute;
  698. bottom: 12rpx;
  699. left: 16rpx;
  700. display: flex;
  701. gap: 8rpx;
  702. }
  703. .ac-card-dim-tag {
  704. padding: 2rpx 14rpx;
  705. border-radius: 16rpx;
  706. font-size: calc(20rpx * var(--font-scale, 1));
  707. color: $app-surface;
  708. font-weight: 500;
  709. line-height: 1.4;
  710. }
  711. /* 正文区 */
  712. .ac-card-body {
  713. padding: 24rpx 24rpx 28rpx;
  714. }
  715. .ac-card-meta-top {
  716. display: flex;
  717. align-items: center;
  718. margin-bottom: 12rpx;
  719. }
  720. .ac-card-category {
  721. font-size: calc(20rpx * var(--font-scale, 1));
  722. color: $brand-primary;
  723. background: rgba(249,115,22,0.08);
  724. padding: 2rpx 14rpx;
  725. border-radius: 8rpx;
  726. margin-right: 16rpx;
  727. }
  728. .ac-card-readtime {
  729. font-size: calc(20rpx * var(--font-scale, 1));
  730. color: $text-ghost-soft;
  731. }
  732. .ac-card-title {
  733. display: block;
  734. font-size: calc(30rpx * var(--font-scale, 1));
  735. font-weight: 600;
  736. color: $text-charcoal;
  737. line-height: 1.45;
  738. margin-bottom: 10rpx;
  739. overflow: hidden;
  740. text-overflow: ellipsis;
  741. display: -webkit-box;
  742. -webkit-line-clamp: 2;
  743. -webkit-box-orient: vertical;
  744. }
  745. .ac-card-summary {
  746. display: block;
  747. font-size: calc(24rpx * var(--font-scale, 1));
  748. color: $facade-text-muted;
  749. line-height: 1.5;
  750. margin-bottom: 16rpx;
  751. overflow: hidden;
  752. text-overflow: ellipsis;
  753. display: -webkit-box;
  754. -webkit-line-clamp: 2;
  755. -webkit-box-orient: vertical;
  756. }
  757. .ac-card-footer {
  758. display: flex;
  759. align-items: center;
  760. font-size: calc(20rpx * var(--font-scale, 1));
  761. color: $facade-text-ghost-light;
  762. }
  763. .ac-card-author {
  764. color: $facade-text-faint;
  765. }
  766. .ac-card-sep {
  767. margin: 0 10rpx;
  768. color: $facade-border-soft;
  769. }
  770. .ac-card-date {
  771. flex: 1;
  772. }
  773. .ac-card-fav {
  774. color: $facade-text-ghost;
  775. }
  776. .ac-card-readcount {
  777. color: $facade-text-ghost;
  778. }
  779. /* ---- 加载更多 / 没有更多 ---- */
  780. .ac-loading-more,
  781. .ac-no-more {
  782. text-align: center;
  783. padding: $uni-space-page;
  784. }
  785. .ac-loading-text {
  786. font-size: calc(24rpx * var(--font-scale, 1));
  787. color: $facade-text-ghost-light;
  788. }
  789. .ac-no-more-text {
  790. font-size: calc(24rpx * var(--font-scale, 1));
  791. color: $facade-border-soft;
  792. }
  793. .ac-bottom-gap {
  794. height: 140rpx;
  795. }
  796. /* ---- 浮动发布按钮 ---- */
  797. .ac-fab {
  798. position: fixed;
  799. right: 36rpx;
  800. bottom: 100rpx;
  801. width: 96rpx;
  802. height: 96rpx;
  803. background: linear-gradient(135deg, $brand-primary, $brand-primary-dark);
  804. color: $app-surface;
  805. border-radius: 50%;
  806. display: flex;
  807. align-items: center;
  808. justify-content: center;
  809. box-shadow: 0 6rpx 20rpx rgba(249,115,22,0.35);
  810. z-index: 100;
  811. }
  812. .ac-fab:active {
  813. transform: scale(0.92);
  814. opacity: 0.85;
  815. }
  816. .ac-fab-icon {
  817. font-size: calc(48rpx * var(--font-scale, 1));
  818. font-weight: 400;
  819. line-height: 1;
  820. }
  821. </style>