From 6320b62b5844a5db051f06f2dcda29a0a5ec0fb6 Mon Sep 17 00:00:00 2001 From: chenkainan Date: Tue, 19 Aug 2025 09:29:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 36 ++--- src/views/Login.vue | 351 ++++++++++++++++++++++++++++++++++++++++ src/views/Register.vue | 356 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 725 insertions(+), 18 deletions(-) create mode 100644 src/views/Login.vue create mode 100644 src/views/Register.vue diff --git a/src/router/index.js b/src/router/index.js index 89922a4..562006c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -131,24 +131,24 @@ const router = new Router({ // }, // component: () => import('@/views/OrderDetail.vue') // }, - // { - // path: '/login', - // name: 'Login', - // meta: { - // title: '登录 - 精品商城', - // keepAlive: false - // }, - // component: () => import('@/views/Login.vue') - // }, - // { - // path: '/register', - // name: 'Register', - // meta: { - // title: '注册 - 精品商城', - // keepAlive: false - // }, - // component: () => import('@/views/Register.vue') - // }, + { + path: '/login', + name: 'Login', + meta: { + title: '登录 - 精品商城', + keepAlive: false + }, + component: () => import('@/views/Login.vue') + }, + { + path: '/register', + name: 'Register', + meta: { + title: '注册 - 精品商城', + keepAlive: false + }, + component: () => import('@/views/Register.vue') + }, // { // path: '*', // name: 'NotFound', diff --git a/src/views/Login.vue b/src/views/Login.vue new file mode 100644 index 0000000..1bb4003 --- /dev/null +++ b/src/views/Login.vue @@ -0,0 +1,351 @@ + + + + + \ No newline at end of file diff --git a/src/views/Register.vue b/src/views/Register.vue new file mode 100644 index 0000000..6415bf7 --- /dev/null +++ b/src/views/Register.vue @@ -0,0 +1,356 @@ + + + + + \ No newline at end of file From 794884fc66867a1eabd4b2096d26020e1929fb18 Mon Sep 17 00:00:00 2001 From: chenkainan Date: Tue, 19 Aug 2025 09:55:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B0=81=E8=A3=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 5 ++ .env.production | 5 ++ src/libs/axios.js | 6 +- src/views/Home.vue | 207 ++++++++++++++++++++++---------------------- src/views/Index.vue | 20 +++++ 5 files changed, 137 insertions(+), 106 deletions(-) create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..73c4a95 --- /dev/null +++ b/.env.development @@ -0,0 +1,5 @@ +NODE_ENV='development' +# 请求域名前缀 +VUE_APP_URL='https://swsz.api.js-dyyj.com' +# 打包后输出目录 +VUE_APP_OUTPUTDIR='dist_dev' \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..8808c55 --- /dev/null +++ b/.env.production @@ -0,0 +1,5 @@ +NODE_ENV='production' +# 请求域名前缀 +VUE_APP_URL='https://api.sutenong.com' +# 打包后输出目录 +VUE_APP_OUTPUTDIR='dist' \ No newline at end of file diff --git a/src/libs/axios.js b/src/libs/axios.js index 728d487..d7fc7af 100644 --- a/src/libs/axios.js +++ b/src/libs/axios.js @@ -17,7 +17,7 @@ http.interceptors.request.use((config) => { config.baseURL = process.env.VUE_APP_URL; } - const token = store.state.user.userInfo.token; + const token = store.state.user?.userInfo?.token || ''; config.headers['token'] = token config.headers['Content-Type'] = 'application/json;charset=UTF-8'; @@ -84,7 +84,7 @@ http.interceptors.response.use(response => { }); // 请求方法挂载 -Vue.prototype.get = (params, url, loading = true) => { +Vue.prototype.get = (params, url, loading = false) => { return new Promise((resolve, reject) => { http.get(url, { params, @@ -99,7 +99,7 @@ Vue.prototype.get = (params, url, loading = true) => { }) } -Vue.prototype.post = (data, url, loading = true) => { +Vue.prototype.post = (data, url, loading = false) => { return new Promise((resolve, reject) => { http.post(url, data, { loading // 传递加载状态参数 diff --git a/src/views/Home.vue b/src/views/Home.vue index d0d2430..906682c 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,27 +1,27 @@