From f36d4a85992192f2162beb21224aefc77e4f341e Mon Sep 17 00:00:00 2001 From: cuiyouliang Date: Tue, 3 Jun 2025 14:42:48 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=BC=80=E5=8F=91ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.ts | 2 +- src/store/modules/mall.ts | 24 ++++++++---------------- src/utils/request.ts | 3 +-- vite.config.ts | 3 ++- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/permission.ts b/src/permission.ts index c63a81b..7c9cc89 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -20,7 +20,7 @@ const isWhiteList = (path: string) => { router.beforeEach(async (to, from, next) => { NProgress.start(); // 仅仅限本地无token调试时候,不做token校验 - /* next(); + /* next(); return;*/ if (getToken()) { to.meta.title && useSettingsStore().setTitle(to.meta.title as string); diff --git a/src/store/modules/mall.ts b/src/store/modules/mall.ts index d54feb3..a0e0908 100644 --- a/src/store/modules/mall.ts +++ b/src/store/modules/mall.ts @@ -1,47 +1,39 @@ import { defineStore } from 'pinia'; -import { reactive } from 'vue'; import { listPmsProductCategory } from '@/api/pms/productCategory'; import { allBrand } from '@/api/pms/brand'; import { areaSelect } from '@/api/system/common.js'; export const useMallStore = defineStore('mall', () => { - const state = reactive({ + const state = ref({ productCategories: [], brandList: [], - areaSelect: [], - aaaaaaa: 'store开发测试' + areaSelect: [] }); - const aaaaaaa = ref('store开发测试'); - const changeAAA = (info: any) => { - aaaaaaa.value = info; - }; const loadProductCategories = async (force: any = false) => { - if (!force && state.productCategories.length > 0) { + if (!force && state.value.productCategories.length > 0) { return Promise.resolve(); } return listPmsProductCategory({}).then((res: any) => { - state.productCategories = res; + state.value.productCategories = res; }); }; const loadAreaSelect = async (force: any = false) => { - if (!force && state.areaSelect.length > 0) { + if (!force && state.value.areaSelect.length > 0) { return Promise.resolve(); } return areaSelect({}).then((res) => { - state.areaSelect = res.data; + state.value.areaSelect = res.data; }); }; const loadBrandList = async (force: any = false) => { - if (!force && state.brandList.length > 0) { + if (!force && state.value.brandList.length > 0) { return Promise.resolve(); } return allBrand({}).then((res: any) => { - state.brandList = res; + state.value.brandList = res; }); }; return { - changeAAA, - aaaaaaa, state, loadProductCategories, loadAreaSelect, diff --git a/src/utils/request.ts b/src/utils/request.ts index b12f48f..c2c67ab 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -124,7 +124,6 @@ service.interceptors.response.use( if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { return res.data; } - return Promise.resolve(res.data); if (code === 401) { // prettier-ignore if (!isRelogin.show) { @@ -148,7 +147,7 @@ service.interceptors.response.use( }); } return Promise.reject('无效的会话,或者会话已过期,请重新登录。'); - } else if (code === HttpStatus.SERVER_ERROR) { + } else if (code === HttpStatus.SERVER_ERROR || code === HttpStatus.NOT_FOUND) { ElMessage({ message: msg, type: 'error' }); return Promise.reject(new Error(msg)); } else if (code === HttpStatus.WARN) { diff --git a/vite.config.ts b/vite.config.ts index eb8e1d2..a72d8e9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -24,7 +24,8 @@ export default defineConfig(({ mode, command }) => { open: true, proxy: { [env.VITE_APP_BASE_API]: { - target: 'http://192.168.1.250:8080', + // target: 'http://192.168.1.250:8080', + target: 'http://192.168.1.13:8080', changeOrigin: true, ws: true, rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), ''),