Browse Source

feat: 调整 ID 获取方式

zhangyuhan 1 year ago
parent
commit
b04dc7448e

+ 8 - 6
apps/bigmember_pc/src/views/article-content/components/ContentHeader.vue

@@ -3,7 +3,10 @@ import shareBox from '@/components/shareBox/index.vue'
 import powerPerson from '@/components/subscribe-manager/powerPerson.vue'
 import QuickMonitor from '@/composables/quick-monitor/component/QuickMonitor.vue'
 import ArticleStar from '@/components/push-list/ArticleStar.vue'
-import { ContentModel } from '@/views/article-content/composables/useContentStore'
+import {
+  ContentModel,
+  ContentId
+} from '@/views/article-content/composables/useContentStore'
 import { computed, getCurrentInstance, onMounted, ref } from 'vue'
 import { useRoute } from 'vue-router/composables'
 import { useStore } from '@/store'
@@ -40,8 +43,7 @@ const { openShare, useShareRef } = useShare()
 // 分发
 const { doSubmitDistribute, openDistribute, usePowerRef } = useDistribute()
 // 监控
-const contentId = params.id.replace('.html', '')
-const { starModel, doFetchStarState } = useArticleStarModel(contentId)
+const { starModel, doFetchStarState } = useArticleStarModel(ContentId.value)
 doFetchStarState()
 
 // 参标
@@ -50,7 +52,7 @@ const {
   JoinBidModel,
   doFetchJoinBid,
   doChangeJoinBid
-} = useQuickJoinBidModel({ id: contentId })
+} = useQuickJoinBidModel({ id: ContentId.value })
 doFetchJoinBid()
 
 const JoinBidInfo = computed(() => {
@@ -121,7 +123,7 @@ const InWhichContainer = window.parent !== window ? 'in-app' : 'in-web'
           class="action-item"
           :cache="true"
           type="project"
-          :params="contentId"
+          :params="ContentId"
         ></quick-monitor>
 
         <div
@@ -143,7 +145,7 @@ const InWhichContainer = window.parent !== window ? 'in-app' : 'in-web'
 
         <div class="action-item">
           <article-star
-            :id="contentId"
+            :id="ContentId"
             :star="starModel.star"
             @change="doFetchStarState"
             @change-labels="doFetchStarState"

+ 9 - 2
apps/bigmember_pc/src/views/article-content/composables/useContentStore.js

@@ -36,12 +36,16 @@ const AgentInfo = ref({
 })
 const Content = reactive(useContentModel())
 const ContentExpands = reactive(useContentExpandModel())
+
 const ContentPageLoading = ref(true)
 const ContentPageExpandsLoading = ref(true)
 
 const ContentModel = computed(() => {
   return Content.model.content
 })
+const ContentId = computed(() => {
+  return ContentModel.value.id
+})
 
 const SummaryModel = computed(() => {
   return Content.model.summary
@@ -86,11 +90,13 @@ async function useContentStore() {
   }
 
   return {
+    useContentStore,
     ContentModel,
     SummaryModel,
+    ContentId,
+    ContentExpandsModel,
     ContentPageLoading,
-    ContentPageExpandsLoading,
-    ContentExpandsModel
+    ContentPageExpandsLoading
   }
 }
 
@@ -98,6 +104,7 @@ export {
   useContentStore,
   ContentModel,
   SummaryModel,
+  ContentId,
   ContentExpandsModel,
   ContentPageLoading,
   ContentPageExpandsLoading

+ 5 - 6
apps/bigmember_pc/src/views/article-content/pages/Article.vue

@@ -28,6 +28,7 @@ import {
   useContentStore,
   ContentExpandsModel,
   ContentModel,
+  ContentId,
   ContentPageLoading,
   ContentPageExpandsLoading,
   SummaryModel
@@ -209,8 +210,6 @@ onBeforeMount(() => {
   window.removeEventListener('visibilitychange', handleFocus)
 })
 
-const contentId = useRoute().params.id.replace('.html', '')
-
 // 打开留资弹窗
 const collectElement = ref(null)
 function doOpenCollectDialog(key) {
@@ -361,7 +360,7 @@ const { elementState, useElementListener } = useHoverHighlightTextPopover({
   }, 150),
   onClick: () => {
     if (popoverElementType.value === 'project-name') {
-      doOpenProjectDetailPage({ id: contentId })
+      doOpenProjectDetailPage({ id: ContentId.value })
     }
     if (popoverElementType.value === 'winner-name') {
       if (elementState.value.winnerId) {
@@ -494,7 +493,7 @@ function doClickFreeView() {
 
                   <div>
                     <attachment-download
-                      :id="contentId"
+                      :id="ContentId"
                       :title="ContentModel.title"
                       :attachment-list="ContentModel.attachments"
                       @doOpenCollect="doOpenCollectDialog"
@@ -591,13 +590,13 @@ function doClickFreeView() {
     <origin-link
       v-if="!canShowMask.show"
       ref="originLinkElement"
-      :id="contentId"
+      :id="ContentId"
       @click-collect="doOpenCollectDialog"
     ></origin-link>
     <template #right-top v-if="timeLineList.length > 0">
       <!--  招标/采购进度  -->
       <content-right-time-line
-        :content-id="contentId"
+        :content-id="ContentId"
         :time-line-list="timeLineList"
         @open="doOpenArticlePage"
       ></content-right-time-line>