diff --git a/.env b/.env index ba70bbc..a720f73 100644 --- a/.env +++ b/.env @@ -2,29 +2,27 @@ # 应用配置 # ===================================================================================== # 网站标题 -VITE_APP_TITLE = 绝弹管理系统 +VITE_TITLE = 绝弹管理系统 # 网站副标题 -VITE_APP_SUBTITLE = 快速开发web应用的模板工具 -# Axios基本URL -VITE_APP_API_BASE_URL = /api +VITE_SUBTITLE = 快速开发web应用的模板工具 +# API接口前缀 +VITE_API_PREFIX = http://127.0.0.1:3030/ +# API文档地址 备注:需为符合 OPENAPI 规范的json文件 +VITE_API_SWAGGER = http://127.0.0.1:3030/openapi.json # ===================================================================================== # 开发设置 # ===================================================================================== -# API接口地址(开发环境) -VITE_API_BASE_URL = http://127.0.0.1:3030 # API代理地址(开发环境) VITE_API_PROXY_URL = /api -# API文档地址(开发环境) 备注:需为openapi规范的json文件 -VITE_API_DOCS_URL = http://127.0.0.1:3030/openapi.json # 端口号(开发环境) -VITE_DEV_PORT = 3020 +VITE_PORT = 3020 # 主机地址(开发环境) -VITE_DEV_HOST = 0.0.0.0 +VITE_HOST = 0.0.0.0 # ===================================================================================== # 构建设置 # ===================================================================================== # 构建时加载的文件后缀. # 例如:设置为todo则会首先尝试加载index.todo.vue文件,不存在时再加载index.vue文件 -VITE_BUILD_EXTENSION = todo \ No newline at end of file +VITE_EXTENSION = todo \ No newline at end of file diff --git a/index.html b/index.html index f3c2f20..205d54a 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - %VITE_APP_TITLE% - %VITE_APP_SUBTITLE% + %VITE_TITLE% - %VITE_SUBTITLE%
@@ -51,7 +51,7 @@
loading -

欢迎访问%VITE_APP_TITLE%

+

欢迎访问%VITE_TITLE%

