create-young-proj 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/index.mjs +2702 -42
- package/package.json +3 -3
- package/template-admin-server/package.json +2 -2
- package/template-vue-admin/build/custom-plugin.ts +30 -0
- package/template-vue-admin/build/index.ts +7 -0
- package/template-vue-admin/build/plugins.ts +59 -0
- package/template-vue-admin/package.json +1 -1
- package/template-vue-admin/src/main.ts +4 -4
- package/template-vue-admin/src/modules/4-auth.ts +8 -4
- package/template-vue-admin/src/shims.d.ts +12 -0
- package/template-vue-admin/tsconfig.node.json +1 -1
- package/template-vue-admin/vite.config.ts +4 -49
- package/template-vue-mobile/.vscode/base.code-snippets +24 -0
- package/template-vue-mobile/.vscode/extensions.json +10 -0
- package/template-vue-mobile/.vscode/settings.json +7 -0
- package/template-vue-mobile/Dockerfile +42 -0
- package/template-vue-mobile/README.md +71 -0
- package/template-vue-mobile/_env +6 -0
- package/template-vue-mobile/_gitignore +30 -0
- package/template-vue-mobile/boot.mjs +16 -0
- package/template-vue-mobile/build/custom-plugin.ts +30 -0
- package/template-vue-mobile/build/index.ts +7 -0
- package/template-vue-mobile/build/plugins.ts +68 -0
- package/template-vue-mobile/config/.devrc +2 -0
- package/template-vue-mobile/config/.onlinerc +1 -0
- package/template-vue-mobile/config/.testrc +1 -0
- package/template-vue-mobile/index.html +25 -0
- package/template-vue-mobile/nitro.config.ts +19 -0
- package/template-vue-mobile/package.json +48 -0
- package/template-vue-mobile/plugins/env.ts +26 -0
- package/template-vue-mobile/public/vite.svg +1 -0
- package/template-vue-mobile/rome.json +24 -0
- package/template-vue-mobile/routes/[...all].ts +11 -0
- package/template-vue-mobile/routes/get/env.ts +25 -0
- package/template-vue-mobile/src/App.vue +29 -0
- package/template-vue-mobile/src/auto-components.d.ts +24 -0
- package/template-vue-mobile/src/auto-imports.d.ts +289 -0
- package/template-vue-mobile/src/components/Init.vue +36 -0
- package/template-vue-mobile/src/global.d.ts +7 -0
- package/template-vue-mobile/src/hooks/useVerifyCode.ts +46 -0
- package/template-vue-mobile/src/layouts/blank.vue +9 -0
- package/template-vue-mobile/src/layouts/default.vue +27 -0
- package/template-vue-mobile/src/layouts/sub.vue +20 -0
- package/template-vue-mobile/src/main.ts +35 -0
- package/template-vue-mobile/src/modules/1-router.ts +40 -0
- package/template-vue-mobile/src/modules/2-pinia.ts +10 -0
- package/template-vue-mobile/src/modules/3-net.ts +46 -0
- package/template-vue-mobile/src/modules/4-auth.ts +64 -0
- package/template-vue-mobile/src/views/[...all_404].vue +557 -0
- package/template-vue-mobile/src/views/base/login.vue +110 -0
- package/template-vue-mobile/src/views/base/resetPasswd.vue +88 -0
- package/template-vue-mobile/src/views/index.vue +18 -0
- package/template-vue-mobile/src/views/my.vue +15 -0
- package/template-vue-mobile/src/views/sub.vue +18 -0
- package/template-vue-mobile/src/vite-env.d.ts +43 -0
- package/template-vue-mobile/tsconfig.json +21 -0
- package/template-vue-mobile/tsconfig.node.json +9 -0
- package/template-vue-mobile/unocss.config.ts +47 -0
- package/template-vue-mobile/vite.config.ts +32 -0
- package/template-vue-mobile/yarn.lock +4395 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
<!--
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2022-12-03 16:21:10
|
4
|
+
* @LastEditTime: 2023-02-01 11:24:56
|
5
|
+
* @Description:
|
6
|
+
-->
|
7
|
+
<script lang="ts" setup>
|
8
|
+
const route = useRoute();
|
9
|
+
const title = computed(() => route.meta.title || import.meta.env.VITE_TITLE);
|
10
|
+
</script>
|
11
|
+
|
12
|
+
<template>
|
13
|
+
<VanNavBar :border="false" left-arrow @click-left="$router.back()">
|
14
|
+
<template #title>
|
15
|
+
<span class="text-[#FFFFFF] text-16px font-700">{{ title }}</span>
|
16
|
+
</template>
|
17
|
+
</VanNavBar>
|
18
|
+
<RouterView v-bind="$attrs" />
|
19
|
+
</template>
|
20
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2022-12-03 15:57:40
|
4
|
+
* @LastEditTime: 2023-02-01 12:01:43
|
5
|
+
* @Description:
|
6
|
+
*/
|
7
|
+
// polyfill
|
8
|
+
import 'core-js/stable';
|
9
|
+
import 'regenerator-runtime/runtime';
|
10
|
+
// 统一浏览器样式
|
11
|
+
import '@unocss/reset/tailwind.css';
|
12
|
+
import 'uno.css';
|
13
|
+
// vant 指令的样式
|
14
|
+
import 'vant/es/toast/style/index';
|
15
|
+
import 'vant/es/dialog/style/index';
|
16
|
+
import 'vant/es/notify/style/index';
|
17
|
+
import 'vant/es/image-preview/style/index';
|
18
|
+
|
19
|
+
import { createApp } from 'vue';
|
20
|
+
import App from './App.vue';
|
21
|
+
|
22
|
+
const app = createApp(App);
|
23
|
+
|
24
|
+
Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true })).map(
|
25
|
+
({ install }) => install(app),
|
26
|
+
);
|
27
|
+
|
28
|
+
setTimeout(async () => {
|
29
|
+
if (window?.__YOUNG_VITE_ENV__?.VITE_ENABLE_VCONSOLE) {
|
30
|
+
const VConsole = await (await import('vconsole')).default;
|
31
|
+
new VConsole();
|
32
|
+
}
|
33
|
+
}, 1e4);
|
34
|
+
|
35
|
+
app.mount('#app');
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2022-03-01 14:01:31
|
4
|
+
* @LastEditTime: 2023-02-01 11:22:42
|
5
|
+
* @Description: 路由模块
|
6
|
+
*/
|
7
|
+
import { createRouter, createWebHashHistory } from 'vue-router';
|
8
|
+
import { setupLayouts } from 'virtual:generated-layouts';
|
9
|
+
import routes from '~pages';
|
10
|
+
|
11
|
+
/**
|
12
|
+
* 路由元数据类型扩展
|
13
|
+
*/
|
14
|
+
declare module 'vue-router' {
|
15
|
+
interface RouteMeta {
|
16
|
+
/**
|
17
|
+
* 页面标题
|
18
|
+
*/
|
19
|
+
title: string;
|
20
|
+
/**
|
21
|
+
* 需要登录,不设置则为白名单页面
|
22
|
+
*/
|
23
|
+
auth?: boolean;
|
24
|
+
/**
|
25
|
+
* 页面布局,对应 layouts 目录下的布局页面,默认为 default
|
26
|
+
*/
|
27
|
+
layout?: 'default' | 'sub' | 'blank';
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
export const finalRoutes = setupLayouts(routes);
|
32
|
+
|
33
|
+
export const router = createRouter({
|
34
|
+
history: createWebHashHistory(),
|
35
|
+
routes: finalRoutes,
|
36
|
+
});
|
37
|
+
|
38
|
+
export const install: UserModule = (app) => {
|
39
|
+
app.use(router);
|
40
|
+
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2022-03-01 14:01:31
|
4
|
+
* @LastEditTime: 2023-01-13 15:54:59
|
5
|
+
* @Description: 网络请求
|
6
|
+
*/
|
7
|
+
import { useHttp } from '@bluesyoung/http';
|
8
|
+
|
9
|
+
let loadingInstance: ReturnType<typeof showLoadingToast>;
|
10
|
+
|
11
|
+
export const startLoading = () => {
|
12
|
+
loadingInstance = showLoadingToast({
|
13
|
+
message: '拼命加载中...',
|
14
|
+
forbidClick: true,
|
15
|
+
});
|
16
|
+
};
|
17
|
+
|
18
|
+
export const endLoading = () => loadingInstance?.close?.();
|
19
|
+
|
20
|
+
export const http = useHttp({
|
21
|
+
timeout: -1,
|
22
|
+
loading: {
|
23
|
+
start: startLoading,
|
24
|
+
end: endLoading,
|
25
|
+
},
|
26
|
+
fail(err) {
|
27
|
+
console.log('🚀 ~ file: 3-net.ts:60 ~ err', err, typeof err);
|
28
|
+
if (typeof err === 'string') {
|
29
|
+
// 通用失败,弹出提示信息
|
30
|
+
showFailToast(err);
|
31
|
+
}
|
32
|
+
|
33
|
+
if (err instanceof Error) {
|
34
|
+
showFailToast(
|
35
|
+
// @ts-ignore 接口出错
|
36
|
+
err?.response?.data?.message || err?.response?.data?.msg || err.message || '网络错误!',
|
37
|
+
);
|
38
|
+
}
|
39
|
+
|
40
|
+
throw err;
|
41
|
+
},
|
42
|
+
});
|
43
|
+
|
44
|
+
export const apis = http.__mixin__({});
|
45
|
+
|
46
|
+
export const install: UserModule = (ctx) => {};
|
@@ -0,0 +1,64 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2022-03-01 19:40:13
|
4
|
+
* @LastEditTime: 2023-02-01 11:46:18
|
5
|
+
* @Description: 权限校验
|
6
|
+
*/
|
7
|
+
import { router } from './1-router';
|
8
|
+
import type { RouteLocationNormalized } from 'vue-router';
|
9
|
+
import { YoungLocalStorage } from '@bluesyoung/utils';
|
10
|
+
|
11
|
+
const changeTitle = (to: RouteLocationNormalized) => {
|
12
|
+
document.title = to.meta.title || (import.meta.env.VITE_TITLE as string);
|
13
|
+
};
|
14
|
+
|
15
|
+
export const hasPermission = (path: string) => {};
|
16
|
+
|
17
|
+
export const sureLeave = async () => {
|
18
|
+
try {
|
19
|
+
await showConfirmDialog({
|
20
|
+
title: '温馨提示',
|
21
|
+
message: '您确定要离开吗?',
|
22
|
+
});
|
23
|
+
return true;
|
24
|
+
} catch (error) {
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
export const install: UserModule = (app) => {
|
30
|
+
// todo: 按需替换为 api 操作
|
31
|
+
const store = new YoungLocalStorage();
|
32
|
+
const api = {
|
33
|
+
getInfo: () => store.get('user.info'),
|
34
|
+
setInfo: () => store.set('user.info', { key: 'cdcsdfdf' }),
|
35
|
+
};
|
36
|
+
|
37
|
+
router.beforeEach(async (to, from) => {
|
38
|
+
// auth
|
39
|
+
if (to.meta.auth) {
|
40
|
+
const info = await api.getInfo();
|
41
|
+
if (info) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
try {
|
45
|
+
// todo: 可根据情况替换为跳转登录页, /base/login
|
46
|
+
await showDialog({
|
47
|
+
title: '温馨提示',
|
48
|
+
message: '我是默认的登录框,点击即登录',
|
49
|
+
showCancelButton: true,
|
50
|
+
});
|
51
|
+
await api.setInfo();
|
52
|
+
return true;
|
53
|
+
} catch (error) {
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
} else {
|
57
|
+
return true;
|
58
|
+
}
|
59
|
+
});
|
60
|
+
|
61
|
+
router.afterEach((to) => {
|
62
|
+
changeTitle(to);
|
63
|
+
});
|
64
|
+
};
|