# vue-lib **Repository Path**: hxyl/vue-lib ## Basic Information - **Project Name**: vue-lib - **Description**: vue3 base lib - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-06-05 - **Last Updated**: 2023-09-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vites/VitePluginAutoRouter 1. 提供自动路由, 2. 一个路由一个文件夹,文件夹名称会作为路由名称,文件夹下需要包含index入口文件,不包含的不会自动导入理由 3. target 路由配置文件位置,绝对路径 4. views 页面存放路径,绝对路径 #### Example ``` /// 在项目vite.config.ts下 import { fileURLToPath, URL } from 'node:url'; import { defineConfig, type Plugin } from 'vite'; import vue from '@vitejs/plugin-vue'; import vueJsx from '@vitejs/plugin-vue-jsx'; /// example: import import VitePluginAutoRouter from 'vue-lib/vites/VitePluginAutoRouter'; export default defineConfig({ plugins: [ vue(), vueJsx(), /// example: use VitePluginAutoRouter({ target: fileURLToPath(new URL('./src/router/index.ts', import.meta.url)), views: fileURLToPath(new URL('./src/views', import.meta.url)) }) ], base: './', resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, }); ``` # decorators/HTTP 1. 提供HTTP装饰器 GET、POST、DELETE、PUT请求,内置了axios@1.4.0 2. HTTP 类装饰器 axios 创建和配置 3. REQ_INTC 类装饰器 request拦截器 4. RES_INTC 类装饰器 response拦截器 5. GET 属性装饰器,只支持静态,get请求 6. POST 属性装饰器,只支持静态,pot请求 #### Example ``` /// example: define import { REQ_INTC, RES_INTC, HTTP, GET, type Execute } from "vue-lib"; @REQ_INTC((req) => { req.headers['X-TOKEN'] = 'xxx'; return req; }) @RES_INTC((res) => { if (res.status == 200) { } return res; }) @HTTP({ baseURL: "/api", headers: { "Content-Type": 'application/json;charset=UTF-8' }, validateStatus: (s) => { return true; }, }) export default class HttpRepositiry { @GET("/a.json") public static json: Execute<{version: number}>; } ``` ``` /// example: call const main = async () => { const res = await HttpRepositiry.json({ version: 1.0 }); console.log(res.data); } main(); ```