正在加载中, 请稍后...
diff --git a/package.json b/package.json index d0e8a9c..bd78322 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "nprogress": "^0.2.0", "numeral": "^2.0.6", "pinia": "^2.0.33", + "pinia-plugin-persistedstate": "^3.2.0", "plop": "^3.1.2", "release-it": "^15.10.1", "swagger-typescript-api": "^12.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f08aae..676a0d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,6 +46,9 @@ devDependencies: pinia: specifier: ^2.0.33 version: 2.1.4(typescript@4.9.5)(vue@3.3.4) + pinia-plugin-persistedstate: + specifier: ^3.2.0 + version: 3.2.0(pinia@2.1.4) plop: specifier: ^3.1.2 version: 3.1.2 @@ -5833,6 +5836,14 @@ packages: dev: true optional: true + /pinia-plugin-persistedstate@3.2.0(pinia@2.1.4): + resolution: {integrity: sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==} + peerDependencies: + pinia: ^2.0.0 + dependencies: + pinia: 2.1.4(typescript@4.9.5)(vue@3.3.4) + dev: true + /pinia@2.1.4(typescript@4.9.5)(vue@3.3.4): resolution: {integrity: sha512-vYlnDu+Y/FXxv1ABo1vhjC+IbqvzUdiUC3sfDRrRyY2CQSrqqaa+iiHmqtARFxJVqWQMCJfXx1PBvFs9aJVLXQ==} peerDependencies: diff --git a/scripts/openapi/README.md b/scripts/openapi/README.md deleted file mode 100644 index 19ac69b..0000000 --- a/scripts/openapi/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## 修改 - -route-docs.ejs -- 移除 `@description` 关键字 \ No newline at end of file diff --git a/scripts/openapi/index.ts b/scripts/openapi/index.ts index 77422e0..b43993b 100644 --- a/scripts/openapi/index.ts +++ b/scripts/openapi/index.ts @@ -8,17 +8,17 @@ const env = loadEnv("development", process.cwd()); const run = async () => { const output = await generateApi({ - url: env.VITE_API_DOCS_URL, + url: env.VITE_API_SWAGGER, templates: path.resolve(__dirname, "./template"), output: path.resolve(process.cwd(), "src/api/service"), - name: "index.ts", + name: "Api.ts", singleHttpClient: false, httpClientType: "axios", unwrapResponseData: false, moduleNameIndex: 1, moduleNameFirstTag: true, cleanOutput: true, - // generateRouteTypes: true, + generateRouteTypes: true, extractRequestParams: true, modular: false, prettier: { @@ -61,3 +61,11 @@ const run = async () => { }; run(); + + +/** + * 模板修改备注: + * + * route-docs.ejs + * - 移除 `@description` 关键字 + */ \ No newline at end of file diff --git a/scripts/release/index.cjs b/scripts/release/index.cjs index 59a22a1..8e3987b 100644 --- a/scripts/release/index.cjs +++ b/scripts/release/index.cjs @@ -57,7 +57,6 @@ module.exports = { return order.indexOf(a.title) - order.indexOf(b.title); }, commitPartial: loadTemplate("commit"), - // headerPartial: loadTemplate('header'), mainTemplate: loadTemplate("main"), }, }, diff --git a/scripts/plop/plopfile.js b/scripts/template/plopfile.js similarity index 100% rename from scripts/plop/plopfile.js rename to scripts/template/plopfile.js diff --git a/scripts/plop/template-page.hbs b/scripts/template/template-page.hbs similarity index 100% rename from scripts/plop/template-page.hbs rename to scripts/template/template-page.hbs diff --git a/scripts/vite/plugin.ts b/scripts/vite/plugin.ts index cc957f2..f4399ae 100644 --- a/scripts/vite/plugin.ts +++ b/scripts/vite/plugin.ts @@ -8,13 +8,13 @@ import pkg from "../../package.json"; * @description 内容:APPTIFY */ const LOGO = ` - ________ ______ ______ _________ ________ ______ __ __ -/_______/\\\\ /_____/\\\\ /_____/\\\\ /________/\\\\/_______/\\\\/_____/\\\\ /_/\\\\/_/\\\\ -\\\\::: _ \\\\ \\\\\\\\:::_ \\\\ \\\\\\\\:::_ \\\\ \\\\\\\\__.::.__\\\\/\\\\__.::._\\\\/\\\\::::_\\\\/_\\\\ \\\\ \\\\ \\\\ \\\\ - \\\\::(_) \\\\ \\\\\\\\:(_) \\\\ \\\\\\\\:(_) \\\\ \\\\ \\\\::\\\\ \\\\ \\\\::\\\\ \\\\ \\\\:\\\\/___/\\\\\\\\:\\\\_\\\\ \\\\ \\\\ - \\\\:: __ \\\\ \\\\\\\\: ___\\\\/ \\\\: ___\\\\/ \\\\::\\\\ \\\\ _\\\\::\\\\ \\\\__\\\\:::._\\\\/ \\\\::::_\\\\/ - \\\\:.\\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\::\\\\ \\\\ /__\\\\::\\\\__/\\\\\\\\:\\\\ \\\\ \\\\::\\\\ \\\\ - \\\\__\\\\/\\\\__\\\\/ \\\\_\\\\/ \\\\_\\\\/ \\\\__\\\\/ \\\\________\\\\/ \\\\_\\\\/ \\\\__\\\\/ + ________ ______ ______ _________ ________ ______ __ __ +/_______/\\\\ /_____/\\\\ /_____/\\\\ /________/\\\\/_______/\\\\/_____/\\\\ /_/\\\\/_/\\\\ +\\\\::: _ \\\\ \\\\\\\\:::_ \\\\ \\\\\\\\:::_ \\\\ \\\\\\\\__.::.__\\\\/\\\\__.::._\\\\/\\\\::::_\\\\/_\\\\ \\\\ \\\\ \\\\ \\\\ + \\\\::(_) \\\\ \\\\\\\\:(_) \\\\ \\\\\\\\:(_) \\\\ \\\\ \\\\::\\\\ \\\\ \\\\::\\\\ \\\\ \\\\:\\\\/___/\\\\\\\\:\\\\_\\\\ \\\\ \\\\ + \\\\:: __ \\\\ \\\\\\\\: ___\\\\/ \\\\: ___\\\\/ \\\\::\\\\ \\\\ _\\\\::\\\\ \\\\__\\\\:::._\\\\/ \\\\::::_\\\\/ + \\\\:.\\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\::\\\\ \\\\ /__\\\\::\\\\__/\\\\\\\\:\\\\ \\\\ \\\\::\\\\ \\\\ + \\\\__\\\\/\\\\__\\\\/ \\\\_\\\\/ \\\\_\\\\/ \\\\__\\\\/ \\\\________\\\\/ \\\\_\\\\/ \\\\__\\\\/ `; /** @@ -68,7 +68,7 @@ export default function plugin(): Plugin { configResolved(resolvedConfig) { config = resolvedConfig; const defaultExt = config.mode === "development" ? "dev" : "prod"; - extension = config.env.VITE_BUILD_EXTENTION || defaultExt; + extension = config.env.VITE_EXTENTION || defaultExt; }, async transformIndexHtml(html) { diff --git a/src/api/instance/useRequest.ts b/src/api/helper/useRequest.ts similarity index 100% rename from src/api/instance/useRequest.ts rename to src/api/helper/useRequest.ts diff --git a/src/api/index.ts b/src/api/index.ts index 584c217..2335ca5 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,2 +1,3 @@ -export * from "./instance"; -export * from "./service"; +export * from "./instance/api"; +export * from "./service/Api"; +export * from "./helper/useRequest"; diff --git a/src/api/instance/instance.ts b/src/api/instance/api.ts similarity index 59% rename from src/api/instance/instance.ts rename to src/api/instance/api.ts index d7825f3..f47f45e 100644 --- a/src/api/instance/instance.ts +++ b/src/api/instance/api.ts @@ -1,34 +1,15 @@ -import { Api } from "../service"; +import { Api } from "../service/Api"; import { toast, IToastOptions } from "@/components"; import { useUserStore, store } from "@/store"; const userStore = useUserStore(store); /** - * 自定义扩展, 例如添加额外的请求函数 - */ -class Service extends Api { - github = { - /** - * 获取当前仓库信息 - */ - getRepoInfo: async () => { - const info: Record = await this.request({ - baseURL: "https://api.github.com", - path: "/repos/juetan/apptify-admin", - method: "GET", - }); - return info; - }, - }; -} - -/** - * api实例 + * API 接口实例 * @see src/api/instance/instance.ts */ -const api = new Service({ - baseURL: import.meta.env.VITE_API_BASE_URL, +export const api = new Api({ + baseURL: import.meta.env.VITE_API_PREFIX, }); /** @@ -42,19 +23,17 @@ api.instance.interceptors.request.use( if (config.toast) { let options: IToastOptions = {}; if (typeof config.toast === "string") { - options = { - message: config.toast, - }; + options = { message: config.toast }; } if (typeof config.toast === "object") { options = config.toast; } - config._closeToast = toast(options); + config.closeToast = toast(options); } return config; }, (error) => { - error.config?._closeToast?.(); + error.config?.closeToast?.(); return Promise.reject(error); } ); @@ -64,14 +43,14 @@ api.instance.interceptors.request.use( */ api.instance.interceptors.response.use( (res) => { - res.config?._closeToast?.(); + res.config.closeToast?.(); if (res.data?.code && res.data.code !== 2000) { return Promise.reject(res); } return res; }, (error) => { - error.config?._closeToast?.(); + error.config.closeToast?.(); if (error.request) { console.log("request error", error.request); } @@ -81,5 +60,3 @@ api.instance.interceptors.response.use( return Promise.reject(error); } ); - -export { api }; diff --git a/src/api/instance/axios.d.ts b/src/api/instance/axios.d.ts index 572edde..2c76af7 100644 --- a/src/api/instance/axios.d.ts +++ b/src/api/instance/axios.d.ts @@ -4,14 +4,14 @@ import { IToastOptions } from "@/components"; declare module "axios" { interface AxiosRequestConfig { /** - * toast config + * 请求弹窗配置 * @default false */ toast?: boolean | string | IToastOptions; /** - * close toast(internal) + * 关闭弹窗 * @private */ - _closeToast?: () => void; + closeToast?: () => void; } } diff --git a/src/api/instance/index.ts b/src/api/instance/index.ts deleted file mode 100644 index 61412d3..0000000 --- a/src/api/instance/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./instance"; -export * from "./useRequest"; - diff --git a/src/api/service/index.ts b/src/api/service/Api.ts similarity index 50% rename from src/api/service/index.ts rename to src/api/service/Api.ts index 52bdd12..d12429f 100644 --- a/src/api/service/index.ts +++ b/src/api/service/Api.ts @@ -63,8 +63,7 @@ export interface User { * @example "example@mail.com" */ email: string; - /** 用户角色 */ - roles: Role[]; + roleIds: number[]; } export interface Role { @@ -164,6 +163,40 @@ export interface AuthUserDto { password: string; } +export interface LoginedUserVo { + /** + * 访问令牌 + * @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjIsInVzZXJuYW1lIjoianVldGFuIiwiaWF0IjoxNjkxMTM5MjI3LCJleHAiOjE2OTExOTkyMjd9.6z7f-xfsHABbsyg401o2boKeqNQ1epPDYfEdavIcfYc" + */ + token: string; + /** + * 登录账号 + * @example "juetan" + */ + username: string; + /** + * 用户昵称 + * @example "绝弹" + */ + nickname: string; + /** + * 用户介绍 + * @example "这个人很懒, 什么也没有留下!" + */ + description: string; + /** + * 用户头像(URL) + * @example "./assets/222421415123.png " + */ + avatar: string; + /** + * 用户邮箱 + * @example "example@mail.com" + */ + email: string; + roleIds: number[]; +} + export interface CreateRoleDto { name: string; slug: string; @@ -179,14 +212,32 @@ export interface UpdateRoleDto { } export interface CreatePermissionDto { + /** + * 权限名称 + * @example "权限名称" + */ name: string; + /** + * 权限标识 + * @example "permission:permission" + */ slug: string; - description: string; + /** 权限描述 */ + description?: string; } export interface UpdatePermissionDto { + /** + * 权限名称 + * @example "权限名称" + */ name?: string; + /** + * 权限标识 + * @example "permission:permission" + */ slug?: string; + /** 权限描述 */ description?: string; } @@ -195,7 +246,47 @@ export interface CreateUploadDto { file: File; } -export type CreatePostDto = object; +export interface Upload { + /** + * 文件名 + * @example "xxx.jpg" + */ + name: string; + /** + * 文件大小 + * @example 1024 + */ + size: number; + /** + * 文件类型 + * @example "image/jpeg" + */ + mimetype: string; + /** + * 文件路径 + * @example "/upload/2021/10/01/xxx.jpg" + */ + path: string; + /** + * 文件哈希 + * @example "xxx" + */ + hash: string; + /** + * 文件后缀 + * @example ".jpg" + */ + extension: string; +} + +export interface CreatePostDto { + /** 文章标题 */ + title: string; + /** 文章描述 */ + description: string; + /** 文章内容 */ + content: string; +} export interface Post { /** @@ -220,7 +311,14 @@ export interface Post { author: User; } -export type UpdatePostDto = object; +export interface UpdatePostDto { + /** 文章标题 */ + title?: string; + /** 文章描述 */ + description?: string; + /** 文章内容 */ + content?: string; +} export interface Response { /** @@ -250,12 +348,487 @@ export interface GetUsersParams { page?: number; /** * 每页条数 - * @min 1 + * @min 0 * @example 10 */ size?: number; } +export interface GetPostsParams { + /** + * 页码 + * @min 1 + * @example 1 + */ + page?: number; + /** + * 每页条数 + * @min 0 + * @example 10 + */ + size?: number; +} + +export namespace User { + /** + * @description 新增用户 + * @tags user + * @name AddUser + * @request POST:/api/v1/users + */ + export namespace AddUser { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = CreateUserDto; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: number; + }; + } + /** + * @description 分页/条件查询用户 + * @tags user + * @name GetUsers + * @request GET:/api/v1/users + */ + export namespace GetUsers { + export type RequestParams = {}; + export type RequestQuery = { + /** + * 用户昵称 + * @example "绝弹" + */ + nickname?: string; + /** + * 页码 + * @min 1 + * @example 1 + */ + page?: number; + /** + * 每页条数 + * @min 0 + * @example 10 + */ + size?: number; + }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: User[]; + }; + } + /** + * @description 根据ID查询用户 + * @tags user + * @name GetUser + * @request GET:/api/v1/users/{id} + */ + export namespace GetUser { + export type RequestParams = { + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: User; + }; + } + /** + * @description 根据ID更新用户 + * @tags user + * @name UpdateUser + * @request PATCH:/api/v1/users/{id} + */ + export namespace UpdateUser { + export type RequestParams = { + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = UpdateUserDto; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 根据ID删除用户 + * @tags user + * @name DelUser + * @request DELETE:/api/v1/users/{id} + */ + export namespace DelUser { + export type RequestParams = { + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } +} + +export namespace Auth { + /** + * @description 账号登陆 + * @tags auth + * @name Login + * @request POST:/api/v1/auth/login + */ + export namespace Login { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = AuthUserDto; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: LoginedUserVo; + }; + } +} + +export namespace Role { + /** + * @description 创建角色 + * @tags role + * @name AddRole + * @request POST:/api/v1/roles + */ + export namespace AddRole { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = CreateRoleDto; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: number; + }; + } + /** + * @description 批量查询角色 + * @tags role + * @name GetRoles + * @request GET:/api/v1/roles + */ + export namespace GetRoles { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 查询角色 + * @tags role + * @name GetRole + * @request GET:/api/v1/roles/{id} + */ + export namespace GetRole { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: string; + }; + } + /** + * @description 更新角色 + * @tags role + * @name UpdateRole + * @request PATCH:/api/v1/roles/{id} + */ + export namespace UpdateRole { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = UpdateRoleDto; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 删除角色 + * @tags role + * @name DelRole + * @request DELETE:/api/v1/roles/{id} + */ + export namespace DelRole { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: string; + }; + } +} + +export namespace Permission { + /** + * @description 创建权限 + * @tags permission + * @name AddPermission + * @request POST:/api/v1/permissions + */ + export namespace AddPermission { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = CreatePermissionDto; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: number; + }; + } + /** + * @description 批量查询权限 + * @tags permission + * @name GetPermissions + * @request GET:/api/v1/permissions + */ + export namespace GetPermissions { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 查询权限 + * @tags permission + * @name GetPermission + * @request GET:/api/v1/permissions/{id} + */ + export namespace GetPermission { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: string; + }; + } + /** + * @description 更新权限 + * @tags permission + * @name UpdatePermission + * @request PATCH:/api/v1/permissions/{id} + */ + export namespace UpdatePermission { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = UpdatePermissionDto; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 删除权限 + * @tags permission + * @name DelPermission + * @request DELETE:/api/v1/permissions/{id} + */ + export namespace DelPermission { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: string; + }; + } +} + +export namespace Upload { + /** + * @description 上传文件 + * @tags upload + * @name AddFile + * @request POST:/api/v1/upload + */ + export namespace AddFile { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = CreateUploadDto; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: number; + }; + } + /** + * @description 批量查询 + * @tags upload + * @name GetUploads + * @request GET:/api/v1/upload + */ + export namespace GetUploads { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 查询 + * @tags upload + * @name GetFile + * @request GET:/api/v1/upload/{id} + */ + export namespace GetFile { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: Upload; + }; + } + /** + * @description 更新 + * @tags upload + * @name UpdateFile + * @request PATCH:/api/v1/upload/{id} + */ + export namespace UpdateFile { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: string; + }; + } + /** + * @description 删除 + * @tags upload + * @name DelFile + * @request DELETE:/api/v1/upload/{id} + */ + export namespace DelFile { + export type RequestParams = { + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } +} + +export namespace Post { + /** + * @description 创建文章 + * @tags post + * @name AddPost + * @request POST:/api/v1/posts + */ + export namespace AddPost { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = CreatePostDto; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: number; + }; + } + /** + * @description 批量查询文章 + * @tags post + * @name GetPosts + * @request GET:/api/v1/posts + */ + export namespace GetPosts { + export type RequestParams = {}; + export type RequestQuery = { + /** + * 页码 + * @min 1 + * @example 1 + */ + page?: number; + /** + * 每页条数 + * @min 0 + * @example 10 + */ + size?: number; + }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 获取文章下载模板 + * @tags post + * @name GetPostTemplate + * @request GET:/api/v1/posts/template.xlsx + */ + export namespace GetPostTemplate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 查询文章 + * @tags post + * @name GetPost + * @request GET:/api/v1/posts/{id} + */ + export namespace GetPost { + export type RequestParams = { + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response & { + data: Post; + }; + } + /** + * @description 更新文章 + * @tags post + * @name UpdatePost + * @request PATCH:/api/v1/posts/{id} + */ + export namespace UpdatePost { + export type RequestParams = { + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = UpdatePostDto; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } + /** + * @description 删除文章 + * @tags post + * @name DelPost + * @request DELETE:/api/v1/posts/{id} + */ + export namespace DelPost { + export type RequestParams = { + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Response; + } +} + import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, HeadersDefaults, ResponseType } from "axios"; export type QueryParamsType = Record; @@ -397,7 +970,7 @@ export class HttpClient { export class Api extends HttpClient { user = { /** - * 创建用户 + * 新增用户 * * @tags user * @name AddUser @@ -406,7 +979,7 @@ export class Api extends HttpClient { return this.request< Response & { - data?: number; + data: number; }, any >({ @@ -420,17 +993,16 @@ export class Api extends HttpClient { return this.request< Response & { - data?: User[]; + data: User[]; }, any >({ @@ -443,21 +1015,20 @@ export class Api extends HttpClient { + getUser: (id: number, params: RequestParams = {}) => { return this.request< Response & { - data?: User; + data: User; }, any >({ - path: `/api/v2/users/${id}`, + path: `/api/v1/users/${id}`, method: "GET", format: "json", ...params, @@ -465,54 +1036,53 @@ export class Api extends HttpClient { - return this.request({ + return this.request({ path: `/api/v1/users/${id}`, method: "PATCH", body: data, type: ContentType.Json, + format: "json", ...params, }); }, /** - * No description + * 根据ID删除用户 * * @tags user - * @name DeleteUser - * @summary 删除用户 + * @name DelUser * @request DELETE:/api/v1/users/{id} */ - deleteUser: (id: number, params: RequestParams = {}) => { - return this.request({ + delUser: (id: number, params: RequestParams = {}) => { + return this.request({ path: `/api/v1/users/${id}`, method: "DELETE", + format: "json", ...params, }); }, }; auth = { /** - * No description + * 账号登陆 * * @tags auth * @name Login - * @summary 账号登录 * @request POST:/api/v1/auth/login */ login: (data: AuthUserDto, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: LoginedUserVo; }, - void + any >({ path: `/api/v1/auth/login`, method: "POST", @@ -525,17 +1095,16 @@ export class Api extends HttpClient { return this.request< Response & { - data?: number; + data: number; }, any >({ @@ -549,33 +1118,32 @@ export class Api extends HttpClient { - return this.request({ + return this.request({ path: `/api/v1/roles`, method: "GET", + format: "json", ...params, }); }, /** - * No description + * 查询角色 * * @tags role * @name GetRole - * @summary 查询角色 * @request GET:/api/v1/roles/{id} */ getRole: (id: string, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: string; }, any >({ @@ -587,35 +1155,34 @@ export class Api extends HttpClient { - return this.request({ + return this.request({ path: `/api/v1/roles/${id}`, method: "PATCH", body: data, type: ContentType.Json, + format: "json", ...params, }); }, /** - * No description + * 删除角色 * * @tags role * @name DelRole - * @summary 删除角色 * @request DELETE:/api/v1/roles/{id} */ delRole: (id: string, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: string; }, any >({ @@ -628,17 +1195,16 @@ export class Api extends HttpClient { return this.request< Response & { - data?: number; + data: number; }, any >({ @@ -652,33 +1218,32 @@ export class Api extends HttpClient { - return this.request({ + return this.request({ path: `/api/v1/permissions`, method: "GET", + format: "json", ...params, }); }, /** - * No description + * 查询权限 * * @tags permission * @name GetPermission - * @summary 查询权限 * @request GET:/api/v1/permissions/{id} */ getPermission: (id: string, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: string; }, any >({ @@ -690,35 +1255,34 @@ export class Api extends HttpClient { - return this.request({ + return this.request({ path: `/api/v1/permissions/${id}`, method: "PATCH", body: data, type: ContentType.Json, + format: "json", ...params, }); }, /** - * No description + * 删除权限 * * @tags permission * @name DelPermission - * @summary 删除权限 * @request DELETE:/api/v1/permissions/{id} */ delPermission: (id: string, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: string; }, any >({ @@ -731,17 +1295,16 @@ export class Api extends HttpClient { + addFile: (data: CreateUploadDto, params: RequestParams = {}) => { return this.request< Response & { - data?: number; + data: number; }, any >({ @@ -755,33 +1318,32 @@ export class Api extends HttpClient { - return this.request({ + return this.request({ path: `/api/v1/upload`, method: "GET", + format: "json", ...params, }); }, /** - * No description + * 查询 * * @tags upload - * @name GetUpload - * @summary 查询 + * @name GetFile * @request GET:/api/v1/upload/{id} */ - getUpload: (id: string, params: RequestParams = {}) => { + getFile: (id: string, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: Upload; }, any >({ @@ -793,17 +1355,16 @@ export class Api extends HttpClient { + updateFile: (id: string, params: RequestParams = {}) => { return this.request< Response & { - data?: string; + data: string; }, any >({ @@ -815,20 +1376,14 @@ export class Api extends HttpClient { - return this.request< - Response & { - data?: string; - }, - any - >({ + delFile: (id: string, params: RequestParams = {}) => { + return this.request({ path: `/api/v1/upload/${id}`, method: "DELETE", format: "json", @@ -838,21 +1393,20 @@ export class Api extends HttpClient { return this.request< Response & { - data?: number; + data: number; }, any >({ - path: `/api/v1/post`, + path: `/api/v1/posts`, method: "POST", body: data, type: ContentType.Json, @@ -862,37 +1416,32 @@ export class Api extends HttpClient { - return this.request({ - path: `/api/v1/post`, + getPosts: (query: GetPostsParams, params: RequestParams = {}) => { + return this.request({ + path: `/api/v1/posts`, method: "GET", + query: query, + format: "json", ...params, }); }, /** - * No description + * 获取文章下载模板 * * @tags post - * @name GetPost - * @summary 查询文章 - * @request GET:/api/v1/post/{id} + * @name GetPostTemplate + * @request GET:/api/v1/posts/template.xlsx */ - getPost: (id: string, params: RequestParams = {}) => { - return this.request< - Response & { - data?: Post; - }, - any - >({ - path: `/api/v1/post/${id}`, + getPostTemplate: (params: RequestParams = {}) => { + return this.request({ + path: `/api/v1/posts/template.xlsx`, method: "GET", format: "json", ...params, @@ -900,35 +1449,56 @@ export class Api extends HttpClient { - return this.request({ - path: `/api/v1/post/${id}`, - method: "PATCH", - body: data, - type: ContentType.Json, + getPost: (id: number, params: RequestParams = {}) => { + return this.request< + Response & { + data: Post; + }, + any + >({ + path: `/api/v1/posts/${id}`, + method: "GET", + format: "json", ...params, }); }, /** - * No description + * 更新文章 + * + * @tags post + * @name UpdatePost + * @request PATCH:/api/v1/posts/{id} + */ + updatePost: (id: number, data: UpdatePostDto, params: RequestParams = {}) => { + return this.request({ + path: `/api/v1/posts/${id}`, + method: "PATCH", + body: data, + type: ContentType.Json, + format: "json", + ...params, + }); + }, + + /** + * 删除文章 * * @tags post * @name DelPost - * @summary 删除文章 - * @request DELETE:/api/v1/post/{id} + * @request DELETE:/api/v1/posts/{id} */ - delPost: (id: string, params: RequestParams = {}) => { - return this.request({ - path: `/api/v1/post/${id}`, + delPost: (id: number, params: RequestParams = {}) => { + return this.request({ + path: `/api/v1/posts/${id}`, method: "DELETE", + format: "json", ...params, }); }, diff --git a/src/components/table/use-interface.ts b/src/components/table/use-interface.ts index 24e63e5..5f3ad01 100644 --- a/src/components/table/use-interface.ts +++ b/src/components/table/use-interface.ts @@ -26,6 +26,7 @@ export interface TableColumnButton { /** * 操作类型 + * @description `delete` 需配置`onClick`属性,`modify` 需配置根对象下的 `modify` 属性 */ type?: "delete" | "modify"; @@ -79,7 +80,7 @@ export interface UseTableOptions extends Omit & { /** - * 继承common.items中指定field值的项 + * 继承`create.items`中指定field值的项 */ extend?: string; })[]; @@ -93,7 +94,7 @@ export interface UseTableOptions extends Omit; /** * 新建弹窗配置 */ @@ -105,7 +106,7 @@ export interface UseTableOptions extends Omit UseTableOptions)): any => { const options: UseTableOptions = typeof optionsOrFn === "function" ? optionsOrFn() : optionsOrFn; @@ -51,9 +51,16 @@ export const useTable = (optionsOrFn: UseTableOptions | (() => UseTableOptions)) Modal.warning({ ...config.columnButtonDelete, onOk: async () => { - const resData: any = await action?.onClick?.(data); - resData.msg && Message.success(resData?.msg || ""); - getTable()?.loadData(); + try { + const resData: any = await action?.onClick?.(data); + resData.msg && Message.success(resData?.msg || ""); + getTable()?.loadData(); + } catch (error: any) { + const message = error.response?.data?.message; + if (message) { + Message.warning(`提示:${message}`); + } + } }, }); }; @@ -97,8 +104,7 @@ export const useTable = (optionsOrFn: UseTableOptions | (() => UseTableOptions)) if (item.extend) { const createItem = createItems.find((i) => i.field === item.extend); if (createItem) { - const mergedItem = merge({}, createItem, item); - searchItems.push(mergedItem); + searchItems.push(merge({}, createItem, item)); continue; } } diff --git a/src/main.ts b/src/main.ts index 788ab4f..767b518 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import { createApp } from "vue"; import App from "./App.vue"; import { router } from "./router"; import { store } from "./store"; -import { style } from "./style"; +import { style } from "./styles"; const run = async () => { const app = createApp(App); diff --git a/src/pages/_login/index.vue b/src/pages/_login/index.vue index 897f82f..11c46d2 100644 --- a/src/pages/_login/index.vue +++ b/src/pages/_login/index.vue @@ -1,6 +1,6 @@ diff --git a/src/pages/role/index.vue b/src/pages/role/index.vue index fb51274..9455772 100644 --- a/src/pages/role/index.vue +++ b/src/pages/role/index.vue @@ -52,7 +52,23 @@ const table = useTable({ ], }, ], - common: { + search: { + items: [ + { + extend: "name", + required: false, + }, + ], + }, + create: { + title: "新建角色", + modalProps: { + width: 580, + maskClosable: false, + }, + formProps: { + layout: "vertical", + }, items: [ { field: "name", @@ -77,26 +93,7 @@ const table = useTable({ options: () => api.permission.getPermissions(), }, ], - modalProps: { - width: 580, - maskClosable: false, - }, - formProps: { - layout: "vertical", - }, - }, - search: { - items: [ - { - field: "name", - label: "角色名称", - type: "input", - required: false, - }, - ], - }, - create: { - title: "新建角色", + submit: ({ model }) => { return api.role.addRole(model as any); }, diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue index 06227e8..2fb33b7 100644 --- a/src/pages/user/index.vue +++ b/src/pages/user/index.vue @@ -10,142 +10,136 @@ import { Table, useTable } from "@/components"; import { dayjs } from "@/plugins"; import { Avatar, Button } from "@arco-design/web-vue"; -const table = useTable(() => { - const nicknameRender = ({ record }: any) => { - return ( -
- - - - - {record.nickname} - 账号:{record.username} - -
- ); - }; - return { - data: async (model, paging) => { - return api.user.getUsers({ ...model, ...paging }); +const table = useTable({ + data: async (model, paging) => { + return api.user.getUsers({ ...model, ...paging }); + }, + columns: [ + { + type: "index", }, - columns: [ - { - type: "index", + { + title: "用户昵称", + dataIndex: "username", + width: 200, + render: ({ record }) => { + return ( +
+ + + + + {record.nickname} + 账号:{record.username} + +
+ ); }, - { - title: "用户昵称", - dataIndex: "username", - width: 200, - render: nicknameRender, - }, - { - title: "用户描述", - dataIndex: "description", - }, - { - title: "用户邮箱", - dataIndex: "email", - }, - { - title: "创建时间", - dataIndex: "createdAt", - width: 200, - render: ({ record }) => dayjs(record.createdAt).format(), - }, - { - title: "操作", - type: "button", - width: 148, - buttons: [ - { - type: "modify", - text: "修改", + }, + { + title: "用户描述", + dataIndex: "description", + }, + { + title: "用户邮箱", + dataIndex: "email", + }, + { + title: "创建时间", + dataIndex: "createdAt", + width: 200, + render: ({ record }) => dayjs(record.createdAt).format(), + }, + { + title: "操作", + type: "button", + width: 148, + buttons: [ + { + type: "modify", + text: "修改", + }, + { + type: "delete", + text: "删除", + onClick: async ({ record }) => { + return api.user.delUser(record.id); }, - { - type: "delete", - text: "删除", - onClick: async (data) => { - return api.user.deleteUser(data.record.id); - }, - }, - ], + }, + ], + }, + ], + search: { + items: [ + { + extend: "username", + required: false, }, ], - search: { - items: [ - { - extend: "username", - required: false, - }, - ], + }, + create: { + title: "新建用户", + trigger: () => ( + + ), + modalProps: { + width: 772, + maskClosable: false, }, - create: { - title: "新建用户", - trigger: () => ( - - ), - modalProps: { - width: 772, - maskClosable: false, - }, - formProps: { - layout: "vertical", - class: "!grid grid-cols-2 gap-x-3", - }, - model: { - avatarUrl: "", - }, - items: [ - { - field: "username", - label: "登录账号", - type: "input", - required: true, - }, - { - field: "nickname", - label: "用户昵称", - type: "input", - }, - { - field: "description", - label: "个人描述", - type: "input", - }, - { - field: "password", - label: "密码", - type: "password", - }, - { - label: "头像", - field: "avatar?avatarUrl", - type: "select", - }, - { - field: "startTime:endTime", - label: "日期范围", - type: "dateRange", - nodeProps: {}, - }, - ], - submit: ({ model }) => { - console.log(model); - }, + formProps: { + layout: "vertical", + class: "!grid grid-cols-2 gap-x-3", }, - modify: { - extend: true, - title: "修改用户", - submit: ({ model }) => { - return api.user.updateUser(model.id, model); + items: [ + { + field: "username", + label: "登录账号", + type: "input", + required: true, }, + { + field: "nickname", + label: "用户昵称", + type: "input", + }, + { + field: "description", + label: "个人描述", + type: "input", + }, + { + field: "password", + label: "密码", + type: "password", + }, + { + label: "头像", + field: "avatar", + type: "select", + }, + { + field: "startTime:endTime", + label: "日期范围", + type: "dateRange", + nodeProps: {}, + }, + ], + submit: ({ model }) => { + console.log(model); }, - }; + }, + modify: { + extend: true, + title: "修改用户", + submit: ({ model }) => { + return api.user.updateUser(model.id, model); + }, + }, }); diff --git a/src/router/guards/guard-auth.ts b/src/router/guards/guard-auth.ts new file mode 100644 index 0000000..452c255 --- /dev/null +++ b/src/router/guards/guard-auth.ts @@ -0,0 +1,34 @@ +import { NavigationGuardWithThis } from "vue-router"; +import { store, useUserStore } from "@/store"; +import { Message } from "@arco-design/web-vue"; + +const userStore = useUserStore(store); + +/** + * 权限守卫 + * @description 校验用户是否有路由的访问权限 + */ +export function useAuthGuard() { + const whitelist = ["/404"]; + const signoutlist = ["/login"]; + const authGuard: NavigationGuardWithThis = async function (to, from, next) { + if (to.meta.auth === false) { + return next(); + } + if (whitelist.includes(to.fullPath)) { + return next(); + } + if (signoutlist.includes(to.fullPath)) { + if (userStore.id) { + Message.warning(`提示:您已登陆,如需重新请退出后再操作!`); + return next(false); + } + return next(); + } + if (!userStore.id) { + return next("/login"); + } + next(); + }; + return authGuard; +} diff --git a/src/router/guards/guard-nprogress.ts b/src/router/guards/guard-nprogress.ts new file mode 100644 index 0000000..9bff1c5 --- /dev/null +++ b/src/router/guards/guard-nprogress.ts @@ -0,0 +1,17 @@ +import { NavigationGuardWithThis } from "vue-router"; +import { NProgress } from "@/plugins"; + +/** + * 进度条守卫 + * @description 在路由跳转时显示进度条 + */ +export const useNprogressGuard = () => { + const before: NavigationGuardWithThis = function (to, from, next) { + NProgress.start(); + next(); + }; + const after: NavigationGuardWithThis = function (to, from, next) { + NProgress.done(); + }; + return { before, after }; +}; diff --git a/src/router/guards/guard-title.ts b/src/router/guards/guard-title.ts new file mode 100644 index 0000000..326ad6a --- /dev/null +++ b/src/router/guards/guard-title.ts @@ -0,0 +1,15 @@ +import { NavigationGuardWithThis } from "vue-router"; + +/** + * 标题首位 + * @description 路由跳转后更新页面标题 + */ +export const useTitleGuard = () => { + const titleGuard: NavigationGuardWithThis = function (to, from, next) { + const title = to.meta.title || import.meta.env.VITE_APP_TITLE; + const subtitle = import.meta.env.VITE_APP_SUBTITLE; + document.title = `${title} | ${subtitle}`; + next(); + }; + return titleGuard; +}; diff --git a/src/router/guards/index.ts b/src/router/guards/index.ts deleted file mode 100644 index 4a8169b..0000000 --- a/src/router/guards/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Router } from 'vue-router'; -import { NProgress } from '@/plugins'; - -/** - * 设置进度条 - * @param router 路由实例 - */ -export const useNprogress = (router: Router) => { - router.beforeEach((to, from, next) => { - NProgress.start(); - next(); - }); - - router.afterEach(() => { - NProgress.done(); - }); -}; - -/** - * 设置文档标题 - * @param router 路由实例 - */ -export const useTitle = (router: Router) => { - router.beforeEach((to, from, next) => { - const title = to.meta.title || import.meta.env.VITE_APP_TITLE; - const subtitle = import.meta.env.VITE_APP_SUBTITLE; - document.title = `${title} | ${subtitle}`; - next(); - }); -}; - -/** - * 设置权限 - * @param router 路由实例 - */ -export const useAuth = (router: Router) => { - router.beforeEach((to, from, next) => { - if (to.meta.auth) { - } - next(); - }); -}; diff --git a/src/router/router/index.ts b/src/router/router/index.ts index fcd0de6..9efdb2a 100644 --- a/src/router/router/index.ts +++ b/src/router/router/index.ts @@ -1,6 +1,12 @@ import { createRouter, createWebHashHistory } from "vue-router"; -import { useAuth, useNprogress, useTitle } from "../guards"; import { routes } from "../routes"; +import { useAuthGuard } from "../guards/guard-auth"; +import { useNprogressGuard } from "../guards/guard-nprogress"; +import { useTitleGuard } from "../guards/guard-title"; + +const nprogressGuard = useNprogressGuard(); +const titleGuard = useTitleGuard(); +const authGuard = useAuthGuard(); const router = createRouter({ history: createWebHashHistory(), @@ -13,8 +19,9 @@ const router = createRouter({ ], }); -useNprogress(router); -useTitle(router); -useAuth(router); +router.beforeEach(nprogressGuard.before); +router.beforeEach(nprogressGuard.after); +router.beforeEach(titleGuard); +router.beforeEach(authGuard); export { router }; diff --git a/src/store/app/index.ts b/src/store/app/index.ts index dc63f4a..e7b419a 100644 --- a/src/store/app/index.ts +++ b/src/store/app/index.ts @@ -1,38 +1,35 @@ -import { useDark } from "@vueuse/core"; import { defineStore } from "pinia"; export const useAppStore = defineStore({ id: "app", - state: () => { - const isDark = useDark({ - onChanged: (isDark) => { - if (isDark) { - document.body.setAttribute("arco-theme", "dark"); - document.body.classList.add("dark"); - return; - } - document.body.setAttribute("arco-theme", "light"); - document.body.classList.remove("dark"); - }, - }); - return { - count: 0, - isDark, - title: import.meta.env.VITE_APP_TITLE, - subtitle: import.meta.env.VITE_APP_SUBTITLE, - }; - }, - getters: { - doubleCount(state) { - return state.count * 2; - }, - }, + state: () => ({ + isDarkMode: false, + title: import.meta.env.VITE_TITLE, + subtitle: import.meta.env.VITE_SUBTITLE, + }), actions: { - increment() { - this.count++; - }, + /** + * 切换暗/亮模式 + */ toggleDark() { - this.isDark = !this.isDark; + this.isDarkMode ? this.setLight() : this.setDark(); + }, + /** + * 切换为亮模式 + */ + setLight() { + document.body.setAttribute("arco-theme", "light"); + document.body.classList.remove("dark"); + this.isDarkMode = false; + }, + /** + * 切换为暗模式 + */ + setDark() { + document.body.setAttribute("arco-theme", "dark"); + document.body.classList.add("dark"); + this.isDarkMode = true; }, }, + persist: true, }); diff --git a/src/store/store/index.ts b/src/store/store/index.ts index 9a62b28..35d468c 100644 --- a/src/store/store/index.ts +++ b/src/store/store/index.ts @@ -1,3 +1,5 @@ import { createPinia } from "pinia"; +import persistedstatePlugin from "pinia-plugin-persistedstate"; export const store = createPinia(); +store.use(persistedstatePlugin); diff --git a/src/store/user/index.ts b/src/store/user/index.ts index 25bfe1f..56891d0 100644 --- a/src/store/user/index.ts +++ b/src/store/user/index.ts @@ -1,14 +1,18 @@ -import { useStorage } from "@vueuse/core"; +import { LoginedUserVo } from "@/api"; import { defineStore } from "pinia"; export const useUserStore = defineStore({ id: "user", state: () => { - const user = useStorage("APP_USER", { + return { + /** + * 用户ID + */ + id: 0, /** * 用户名称 */ - name: "绝弹", + username: "绝弹", /** * 用户头像地址 */ @@ -17,22 +21,35 @@ export const useUserStore = defineStore({ * JWT令牌 */ accessToken: "", - }); - return user; + /** + * 刷新令牌 + */ + refreshToken: "", + }; }, actions: { + /** + * 设置令牌 + */ setToken(token: string) { this.accessToken = token; }, + /** + * 清除用户信息 + */ clearUser() { - this.name = ""; + this.username = ""; this.avatar = ""; this.accessToken = ""; }, - setUser(user: { name: string; avatar: string; accessToken: string }) { - this.name = user.name; + /** + * 设置用户信息 + */ + setUser(user: LoginedUserVo) { + this.username = user.username; this.avatar = user.avatar; - this.accessToken = user.accessToken; + this.accessToken = user.token; }, }, + persist: true, }); diff --git a/src/style/css-arco.less b/src/styles/css-arco.less similarity index 100% rename from src/style/css-arco.less rename to src/styles/css-arco.less diff --git a/src/style/css-base.less b/src/styles/css-base.less similarity index 100% rename from src/style/css-base.less rename to src/styles/css-base.less diff --git a/src/style/css-transition.less b/src/styles/css-transition.less similarity index 100% rename from src/style/css-transition.less rename to src/styles/css-transition.less diff --git a/src/style/css-unocss.less b/src/styles/css-unocss.less similarity index 100% rename from src/style/css-unocss.less rename to src/styles/css-unocss.less diff --git a/src/style/index.ts b/src/styles/index.ts similarity index 100% rename from src/style/index.ts rename to src/styles/index.ts diff --git a/src/types/auto-component.d.ts b/src/types/auto-component.d.ts index 9098020..e98b15c 100644 --- a/src/types/auto-component.d.ts +++ b/src/types/auto-component.d.ts @@ -11,16 +11,23 @@ declare module '@vue/runtime-core' { ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb'] ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem'] AButton: typeof import('@arco-design/web-vue')['Button'] + ACheckbox: typeof import('@arco-design/web-vue')['Checkbox'] AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider'] ADoption: typeof import('@arco-design/web-vue')['Doption'] ADrawer: typeof import('@arco-design/web-vue')['Drawer'] ADropdown: typeof import('@arco-design/web-vue')['Dropdown'] + AForm: typeof import('@arco-design/web-vue')['Form'] + AFormItem: typeof import('@arco-design/web-vue')['FormItem'] + AInput: typeof import('@arco-design/web-vue')['Input'] + AInputPassword: typeof import('@arco-design/web-vue')['InputPassword'] ALayout: typeof import('@arco-design/web-vue')['Layout'] ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent'] ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader'] ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider'] + ALink: typeof import('@arco-design/web-vue')['Link'] AMenu: typeof import('@arco-design/web-vue')['Menu'] AMenuItem: typeof import('@arco-design/web-vue')['MenuItem'] + ASpace: typeof import('@arco-design/web-vue')['Space'] ASubMenu: typeof import('@arco-design/web-vue')['SubMenu'] ATag: typeof import('@arco-design/web-vue')['Tag'] ATooltip: typeof import('@arco-design/web-vue')['Tooltip'] diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 42d43ee..ce450dc 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -4,15 +4,15 @@ interface ImportMetaEnv { /** * 网站标题 */ - VITE_APP_TITLE: string; + VITE_TITLE: string; /** * 网站副标题 */ - VITE_APP_SUBTITLE: string; + VITE_SUBTITLE: string; /** * 自定义的文件后缀 */ - VITE_BUILD_EXTENSION: string; + VITE_EXTENSION: string; /** * API 地址 */ @@ -20,11 +20,11 @@ interface ImportMetaEnv { /** * 开发服务器主机 */ - VITE_DEV_HOST: string; + VITE_HOST: string; /** * 开发服务器端口 */ - VITE_DEV_PORT: number; + VITE_PORT: number; } interface ImportMeta { diff --git a/src/utils/message.ts b/src/utils/message.ts new file mode 100644 index 0000000..9508226 --- /dev/null +++ b/src/utils/message.ts @@ -0,0 +1,7 @@ +import { Message } from "@arco-design/web-vue"; + +export const message = { + warning() { + Message.warning(``) + } +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 120da36..68afe33 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,8 +17,8 @@ import plugin from "./scripts/vite/plugin"; export default defineConfig(({ mode }) => { // 加载顺序,后者优先级高:.env .env.locale .env.[mode] .env.[mode].locale const env = loadEnv(mode, process.cwd()); - const host = env.VITE_DEV_HOST || "0.0.0.0"; - const port = Number(env.VITE_DEV_PORT || 3020); + const host = env.VITE_HOST || "0.0.0.0"; + const port = Number(env.VITE_PORT || 3020); return { base: "./", @@ -39,7 +39,7 @@ export default defineConfig(({ mode }) => { less: { javascriptEnabled: true, modifyVars: { - hack: `true; @import (reference) "${resolve("src/style/css-arco.less")}";`, + hack: `true; @import (reference) "${resolve("src/styles/css-arco.less")}";`, arcoblue: "#66f", }, },