create-young-proj 0.10.2 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.mjs +9 -9
- package/package.json +1 -1
- package/template-nuxt-admin/README.md +42 -1
- package/template-nuxt-admin/components/layout/Main.vue +2 -2
- package/template-nuxt-admin/components/layout/NavBar.vue +11 -2
- package/template-nuxt-admin/components/layout/SideBar.vue +6 -2
- package/template-nuxt-admin/components/layout/SubMenu.vue +9 -2
- package/template-nuxt-admin/components/layout/TabsBar.vue +4 -5
- package/template-nuxt-admin/composables/api.ts +17 -3
- package/template-nuxt-admin/composables/nav.ts +20 -3
- package/template-nuxt-admin/composables/tags.ts +29 -1
- package/template-nuxt-admin/middleware/auth.global.ts +16 -4
- package/template-nuxt-admin/nuxt.config.ts +5 -1
- package/template-nuxt-admin/package.json +5 -5
- package/template-nuxt-admin/pages/home/[id].vue +2 -2
- package/template-nuxt-admin/pages/index.vue +2 -7
- package/template-nuxt-admin/pages/login.vue +2 -2
- package/template-nuxt-admin/pages/system/menuList.vue +0 -1
- package/template-nuxt-admin/public/bg.webp +0 -0
- package/template-nuxt-admin/public/favicon.svg +2 -0
- package/template-nuxt-admin/public/logo.svg +2 -0
- package/template-nuxt-admin/server/plugins/env.ts +3 -4
- package/template-nuxt-admin/utils/tool.ts +17 -1
- package/template-nuxt-admin/yarn.lock +706 -854
- package/template-uni-app/auto-imports.d.ts +9 -6
- package/template-uni-app/custom-plugins/index.ts +1 -2
- package/template-uni-app/dist/dev/mp-weixin/apis/index.js +5 -6
- package/template-uni-app/dist/dev/mp-weixin/apis/requests/get.js +2 -2
- package/template-uni-app/dist/dev/mp-weixin/apis/requests/post.js +4 -4
- package/template-uni-app/dist/dev/mp-weixin/app.js +4 -5
- package/template-uni-app/dist/dev/mp-weixin/common/vendor.js +1448 -2471
- package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.js +7 -8
- package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.wxml +1 -1
- package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.js +7 -8
- package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.wxml +1 -1
- package/template-uni-app/dist/dev/mp-weixin/layouts/default.js +1 -2
- package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.wxml +1 -1
- package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.js +4 -5
- package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.wxml +1 -1
- package/template-uni-app/dist/dev/mp-weixin/pages/index.js +4 -5
- package/template-uni-app/dist/dev/mp-weixin/pages/index.wxml +1 -1
- package/template-uni-app/dist/dev/mp-weixin/pages/my.wxml +1 -1
- package/template-uni-app/dist/dev/mp-weixin/project.config.json +1 -2
- package/template-uni-app/dist/dev/mp-weixin/project.private.config.json +6 -0
- package/template-uni-app/dist/dev/mp-weixin/store/local/index.js +3 -1
- package/template-uni-app/dist/dev/mp-weixin/utils/modal.js +10 -14
- package/template-uni-app/dist/dev/mp-weixin/utils/route.js +4 -6
- package/template-uni-app/dist/dev/mp-weixin/utils/system.js +4 -4
- package/template-uni-app/package.json +2 -3
- package/template-uni-app/pnpm-lock.yaml +154 -105
- package/template-uni-app/src/apis/index.ts +2 -2
- package/template-uni-app/src/apis/requests/get.ts +5 -5
- package/template-uni-app/src/apis/requests/post.ts +5 -5
- package/template-uni-app/vite.config.ts +2 -3
- package/template-nuxt-admin/public/favicon.ico +0 -0
- package/template-uni-app/custom-plugins/polyfill.ts +0 -32
- package/template-uni-app/dist/dev/mp-weixin/apis/lib/index.js +0 -90
- package/template-uni-app/src/apis/lib/index.ts +0 -235
- package/template-vue-admin/.vscode/extensions.json +0 -10
- package/template-vue-admin/.vscode/list-add.code-snippets +0 -108
- package/template-vue-admin/.vscode/list-export.code-snippets +0 -72
- package/template-vue-admin/.vscode/list.code-snippets +0 -61
- package/template-vue-admin/.vscode/settings.json +0 -7
- package/template-vue-admin/Dockerfile +0 -42
- package/template-vue-admin/README.md +0 -75
- package/template-vue-admin/_env +0 -8
- package/template-vue-admin/_gitignore +0 -30
- package/template-vue-admin/boot.mjs +0 -16
- package/template-vue-admin/build/custom-plugin.ts +0 -57
- package/template-vue-admin/build/index.ts +0 -7
- package/template-vue-admin/build/plugins.ts +0 -59
- package/template-vue-admin/config/.devrc +0 -2
- package/template-vue-admin/config/.onlinerc +0 -2
- package/template-vue-admin/config/.testrc +0 -2
- package/template-vue-admin/index.html +0 -21
- package/template-vue-admin/nitro.config.ts +0 -19
- package/template-vue-admin/package.json +0 -51
- package/template-vue-admin/plugins/init.ts +0 -31
- package/template-vue-admin/public/vite.svg +0 -1
- package/template-vue-admin/rome.json +0 -26
- package/template-vue-admin/routes/api/[...all].ts +0 -49
- package/template-vue-admin/routes/get/env.ts +0 -18
- package/template-vue-admin/src/App.vue +0 -14
- package/template-vue-admin/src/apis/delete.ts +0 -36
- package/template-vue-admin/src/apis/get.ts +0 -83
- package/template-vue-admin/src/apis/index.ts +0 -10
- package/template-vue-admin/src/apis/patch.ts +0 -78
- package/template-vue-admin/src/apis/post.ts +0 -76
- package/template-vue-admin/src/assets/img/login_background.jpg +0 -0
- package/template-vue-admin/src/auto-components.d.ts +0 -38
- package/template-vue-admin/src/auto-imports.d.ts +0 -302
- package/template-vue-admin/src/layouts/blank.vue +0 -9
- package/template-vue-admin/src/layouts/default/components/Link.vue +0 -23
- package/template-vue-admin/src/layouts/default/components/Logo.vue +0 -20
- package/template-vue-admin/src/layouts/default/components/Menu.vue +0 -54
- package/template-vue-admin/src/layouts/default/components/NavSearch.vue +0 -52
- package/template-vue-admin/src/layouts/default/components/ScrollPane.vue +0 -79
- package/template-vue-admin/src/layouts/default/components/TagsView.vue +0 -137
- package/template-vue-admin/src/layouts/default/components/TopMenu.vue +0 -21
- package/template-vue-admin/src/layouts/default/components/UserCenter.vue +0 -50
- package/template-vue-admin/src/layouts/default/index.vue +0 -95
- package/template-vue-admin/src/main.ts +0 -46
- package/template-vue-admin/src/modules/1-router.ts +0 -48
- package/template-vue-admin/src/modules/2-pinia.ts +0 -10
- package/template-vue-admin/src/modules/3-net.ts +0 -79
- package/template-vue-admin/src/modules/4-auth.ts +0 -124
- package/template-vue-admin/src/modules/5-checkupdate.ts +0 -38
- package/template-vue-admin/src/shims.d.ts +0 -12
- package/template-vue-admin/src/stores/index.ts +0 -9
- package/template-vue-admin/src/stores/local/index.ts +0 -31
- package/template-vue-admin/src/stores/session/index.ts +0 -63
- package/template-vue-admin/src/stores/tags.ts +0 -109
- package/template-vue-admin/src/typings/global.d.ts +0 -70
- package/template-vue-admin/src/typings/index.ts +0 -13
- package/template-vue-admin/src/typings/system.d.ts +0 -46
- package/template-vue-admin/src/views/403.vue +0 -33
- package/template-vue-admin/src/views/[...all_404].vue +0 -557
- package/template-vue-admin/src/views/base/login.vue +0 -194
- package/template-vue-admin/src/views/dashboard/[name].vue +0 -28
- package/template-vue-admin/src/views/index.vue +0 -25
- package/template-vue-admin/src/views/system/api.vue +0 -160
- package/template-vue-admin/src/views/system/hooks/useRole.ts +0 -286
- package/template-vue-admin/src/views/system/menuList.vue +0 -194
- package/template-vue-admin/src/views/system/role.vue +0 -131
- package/template-vue-admin/src/views/system/user.vue +0 -192
- package/template-vue-admin/src/vite-env.d.ts +0 -52
- package/template-vue-admin/tsconfig.json +0 -21
- package/template-vue-admin/tsconfig.node.json +0 -9
- package/template-vue-admin/unocss.config.ts +0 -47
- package/template-vue-admin/vite.config.ts +0 -32
@@ -1,14 +1,14 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-18 16:50:32
|
4
|
-
* @LastEditTime: 2023-
|
4
|
+
* @LastEditTime: 2023-09-19 10:19:44
|
5
5
|
* @Description:
|
6
6
|
*/
|
7
|
-
import type {
|
7
|
+
import type { YoungHttp, YoungHttpAuthReq, YoungHttpFreeReq } from '@bluesyoung/http'
|
8
8
|
|
9
|
-
export function useGet(http:
|
10
|
-
const FreeReq:
|
11
|
-
const AuthReq:
|
9
|
+
export function useGet(http: YoungHttp) {
|
10
|
+
const FreeReq: YoungHttpFreeReq = args => http.freeReq({ method: 'GET', ...args })
|
11
|
+
const AuthReq: YoungHttpAuthReq = args => http.authReq({ method: 'GET', ...args })
|
12
12
|
|
13
13
|
return {
|
14
14
|
getByUserName: (name: string) =>
|
@@ -1,14 +1,14 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-18 16:59:34
|
4
|
-
* @LastEditTime: 2023-
|
4
|
+
* @LastEditTime: 2023-09-19 10:20:17
|
5
5
|
* @Description:
|
6
6
|
*/
|
7
|
-
import type {
|
7
|
+
import type { YoungHttp, YoungHttpAuthReq, YoungHttpFreeReq } from '@bluesyoung/http'
|
8
8
|
|
9
|
-
export function usePost(http:
|
10
|
-
const FreeReq:
|
11
|
-
const AuthReq:
|
9
|
+
export function usePost(http: YoungHttp) {
|
10
|
+
const FreeReq: YoungHttpFreeReq = args => http.freeReq({ method: 'GET', ...args })
|
11
|
+
const AuthReq: YoungHttpAuthReq = args => http.authReq({ method: 'GET', ...args })
|
12
12
|
|
13
13
|
return {
|
14
14
|
createRepo: async (name: string) => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-18 11:03:01
|
4
|
-
* @LastEditTime: 2023-
|
4
|
+
* @LastEditTime: 2023-09-19 10:18:06
|
5
5
|
* @Description:
|
6
6
|
*/
|
7
7
|
import { resolve } from 'node:path'
|
@@ -15,7 +15,7 @@ import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
|
15
15
|
import Unocss from 'unocss/vite'
|
16
16
|
import AutoImport from 'unplugin-auto-import/vite'
|
17
17
|
import AutoComponents from 'unplugin-vue-components/vite'
|
18
|
-
import { multiConf
|
18
|
+
import { multiConf } from './custom-plugins'
|
19
19
|
|
20
20
|
// https://vitejs.dev/config/
|
21
21
|
export default ({ command, mode }: ConfigEnv) => {
|
@@ -28,7 +28,6 @@ export default ({ command, mode }: ConfigEnv) => {
|
|
28
28
|
},
|
29
29
|
},
|
30
30
|
plugins: [
|
31
|
-
polyfillFormData(),
|
32
31
|
// 仅用于增加语法提示,实际导入依靠 uni-app 的 easycom
|
33
32
|
AutoComponents({
|
34
33
|
dts: true,
|
Binary file
|
@@ -1,32 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: zhangyang
|
3
|
-
* @Date: 2023-07-18 15:58:06
|
4
|
-
* @LastEditTime: 2023-07-19 14:32:28
|
5
|
-
* @Description:
|
6
|
-
*/
|
7
|
-
import type { Plugin } from 'vite'
|
8
|
-
|
9
|
-
export function polyfillFormData() {
|
10
|
-
return {
|
11
|
-
name: 'vite-plugin-uni-axios',
|
12
|
-
transform(code, id) {
|
13
|
-
if (process.env.UNI_PLATFORM?.includes('mp')) {
|
14
|
-
if (id.includes('/form-data/lib/browser.js')) {
|
15
|
-
return {
|
16
|
-
code: code.replace('window', 'globalThis'),
|
17
|
-
}
|
18
|
-
}
|
19
|
-
if (id.includes('/axios/lib/platform/browser/classes/FormData.js')) {
|
20
|
-
return {
|
21
|
-
code: 'import FormData from \'miniprogram-formdata\';\nexport default FormData;',
|
22
|
-
}
|
23
|
-
}
|
24
|
-
if (id.includes('/axios/lib/platform/browser/classes/Blob.js')) {
|
25
|
-
return {
|
26
|
-
code: 'import Blob from \'miniprogram-blob\';\nexport default Blob;',
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
},
|
31
|
-
} as Plugin
|
32
|
-
}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
const common_vendor = require("../../common/vendor.js");
|
3
|
-
const defaultConfig = {
|
4
|
-
baseURL: "/api",
|
5
|
-
method: "post",
|
6
|
-
timeout: 5e3,
|
7
|
-
loading: {
|
8
|
-
start: console.log.bind(null, "🚀 ~ http loading start"),
|
9
|
-
end: console.log.bind(null, "🚀 ~ http loading end")
|
10
|
-
},
|
11
|
-
fail: console.error.bind(null, "🚀 ~ http loading error"),
|
12
|
-
checkFn: (res) => res,
|
13
|
-
headers: {
|
14
|
-
getCommonHeaders: () => ({}),
|
15
|
-
getAuthHeaders: () => ({})
|
16
|
-
}
|
17
|
-
};
|
18
|
-
const useHttp = (config = {}) => {
|
19
|
-
const finalConfig = common_vendor.defu(config, defaultConfig);
|
20
|
-
const { baseURL, lazyBaseURL, method, timeout, headers, checkFn, loading, fail } = finalConfig;
|
21
|
-
const net = common_vendor.axios.create({
|
22
|
-
method,
|
23
|
-
timeout,
|
24
|
-
headers: headers.getCommonHeaders(),
|
25
|
-
adapter: common_vendor.Bt()
|
26
|
-
});
|
27
|
-
net.interceptors.request.use(
|
28
|
-
(req) => {
|
29
|
-
!req.notLoading && loading.start();
|
30
|
-
if (!req.baseURL) {
|
31
|
-
req.baseURL = (lazyBaseURL == null ? void 0 : lazyBaseURL()) ?? baseURL;
|
32
|
-
}
|
33
|
-
return req;
|
34
|
-
},
|
35
|
-
(error) => {
|
36
|
-
fail(error);
|
37
|
-
return Promise.reject(error);
|
38
|
-
}
|
39
|
-
);
|
40
|
-
net.interceptors.response.use(
|
41
|
-
(response) => {
|
42
|
-
!response.config.notLoading && loading.end();
|
43
|
-
const data = response.data;
|
44
|
-
try {
|
45
|
-
return checkFn(data);
|
46
|
-
} catch (err) {
|
47
|
-
fail(err);
|
48
|
-
}
|
49
|
-
},
|
50
|
-
(error) => {
|
51
|
-
!error.config.notLoading && loading.end();
|
52
|
-
fail(error);
|
53
|
-
}
|
54
|
-
);
|
55
|
-
return {
|
56
|
-
get: void 0,
|
57
|
-
post: void 0,
|
58
|
-
delete: void 0,
|
59
|
-
put: void 0,
|
60
|
-
patch: void 0,
|
61
|
-
head: void 0,
|
62
|
-
purge: void 0,
|
63
|
-
options: void 0,
|
64
|
-
link: void 0,
|
65
|
-
unlink: void 0,
|
66
|
-
__instance__: net,
|
67
|
-
__mixin__(extentions) {
|
68
|
-
for (const method2 in extentions) {
|
69
|
-
if (Object.prototype.hasOwnProperty.call(extentions, method2)) {
|
70
|
-
const originFns = this[method2] || {};
|
71
|
-
const fns = extentions[method2];
|
72
|
-
this[method2] = {
|
73
|
-
...originFns,
|
74
|
-
...fns
|
75
|
-
};
|
76
|
-
}
|
77
|
-
}
|
78
|
-
return this;
|
79
|
-
},
|
80
|
-
freeReq: net.request,
|
81
|
-
authReq: (args) => net.request({
|
82
|
-
...args,
|
83
|
-
headers: {
|
84
|
-
...headers.getAuthHeaders(),
|
85
|
-
...args == null ? void 0 : args.headers
|
86
|
-
}
|
87
|
-
})
|
88
|
-
};
|
89
|
-
};
|
90
|
-
exports.useHttp = useHttp;
|
@@ -1,235 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: zhangyang
|
3
|
-
* @Date: 2023-07-18 16:36:39
|
4
|
-
* @LastEditTime: 2023-09-06 19:40:19
|
5
|
-
* @Description:
|
6
|
-
*/
|
7
|
-
/// <reference types="@uni-helper/axios-adapter/client" />
|
8
|
-
import type { AxiosAdapter, AxiosInstance, AxiosRequestConfig, Method } from 'axios'
|
9
|
-
import axios from 'axios'
|
10
|
-
import { defu } from 'defu'
|
11
|
-
import { createUniAppAxiosAdapter } from '@uni-helper/axios-adapter'
|
12
|
-
|
13
|
-
type Simplify<T> = {
|
14
|
-
[P in keyof T]: T[P];
|
15
|
-
}
|
16
|
-
|
17
|
-
type SetRequired<T, K extends keyof T> = Simplify<
|
18
|
-
// 将要设置为可选类型的结构取出并设置为必选
|
19
|
-
Required<Pick<T, K>> &
|
20
|
-
// 取并集
|
21
|
-
// 排除需要设置为可选属性的结构,其余的保持不变
|
22
|
-
Pick<T, Exclude<keyof T, K>>
|
23
|
-
>
|
24
|
-
|
25
|
-
export type AllMethod = Lowercase<Method>
|
26
|
-
export type Fn<T = any, R = any> = (...args: T[]) => Promise<R>
|
27
|
-
export type Cbks = {
|
28
|
-
[k in AllMethod]?: Record<string, Fn>;
|
29
|
-
}
|
30
|
-
|
31
|
-
type Handlers<R extends Cbks> = {
|
32
|
-
[P in keyof R]?: R[P];
|
33
|
-
}
|
34
|
-
|
35
|
-
type Headers = Record<string, string>
|
36
|
-
|
37
|
-
type Req = <X = any>(config: AxiosRequestConfig<unknown>) => Promise<X>
|
38
|
-
|
39
|
-
interface Prototype {
|
40
|
-
__instance__: AxiosInstance
|
41
|
-
__mixin__<T extends Cbks>(
|
42
|
-
extentions: Handlers<T>,
|
43
|
-
): SetRequired<Handlers<T>, keyof T> & ThisType<Handlers<T>>
|
44
|
-
|
45
|
-
freeReq: Req
|
46
|
-
authReq: Req
|
47
|
-
}
|
48
|
-
|
49
|
-
export enum UsefulContentTypes {
|
50
|
-
JSON = 'application/json; charset=UTF-8',
|
51
|
-
URLEncoded = 'application/x-www-form-urlencoded; charset=UTF-8',
|
52
|
-
FormData = 'multipart/form-data; charset=UTF-8',
|
53
|
-
}
|
54
|
-
|
55
|
-
export interface DefaultMsg {
|
56
|
-
code: number
|
57
|
-
msg: string
|
58
|
-
data: any
|
59
|
-
}
|
60
|
-
|
61
|
-
export interface DefaultHttpConfig<Msg = DefaultMsg> {
|
62
|
-
/**
|
63
|
-
* 基础地址
|
64
|
-
* @default /api
|
65
|
-
*/
|
66
|
-
baseURL: string
|
67
|
-
/**
|
68
|
-
* 动态获取基础地址
|
69
|
-
*/
|
70
|
-
lazyBaseURL?: () => string
|
71
|
-
/**
|
72
|
-
* 默认方法
|
73
|
-
* @default post
|
74
|
-
*/
|
75
|
-
method: AllMethod
|
76
|
-
/**
|
77
|
-
* 超时时间
|
78
|
-
* @default 5e3 5s
|
79
|
-
*/
|
80
|
-
timeout: number
|
81
|
-
/**
|
82
|
-
* 加载函数
|
83
|
-
*/
|
84
|
-
loading: {
|
85
|
-
start: () => void
|
86
|
-
end: () => void
|
87
|
-
}
|
88
|
-
/**
|
89
|
-
* 错误处理函数,进行错误处理或继续抛出错误
|
90
|
-
* 接受各种抛出的错误
|
91
|
-
* @default console.error
|
92
|
-
*/
|
93
|
-
fail: (err: string | number | Error | Msg) => void
|
94
|
-
/**
|
95
|
-
* 结果校验 + 数据解析,判断此次请求是否正常,正常则返回解包数据,否则抛出异常
|
96
|
-
* 不传则默认使用标准 http 状态码作为判断结果,并原样返回
|
97
|
-
* @default () => any | never
|
98
|
-
*/
|
99
|
-
checkFn: (res: Msg) => any | never
|
100
|
-
/**
|
101
|
-
* 请求头
|
102
|
-
*/
|
103
|
-
headers: {
|
104
|
-
/**
|
105
|
-
* 生成公共请求头
|
106
|
-
* @default () => {}
|
107
|
-
*/
|
108
|
-
getCommonHeaders?: () => Headers
|
109
|
-
/**
|
110
|
-
* 生成鉴权请求头
|
111
|
-
* @default () => {}
|
112
|
-
*/
|
113
|
-
getAuthHeaders?: () => Headers
|
114
|
-
}
|
115
|
-
/**
|
116
|
-
* 自定义适配器
|
117
|
-
* 微信小程序等其他非标准环境时传入
|
118
|
-
*/
|
119
|
-
adapter?: AxiosAdapter
|
120
|
-
}
|
121
|
-
|
122
|
-
const defaultConfig: DefaultHttpConfig = {
|
123
|
-
baseURL: '/api',
|
124
|
-
method: 'post',
|
125
|
-
timeout: 5e3,
|
126
|
-
loading: {
|
127
|
-
start: console.log.bind(null, '🚀 ~ http loading start'),
|
128
|
-
end: console.log.bind(null, '🚀 ~ http loading end'),
|
129
|
-
},
|
130
|
-
fail: console.error.bind(null, '🚀 ~ http loading error'),
|
131
|
-
checkFn: res => res,
|
132
|
-
headers: {
|
133
|
-
getCommonHeaders: () => ({}),
|
134
|
-
getAuthHeaders: () => ({}),
|
135
|
-
},
|
136
|
-
}
|
137
|
-
|
138
|
-
declare module 'axios' {
|
139
|
-
export interface AxiosRequestConfig {
|
140
|
-
/**
|
141
|
-
* 禁用 loading 动画
|
142
|
-
* @default false
|
143
|
-
*/
|
144
|
-
notLoading?: boolean
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
export function useHttp<Msg extends Record<string, any> = DefaultMsg, Fns extends Cbks = Cbks>(config: Partial<DefaultHttpConfig<Msg>> = {}) {
|
149
|
-
const finalConfig = defu(config, defaultConfig)
|
150
|
-
|
151
|
-
const { baseURL, lazyBaseURL, method, timeout, headers, checkFn, loading, fail } = finalConfig
|
152
|
-
|
153
|
-
const net = axios.create({
|
154
|
-
method,
|
155
|
-
timeout,
|
156
|
-
headers: headers.getCommonHeaders!(),
|
157
|
-
adapter: createUniAppAxiosAdapter(),
|
158
|
-
})
|
159
|
-
|
160
|
-
net.interceptors.request.use(
|
161
|
-
(req) => {
|
162
|
-
!req.notLoading && loading.start()
|
163
|
-
if (!req.baseURL)
|
164
|
-
req.baseURL = lazyBaseURL?.() ?? baseURL
|
165
|
-
|
166
|
-
return req
|
167
|
-
},
|
168
|
-
(error) => {
|
169
|
-
fail(error)
|
170
|
-
return Promise.reject(error)
|
171
|
-
},
|
172
|
-
)
|
173
|
-
|
174
|
-
net.interceptors.response.use(
|
175
|
-
(response) => {
|
176
|
-
!response.config.notLoading && loading.end()
|
177
|
-
const data = response.data
|
178
|
-
|
179
|
-
try {
|
180
|
-
return checkFn(data)
|
181
|
-
}
|
182
|
-
catch (err) {
|
183
|
-
// 应用逻辑异常
|
184
|
-
fail(err as any)
|
185
|
-
}
|
186
|
-
},
|
187
|
-
(error) => {
|
188
|
-
!error.config.notLoading && loading.end()
|
189
|
-
// http 异常
|
190
|
-
fail(error)
|
191
|
-
},
|
192
|
-
)
|
193
|
-
|
194
|
-
return {
|
195
|
-
get: undefined,
|
196
|
-
post: undefined,
|
197
|
-
delete: undefined,
|
198
|
-
put: undefined,
|
199
|
-
patch: undefined,
|
200
|
-
head: undefined,
|
201
|
-
purge: undefined,
|
202
|
-
options: undefined,
|
203
|
-
link: undefined,
|
204
|
-
unlink: undefined,
|
205
|
-
__instance__: net,
|
206
|
-
__mixin__(extentions: any) {
|
207
|
-
for (const method in extentions) {
|
208
|
-
if (Object.prototype.hasOwnProperty.call(extentions, method)) {
|
209
|
-
// @ts-expect-error
|
210
|
-
const originFns = this[method] || {}
|
211
|
-
const fns = extentions[method]
|
212
|
-
// @ts-expect-error
|
213
|
-
this[method] = {
|
214
|
-
...originFns,
|
215
|
-
...fns,
|
216
|
-
}
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
return this
|
221
|
-
},
|
222
|
-
|
223
|
-
freeReq: net.request,
|
224
|
-
authReq: (args: AxiosRequestConfig) =>
|
225
|
-
net.request({
|
226
|
-
...args,
|
227
|
-
headers: {
|
228
|
-
...headers.getAuthHeaders!(),
|
229
|
-
...args?.headers,
|
230
|
-
},
|
231
|
-
}),
|
232
|
-
} as unknown as Handlers<Fns> & Prototype
|
233
|
-
}
|
234
|
-
|
235
|
-
export type Http = ReturnType<typeof useHttp>
|
@@ -1,108 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"list-add-admin": {
|
3
|
-
"prefix": "list-add",
|
4
|
-
"body": [
|
5
|
-
"<route lang=\"yaml\">",
|
6
|
-
"meta:",
|
7
|
-
" title: $1",
|
8
|
-
" authPath: $2",
|
9
|
-
"</route>",
|
10
|
-
"",
|
11
|
-
"<script lang=\"ts\" setup>",
|
12
|
-
"import { useFormMode, YoungDialog, YoungPagination, YoungTable, YoungSelect } from '@bluesyoung/ui-vue3-element-plus';",
|
13
|
-
"import type { TableHeadItem, TableDataItem, SelectOptionItem } from '@bluesyoung/ui-vue3-element-plus';",
|
14
|
-
"import { deepClone } from '@bluesyoung/utils';",
|
15
|
-
"import { $3 } from '@/typings';",
|
16
|
-
"import { apis } from '@/modules/3-net';",
|
17
|
-
"",
|
18
|
-
"interface Form extends $3 {};",
|
19
|
-
"const FORM_TEMP: Form = {};",
|
20
|
-
"const {",
|
21
|
-
" isAdd,",
|
22
|
-
" isEdit,",
|
23
|
-
" edit,",
|
24
|
-
" del,",
|
25
|
-
" sure,",
|
26
|
-
" clear,",
|
27
|
-
" form,",
|
28
|
-
" formRef,",
|
29
|
-
" validForm",
|
30
|
-
"} = useFormMode<Form>(FORM_TEMP, {",
|
31
|
-
" addCbk: async () => {",
|
32
|
-
" const res = await validForm() as boolean;",
|
33
|
-
" if (res) {",
|
34
|
-
" const v = deepClone(form.value);",
|
35
|
-
" // await apis.post.addUserItem(v);",
|
36
|
-
" ElMessage.success('新增成功!');",
|
37
|
-
" }",
|
38
|
-
" return res;",
|
39
|
-
" },",
|
40
|
-
" modCbk: async () => {",
|
41
|
-
" const res = await validForm() as boolean;",
|
42
|
-
" if (res) {",
|
43
|
-
" const v = deepClone(form.value);",
|
44
|
-
" // await apis.patch.changeUserItem(v);",
|
45
|
-
" ElMessage.success('修改成功!');",
|
46
|
-
" }",
|
47
|
-
" return res;",
|
48
|
-
" },",
|
49
|
-
" delCbk: async (row) => {",
|
50
|
-
" // await apis.delete.deleteUser(row.id.toString());",
|
51
|
-
" ElMessage.success('删除成功!');",
|
52
|
-
" query.pageNum = 1;",
|
53
|
-
" },",
|
54
|
-
" cgEffect: () => getList()",
|
55
|
-
"});",
|
56
|
-
"const tableHead: TableHeadItem<Form>[] = [",
|
57
|
-
" { prop: '', label: '' },",
|
58
|
-
"];",
|
59
|
-
"interface Query extends BaseQuery {};",
|
60
|
-
"const query = reactive<Query>({",
|
61
|
-
" pageNum: 1,",
|
62
|
-
" pageSize: 50,",
|
63
|
-
" total: 0,",
|
64
|
-
"});",
|
65
|
-
"",
|
66
|
-
"const tableData = ref<TableDataItem<Form>[]>([]);",
|
67
|
-
"const getList = async () => {",
|
68
|
-
" // const { list, pageNum, pageSize, total } = await apis.get.getUserList(query);",
|
69
|
-
" // tableData.value = deepClone(list || []);",
|
70
|
-
" // query.pageNum = +pageNum || 1;",
|
71
|
-
" // query.pageSize = +pageSize || 50;",
|
72
|
-
" // query.total = +total || 0;",
|
73
|
-
"};",
|
74
|
-
"",
|
75
|
-
"getList();",
|
76
|
-
"</script>",
|
77
|
-
"",
|
78
|
-
"<template>",
|
79
|
-
" <div class=\"flex\">",
|
80
|
-
" <div class=\"m-2\">",
|
81
|
-
" <ElInput v-model=\"query.\" placeholder=\"请输入\" />",
|
82
|
-
" </div>",
|
83
|
-
" <div class=\"m-2\">",
|
84
|
-
" <ElButton type=\"primary\" @click=\"getList\">搜索</ElButton>",
|
85
|
-
" </div>",
|
86
|
-
" <div class=\"m-2\">",
|
87
|
-
" <ElButton type=\"success\" @click=\"isAdd = true\">添加</ElButton>",
|
88
|
-
" </div>",
|
89
|
-
" </div>",
|
90
|
-
" <div class=\"m-2\">",
|
91
|
-
" <YoungTable :table-data=\"tableData\" :table-head=\"tableHead\" :table-height=\"680\" />",
|
92
|
-
" <YoungPagination v-show=\"query.total > 0\" v-model:page=\"query.pageNum\" v-model:limit=\"query.pageSize\"",
|
93
|
-
" :total=\"query.total\" @page-change=\"getList\" />",
|
94
|
-
" </div>",
|
95
|
-
" <YoungDialog :is-add=\"isAdd\" :is-edit=\"isEdit\" width=\"520px\" @sure=\"sure\" @clear=\"clear\">",
|
96
|
-
" <template #body>",
|
97
|
-
" <ElForm ref=\"formRef\" :model=\"form\" label-width=\"100px\">",
|
98
|
-
" <ElFormItem label=\"\" prop=\"\">",
|
99
|
-
" <ElInput v-model=\"form.\" class=\"!w-300px\" />",
|
100
|
-
" </ElFormItem>",
|
101
|
-
" </ElForm>",
|
102
|
-
" </template>",
|
103
|
-
" </YoungDialog>",
|
104
|
-
"</template>",
|
105
|
-
],
|
106
|
-
"description": "list-add-admin"
|
107
|
-
}
|
108
|
-
}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"list-export-admin": {
|
3
|
-
"prefix": "list-export",
|
4
|
-
"body": [
|
5
|
-
"<route lang=\"yaml\">",
|
6
|
-
"meta:",
|
7
|
-
" title: $1",
|
8
|
-
" authPath: $2",
|
9
|
-
"</route>",
|
10
|
-
"",
|
11
|
-
"<script lang=\"ts\" setup>",
|
12
|
-
"import { YoungTable, YoungPagination} from '@bluesyoung/ui-vue3-element-plus';",
|
13
|
-
"import type { TableDataItem, TableHeadItem } from '@bluesyoung/ui-vue3-element-plus';",
|
14
|
-
"import type { $3 } from '@/typings';",
|
15
|
-
"import { apis } from '@/modules/3-net';",
|
16
|
-
"",
|
17
|
-
"interface Form extends $3 {};",
|
18
|
-
"",
|
19
|
-
"const tableHead: TableHeadItem<Form>[] = [",
|
20
|
-
" { prop: '', label: '' },",
|
21
|
-
"];",
|
22
|
-
"const tableData = ref<TableDataItem<Form>[]>([]);",
|
23
|
-
"",
|
24
|
-
"type Query = BaseQuery & Partial<Form>;",
|
25
|
-
"const query = reactive<Query>({",
|
26
|
-
" pageNum: 1,",
|
27
|
-
" pageSize: 10,",
|
28
|
-
" total: 0,",
|
29
|
-
"});",
|
30
|
-
"",
|
31
|
-
"const getList = async () => {",
|
32
|
-
" // const { list, pageNum, pageSize, total } = await apis.get.getApiList(query);",
|
33
|
-
" // tableData.value = deepClone(list || []);",
|
34
|
-
" // query.pageNum = +pageNum || 1;",
|
35
|
-
" // query.pageSize = +pageSize || 50;",
|
36
|
-
" // query.total = +total || 0;",
|
37
|
-
"};",
|
38
|
-
"",
|
39
|
-
"const exportHandler = async () => {",
|
40
|
-
" const { useExport2Excel } = await import('@bluesyoung/ui-vue3-element-plus');",
|
41
|
-
" await useExport2Excel({",
|
42
|
-
" filename: '数据导出',",
|
43
|
-
" tableHead: tableHead,",
|
44
|
-
" tableData: tableData.value",
|
45
|
-
" });",
|
46
|
-
"};",
|
47
|
-
"",
|
48
|
-
"getList();",
|
49
|
-
"</script>",
|
50
|
-
"",
|
51
|
-
"<template>",
|
52
|
-
" <div class=\"flex\">",
|
53
|
-
" <div class=\"m-2\">",
|
54
|
-
" <ElInput v-model=\"query.\" placeholder=\"请输入\" />",
|
55
|
-
" </div>",
|
56
|
-
" <div class=\"m-2\">",
|
57
|
-
" <ElButton type=\"primary\" @click=\"getList\">搜索</ElButton>",
|
58
|
-
" </div>",
|
59
|
-
" <div class=\"m-2\">",
|
60
|
-
" <ElButton :disabled=\"tableData.length <= 0\" type=\"success\" @click=\"exportHandler\">导出</ElButton>",
|
61
|
-
" </div>",
|
62
|
-
" </div>",
|
63
|
-
" <div class=\"m-2\">",
|
64
|
-
" <YoungTable :table-data=\"tableData\" :table-head=\"tableHead\" :table-height=\"680\" />",
|
65
|
-
" <YoungPagination v-model:page=\"query.pageNum\" v-model:limit=\"query.pageSize\" :total=\"query.total\"",
|
66
|
-
" @page-change=\"getList\" />",
|
67
|
-
" </div>",
|
68
|
-
"</template>"
|
69
|
-
],
|
70
|
-
"description": "list-export-admin"
|
71
|
-
}
|
72
|
-
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"list-admin": {
|
3
|
-
"prefix": "list",
|
4
|
-
"body": [
|
5
|
-
"<route lang=\"yaml\">",
|
6
|
-
"meta:",
|
7
|
-
" title: $1",
|
8
|
-
" authPath: $2",
|
9
|
-
"</route>",
|
10
|
-
"",
|
11
|
-
"<script lang=\"ts\" setup>",
|
12
|
-
"import { YoungPagination, YoungTable } from '@bluesyoung/ui-vue3-element-plus';",
|
13
|
-
"import type { TableHeadItem, TableDataItem } from '@bluesyoung/ui-vue3-element-plus';",
|
14
|
-
"import { deepClone } from '@bluesyoung/utils';",
|
15
|
-
"import { $3 } from '@/typings';",
|
16
|
-
"import { apis } from '@/modules/3-net';",
|
17
|
-
"",
|
18
|
-
"interface Form extends $3 { };",
|
19
|
-
"",
|
20
|
-
"const tableHead: TableHeadItem<Form>[] = [",
|
21
|
-
" { prop: '', label: '' },",
|
22
|
-
"];",
|
23
|
-
"interface Query extends BaseQuery {};",
|
24
|
-
"const query = reactive<Query>({",
|
25
|
-
" pageNum: 1,",
|
26
|
-
" pageSize: 50,",
|
27
|
-
" total: 0,",
|
28
|
-
"});",
|
29
|
-
"",
|
30
|
-
"const tableData = ref<TableDataItem<Form>[]>([]);",
|
31
|
-
"const roleList = ref<SelectOptionItem[]>([]);",
|
32
|
-
"const getList = async () => {",
|
33
|
-
" // const { list, pageNum, pageSize, total } = await apis.get.getUserList(query);",
|
34
|
-
" // tableData.value = deepClone(list || []);",
|
35
|
-
" // query.pageNum = +pageNum || 1;",
|
36
|
-
" // query.pageSize = +pageSize || 50;",
|
37
|
-
" // query.total = +total || 0;",
|
38
|
-
"};",
|
39
|
-
"",
|
40
|
-
"getList();",
|
41
|
-
"</script>",
|
42
|
-
"",
|
43
|
-
"<template>",
|
44
|
-
" <div class=\"flex\">",
|
45
|
-
" <div class=\"m-2\">",
|
46
|
-
" <ElInput v-model=\"query.\" placeholder=\"请输入\" />",
|
47
|
-
" </div>",
|
48
|
-
" <div class=\"m-2\">",
|
49
|
-
" <ElButton type=\"primary\" @click=\"getList\">搜索</ElButton>",
|
50
|
-
" </div>",
|
51
|
-
" </div>",
|
52
|
-
" <div class=\"m-2\">",
|
53
|
-
" <YoungTable :table-data=\"tableData\" :table-head=\"tableHead\" :table-height=\"680\" />",
|
54
|
-
" <YoungPagination v-show=\"query.total > 0\" v-model:page=\"query.pageNum\" v-model:limit=\"query.pageSize\" :total=\"query.total\"",
|
55
|
-
" @page-change=\"getList\" />",
|
56
|
-
" </div>",
|
57
|
-
"</template>",
|
58
|
-
],
|
59
|
-
"description": "list-admin"
|
60
|
-
}
|
61
|
-
}
|