소스 검색

文物列表scroll行为优化

任一存 2 년 전
부모
커밋
e021103f96
3개의 변경된 파일23개의 추가작업 그리고 20개의 파일을 삭제
  1. 3 0
      src/store/index.js
  2. 1 0
      src/views/RelicList.vue
  3. 19 20
      src/views/UnitList.vue

+ 3 - 0
src/store/index.js

@@ -13,6 +13,9 @@ export default createStore({
     },
     },
     recordRelicListScrollValue(state, value) {
     recordRelicListScrollValue(state, value) {
       state.relicListScrollValue = value
       state.relicListScrollValue = value
+    },
+    resetRelicListScrollValue(state) {
+      state.relicListScrollValue = 0
     }
     }
   },
   },
   actions: {
   actions: {

+ 1 - 0
src/views/RelicList.vue

@@ -97,6 +97,7 @@ onMounted(() => {
 })
 })
 
 
 function onClickTabItem(idx) {
 function onClickTabItem(idx) {
+  relicListEl.value.scrollLeft = 0
   router.push({
   router.push({
     name: route.name,
     name: route.name,
     query: {
     query: {

+ 19 - 20
src/views/UnitList.vue

@@ -59,29 +59,28 @@
   </div>
   </div>
 </template>
 </template>
 
 
-<script>
-import { mapState } from "vuex"
+<script setup>
 import { numberToWords } from "pixiu-number-toolkit"
 import { numberToWords } from "pixiu-number-toolkit"
+import { computed, ref, onMounted } from "vue"
+import { useStore } from "vuex"
+const {
+  windowSizeInCssForRef,
+  windowSizeWhenDesignForRef,
+} = useSizeAdapt()
 
 
-export default {
-  data() {
-    return {
-      isExpand: false,
-    }
-  },
-  computed: {
-    ...mapState([
-      'data'
-    ])
-  },
-  mounted() {
-  },
-  methods: {
-    int2zh(idx) {
-      return numberToWords(idx, "zh")
-    }
-  },
+const store = useStore()
+
+const data = computed(() => {
+  return store.state.data
+})
+
+function int2zh(idx) {
+  return numberToWords(idx, "zh")
 }
 }
+
+onMounted(() => {
+  store.commit('resetRelicListScrollValue')
+})
 </script>
 </script>
 
 
 <style lang="less" scoped>
 <style lang="less" scoped>