Browse Source

Merge branch 'master' of http://192.168.3.207:10080/jianyu/jy-docs

TANGSHIZHE 4 years ago
parent
commit
0489058b66

+ 10 - 2
jydocs-back/servers/stdDoc.go

@@ -4,6 +4,7 @@ import (
 	. "app.yhyue.com/moapp/jybase/api"
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/redis"
 	"fmt"
 	"jy-docs/config"
 	"jy-docs/public"
@@ -143,7 +144,6 @@ func (stdDoc *StdDoc) GetDoc(sign string) {
 		fileId := detail.OssPdfId
 		if sign == "Down" {
 			fileId = detail.OssDocId
-			go rpc.DocStatistics(userId, docId, rpc.Down) //统计下载次数
 		}
 		url, err := rpc.GetFileContext(userId, fileId)
 		if err != nil {
@@ -176,11 +176,19 @@ func (stdDoc *StdDoc) TopList() {
 		} else {
 			return nil, fmt.Errorf("未知请求")
 		}
-		//存入redis缓存
+		topKey := fmt.Sprintf("jydoc_indexCache_%s_%d", reqSort, num)
+		listCache := redis.Get("other", topKey)
+		if listCache != nil {
+			return listCache, nil
+		}
+		log.Println("flush", topKey)
 		list, _, err := rpc.GetDocQuery(userId, "", "", 1, num, reqSort)
 		if err != nil {
 			return nil, err
 		}
+		if len(list) > 0 { //存入redis缓存
+			redis.Put("other", topKey, list, 60*5)
+		}
 		return list, nil
 	}()
 	if errMsg != nil {

+ 1 - 1
jydocs-mobile/.env.development

@@ -3,4 +3,4 @@ VUE_APP_MOCK=false
 VUE_APP_BASE_API = '/jydocs'
 BASE_URL = '/dev/docs/'
 VUE_APP_BASE_URL = '/dev/docs/'
-VUE_APP_LOG_URL='https://web2-jytest.jianyu360.cn/jyintegral/actionInfo?logAction='
+VUE_APP_LOG_URL='https://web2-jytest.jydev.jianyu360.com/jyLogs/actionInfo?logAction='

+ 1 - 4
jydocs-mobile/src/components/Recharge.vue

@@ -45,9 +45,6 @@ import { Icon, Popup, Sticky } from 'vant'
       [Popup.name]: Popup,
       [Sticky.name]: Sticky,
       [Icon.name]: Icon
-    },
-    created () {
-      console.log('111')
     }
   })
 export default class extends Vue {
@@ -59,7 +56,7 @@ export default class extends Vue {
     }
 
     buyMoney () {
-      window.location.href = `/page_points_app/pay?id=${this.detailData.id}`
+      window.location.href = `/page_points_app/pay?id=${this.detailData.docId}`
     }
 }
 </script>

+ 17 - 7
jydocs-mobile/src/store/modules/main.ts

@@ -28,7 +28,7 @@ function recoveryPageData (key: string, defaultValues = {}) {
   return sessionStorage.getItem(key) ? JSON.parse(sessionStorage.getItem(key) || '') : defaultValues
 }
 function checkType (type: string | number) {
-  let typeStr = ''
+  let typeStr = type
   switch (type) {
     case 1: {
       typeStr = 'word'
@@ -87,7 +87,7 @@ const modulesOption: modulesOption = {
       }
       sessionStorage.setItem('jy-docs-home-page', JSON.stringify(state.homePageData))
     },
-    // 我的文库页面数据
+    // 搜索页面数据
     saveSearchPageState (state, data) {
       console.log(data)
       for (const key in data) {
@@ -95,7 +95,7 @@ const modulesOption: modulesOption = {
       }
       sessionStorage.setItem('jy-docs-search-page', JSON.stringify(data))
     },
-    // 清除提现成功数据
+    // 清除搜索页面数据
     clearSearchPageState (state) {
       state.searchPageData = {}
       sessionStorage.setItem('jy-docs-search-page', JSON.stringify({}))
@@ -107,10 +107,20 @@ const modulesOption: modulesOption = {
       }
       sessionStorage.setItem('jy-docs-user-lib', JSON.stringify(data))
     },
-    // 清除提现成功数据
-    clearMyLibState (state) {
-      state.userLib = {}
-      sessionStorage.setItem('jy-docs-user-lib', JSON.stringify({}))
+    // 清除我的文库页面数据
+    clearMyLibState (state, data = '') { // clearLib,clearCollections
+      if (data === 'clearLib') {
+        if (state.userLib && Object.keys(state.userLib).length !== 0) {
+          delete state.userLib.myLibListState
+        }
+      } else if (data === 'clearCollections') {
+        if (state.userLib && Object.keys(state.userLib).length !== 0) {
+          delete state.userLib.myCollectionListState
+        }
+      } else {
+        state.userLib = {}
+      }
+      sessionStorage.setItem('jy-docs-user-lib', JSON.stringify(state.userLib))
     }
   },
   actions: {

+ 9 - 3
jydocs-mobile/src/views/Search.vue

@@ -139,6 +139,8 @@ export default class extends Vue {
     list: []
   }
 
+  restored = false // 当前数据是否走过缓存
+
   get activeSortType () {
     return this.sortTypeList.find(item => {
       return item.active
@@ -150,17 +152,20 @@ export default class extends Vue {
   }
 
   created () {
-    const y = this.reStoreState()
-    if (!y) {
+    this.restored = this.reStoreState()
+    if (!this.restored) {
       this.getTags()
     }
   }
 
   mounted () {
-    this.onFocus()
+    if (!this.restored) {
+      this.onFocus()
+    }
   }
 
   onFocus () {
+    console.log('fffff')
     const dom = document.querySelector('#mySearch input') as HTMLInputElement
     if (dom) {
       this.$nextTick(() => {
@@ -262,6 +267,7 @@ export default class extends Vue {
     const { data } = await this.doSearchRquesst(query)
     this.listState.loading = false
     this.listState.loaded = true
+    this.$toast.clear()
     if (data && Array.isArray(data.list)) {
       this.listState.pageNum += 1
       this.listState.total = data.total

+ 7 - 3
jydocs-mobile/src/views/details/details.vue

@@ -41,7 +41,7 @@
 
 <script lang="ts">
 import { Component, Vue } from 'vue-property-decorator'
-import { mapActions } from 'vuex'
+import { mapActions, mapMutations } from 'vuex'
 import { Icon, Toast, GoodsAction, GoodsActionIcon, GoodsActionButton } from 'vant'
 import Recharge from '@/components/Recharge.vue'
 import sharePop from '@/components/SharePopup.vue'
@@ -70,10 +70,14 @@ const pdfjsViewer = require('pdfjs-dist/web/pdf_viewer.js')
       getShare: 'main/getShare',
       getAdd: 'main/getAdd',
       getRemove: 'main/getRemove'
+    }),
+    ...mapMutations({
+      clearLibState: 'main/clearMyLibState'
     })
   }
 })
 export default class extends Vue {
+  clearLibState: any
   getDetails: any
   getCoin: any
   getDown: any
@@ -273,16 +277,16 @@ export default class extends Vue {
   canged () {
     if (this.collectd === 0) {
       this.getAdd({ docId: this.docIds }).then((res: any) => {
-        console.log(res)
         if (res.error_code === 0) {
+          this.clearLibState('clearCollections') // 清除我的收藏列表缓存数据
           this.collectd = 1
           Toast('收藏成功')
         }
       })
     } else {
       this.getRemove({ docId: this.docIds }).then((res: any) => {
-        console.log(res)
         if (res.error_code === 0) {
+          this.clearLibState('clearCollections') // 清除我的收藏列表缓存数据
           this.collectd = 0
           Toast('取消收藏')
         }

+ 6 - 3
jydocs-mobile/src/views/purchase/purchasesuccess.vue

@@ -38,14 +38,16 @@
 <script lang="ts">
 import { Component, Vue } from 'vue-property-decorator'
 import { dateFormatter } from '../../utils/globalFunctions'
-// import { mapState } from 'vuex'
+import { mapMutations } from 'vuex'
 
 @Component({
   name: 'test',
-  components: {
-  }
+  ...mapMutations({
+    clearLibState: 'main/clearMyLibState'
+  })
 })
 export default class extends Vue {
+  clearLibState: any
   count = 3
   timer: any
   $router: any
@@ -62,6 +64,7 @@ export default class extends Vue {
     this.query = location.href.split('/')[location.href.split('/').length - 1] // 获取num
     this.setCountDown()
     this.setSession()
+    this.clearLibState('clearLib') // 清除我的文库列表缓存数据
   }
 
   setSession () {

+ 3 - 1
jydocs-pc/.eslintrc.js

@@ -9,7 +9,9 @@ module.exports = {
   ],
   globals: {
     loginflag: true,
-    $: true
+    $: true,
+    pdfjsLib: true,
+    pdfjsViewer: true
   },
   parserOptions: {
     parser: 'babel-eslint'

+ 0 - 1
jydocs-pc/package.json

@@ -13,7 +13,6 @@
     "axios": "^0.21.1",
     "core-js": "^3.4.3",
     "element-ui": "^2.15.1",
-    "pdfjs-dist": "^2.1.266",
     "single-spa-vue": "^1.5.4",
     "systemjs-webpack-interop": "^1.1.2",
     "vue": "^2.6.10",

+ 1 - 3
jydocs-pc/src/views/Content.vue

@@ -89,8 +89,6 @@ import { Button, Tooltip, Divider, Message } from 'element-ui'
 import { getDetails, getShow, getRecommend, getDown, getAdverse, getCoin, getAdd, getRemove } from '../api/modules/detail'
 import { formatSize, dateFormatter } from '@/utils/'
 import vRecommend from '@/components/recommend'
-const pdfjsLib = require('pdfjs-dist/build/pdf.js')
-const pdfjsViewer = require('pdfjs-dist/web/pdf_viewer.js')
 export default {
   components: {
     [Button.name]: Button,
@@ -254,7 +252,7 @@ export default {
           this.datas.docFileSize = formatSize(this.datas.docFileSize)
           this.datas.uploadDate = dateFormatter(this.datas.uploadDate, 'yyyy-MM-dd')
           this.datas.docSummary = this.datas.docSummary.split('').length >= 500 ? this.datas.docSummary + '...' : this.datas.docSummary
-          this.datas.tags = this.datas.tags.split(',')
+          this.datas.tags = this.datas.tags.split(',').slice(0,3)
           this.buyed = res.data.data.status
           this.coined()
           this.recommend(res.data.data.detail.tags)

+ 4 - 1
jydocs-pc/src/views/Home.vue

@@ -127,7 +127,7 @@ import { getHomeActivity, getHomeHot } from '../api/modules/home'
 import { recoveryPageData } from '../utils'
 
 function checkType (type) {
-  let typeStr = ''
+  let typeStr = type
   switch (type) {
     case 1: {
       typeStr = 'word'
@@ -375,17 +375,20 @@ export default {
       white-space: nowrap;
       text-overflow: ellipsis;
     }
+
     .van-multi-ellipsis--l2 {
       display: -webkit-box;
       overflow: hidden;
       text-overflow: ellipsis;
       -webkit-line-clamp: 2;
       -webkit-box-orient: vertical;
+
     }
 
     .hot-keep-group {
       .card-item {
         width: 33.33%;
+        overflow: hidden;
       }
     }
 

+ 2 - 1
jydocs-pc/src/views/Search.vue

@@ -184,7 +184,8 @@ export default {
       const { docFileSize: size, downTimes, uploadDate, docPageSize } = item
       const subInfoArr = []
       if (uploadDate !== undefined) {
-        subInfoArr.push(dateFormatter(uploadDate, 'yyyy/MM/dd'))
+        const data = uploadDate.replace(/-/g, '/')
+        subInfoArr.push(dateFormatter(data, 'yyyy/MM/dd'))
       }
       if (downTimes !== undefined) {
         subInfoArr.push(`${downTimes}次下载`)

+ 0 - 5
jydocs-pc/yarn.lock

@@ -6420,11 +6420,6 @@ pbkdf2@^3.0.3:
     safe-buffer "^5.0.1"
     sha.js "^2.4.8"
 
-pdfjs-dist@^2.1.266:
-  version "2.6.347"
-  resolved "https://registry.npm.taobao.org/pdfjs-dist/download/pdfjs-dist-2.6.347.tgz#f257ed66e83be900cd0fd28524a2187fb9e25cd5"
-  integrity sha1-8lftZug76QDND9KFJKIYf7niXNU=
-
 performance-now@^2.1.0:
   version "2.1.0"
   resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"