重要学API
This commit is contained in:
1 parent
0962f2f6ce
commit
a4f3f9e2b4
15 files changed
+1825
-7
No files matched your search
+3
-1
@@ -1,3 +1,5 @@
|
||||
<template>初始化项目</template>
|
||||
<template>
|
||||
<router-view></router-view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup></script>
|
||||
@@ -0,0 +1,18 @@
|
||||
// 引入axios组件
|
||||
import axios from "axios";
|
||||
import type {AxiosInstance} from "axios"
|
||||
/**
|
||||
* 指定常量 环境变量来定义自定义环境,指定环境变量
|
||||
* 指定环境变量前面加前缀名VITE_API不然不能读取
|
||||
*/
|
||||
const BASE_URL:string = import.meta.env.VITE_API_BASE_URL;
|
||||
|
||||
// 创建实例
|
||||
const instanse:AxiosInstance = axios.create({
|
||||
// 添加参数
|
||||
baseURL: BASE_URL, // 路径参数
|
||||
timeout: 60000 // 请求超时设置1分钟
|
||||
})
|
||||
|
||||
// 导出参数
|
||||
export default instanse
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as process from "process";
|
||||
import type {AxiosPromise} from "axios";
|
||||
import request from "@/api/request";
|
||||
import type { TokenRequest } from "@/api/types"
|
||||
|
||||
|
||||
const createToken = (tokenRequest:TokenRequest):Promise<AxiosPromise<string>> => {
|
||||
return request.post('/token', tokenRequest)
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
createToken, // 导出createToken接口
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
//创建模型
|
||||
export type TokenRequest = {
|
||||
username: string,
|
||||
password: string
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg id="457bf273-24a3-4fd8-a857-e9b918267d6a" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="698" height="698" viewBox="0 0 698 698"><defs><linearGradient id="b247946c-c62f-4d08-994a-4c3d64e1e98f" x1="349" y1="698" x2="349" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"/><stop offset="0.54" stop-color="gray" stop-opacity="0.12"/><stop offset="1" stop-color="gray" stop-opacity="0.1"/></linearGradient></defs><title>profile pic</title><g opacity="0.5"><circle cx="349" cy="349" r="349" fill="url(#b247946c-c62f-4d08-994a-4c3d64e1e98f)"/></g><circle cx="349.68" cy="346.77" r="341.64" fill="#f5f5f5"/><path d="M601,790.76a340,340,0,0,0,187.79-56.2c-12.59-68.8-60.5-72.72-60.5-72.72H464.09s-45.21,3.71-59.33,67A340.07,340.07,0,0,0,601,790.76Z" transform="translate(-251 -101)" fill="#38d39f"/><circle cx="346.37" cy="339.57" r="164.9" fill="#333"/><path d="M293.15,476.92H398.81a0,0,0,0,1,0,0v84.53A52.83,52.83,0,0,1,346,614.28h0a52.83,52.83,0,0,1-52.83-52.83V476.92a0,0,0,0,1,0,0Z" opacity="0.1"/><path d="M296.5,473h99a3.35,3.35,0,0,1,3.35,3.35v81.18A52.83,52.83,0,0,1,346,610.37h0a52.83,52.83,0,0,1-52.83-52.83V476.35A3.35,3.35,0,0,1,296.5,473Z" fill="#fdb797"/><path d="M544.34,617.82a152.07,152.07,0,0,0,105.66.29v-13H544.34Z" transform="translate(-251 -101)" opacity="0.1"/><circle cx="346.37" cy="372.44" r="151.45" fill="#fdb797"/><path d="M489.49,335.68S553.32,465.24,733.37,390l-41.92-65.73-74.31-26.67Z" transform="translate(-251 -101)" opacity="0.1"/><path d="M489.49,333.78s63.83,129.56,243.88,54.3l-41.92-65.73-74.31-26.67Z" transform="translate(-251 -101)" fill="#333"/><path d="M488.93,325a87.49,87.49,0,0,1,21.69-35.27c29.79-29.45,78.63-35.66,103.68-69.24,6,9.32,1.36,23.65-9,27.65,24-.16,51.81-2.26,65.38-22a44.89,44.89,0,0,1-7.57,47.4c21.27,1,44,15.4,45.34,36.65.92,14.16-8,27.56-19.59,35.68s-25.71,11.85-39.56,14.9C608.86,369.7,462.54,407.07,488.93,325Z" transform="translate(-251 -101)" fill="#333"/><ellipse cx="194.86" cy="372.3" rx="14.09" ry="26.42" fill="#fdb797"/><ellipse cx="497.8" cy="372.3" rx="14.09" ry="26.42" fill="#fdb797"/></svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg id="ae7ad495-543d-4c4b-9483-8059c5566fe6" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1009.54" height="839.64" viewBox="0 0 1009.54 839.64"><defs><linearGradient id="f9d7795c-47ab-4264-adf8-fc9a284cd87a" x1="491.14" y1="640.96" x2="698.09" y2="640.96" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"/><stop offset="0.54" stop-color="gray" stop-opacity="0.12"/><stop offset="1" stop-color="gray" stop-opacity="0.1"/></linearGradient></defs><title>personalization</title><path d="M681.78,141.58c-64.72-2.25-126.36-23.14-185.22-46S379.4,47.39,316.23,35.28c-40.63-7.79-87.1-8.89-119.83,12.89-31.51,21-41.69,57.15-47.16,90.73-4.12,25.26-6.54,51.85,4.74,75.49,7.84,16.42,21.74,30.22,31.36,45.95,33.47,54.72,9.81,122.2-26.45,175.63-17,25.07-36.75,49-49.88,75.66s-19.2,57.25-7.71,84.47c11.38,27,38.51,47.24,67.9,61.49,59.69,28.95,130,37.23,198.61,41.92,151.83,10.39,304.46,5.89,456.69,1.39,56.34-1.67,112.92-3.36,168.34-12.07,30.78-4.84,62.55-12.51,84.9-31.05,28.36-23.53,35.39-63.37,16.38-92.88-31.88-49.49-120-61.78-142.31-114.89-12.26-29.24.33-61.8,18.16-88.92,38.24-58.16,102.33-109.19,105.7-175.67,2.32-45.66-28.49-91.39-76.13-113-49.93-22.64-119.18-19.8-156,17.69C805.59,128.71,738.93,143.56,681.78,141.58Z" transform="translate(-95.23 -30.18)" fill="#38d39f" opacity="0.1"/><ellipse cx="483.49" cy="780.99" rx="303.97" ry="41.12" fill="#38d39f" opacity="0.1"/><path d="M428.24,688.75s21-3.36,33.6,11.48c0,0-9.24,7.28-29.12-2.8Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M426,688.42S412.6,705,419.17,723.27c0,0,10.92-4.37,12.11-26.63Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M414,661.31s8.4-15.4,42,6.16c0,0-4.48,10.36-19.32,9.52S417.87,669.43,414,661.31Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M411.79,660.2s-17.43-2-19.12,37.9c0,0,11.05,2.3,18.9-10.33S416.17,668.08,411.79,660.2Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M401.63,628.38s9.8-27.17,45.37-7.85c0,0-8.12,24.93-41.73,17.09Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M390.71,587.77s18.48-27.44,51.25-2c0,0-11.48,25.76-48.45,11.76Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M386.79,549.13s21.56-25.2,54,0c0,0-20.45,22.12-54,6.44Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M383.43,511.61s21.84-26.33,52.93-1.4c0,0-24.65,23.24-52.93,7.56Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M385.39,478.28s23-33.88,52.09-10.92c0,0-24.65,29.13-52.09,17.36Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M390.71,439.36s24.36-33.6,52.65-7.84c0,0-28.85,29.12-52.65,14Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M398.84,404.57s28.83-31.57,54-19c0,0-30.06,33.53-55.26,27.37Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M408.91,371.6s33.33-38.65,52.65-25.77c0,0-24.52,30-55,33.05Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M423.46,333.34s29.14-31.58,50.42-23.74c0,0-24.92,32.77-54.33,33.61Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M436.64,297.56s32.2-30.24,46.2-24.92c0,0-23.24,33.6-47.6,31.64Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M449.52,264.52s27.72-36.12,42.84-33.32c0,0-16.8,32.2-42.84,37Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M463.49,220s24.51-27.7,37.74-27.63c0,0-19.34,37-38.74,36.66Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M471.78,190.31l23.66-57.68s1.19,52.14-26.68,68.38Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M481.38,126.7s3.92-48.16,1.4-52.08c0,0,16.93,40-1.56,73.36Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M400.72,627.73s-24.55-15.21-40.43,22c0,0,21.84,14.5,43.31-12.51Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M389.93,586.22s-30.1-13.73-44.71,25.12c0,0,23.26,16,47.45-15.3Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M385.39,551.44s-21.56-25.2-54,0c0,0,20.44,22.12,54,6.44Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M382.7,511.61s-21.85-26.33-52.93-1.4c0,0,24.64,23.24,52.93,7.56Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M385.39,479.24s-15.32-37.95-48.62-21.63c0,0,18,33.66,47.27,27.93Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M392.64,439.17s-15.22-38.61-49-20.71c0,0,20.68,35.39,47.5,26.68Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M402.08,404.77s-6-42.34-33.95-46.13c0,0,5.93,44.64,30.22,53.75Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M409.63,371.67s-2.35-51-25.5-52.77c0,0,.78,38.7,22.89,60Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M425.87,331.88s-6.91-42.4-29-47.59c0,0,2.74,41.07,26.81,58Z" transform="translate(-95.23 -30.18)" fill="#38d39f"/><path d="M439.26,297.87s-.24-44.18-13.74-50.67c0,0-8.37,40,9.83,56.31Z" transform="translate(-95.23 -30.18)" fillLine truncated
|
||||
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 850 KiB |
+13
-1
@@ -1,4 +1,16 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
// 引入TDesign
|
||||
import TDesign from 'tdesign-vue-next';
|
||||
// 引入组件库的少量全局样式变量
|
||||
import 'tdesign-vue-next/dist/reset.css';
|
||||
import 'tdesign-vue-next/es/style/index.css';
|
||||
|
||||
createApp(App).mount('#app')
|
||||
// 引入路由
|
||||
import router from "@/views/router/Index";
|
||||
const app = createApp(App)
|
||||
// 挂载根实例
|
||||
app.use(router)
|
||||
// 挂载根实例
|
||||
app.use(TDesign)
|
||||
app.mount('#app')
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<div>控制台</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<img class="wave" src="../../assets/img/wave.png" alt=""/>
|
||||
<div class="container">
|
||||
<!--左边的背景图-->
|
||||
<div class="bg">
|
||||
<img src="../../assets/img/bg.svg" alt="">
|
||||
</div>
|
||||
<div class="login-container">
|
||||
<!--引入的卡片区域-->
|
||||
<t-card class="login-cart">
|
||||
<img class="avatar" src="../../assets/img/avatar.svg" alt="">
|
||||
<h2>Vue3-Admin</h2>
|
||||
<!--引入的表单区域-->
|
||||
<t-form ref="form" class="login-from" :data="loginFrom" :rules="rules" :colon="true" :label-width="0">
|
||||
<!--用户区域-->
|
||||
<t-form-item name="username">
|
||||
<t-input clearable v-model="loginFrom.username" placeholder="请输入账户名">
|
||||
<template #prefix-icon>
|
||||
<icon name="user"/>
|
||||
</template>
|
||||
</t-input>
|
||||
</t-form-item>
|
||||
<!--密码区域-->
|
||||
<t-form-item name="password">
|
||||
<t-input type="password" clearable placeholder="请输入密码">
|
||||
<template #prefix-icon>
|
||||
<icon name="lock-on"/>
|
||||
</template>
|
||||
</t-input>
|
||||
</t-form-item>
|
||||
<!--登录按钮-->
|
||||
<t-form-item>
|
||||
<t-button theme="primary" type="submit" block>登录</t-button>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
</t-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {Icon} from "tdesign-vue-next";
|
||||
import {reactive} from "vue";
|
||||
import type { TokenRequest } from "@/api/types"
|
||||
|
||||
|
||||
// 验证规则,内容区域为空的时候提示
|
||||
const rules = {
|
||||
username: [
|
||||
{required: true, message: '请输入账号...'},
|
||||
],
|
||||
password: [
|
||||
{required: true, message: '请输入密码...'},
|
||||
]
|
||||
}
|
||||
|
||||
//创建对象
|
||||
const loginFrom = reactive<TokenRequest>({
|
||||
username: '',
|
||||
password: '',
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
template {
|
||||
overflow: hidden;
|
||||
}
|
||||
// 左边的背景图的属性
|
||||
.wave {
|
||||
position: fixed;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
// 总体布局属性
|
||||
.container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-gap: 7rem;
|
||||
padding: 0 2rem;
|
||||
// bg 是左边的图片大小属性
|
||||
.bg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
// img 是左边的图片大小属性
|
||||
.bg img {
|
||||
width: 500px;
|
||||
}
|
||||
// login-container 是右边的所有内容的总属性
|
||||
.login-container {
|
||||
display: flex;
|
||||
width: 380px;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login-cart {
|
||||
width: 100%;
|
||||
// 网站名称的属性
|
||||
h2 {
|
||||
font-size: 2.5rem;
|
||||
margin: 25px 0;
|
||||
color: #333;
|
||||
}
|
||||
// 头像的属性
|
||||
.avatar {
|
||||
width: 100px;
|
||||
}
|
||||
// 输入内容 t-from 的属性
|
||||
.login-from {
|
||||
width: 100%;
|
||||
margin-top: 3.6rem;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,27 @@
|
||||
// 引入router的组件
|
||||
import type { RouteRecordRaw } from "vue-router";
|
||||
// 引入两个组件
|
||||
import LoginView from "@/views/login/Index.vue"
|
||||
import DashboardView from "@/views/dashboard/Index.vue"
|
||||
import {createRouter, createWebHashHistory} from "vue-router";
|
||||
|
||||
// 2. 定义一些路由
|
||||
// 每个路由都需要映射到一个组件。
|
||||
// 我们后面再讨论嵌套路由。
|
||||
const routes:Array<RouteRecordRaw> = [
|
||||
{ path:'/', name : 'dashboard', component : DashboardView },
|
||||
{ path:'/login', name : 'login', component : LoginView }
|
||||
]
|
||||
|
||||
// 3. 创建路由实例并传递 `routes` 配置
|
||||
// 你可以在这里输入更多的配置,但我们在这里
|
||||
// 暂时保持简单
|
||||
const router = createRouter({
|
||||
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
|
||||
history: createWebHashHistory(),
|
||||
strict: true, // 按照严模式匹配
|
||||
routes, // `routes: routes` 的缩写
|
||||
scrollBehavior : () => ({ left:0, top:0 }) //跳转页面之后回到顶部
|
||||
})
|
||||
|
||||
export default router // 导出路由
|
||||
Reference in new issue
Block a user