fix: modify fecth demo

This commit is contained in:
chansee97 2024-03-25 09:51:29 +08:00
parent a607b63950
commit 1733842331
4 changed files with 13 additions and 14 deletions

View File

@ -46,8 +46,8 @@ export function dictData() {
})
}
/* 模拟获取二进制文件 */
export function getBlob() {
const methodInstance = blankInstance.Get('https://images.unsplash.com/photo-1663529628961-80aa6ebcd157?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=764&q=80')
export function getBlob(url: string) {
const methodInstance = blankInstance.Get<Blob>(url)
methodInstance.meta = {
// 标识为bolb数据
isBlob: true,
@ -57,11 +57,10 @@ export function getBlob() {
/* 带进度的下载文件 */
export function downloadFile(url: string) {
const methodInstance = blankInstance.Get(url, {
return blankInstance.Get(url, {
// 开启下载进度
enableDownload: true,
})
return methodInstance
}
/* 测试状态码500失败 */
export function FailedRequest() {

View File

@ -177,20 +177,22 @@ export const useRouteStore = defineStore('route-store', {
if (!data)
return
this.rowRoutes = data
return data
}
else {
this.rowRoutes = staticRoutes
return staticRoutes
}
},
async initAuthRoute() {
this.isInitAuthRoute = false
// 初始化路由信息
await this.initRouteInfo()
const rowRoutes = await this.initRouteInfo()
this.rowRoutes = rowRoutes
// 生成真实路由并插入
this.createRoutes(this.rowRoutes)
this.createRoutes(rowRoutes)
// 生成侧边菜单
this.createMenus(this.rowRoutes)
this.createMenus(rowRoutes)
this.isInitAuthRoute = true
},

View File

@ -114,8 +114,9 @@ function getDictData() {
})
}
//
const imagePath = ref('https://images.unsplash.com/photo-1663529628961-80aa6ebcd157?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=764&q=80')
function getBlobFile() {
getBlob().then((res) => {
getBlob(imagePath.value).then((res) => {
msg.value = 'this is blob!'
const link = URL.createObjectURL(res)
const eleLink = document.createElement('a')
@ -192,7 +193,7 @@ const downloadProcess = computed(() => {
click
</n-button>
</n-descriptions-item>
<n-descriptions-item label="带进度的下载文件" span="3">
<n-descriptions-item label="带进度的下载文件" :span="3">
<n-input v-model:value="downloadPath" />
<div>文件大小{{ downloading.total }}B</div>
<div>已下载{{ downloading.loaded }}B</div>

View File

@ -1,11 +1,10 @@
import { resolve } from 'node:path'
import type { ConfigEnv } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import { createVitePlugins } from './build/plugins'
import { createViteProxy, proxyConfig } from './build/proxy'
// https://vitejs.dev/config/
export default defineConfig(({ mode }: ConfigEnv) => {
export default defineConfig(({ mode }) => {
// 在开发环境下 command 的值为 serve 生产环境下为 build
// 根据当前工作目录中的 `mode` 加载 .env 文件
@ -29,8 +28,6 @@ export default defineConfig(({ mode }: ConfigEnv) => {
build: {
target: 'esnext',
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
sourcemap: false, // 构建后是否生成 source map 文件
assetsInlineLimit: 4096, // 4kb内资源使用base64
},
optimizeDeps: {
include: ['echarts', 'md-editor-v3', '@tinymce/tinymce-vue'],