diff --git a/bun.lockb b/bun.lockb index 9ab9cbf..9d9d120 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index eac03cc..19d4d0e 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "type-check": "vue-tsc --build --force" }, "dependencies": { + "@element-plus/icons-vue": "^2.3.1", "axios": "^1.7.7", "element-plus": "^2.8.2", "pinia": "^2.1.7", diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..8f9dd56 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,15 @@ +/** + * api 管理 + */ + +import request from "@/utils/request" + +export default { + login(params: any) { + return request({ + url: '/user/login', + method: 'post', + data: params + }) + } +} \ No newline at end of file diff --git a/src/assets/base.css b/src/assets/base.css deleted file mode 100644 index 8816868..0000000 --- a/src/assets/base.css +++ /dev/null @@ -1,86 +0,0 @@ -/* color palette from */ -:root { - --vt-c-white: #ffffff; - --vt-c-white-soft: #f8f8f8; - --vt-c-white-mute: #f2f2f2; - - --vt-c-black: #181818; - --vt-c-black-soft: #222222; - --vt-c-black-mute: #282828; - - --vt-c-indigo: #2c3e50; - - --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); - --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); - --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); - --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); - - --vt-c-text-light-1: var(--vt-c-indigo); - --vt-c-text-light-2: rgba(60, 60, 60, 0.66); - --vt-c-text-dark-1: var(--vt-c-white); - --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); -} - -/* semantic color variables for this project */ -:root { - --color-background: var(--vt-c-white); - --color-background-soft: var(--vt-c-white-soft); - --color-background-mute: var(--vt-c-white-mute); - - --color-border: var(--vt-c-divider-light-2); - --color-border-hover: var(--vt-c-divider-light-1); - - --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-1); - - --section-gap: 160px; -} - -@media (prefers-color-scheme: dark) { - :root { - --color-background: var(--vt-c-black); - --color-background-soft: var(--vt-c-black-soft); - --color-background-mute: var(--vt-c-black-mute); - - --color-border: var(--vt-c-divider-dark-2); - --color-border-hover: var(--vt-c-divider-dark-1); - - --color-heading: var(--vt-c-text-dark-1); - --color-text: var(--vt-c-text-dark-2); - } -} - -*, -*::before, -*::after { - box-sizing: border-box; - margin: 0; - font-weight: normal; -} - -body { - min-height: 100vh; - color: var(--color-text); - background: var(--color-background); - transition: - color 0.5s, - background-color 0.5s; - line-height: 1.6; - font-family: - Inter, - -apple-system, - BlinkMacSystemFont, - 'Segoe UI', - Roboto, - Oxygen, - Ubuntu, - Cantarell, - 'Fira Sans', - 'Droid Sans', - 'Helvetica Neue', - sans-serif; - font-size: 15px; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} diff --git a/src/assets/main.css b/src/assets/main.css deleted file mode 100644 index 68e83ff..0000000 --- a/src/assets/main.css +++ /dev/null @@ -1,34 +0,0 @@ -@import './base.css'; - -#app { - margin: 0 auto; - padding: 2rem; - font-weight: normal; -} - -a, -.green { - text-decoration: none; - color: hsla(160, 100%, 37%, 1); - transition: 0.4s; - padding: 3px; -} - -@media (hover: hover) { - a:hover { - background-color: hsla(160, 100%, 37%, 0.2); - } -} - -@media (min-width: 1024px) { - body { - display: flex; - place-items: center; - } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } -} \ No newline at end of file diff --git a/src/components/Login/LoginA.vue b/src/components/Login/LoginA.vue index 1189530..4e4be9c 100644 --- a/src/components/Login/LoginA.vue +++ b/src/components/Login/LoginA.vue @@ -1,15 +1,101 @@ - diff --git a/src/config/index.ts b/src/config/index.ts index b08497a..90aacad 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -5,8 +5,8 @@ const env = import.meta.env.MODE == "development" ? 'dev' : 'prod' const EnvConfig = { dev: { - baseApi: '/', - mockApi: 'https://mock.presstime.cn/mock/668987cbcb2f4f1158f47e0e/manager-fe', + baseApi: 'http://localhost:9000/api/v1', + mockApi: 'http://localhost:9000/api/v1', }, test: { baseApi: '//test.demo/api', diff --git a/src/main.ts b/src/main.ts index e2c12a5..59baaf0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,15 +1,18 @@ // 程序入口 +import api from "@/api" +import App from '@/App.vue' +import router from '@/router' import storage from '@/stores/storage' import request from '@/utils/request' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import { createPinia } from 'pinia' import { createApp } from 'vue' -import App from './App.vue' -import router from './router' + const app = createApp(App) app.config.globalProperties.$request = request +app.config.globalProperties.$api = api app.config.globalProperties.$storage = storage app.use(ElementPlus) diff --git a/src/router/index.ts b/src/router/index.ts index 492a212..e93a3f6 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,11 +1,11 @@ // index.js - router +import LoginA from "@/components/Login/LoginA.vue" import storage from "@/stores/storage" import useColorLogOutPut from "@/utils/color_log" import About from "@/views/About.vue" import ApiPage from '@/views/ApiPage.vue' import Base from "@/views/Base.vue" import Home from "@/views/Home.vue" -import Login from "@/views/Login.vue" import Welcome from "@/views/Welcome.vue" import { createRouter, createWebHashHistory } from "vue-router" @@ -34,7 +34,7 @@ const routes = [ { name: 'Login', path: '/Login', - component: Login, + component: LoginA, meta: { title: "登陆页^_^" } diff --git a/src/utils/request.ts b/src/utils/request.ts index 2e0533f..55a542f 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,10 +1,10 @@ -import config from "@/config" -import router from "@/router" -import axios from "axios" -import { ElMessage } from "element-plus" +import config from '@/config' +import router from '@/router' +import axios from 'axios' +import { ElMessage } from 'element-plus' -const TOKEN_ERROR = "Token 已过期" -const NETWORK_ERROR = "网络异常" +const TOKEN_ERROR = 'Token 已过期' +const NETWORK_ERROR = '网络异常' const service = axios.create({ baseURL: config.baseApi, @@ -16,7 +16,7 @@ service.interceptors.request.use((req: any) => { const headers = req.headers if (!headers.Authorization) { - headers.Authorization = "bear fromsko" + headers.Authorization = 'bear fromsko' } return req }) @@ -40,39 +40,39 @@ service.interceptors.response.use((res: any) => { }) interface RequestOptions { - method?: string; - params?: any; - data?: any; - url: string; + method?: string + mock?: boolean + params?: any + data?: any + url: string } function request(options: RequestOptions): any { - options.method = options.method || 'get'; + options.method = options.method || 'get' if (options.method.toLowerCase() === 'get') { - options.params = options.data; + options.params = options.data } - if (config.env === "prod") { - service.defaults.baseURL = config.baseApi; + if (config.env === 'prod') { + service.defaults.baseURL = config.baseApi } else { - service.defaults.baseURL = config.mock ? config.mockApi : config.baseApi; + service.defaults.baseURL = config.mock ? config.mockApi : config.baseApi } - return service(options); + return service(options) } ['get', 'post', 'delete', 'put'].forEach((item) => { // 使用 as any 来避免类型检查错误 - (request as any)[item] = (url: string, data: any, options: any) => { + ; (request as any)[item] = (url: string, data: any, options: any) => { return request({ url, data, method: item, - ...options - }); - }; -}); + ...options, + }) + } +}) - -export default request \ No newline at end of file +export default request diff --git a/src/views/Home.vue b/src/views/Home.vue index 3bf4545..437ff83 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,69 +1,69 @@ diff --git a/vite.config.ts b/vite.config.ts index 5c45e1d..cbec69b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,7 @@ import { fileURLToPath, URL } from 'node:url' -import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +import { defineConfig } from 'vite' // https://vitejs.dev/config/ export default defineConfig({ @@ -12,5 +12,8 @@ export default defineConfig({ alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } + }, + server: { + ws: false } })