Commit 2e8865a4 by suwenbiao

更新

parent dc07bbc0
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,7 +11,10 @@
"dependencies": {
"axios": "^1.6.0",
"element-plus": "^2.4.1",
"vue": "^3.3.4"
"npm": "^10.2.1",
"vue": "^3.3.4",
"vue-router": "^4.2.5",
"vuex": "^4.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
......
import request from './request'; // 请替换成你实际使用的请求库
// 定义一个登录请求的函数
export const login = async (email:string, password:string) => {
try {
const result = await request({
method: 'POST',
url: `/auth/login?login=${email}&password=${password}`,
// 其他请求配置...
});
return result.data; // 返回请求成功时的数据
} catch (error) {
// 处理请求失败的逻辑
console.error('Error fetching data:', error);
throw error; // 将错误继续抛出,以便在组件中处理
}
};
\ No newline at end of file
......@@ -2,19 +2,19 @@
<script setup lang="ts">
import { ref } from 'vue'
// import request from '../api/request'
import { login } from '../api/login'
import request from '../api/request'
const data = ref('')
const fetchData = async () => {
try {
// 调用login函数,并传递登录名和密码
const result = await login('shi.jiuyan@163.com', '654321');
const result = await request<string>({
method: 'POST',
url: '/auth/login?login=shi.jiuyan@163.com&password=654321',
// 其他请求配置...
});
data.value = result.data; // 注意这里的修改
// 处理请求成功的逻辑
console.log('Login successful:', result);
// 这里你可以将数据保存到响应式的Vue数据中,或者进行其他操作
} catch (error) {
// 处理请求失败的逻辑
console.error('Error fetching data:', error);
......
import { createApp } from 'vue'
import './style.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
// import store from './store'
createApp(App).mount('#app')
const app = createApp(App)
// app.use(store)
app.use(router)
app.use(ElementPlus)
app.mount('#app')
\ No newline at end of file
......@@ -9,14 +9,6 @@ const routes: Array<RouteRecordRaw> = [
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
},
{
path: '/login',
name: 'about',
// route level code-splitting
......
......@@ -5,3 +5,4 @@ import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment