create-young-proj 0.6.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. package/README.md +5 -3
  2. package/dist/index.mjs +9 -9
  3. package/package.json +3 -6
  4. package/template-nuxt-admin/Dockerfile +41 -0
  5. package/template-nuxt-admin/README.md +57 -0
  6. package/template-nuxt-admin/_gitignore +23 -0
  7. package/template-nuxt-admin/_npmrc +2 -0
  8. package/template-nuxt-admin/app.vue +41 -0
  9. package/template-nuxt-admin/boot.mjs +16 -0
  10. package/template-nuxt-admin/components/ScreenFull.vue +18 -0
  11. package/template-nuxt-admin/components/TopSearch.vue +73 -0
  12. package/template-nuxt-admin/components/TopUser.vue +69 -0
  13. package/template-nuxt-admin/components/YoungChangePassword.vue +87 -0
  14. package/template-nuxt-admin/components/YoungCodeInput.vue +60 -0
  15. package/template-nuxt-admin/components/YoungLink.vue +23 -0
  16. package/template-nuxt-admin/components/YoungLoading.vue +39 -0
  17. package/template-nuxt-admin/components/layout/Footer.vue +29 -0
  18. package/template-nuxt-admin/components/layout/Logo.vue +52 -0
  19. package/template-nuxt-admin/components/layout/Main.vue +26 -0
  20. package/template-nuxt-admin/components/layout/NavBar.vue +77 -0
  21. package/template-nuxt-admin/components/layout/SideBar.vue +89 -0
  22. package/template-nuxt-admin/components/layout/SubMenu.vue +46 -0
  23. package/template-nuxt-admin/components/layout/TabsBar.vue +183 -0
  24. package/template-nuxt-admin/composables/api.ts +104 -0
  25. package/template-nuxt-admin/composables/apis/delete.ts +37 -0
  26. package/template-nuxt-admin/composables/apis/get.ts +83 -0
  27. package/template-nuxt-admin/composables/apis/index.ts +10 -0
  28. package/template-nuxt-admin/composables/apis/patch.ts +74 -0
  29. package/template-nuxt-admin/composables/apis/post.ts +85 -0
  30. package/template-nuxt-admin/composables/config.ts +13 -0
  31. package/template-nuxt-admin/composables/icon.ts +27 -0
  32. package/template-nuxt-admin/composables/nav.ts +60 -0
  33. package/template-nuxt-admin/composables/tags.ts +114 -0
  34. package/template-nuxt-admin/composables/user.ts +29 -0
  35. package/template-nuxt-admin/config/.devrc +1 -0
  36. package/template-nuxt-admin/config/.onlinerc +1 -0
  37. package/template-nuxt-admin/config/.testrc +1 -0
  38. package/template-nuxt-admin/env.d.ts +47 -0
  39. package/template-nuxt-admin/error.vue +53 -0
  40. package/template-nuxt-admin/layouts/blank.vue +9 -0
  41. package/template-nuxt-admin/layouts/default.vue +124 -0
  42. package/template-nuxt-admin/middleware/auth.global.ts +50 -0
  43. package/template-nuxt-admin/nuxt.config.ts +101 -0
  44. package/template-nuxt-admin/package.json +44 -0
  45. package/template-nuxt-admin/pages/home/[id].vue +28 -0
  46. package/template-nuxt-admin/pages/index.vue +20 -0
  47. package/template-nuxt-admin/pages/login.vue +179 -0
  48. package/template-nuxt-admin/pages/system/api.vue +166 -0
  49. package/template-nuxt-admin/pages/system/hooks/useRole.ts +336 -0
  50. package/template-nuxt-admin/pages/system/menuList.vue +329 -0
  51. package/template-nuxt-admin/pages/system/role.vue +117 -0
  52. package/template-nuxt-admin/pages/system/user.vue +214 -0
  53. package/template-nuxt-admin/plugins/directive.ts +26 -0
  54. package/template-nuxt-admin/public/default_avatar.svg +1 -0
  55. package/template-nuxt-admin/public/favicon.ico +0 -0
  56. package/template-nuxt-admin/public/image_placeholder.svg +15 -0
  57. package/template-nuxt-admin/public/tabbar_bg.png +0 -0
  58. package/template-nuxt-admin/rome.json +26 -0
  59. package/template-nuxt-admin/server/api/[...all].ts +10 -0
  60. package/template-nuxt-admin/server/plugins/env.ts +89 -0
  61. package/template-nuxt-admin/server/routes/get/env.ts +13 -0
  62. package/template-nuxt-admin/server/tsconfig.json +3 -0
  63. package/template-nuxt-admin/server/utils/index.ts +35 -0
  64. package/template-nuxt-admin/styles/element.scss +30 -0
  65. package/template-nuxt-admin/styles/index.scss +59 -0
  66. package/template-nuxt-admin/styles/variable.scss +103 -0
  67. package/template-nuxt-admin/tsconfig.json +7 -0
  68. package/template-nuxt-admin/typings/global.d.ts +16 -0
  69. package/template-nuxt-admin/typings/system.d.ts +66 -0
  70. package/template-nuxt-admin/typings/user.d.ts +19 -0
  71. package/template-nuxt-admin/uno.config.ts +40 -0
  72. package/template-nuxt-admin/utils/tool.ts +207 -0
  73. package/template-nuxt-admin/yarn.lock +7103 -0
  74. package/template-uni-app/README.md +20 -0
  75. package/template-uni-app/_env +1 -1
  76. package/template-uni-app/_env.development +2 -2
  77. package/template-uni-app/_env.production +0 -3
  78. package/template-uni-app/_env.test +0 -3
  79. package/template-uni-app/_npmrc +2 -0
  80. package/template-uni-app/auto-imports.d.ts +3 -0
  81. package/template-uni-app/dist/dev/mp-weixin/apis/index.js +44 -0
  82. package/template-uni-app/dist/dev/mp-weixin/apis/lib/index.js +90 -0
  83. package/template-uni-app/dist/dev/mp-weixin/apis/requests/get.js +10 -0
  84. package/template-uni-app/dist/dev/mp-weixin/apis/requests/index.js +1 -0
  85. package/template-uni-app/dist/dev/mp-weixin/apis/requests/post.js +15 -0
  86. package/template-uni-app/dist/dev/mp-weixin/app.js +93 -0
  87. package/template-uni-app/dist/dev/mp-weixin/app.json +51 -0
  88. package/template-uni-app/dist/dev/mp-weixin/app.wxss +2378 -0
  89. package/template-uni-app/dist/dev/mp-weixin/common/assets.js +13 -0
  90. package/template-uni-app/dist/dev/mp-weixin/common/vendor.js +10189 -0
  91. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.js +22 -0
  92. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.json +4 -0
  93. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.wxml +1 -0
  94. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.wxss +0 -0
  95. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.js +22 -0
  96. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.json +4 -0
  97. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.wxml +1 -0
  98. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.wxss +0 -0
  99. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.js +82 -0
  100. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.json +4 -0
  101. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.wxml +1 -0
  102. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.wxss +108 -0
  103. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.js +56 -0
  104. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.json +4 -0
  105. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.wxml +1 -0
  106. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.wxss +88 -0
  107. package/template-uni-app/dist/dev/mp-weixin/config/enum.js +21 -0
  108. package/template-uni-app/dist/dev/mp-weixin/config/index.js +1 -0
  109. package/template-uni-app/dist/dev/mp-weixin/config/map.js +1 -0
  110. package/template-uni-app/dist/dev/mp-weixin/layouts/default.js +30 -0
  111. package/template-uni-app/dist/dev/mp-weixin/layouts/default.json +6 -0
  112. package/template-uni-app/dist/dev/mp-weixin/layouts/default.wxml +1 -0
  113. package/template-uni-app/dist/dev/mp-weixin/layouts/default.wxss +0 -0
  114. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.js +56 -0
  115. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.json +9 -0
  116. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.wxml +1 -0
  117. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.wxss +0 -0
  118. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.js +98 -0
  119. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.json +4 -0
  120. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.wxml +1 -0
  121. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.wxss +125 -0
  122. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.js +38 -0
  123. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.json +5 -0
  124. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.wxml +1 -0
  125. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.wxss +0 -0
  126. package/template-uni-app/dist/dev/mp-weixin/pages/index.js +51 -0
  127. package/template-uni-app/dist/dev/mp-weixin/pages/index.json +5 -0
  128. package/template-uni-app/dist/dev/mp-weixin/pages/index.wxml +1 -0
  129. package/template-uni-app/dist/dev/mp-weixin/pages/index.wxss +0 -0
  130. package/template-uni-app/dist/dev/mp-weixin/pages/my.js +22 -0
  131. package/template-uni-app/dist/dev/mp-weixin/pages/my.json +3 -0
  132. package/template-uni-app/dist/dev/mp-weixin/pages/my.wxml +1 -0
  133. package/template-uni-app/dist/dev/mp-weixin/pages/my.wxss +0 -0
  134. package/template-uni-app/dist/dev/mp-weixin/project.config.json +56 -0
  135. package/template-uni-app/dist/dev/mp-weixin/static/back.png +0 -0
  136. package/template-uni-app/dist/dev/mp-weixin/static/h.png +0 -0
  137. package/template-uni-app/dist/dev/mp-weixin/static/home.png +0 -0
  138. package/template-uni-app/dist/dev/mp-weixin/static/home_active.png +0 -0
  139. package/template-uni-app/dist/dev/mp-weixin/static/more.png +0 -0
  140. package/template-uni-app/dist/dev/mp-weixin/static/my.png +0 -0
  141. package/template-uni-app/dist/dev/mp-weixin/static/my_active.png +0 -0
  142. package/template-uni-app/dist/dev/mp-weixin/static/network.png +0 -0
  143. package/template-uni-app/dist/dev/mp-weixin/store/index.js +8 -0
  144. package/template-uni-app/dist/dev/mp-weixin/store/local/index.js +11 -0
  145. package/template-uni-app/dist/dev/mp-weixin/store/system.js +14 -0
  146. package/template-uni-app/dist/dev/mp-weixin/utils/modal.js +82 -0
  147. package/template-uni-app/dist/dev/mp-weixin/utils/route.js +85 -0
  148. package/template-uni-app/dist/dev/mp-weixin/utils/system.js +27 -0
  149. package/template-uni-app/src/apis/index.ts +17 -14
  150. package/template-uni-app/src/components/young-loading/young-loading.vue +6 -13
  151. package/template-uni-app/src/components/young-loading-mini/young-loading-mini.vue +3 -10
  152. package/template-uni-app/src/layouts/default.vue +2 -3
  153. package/template-uni-app/src/layouts/tabbar.vue +22 -15
  154. package/template-uni-app/src/pages/index.vue +12 -3
  155. package/template-uni-app/src/pages/my.vue +15 -12
  156. package/template-uni-app/src/pages.json +8 -2
  157. package/template-uni-app/src/store/system.ts +4 -3
  158. package/template-uni-app/src/typings/global.d.ts +7 -0
  159. package/template-uni-app/src/utils/auth.ts +71 -1
  160. package/template-uni-app/src/utils/modal.ts +30 -7
  161. package/template-vue-admin/src/views/system/menuList.vue +3 -3
