diff --git a/package.json b/package.json
index 924d0c3..ec6bdd3 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,8 @@
"dependencies": {
"axios": "^1.8.4",
"element-plus": "^2.9.8",
- "vue": "^3.5.13"
+ "vue": "^3.5.13",
+ "vue-router": "^4.5.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 17e407c..9ca12af 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -17,6 +17,9 @@ importers:
vue:
specifier: ^3.5.13
version: 3.5.13
+ vue-router:
+ specifier: ^4.5.0
+ version: 4.5.0(vue@3.5.13)
devDependencies:
'@vitejs/plugin-vue':
specifier: ^5.2.2
@@ -363,6 +366,9 @@ packages:
'@vue/compiler-ssr@3.5.13':
resolution: {integrity: sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==}
+ '@vue/devtools-api@6.6.4':
+ resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
+
'@vue/reactivity@3.5.13':
resolution: {integrity: sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==}
@@ -630,6 +636,11 @@ packages:
'@vue/composition-api':
optional: true
+ vue-router@4.5.0:
+ resolution: {integrity: sha512-HDuk+PuH5monfNuY+ct49mNmkCRK4xJAV9Ts4z9UFc4rzdDnxQLyCMGGc8pKhZhHTVzfanpNwB/lwqevcBwI4w==}
+ peerDependencies:
+ vue: ^3.2.0
+
vue@3.5.13:
resolution: {integrity: sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==}
peerDependencies:
@@ -854,6 +865,8 @@ snapshots:
'@vue/compiler-dom': 3.5.13
'@vue/shared': 3.5.13
+ '@vue/devtools-api@6.6.4': {}
+
'@vue/reactivity@3.5.13':
dependencies:
'@vue/shared': 3.5.13
@@ -1138,6 +1151,11 @@ snapshots:
dependencies:
vue: 3.5.13
+ vue-router@4.5.0(vue@3.5.13):
+ dependencies:
+ '@vue/devtools-api': 6.6.4
+ vue: 3.5.13
+
vue@3.5.13:
dependencies:
'@vue/compiler-dom': 3.5.13
diff --git a/src/App.vue b/src/App.vue
index 3a3c8f9..98240ae 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,44 +1,3 @@
-
-
-
-
-
-
- main
-
+
-
-
diff --git a/src/api/request.js b/src/api/request.js
index 37fb999..83b90da 100644
--- a/src/api/request.js
+++ b/src/api/request.js
@@ -27,15 +27,14 @@ service.interceptors.response.use(
response => {
const res = response.data;
// 假设统一应答数据结构中有一个 code 字段表示请求状态
- if (res.code !== 0) {
- console.log('请求失败:', res.message);
- return Promise.reject(new Error(res.message || 'Error'));
+ if (res.code !== 2) {
+ console.log('请求失败:', res);
+ return Promise.reject(new Error(res.msg || 'Error'));
} else {
return res.data;
}
},
error => {
- console.log('请求出错:', error.message);
return Promise.reject(error);
}
);
diff --git a/src/main.js b/src/main.js
index 05bfbb5..548b772 100644
--- a/src/main.js
+++ b/src/main.js
@@ -3,10 +3,12 @@ import './style.css'
import App from './App.vue'
import axios from 'axios'
import ElementPlus from 'element-plus'
+import router from './router'
import 'element-plus/dist/index.css'
const app=createApp(App)
+app.use(router)
app.use(ElementPlus)
app.config.globalProperties.$axios=axios
diff --git a/src/router/index.js b/src/router/index.js
new file mode 100644
index 0000000..f6ae5cd
--- /dev/null
+++ b/src/router/index.js
@@ -0,0 +1,22 @@
+import { createRouter, createWebHistory } from 'vue-router';
+
+const routes = [
+ {
+ path: '/',
+ name: 'Home',
+ component: ()=> import("../views/home.vue"),
+ },
+ {
+ path: '/about',
+ name: 'About',
+ component: ()=> import("../views/about.vue"),
+ }
+];
+
+const router = createRouter({
+ //history: createWebHashHistory(), http://localhost/#about
+ history: createWebHistory(), //http://localhost/about
+ routes
+});
+
+export default router;
\ No newline at end of file
diff --git a/src/views/about.vue b/src/views/about.vue
new file mode 100644
index 0000000..9d60fb2
--- /dev/null
+++ b/src/views/about.vue
@@ -0,0 +1,5 @@
+
+
+
\ No newline at end of file
diff --git a/src/views/home.vue b/src/views/home.vue
new file mode 100644
index 0000000..7f706f8
--- /dev/null
+++ b/src/views/home.vue
@@ -0,0 +1,37 @@
+
+
+
hello home
+
+
+ main
+
+
+
+
+
\ No newline at end of file