放弃vuex改用pinia (#872)

Co-authored-by: bypanghu <bypanghu@163.com>
This commit is contained in:
奇淼(piexlmax
2022-01-07 12:29:32 +08:00
committed by GitHub
co-authored by bypanghu
parent eca5967b4d
commit 727caf3f4f
60 changed files with 681 additions and 918 deletions
@@ -30,14 +30,13 @@
<script setup>
import SparkMD5 from 'spark-md5'
import axios from 'axios'
import {
findFile,
breakpointContinueFinish,
removeChunk,
breakpointContinue
} from '@/api/breakpoint'
import { computed, ref, watch } from 'vue'
import { ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
const file = ref(null)
@@ -101,7 +100,7 @@ const choseFile = async(e) => {
})
} else {
waitUpLoad.value = [] // 秒传则没有需要上传的切片
ElMessage.success("文件已秒传")
ElMessage.success('文件已秒传')
}
waitNum.value = waitUpLoad.value.length // 记录长度用于百分比展示
console.log(waitNum.value)
@@ -141,7 +140,7 @@ const sliceFile = () => {
})
}
watch(waitNum,()=>{percentage.value = Math.floor(((formDataList.value.length - waitNum.value) / formDataList.value.length) * 100)})
watch(waitNum, () => { percentage.value = Math.floor(((formDataList.value.length - waitNum.value) / formDataList.value.length) * 100) })
const upLoadFileSlice = async(item) => {
// 切片上传
@@ -164,7 +163,7 @@ const upLoadFileSlice = async(item) => {
fileMd5: fileMd5.value,
filePath: res.data.filePath,
}
ElMessage.success("上传成功")
ElMessage.success('上传成功')
await removeChunk(params)
}
}
+4 -5
View File
@@ -6,7 +6,7 @@
<el-upload
class="excel-btn"
:action="`${path}/excel/importExcel`"
:headers="{'x-token':token}"
:headers="{'x-token':userStore.token}"
:on-success="loadExcel"
:show-file-list="false"
>
@@ -40,10 +40,10 @@ export default {
</script>
<script setup>
import { useStore } from 'vuex'
import { useUserStore } from '@/pinia/modules/user'
import { exportExcel, loadExcelData, downloadTemplate } from '@/api/excel'
import { getMenuList } from '@/api/menu'
import { computed, ref } from 'vue'
import { ref } from 'vue'
const path = ref(import.meta.env.VITE_BASE_API)
const page = ref(1)
@@ -63,8 +63,7 @@ const getTableData = async(f = () => {}) => {
}
getTableData(getMenuList)
const store = useStore()
const token = computed(() => store.getters['user/token'])
const userStore = useUserStore()
const handleExcelExport = (fileName) => {
if (!fileName || typeof fileName !== 'string') {
+4 -1
View File
@@ -2,7 +2,7 @@
<div>
<router-view v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear">
<keep-alive :include="$store.getters['router/keepAliveRouters']">
<keep-alive :include="useRouterStore.keepAliveRouters">
<component :is="Component" />
</keep-alive>
</transition>
@@ -15,3 +15,6 @@ export default {
name: 'Example'
}
</script>
<script setup>
import { useRouterStore } from '@/pinia/modules/router'
</script>
+4 -6
View File
@@ -5,7 +5,7 @@
<el-upload
:action="`${path}/fileUploadAndDownload/upload`"
:before-upload="checkFile"
:headers="{ 'x-token': token }"
:headers="{ 'x-token': userStore.token }"
:on-error="uploadError"
:on-success="uploadSuccess"
:show-file-list="false"
@@ -67,20 +67,18 @@
</template>
<script setup>
import { useStore } from 'vuex'
import { getFileList, deleteFile } from '@/api/fileUploadAndDownload'
import { downloadImage } from '@/utils/downloadImg'
import { useUserStore } from '@/pinia/modules/user'
import CustomPic from '@/components/customPic/index.vue'
import UploadImage from '@/components/upload/image.vue'
import { formatDate } from '@/utils/format'
import { computed, ref } from 'vue'
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
const store = useStore()
const path = ref(import.meta.env.VITE_BASE_API)
const token = computed(() => store.getters['user/token'])
const userStore = useUserStore()
const imageUrl = ref('')