@@ -0,0 +1,207 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-05-28 16:01:24
4
+ * @LastEditTime: 2023-07-31 14:45:23
5
+ * @Description:
6
+ */
7
+ import { randomId } from '@bluesyoung/utils';
8
+ import YoungChangePassword from '@/components/YoungChangePassword.vue';
9
+ import { createVNode, render } from 'vue';
10
+
11
+ /**
12
+ * 补0函数
13
+ */
14
+ export function addZero(s: number) {
15
+ return s < 10 ? '0' + s : s;
16
+ }
17
+
18
+ /**
19
+ * 生成数组的随机索引
20
+ */
21
+ export function getRandomIndex(length: number) {
22
+ return Math.floor(Math.random() * length);
23
+ }
24
+
25
+ /**
26
+ * 设备唯一标识
27
+ */
28
+ export function getUUID() {
29
+ return useLocalStorage('uuid', randomId() + randomId() + randomId() + randomId()).value;
30
+ }
31
+
32
+ /**
33
+ * html 转 text
34
+ */
35
+ export function html2text(html: string) {
36
+ if (!html) {
37
+ return '';
38
+ }
39
+ return html.toString().replace(/<[^>]+>/g, '');
40
+ }
41
+
42
+ /**
43
+ * 响应式的屏幕大小
44
+ */
45
+ export const WindowSize = reactive({
46
+ 'lt-sm': useMediaQuery('(max-width: 639.9px)'),
47
+ sm: useMediaQuery('(min-width: 640px)'),
48
+ 'lt-md': useMediaQuery('(max-width: 767.9px)'),
49
+ md: useMediaQuery('(min-width: 768px)'),
50
+ 'lt-lg': useMediaQuery('(max-width: 1023.9px)'),
51
+ lg: useMediaQuery('(min-width: 1024px)'),
52
+ 'lt-xl': useMediaQuery('(max-width: 1279.9px)'),
53
+ xl: useMediaQuery('(min-width: 1280px)'),
54
+ 'lt-2xl': useMediaQuery('(max-width: 1535.9px)'),
55
+ '2xl': useMediaQuery('(min-width: 1536px)'),
56
+ });
57
+
58
+ /**
59
+ * 分页是否超过一页
60
+ */
61
+ export function moreThanOnePage(query: {
62
+ total: number;
63
+ limit: number;
64
+ }) {
65
+ return query.total > query.limit;
66
+ }
67
+
68
+ /**
69
+ * 当前浏览器是否支持下载
70
+ */
71
+ export function isSupportDownload() {
72
+ const NotAllowed = [/Alipay/gim, /BYTEDANCE/gim, /DINGTALK/gim, /MICROMESSENGER/gim];
73
+
74
+ return !NotAllowed.some((reg) => reg.test(navigator.userAgent));
75
+ }
76
+
77
+ /**
78
+ * 登录校验
79
+ */
80
+ export function checkLogin(force = true) {
81
+ const { hasLogin } = storeToRefs(useUserStore());
82
+
83
+ if (!hasLogin.value) {
84
+ force &&
85
+ showDialog({
86
+ title: '温馨提示',
87
+ message: '未登录,请登录后再继续!',
88
+ showCancelButton: true,
89
+ })
90
+ .then(() => {
91
+ navigateTo(
92
+ `/login?redirect=${encodeURIComponent(location.href.replace(location.origin, ''))}`,
93
+ );
94
+ })
95
+ .catch(() => {
96
+ navigateTo({
97
+ path: '/',
98
+ replace: true,
99
+ });
100
+ });
101
+ return false;
102
+ } else {
103
+ return true;
104
+ }
105
+ }
106
+
107
+ /**
108
+ * 页面滚动是否超过一定距离
109
+ */
110
+ export function useScrollOver(distance = 40) {
111
+ const { y } = useScroll(window);
112
+ const scrolled = computed(() => y.value > distance);
113
+
114
+ return {
115
+ scrolled,
116
+ };
117
+ }
118
+
119
+ /**
120
+ * 生成用户导航栏
121
+ */
122
+ export async function generateNavData() {
123
+ const { hasLogin } = storeToRefs(useUserStore());
124
+ if (!hasLogin.value) {
125
+ showNotify({
126
+ type: 'danger',
127
+ message: '登录过期,请重新登录!',
128
+ });
129
+
130
+ return navigateTo('/login');
131
+ }
132
+
133
+ // 清除没有子元素的children
134
+ const clearChildren = (arr: NavArrItem[]) => {
135
+ for (const item of arr) {
136
+ if (
137
+ item?.children?.length === 0 ||
138
+ item.children?.filter((n) => +n.visible === 1).length === 0
139
+ ) {
140
+ delete item.children;
141
+ } else if (item.children) {
142
+ clearChildren(item.children);
143
+ }
144
+ }
145
+ return arr;
146
+ };
147
+
148
+ const { nav_arr, flat_nav_arr, auth_routes } = storeToRefs(useNavStore());
149
+
150
+ const tree = await apis.get.getUserMenuTree();
151
+ const menu = Object.values(tree);
152
+
153
+ let role_route: string[] = [];
154
+ const generateRoleRoute = (arr: NavArrItem[], num?: number): string[] => {
155
+ if (num === 1) {
156
+ role_route = [];
157
+ flat_nav_arr.value = [];
158
+ }
159
+ for (const item of arr) {
160
+ if (item.component) {
161
+ role_route.push(item.component);
162
+ +item.visible === 1 && flat_nav_arr.value.push(item);
163
+ }
164
+ // 子节点递归遍历
165
+ if (Array.isArray(item.children) && item.children.length > 0) {
166
+ const part = JSON.parse(JSON.stringify(item.children));
167
+ // 尾递归优化
168
+ generateRoleRoute(part);
169
+ }
170
+ }
171
+ return role_route;
172
+ };
173
+
174
+ auth_routes.value = generateRoleRoute(menu, 1);
175
+
176
+ /**
177
+ * 最终导航数组
178
+ */
179
+ nav_arr.value = clearChildren(menu.filter((item) => +item.visible === 1));
180
+ }
181
+
182
+ /**
183
+ * 权限校验
184
+ * @param path
185
+ */
186
+ export function hasPermission(path: string) {
187
+ const { auth_routes } = storeToRefs(useNavStore());
188
+ return ['/', ...auth_routes.value].includes(path);
189
+ }
190
+
191
+ /**
192
+ * 修改密码
193
+ */
194
+ export function useChangePassword() {
195
+ const appendTo = document.createElement('div');
196
+
197
+ const vnode = createVNode(YoungChangePassword, {
198
+ onDestroy: () => {
199
+ document.body.removeChild(appendTo);
200
+ },
201
+ });
202
+ render(vnode, appendTo);
203
+
204
+ document.body.appendChild(appendTo);
205
+
206
+ vnode.component!.exposed?.show();
207
+ }