diff --git a/src/service/api/test.ts b/src/service/api/test.ts index 3690e33..9e9ab3c 100644 --- a/src/service/api/test.ts +++ b/src/service/api/test.ts @@ -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(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() { diff --git a/src/store/route.ts b/src/store/route.ts index 4c9beda..c433320 100644 --- a/src/store/route.ts +++ b/src/store/route.ts @@ -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 }, diff --git a/src/views/test/test1/index.vue b/src/views/plugin/fetch/index.vue similarity index 95% rename from src/views/test/test1/index.vue rename to src/views/plugin/fetch/index.vue index 6f31559..854f6fc 100644 --- a/src/views/test/test1/index.vue +++ b/src/views/plugin/fetch/index.vue @@ -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 - +
文件大小:{{ downloading.total }}B
已下载:{{ downloading.loaded }}B
diff --git a/vite.config.ts b/vite.config.ts index 1cdb67d..d150c6e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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'],