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.
Files changed (130) hide show
  1. package/dist/index.mjs +9 -9
  2. package/package.json +1 -1
  3. package/template-nuxt-admin/README.md +42 -1
  4. package/template-nuxt-admin/components/layout/Main.vue +2 -2
  5. package/template-nuxt-admin/components/layout/NavBar.vue +11 -2
  6. package/template-nuxt-admin/components/layout/SideBar.vue +6 -2
  7. package/template-nuxt-admin/components/layout/SubMenu.vue +9 -2
  8. package/template-nuxt-admin/components/layout/TabsBar.vue +4 -5
  9. package/template-nuxt-admin/composables/api.ts +17 -3
  10. package/template-nuxt-admin/composables/nav.ts +20 -3
  11. package/template-nuxt-admin/composables/tags.ts +29 -1
  12. package/template-nuxt-admin/middleware/auth.global.ts +16 -4
  13. package/template-nuxt-admin/nuxt.config.ts +5 -1
  14. package/template-nuxt-admin/package.json +5 -5
  15. package/template-nuxt-admin/pages/home/[id].vue +2 -2
  16. package/template-nuxt-admin/pages/index.vue +2 -7
  17. package/template-nuxt-admin/pages/login.vue +2 -2
  18. package/template-nuxt-admin/pages/system/menuList.vue +0 -1
  19. package/template-nuxt-admin/public/bg.webp +0 -0
  20. package/template-nuxt-admin/public/favicon.svg +2 -0
  21. package/template-nuxt-admin/public/logo.svg +2 -0
  22. package/template-nuxt-admin/server/plugins/env.ts +3 -4
  23. package/template-nuxt-admin/utils/tool.ts +17 -1
  24. package/template-nuxt-admin/yarn.lock +706 -854
  25. package/template-uni-app/auto-imports.d.ts +9 -6
  26. package/template-uni-app/custom-plugins/index.ts +1 -2
  27. package/template-uni-app/dist/dev/mp-weixin/apis/index.js +5 -6
  28. package/template-uni-app/dist/dev/mp-weixin/apis/requests/get.js +2 -2
  29. package/template-uni-app/dist/dev/mp-weixin/apis/requests/post.js +4 -4
  30. package/template-uni-app/dist/dev/mp-weixin/app.js +4 -5
  31. package/template-uni-app/dist/dev/mp-weixin/common/vendor.js +1448 -2471
  32. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.js +7 -8
  33. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.wxml +1 -1
  34. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.js +7 -8
  35. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.wxml +1 -1
  36. package/template-uni-app/dist/dev/mp-weixin/layouts/default.js +1 -2
  37. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.wxml +1 -1
  38. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.js +4 -5
  39. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.wxml +1 -1
  40. package/template-uni-app/dist/dev/mp-weixin/pages/index.js +4 -5
  41. package/template-uni-app/dist/dev/mp-weixin/pages/index.wxml +1 -1
  42. package/template-uni-app/dist/dev/mp-weixin/pages/my.wxml +1 -1
  43. package/template-uni-app/dist/dev/mp-weixin/project.config.json +1 -2
  44. package/template-uni-app/dist/dev/mp-weixin/project.private.config.json +6 -0
  45. package/template-uni-app/dist/dev/mp-weixin/store/local/index.js +3 -1
  46. package/template-uni-app/dist/dev/mp-weixin/utils/modal.js +10 -14
  47. package/template-uni-app/dist/dev/mp-weixin/utils/route.js +4 -6
  48. package/template-uni-app/dist/dev/mp-weixin/utils/system.js +4 -4
  49. package/template-uni-app/package.json +2 -3
  50. package/template-uni-app/pnpm-lock.yaml +154 -105
  51. package/template-uni-app/src/apis/index.ts +2 -2
  52. package/template-uni-app/src/apis/requests/get.ts +5 -5
  53. package/template-uni-app/src/apis/requests/post.ts +5 -5
  54. package/template-uni-app/vite.config.ts +2 -3
  55. package/template-nuxt-admin/public/favicon.ico +0 -0
  56. package/template-uni-app/custom-plugins/polyfill.ts +0 -32
  57. package/template-uni-app/dist/dev/mp-weixin/apis/lib/index.js +0 -90
  58. package/template-uni-app/src/apis/lib/index.ts +0 -235
  59. package/template-vue-admin/.vscode/extensions.json +0 -10
  60. package/template-vue-admin/.vscode/list-add.code-snippets +0 -108
  61. package/template-vue-admin/.vscode/list-export.code-snippets +0 -72
  62. package/template-vue-admin/.vscode/list.code-snippets +0 -61
  63. package/template-vue-admin/.vscode/settings.json +0 -7
  64. package/template-vue-admin/Dockerfile +0 -42
  65. package/template-vue-admin/README.md +0 -75
  66. package/template-vue-admin/_env +0 -8
  67. package/template-vue-admin/_gitignore +0 -30
  68. package/template-vue-admin/boot.mjs +0 -16
  69. package/template-vue-admin/build/custom-plugin.ts +0 -57
  70. package/template-vue-admin/build/index.ts +0 -7
  71. package/template-vue-admin/build/plugins.ts +0 -59
  72. package/template-vue-admin/config/.devrc +0 -2
  73. package/template-vue-admin/config/.onlinerc +0 -2
  74. package/template-vue-admin/config/.testrc +0 -2
  75. package/template-vue-admin/index.html +0 -21
  76. package/template-vue-admin/nitro.config.ts +0 -19
  77. package/template-vue-admin/package.json +0 -51
  78. package/template-vue-admin/plugins/init.ts +0 -31
  79. package/template-vue-admin/public/vite.svg +0 -1
  80. package/template-vue-admin/rome.json +0 -26
  81. package/template-vue-admin/routes/api/[...all].ts +0 -49
  82. package/template-vue-admin/routes/get/env.ts +0 -18
  83. package/template-vue-admin/src/App.vue +0 -14
  84. package/template-vue-admin/src/apis/delete.ts +0 -36
  85. package/template-vue-admin/src/apis/get.ts +0 -83
  86. package/template-vue-admin/src/apis/index.ts +0 -10
  87. package/template-vue-admin/src/apis/patch.ts +0 -78
  88. package/template-vue-admin/src/apis/post.ts +0 -76
  89. package/template-vue-admin/src/assets/img/login_background.jpg +0 -0
  90. package/template-vue-admin/src/auto-components.d.ts +0 -38
  91. package/template-vue-admin/src/auto-imports.d.ts +0 -302
  92. package/template-vue-admin/src/layouts/blank.vue +0 -9
  93. package/template-vue-admin/src/layouts/default/components/Link.vue +0 -23
  94. package/template-vue-admin/src/layouts/default/components/Logo.vue +0 -20
  95. package/template-vue-admin/src/layouts/default/components/Menu.vue +0 -54
  96. package/template-vue-admin/src/layouts/default/components/NavSearch.vue +0 -52
  97. package/template-vue-admin/src/layouts/default/components/ScrollPane.vue +0 -79
  98. package/template-vue-admin/src/layouts/default/components/TagsView.vue +0 -137
  99. package/template-vue-admin/src/layouts/default/components/TopMenu.vue +0 -21
  100. package/template-vue-admin/src/layouts/default/components/UserCenter.vue +0 -50
  101. package/template-vue-admin/src/layouts/default/index.vue +0 -95
  102. package/template-vue-admin/src/main.ts +0 -46
  103. package/template-vue-admin/src/modules/1-router.ts +0 -48
  104. package/template-vue-admin/src/modules/2-pinia.ts +0 -10
  105. package/template-vue-admin/src/modules/3-net.ts +0 -79
  106. package/template-vue-admin/src/modules/4-auth.ts +0 -124
  107. package/template-vue-admin/src/modules/5-checkupdate.ts +0 -38
  108. package/template-vue-admin/src/shims.d.ts +0 -12
  109. package/template-vue-admin/src/stores/index.ts +0 -9
  110. package/template-vue-admin/src/stores/local/index.ts +0 -31
  111. package/template-vue-admin/src/stores/session/index.ts +0 -63
  112. package/template-vue-admin/src/stores/tags.ts +0 -109
  113. package/template-vue-admin/src/typings/global.d.ts +0 -70
  114. package/template-vue-admin/src/typings/index.ts +0 -13
  115. package/template-vue-admin/src/typings/system.d.ts +0 -46
  116. package/template-vue-admin/src/views/403.vue +0 -33
  117. package/template-vue-admin/src/views/[...all_404].vue +0 -557
  118. package/template-vue-admin/src/views/base/login.vue +0 -194
  119. package/template-vue-admin/src/views/dashboard/[name].vue +0 -28
  120. package/template-vue-admin/src/views/index.vue +0 -25
  121. package/template-vue-admin/src/views/system/api.vue +0 -160
  122. package/template-vue-admin/src/views/system/hooks/useRole.ts +0 -286
  123. package/template-vue-admin/src/views/system/menuList.vue +0 -194
  124. package/template-vue-admin/src/views/system/role.vue +0 -131
  125. package/template-vue-admin/src/views/system/user.vue +0 -192
  126. package/template-vue-admin/src/vite-env.d.ts +0 -52
  127. package/template-vue-admin/tsconfig.json +0 -21
  128. package/template-vue-admin/tsconfig.node.json +0 -9
  129. package/template-vue-admin/unocss.config.ts +0 -47
  130. package/template-vue-admin/vite.config.ts +0 -32
@@ -1,194 +0,0 @@
1
- <!--
2
- * @Author: zhangyang
3
- * @Date: 2023-01-04 12:08:08
4
- * @LastEditTime: 2023-05-18 15:50:17
5
- * @Description:
6
- -->
7
- <route lang="yaml">
8
- meta:
9
- layout: blank
10
- auth: false
11
- </route>
12
-
13
- <script lang="ts" setup>
14
- import { setToken } from '@/stores';
15
- import { generateNavData } from '@/modules/4-auth';
16
- import { apis } from '@/modules/3-net';
17
-
18
- const title = window.__YOUNG_VITE_ENV__.VITE_TITLE || '管理后台';
19
-
20
- type LoginType = 'code' | 'scan';
21
- const loginType = ref<LoginType>('code');
22
- const changeType = () => {
23
- if (loginType.value === 'code') {
24
- loginType.value = 'scan';
25
- } else {
26
- loginType.value = 'code';
27
- }
28
- };
29
-
30
- const formRef = ref();
31
- const form = reactive({
32
- username: '',
33
- password: ''
34
- });
35
- const rules = {
36
- username: [{ required: true, trigger: 'blur', message: '请输入帐户名' }],
37
- password: [{ required: true, trigger: 'blur', message: '请输入密码' }]
38
- };
39
-
40
- /**
41
- * 路由器实例,负责改变路由
42
- */
43
- const router = useRouter();
44
- const loginHandler = () => {
45
- formRef.value?.validate(async (valid: boolean) => {
46
- try {
47
- if (valid) {
48
- const data = await apis.post.login(form);
49
- if (data) {
50
- setToken(data);
51
- await generateNavData();
52
- router.push('/');
53
- }
54
- } else {
55
- ElMessage.error('请仔细检查表单内容');
56
- return;
57
- }
58
- } catch (error) {
59
- console.error(error);
60
- }
61
- });
62
- };
63
-
64
- const start = () => {
65
- ElMessage.success('敬请期待!');
66
- };
67
- </script>
68
- <template>
69
- <div class="login-main">
70
- <div class="logo flex justify-center items-center pl-12 pt-4">
71
- </div>
72
- <div class="mx-auto flex justify-center flex-col items-center">
73
- <div class="text-3xl mb-7">{{ title }}</div>
74
- <div class="form">
75
- <ElCard>
76
- <template #header>
77
- <span v-show="loginType === 'scan'">{{ '扫码登录' }}</span>
78
- <span v-show="loginType === 'code'">{{ '密码登录' }}</span>
79
- <div class="icon-container" @click="changeType">
80
- <svg v-show="loginType === 'scan'" title="账号密码登录" t="1646619966567" class="icon" viewBox="0 0 1076 1024"
81
- version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2882" width="200" height="200">
82
- <path
83
- d="M986.22796 0H90.275175A90.275175 90.275175 0 0 0 0 90.086315v634.570269a90.275175 90.275175 0 0 0 90.275175 90.275175h291.411288l-51.369975 152.410181H226.632239a28.32903 28.32903 0 0 0 0 56.65806h623.238657a28.32903 28.32903 0 0 0 0-56.65806h-103.495389l-51.369974-152.410181h291.222427A90.275175 90.275175 0 0 0 1076.503135 724.845444V90.086315A90.275175 90.275175 0 0 0 986.22796 0z m0 56.65806A33.617115 33.617115 0 0 1 1019.845076 90.086315V623.238657H56.65806V90.086315A33.617115 33.617115 0 0 1 90.275175 56.65806zM389.996311 967.34194l51.369975-152.410181h193.770564l51.369974 152.410181z m287.822944-209.06824H90.275175A33.617115 33.617115 0 0 1 56.65806 724.845444V679.896717h963.187016v45.704168a33.617115 33.617115 0 0 1-33.428256 33.617116z"
84
- p-id="2883"></path>
85
- </svg>
86
- <svg v-show="loginType === 'code'" t="1646619725486" viewBox="0 0 1024 1024" version="1.1" class="icon"
87
- xmlns="http://www.w3.org/2000/svg" p-id="2043" width="200" height="200">
88
- <path
89
- d="M384 554.666667a85.333333 85.333333 0 0 1 85.333333 85.333333v234.666667a85.333333 85.333333 0 0 1-85.333333 85.333333H149.333333a85.333333 85.333333 0 0 1-85.333333-85.333333V640a85.333333 85.333333 0 0 1 85.333333-85.333333h234.666667z m226.133333 277.333333c4.693333 0 8.533333 3.84 8.533334 8.533333V896h183.466666c4.693333 0 8.533333 3.84 8.533334 8.533333v46.933334a8.533333 8.533333 0 0 1-8.533334 8.533333H563.2a8.533333 8.533333 0 0 1-8.533333-8.533333v-110.933334c0-4.693333 3.84-8.533333 8.533333-8.533333h46.933333z m341.333334 0c4.693333 0 8.533333 3.84 8.533333 8.533333v110.933334a8.533333 8.533333 0 0 1-8.533333 8.533333h-46.933334a8.533333 8.533333 0 0 1-8.533333-8.533333v-110.933334c0-4.693333 3.84-8.533333 8.533333-8.533333h46.933334zM384 618.666667H149.333333a21.333333 21.333333 0 0 0-21.184 18.837333L128 640v234.666667a21.333333 21.333333 0 0 0 18.837333 21.184L149.333333 896h234.666667a21.333333 21.333333 0 0 0 21.184-18.837333L405.333333 874.666667V640a21.333333 21.333333 0 0 0-18.837333-21.184L384 618.666667z m418.133333 149.333333c4.693333 0 8.533333 3.84 8.533334 8.533333v46.933334a8.533333 8.533333 0 0 1-8.533334 8.533333h-46.933333a8.533333 8.533333 0 0 1-8.533333-8.533333v-46.933334c0-4.693333 3.84-8.533333 8.533333-8.533333h46.933333zM298.666667 704a21.333333 21.333333 0 0 1 21.333333 21.333333v64a21.333333 21.333333 0 0 1-21.333333 21.333334h-64a21.333333 21.333333 0 0 1-21.333334-21.333334v-64a21.333333 21.333333 0 0 1 21.333334-21.333333h64z m503.466666-149.333333c4.693333 0 8.533333 3.84 8.533334 8.533333v46.933333a8.533333 8.533333 0 0 1-8.533334 8.533334H618.666667v64h119.466666c4.693333 0 8.533333 3.84 8.533334 8.533333v46.933333a8.533333 8.533333 0 0 1-8.533334 8.533334h-174.933333a8.533333 8.533333 0 0 1-8.533333-8.533334v-174.933333c0-4.693333 3.84-8.533333 8.533333-8.533333h238.933333z m149.333334 128c4.693333 0 8.533333 3.84 8.533333 8.533333v46.933333a8.533333 8.533333 0 0 1-8.533333 8.533334h-132.266667a8.533333 8.533333 0 0 1-8.533333-8.533334v-46.933333c0-4.693333 3.84-8.533333 8.533333-8.533333h132.266667z m0-128c4.693333 0 8.533333 3.84 8.533333 8.533333v46.933333a8.533333 8.533333 0 0 1-8.533333 8.533334h-46.933334a8.533333 8.533333 0 0 1-8.533333-8.533334v-46.933333c0-4.693333 3.84-8.533333 8.533333-8.533333h46.933334zM384 64a85.333333 85.333333 0 0 1 85.333333 85.333333v234.666667a85.333333 85.333333 0 0 1-85.333333 85.333333H149.333333a85.333333 85.333333 0 0 1-85.333333-85.333333V149.333333a85.333333 85.333333 0 0 1 85.333333-85.333333h234.666667z m490.666667 0a85.333333 85.333333 0 0 1 85.333333 85.333333v234.666667a85.333333 85.333333 0 0 1-85.333333 85.333333H640a85.333333 85.333333 0 0 1-85.333333-85.333333V149.333333a85.333333 85.333333 0 0 1 85.333333-85.333333h234.666667zM384 128H149.333333a21.333333 21.333333 0 0 0-21.184 18.837333L128 149.333333v234.666667a21.333333 21.333333 0 0 0 18.837333 21.184L149.333333 405.333333h234.666667a21.333333 21.333333 0 0 0 21.184-18.837333L405.333333 384V149.333333a21.333333 21.333333 0 0 0-18.837333-21.184L384 128z m490.666667 0H640a21.333333 21.333333 0 0 0-21.184 18.837333L618.666667 149.333333v234.666667a21.333333 21.333333 0 0 0 18.837333 21.184L640 405.333333h234.666667a21.333333 21.333333 0 0 0 21.184-18.837333L896 384V149.333333a21.333333 21.333333 0 0 0-18.837333-21.184L874.666667 128z m-576 85.333333a21.333333 21.333333 0 0 1 21.333333 21.333334v64a21.333333 21.333333 0 0 1-21.333333 21.333333h-64a21.333333 21.333333 0 0 1-21.333334-21.333333v-64a21.333333 21.333333 0 0 1 21.333334-21.333334h64z m490.666666 0a21.333333 21.333333 0 0 1 21.333334 21.333334v64a21.333333 21.333333 0 0 1-21.333334 21.333333h-64a21.333333 21.333333 0 0 1-21.333333-21.333333v-64a21.333333 21.333333 0 0 1 21.333333-21.333334h64z"
90
- fill="#333333" p-id="2044"></path>
91
- </svg>
92
- </div>
93
- </template>
94
- <div v-show="loginType === 'scan'">
95
- <div class="text-center m-20px">
96
- <ElButton type="primary" size="large" class="len" @click="start">钉钉扫码登录</ElButton>
97
- </div>
98
- <div class="w-384px text-center text-[#f56c6c]">首次登录请联系系统管理员开通权限</div>
99
- </div>
100
- <div class="code" v-show="loginType === 'code'">
101
- <ElForm ref="formRef" :model="form" :rules="rules" @keyup.enter="loginHandler">
102
- <ElFormItem prop="username">
103
- <ElInput v-model.trim="form.username" size="large" placeholder="请输入用户名" tabindex="1" auto-complete="on"
104
- clearable class="len" />
105
- </ElFormItem>
106
- <ElFormItem prop="password">
107
- <ElInput v-model.trim="form.password" size="large" placeholder="请输入密码" tabindex="2" auto-complete="on"
108
- type="password" clearable show-password class="len" />
109
- </ElFormItem>
110
- </ElForm>
111
- <ElButton type="primary" size="large" class="len" @click="loginHandler">登 录</ElButton>
112
- </div>
113
- </ElCard>
114
- </div>
115
- </div>
116
- </div>
117
- </template>
118
-
119
- <style lang="scss" scoped>
120
- .login-main {
121
- width: 100vw;
122
- height: 100vh;
123
- margin: 0;
124
- padding: 0;
125
- background-image: url('@/assets/img/login_background.jpg');
126
- background-repeat: norepeat;
127
- background-size: cover;
128
- position: relative;
129
- display: flex;
130
- justify-content: space-evenly;
131
- align-items: center;
132
-
133
- .logo {
134
- position: absolute;
135
- left: 0;
136
- top: 0;
137
- }
138
-
139
- .title {
140
- font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
141
- font-size: 2.1rem;
142
- text-align: center;
143
- }
144
-
145
- .form {
146
- $iw: 1.5rem;
147
- position: relative;
148
- display: flex;
149
- justify-content: center;
150
- align-items: center;
151
-
152
- .icon {
153
- width: $iw;
154
- height: $iw;
155
- position: absolute;
156
- right: 0;
157
- top: 0;
158
- margin: 0.5rem;
159
-
160
- &:hover {
161
- cursor: pointer;
162
- }
163
-
164
- }
165
-
166
-
167
- .code {
168
- padding: 4rem 1rem;
169
-
170
- .len {
171
- width: 20rem;
172
- margin-bottom: 0.3rem;
173
- }
174
- }
175
-
176
- .img-btn {
177
- width: 168px;
178
- height: 28px;
179
- display: flex;
180
- justify-content: center;
181
- align-items: center;
182
-
183
- #img-zx {
184
- height: 5rem;
185
- margin-top: 0.5rem;
186
- }
187
-
188
- #img-zc {
189
- height: 2rem;
190
- }
191
- }
192
- }
193
- }
194
- </style>
@@ -1,28 +0,0 @@
1
- <!--
2
- * @Author: zhangyang
3
- * @Date: 2022-10-26 09:55:45
4
- * @LastEditTime: 2023-05-18 15:50:31
5
- * @Description:
6
- -->
7
- <route lang="yaml">
8
- meta:
9
- title: 欢迎页
10
- auth: false
11
- </route>
12
-
13
- <script lang="ts" setup>
14
- import { generateNavData } from '@/modules/4-auth';
15
-
16
- const title = window.__YOUNG_VITE_ENV__.VITE_TITLE || '管理后台';
17
-
18
- // 每次进入直接拉取最近的菜单数据,同时登录过期时也可触发登录
19
- generateNavData(true);
20
- </script>
21
-
22
- <template>
23
- <div>
24
- <div class="text-4xl my-20 text-center font-bold">
25
- 欢迎使用{{ title }}
26
- </div>
27
- </div>
28
- </template>
@@ -1,25 +0,0 @@
1
- <!--
2
- * @Author: zhangyang
3
- * @Date: 2022-10-25 11:54:36
4
- * @LastEditTime: 2023-05-18 15:49:57
5
- * @Description:
6
- -->
7
- <route lang="yaml">
8
- meta:
9
- title: 入口
10
- auth: false
11
- </route>
12
-
13
- <script lang="ts" setup>
14
- const router = useRouter();
15
- onMounted(() => {
16
- router.replace('/dashboard/index');
17
- });
18
- onUpdated(() => {
19
- router.replace('/dashboard/index');
20
- });
21
- </script>
22
-
23
- <template>
24
- <div></div>
25
- </template>
@@ -1,160 +0,0 @@
1
- <!--
2
- * @Author: zhangyang
3
- * @Date: 2022-10-27 14:24:32
4
- * @LastEditTime: 2023-01-09 11:51:07
5
- * @Description:
6
- -->
7
- <route lang="yaml">
8
- meta:
9
- title: 接口管理
10
- </route>
11
-
12
- <script lang="ts" setup>
13
- import { useFormMode, YoungDialog, YoungTable, YoungPagination, YoungSelect } from '@bluesyoung/ui-vue3-element-plus';
14
- import type { TableDataItem, TableHeadItem, SelectOptionItem } from '@bluesyoung/ui-vue3-element-plus';
15
- import { deepClone } from '@bluesyoung/utils';
16
- import type { ApiItem, RoleItem } from '@/typings';
17
- import { MethodObj } from '@/typings';
18
- import { apis } from '@/modules/3-net';
19
- import { ElButton, ElTag } from 'element-plus';
20
-
21
- interface Form extends ApiItem { };
22
- const FORM_TEMP: Form = {
23
- id: 0,
24
- path: '',
25
- desc: '',
26
- method: 'POST',
27
- category: '',
28
- roleIds: []
29
- };
30
- const {
31
- isAdd,
32
- isEdit,
33
- edit,
34
- del,
35
- sure,
36
- clear,
37
- form,
38
- formRef,
39
- validForm
40
- } = useFormMode<Form>(FORM_TEMP, {
41
- addCbk: async () => {
42
- const res = await validForm() as boolean;
43
- if (res) {
44
- const v = deepClone(form.value);
45
- await apis.post.addApiItem(v);
46
- ElMessage.success('新增成功!');
47
- }
48
- return res;
49
- },
50
- modCbk: async () => {
51
- const res = await validForm() as boolean;
52
- if (res) {
53
- const v = deepClone(form.value);
54
- await apis.patch.changeApiItem(v);
55
- ElMessage.success('修改成功!');
56
- }
57
- return res;
58
- },
59
- delCbk: async (row) => {
60
- await apis.delete.deleteApi(row.id.toString());
61
- ElMessage.success('删除成功!');
62
- query.pageNum = 1;
63
- },
64
- cgEffect: () => getList(),
65
- });
66
- const tableHead: TableHeadItem<Form>[] = [
67
- { prop: 'id', label: '接口ID' },
68
- { prop: 'desc', label: '接口描述' },
69
- { prop: 'category', label: '接口分组' },
70
- { prop: 'path', label: '接口路径' },
71
- { prop: 'creator', label: '创建信息' },
72
- {
73
- prop: 'method', label: '接口方法', render: (row) => h(ElTag, {
74
- effect: 'dark',
75
- type: MethodObj[row.method]
76
- },
77
- {
78
- default: () => row.method
79
- }
80
- )
81
- },
82
- {
83
- prop: 'id', label: '操作', render: (row) => h('div', [
84
- h(ElButton, { type: 'primary', link: true, onClick: () => edit(row) }, { default: () => '编辑' }),
85
- h(ElButton, { type: 'danger', link: true, onClick: () => del(row) }, { default: () => '删除' })
86
- ])
87
- }
88
- ];
89
- const tableData = ref<TableDataItem<Form>[]>([]);
90
-
91
- type Query = BaseQuery & Partial<Form>;
92
- const query = reactive<Query>({
93
- pageNum: 1,
94
- pageSize: 10,
95
- total: 0,
96
- path: '',
97
- });
98
-
99
- const roleList = ref<SelectOptionItem<number>[]>([]);
100
-
101
- const getList = async () => {
102
- const { list: role_list } = await apis.get.getRoleList({ noPagination: true });
103
- roleList.value = (role_list || []).map((item: RoleItem) => {
104
- return {
105
- label: item.name,
106
- value: item.id
107
- };
108
- });
109
-
110
- const { list, pageNum, pageSize, total } = await apis.get.getApiList(query);
111
- tableData.value = deepClone(list || []);
112
- query.pageNum = +pageNum || 1;
113
- query.pageSize = +pageSize || 50;
114
- query.total = +total || 0;
115
- };
116
-
117
- getList();
118
- </script>
119
-
120
- <template>
121
- <div class="flex">
122
- <div class="m-2">
123
- <ElInput v-model="query.path" placeholder="请输入接口路径" />
124
- </div>
125
- <div class="m-2">
126
- <ElButton type="primary" @click="getList">搜索</ElButton>
127
- </div>
128
- <div class="m-2">
129
- <ElButton type="success" @click="isAdd = true">添加接口</ElButton>
130
- </div>
131
- </div>
132
- <div class="m-2">
133
- <YoungTable :table-data="tableData" :table-head="tableHead" :table-height="680" />
134
- <YoungPagination v-model:page="query.pageNum" v-model:limit="query.pageSize" :total="query.total"
135
- @page-change="getList" />
136
- </div>
137
- <YoungDialog :is-add="isAdd" :is-edit="isEdit" width="520px" @sure="sure" @clear="clear">
138
- <template #body>
139
- <ElForm ref="formRef" :model="form" label-width="100px">
140
- <ElFormItem label="分组名称" prop="category" :rules="{ required: true, message: '请填写分组名称', trigger: 'blur' }">
141
- <ElInput v-model="form.category" class="!w-300px" />
142
- </ElFormItem>
143
- <ElFormItem label="接口描述" prop="desc" :rules="{ required: true, message: '请填写接口描述', trigger: 'blur' }">
144
- <ElInput v-model="form.desc" class="!w-300px" />
145
- </ElFormItem>
146
- <ElFormItem label="请求方法">
147
- <YoungSelect v-model="form.method" class="!w-300px"
148
- :options="Object.keys(MethodObj).map((item) => ({ label: item, value: item }))" />
149
- </ElFormItem>
150
- <ElFormItem label="接口路径" prop="path"
151
- :rules="{ message: '请填写合法的接口路径, eg: /user/list', trigger: 'blur', validator: (_: any, v: string) => /\/(.*)\/(.*)/.test(v) }">
152
- <ElInput v-model="form.path" class="!w-300px" />
153
- </ElFormItem>
154
- <ElFormItem label="关联角色">
155
- <YoungSelect v-model="form.roleIds" multiple placeholder="请选择角色" class="!w-300px" :options="roleList" />
156
- </ElFormItem>
157
- </ElForm>
158
- </template>
159
- </YoungDialog>
160
- </template>
@@ -1,286 +0,0 @@
1
- /*
2
- * @Author: zhangyang
3
- * @Date: 2022-10-27 09:25:09
4
- * @LastEditTime: 2023-01-09 14:20:07
5
- * @Description:
6
- */
7
- import type { RoleItem, ApiItem } from '@/typings';
8
- import type { TableDataItem, TableHeadItem } from '@bluesyoung/ui-vue3-element-plus';
9
- import { useFormMode } from '@bluesyoung/ui-vue3-element-plus';
10
- import { deepClone } from '@bluesyoung/utils';
11
- import { apis } from '@/modules/3-net';
12
- export const useRoleBase = () => {
13
- const FORM_TEMP: RoleItem = {
14
- id: 0,
15
- name: '',
16
- keyword: '',
17
- desc: '',
18
- status: 1,
19
- sort: 0,
20
- };
21
- interface Query extends BaseQuery {
22
- name: string;
23
- keyword: string;
24
- status: 0 | 1;
25
- }
26
- const query = reactive<Query>({
27
- pageNum: 1,
28
- pageSize: 50,
29
- total: 0,
30
- name: '',
31
- keyword: '',
32
- status: 1,
33
- });
34
-
35
- const { isAdd, isEdit, edit, del, sure, clear, form, formRef, validForm } = useFormMode(
36
- FORM_TEMP,
37
- {
38
- addCbk: async () => {
39
- const res = (await validForm()) as boolean;
40
- if (res) {
41
- const v = deepClone(form.value);
42
- await apis.post.addRoleItem(v);
43
- ElMessage.success('新增成功!');
44
- }
45
- return res;
46
- },
47
- modCbk: async () => {
48
- const res = (await validForm()) as boolean;
49
- if (res) {
50
- const v = deepClone(form.value);
51
- await apis.patch.changeRoleItem(v);
52
- ElMessage.success('修改成功!');
53
- }
54
- return res;
55
- },
56
- delCbk: async (row) => {
57
- await apis.delete.deleteRole(row.id.toString());
58
- ElMessage.success('删除成功!');
59
- query.pageNum = 1;
60
- },
61
- cgEffect: () => getList(),
62
- },
63
- );
64
-
65
- /**
66
- * @param status 0 | 1
67
- */
68
- const changeStatus = async (id: number, status: number) => {
69
- await apis.patch.changeRoleItem({ id, status });
70
- ElMessage.success('修改成功!');
71
- getList();
72
- };
73
-
74
- const tableHead: TableHeadItem<RoleItem>[] = [
75
- { label: '角色ID', prop: 'id' },
76
- { label: '角色关键字', prop: 'keyword' },
77
- { label: '角色名称', prop: 'name' },
78
- { label: '角色描述', prop: 'desc' },
79
- { label: '创建信息', prop: 'creator' },
80
- ];
81
- const tableData = ref<TableDataItem<RoleItem>[]>([]);
82
- const getList = async () => {
83
- const { list, pageNum, pageSize, total } = await apis.get.getRoleList(query);
84
- tableData.value = deepClone(list || []);
85
- query.pageNum = +pageNum || 1;
86
- query.pageSize = +pageSize || 50;
87
- query.total = +total || 0;
88
- };
89
-
90
- return {
91
- query,
92
- getList,
93
- tableHead,
94
- tableData,
95
- baseFormRef: formRef,
96
- changeStatus,
97
- base: reactive({
98
- form,
99
- isAdd,
100
- isEdit,
101
- edit,
102
- del,
103
- sure,
104
- clear,
105
- }),
106
- };
107
- };
108
-
109
- export const useRoleMenu = () => {
110
- const showPriority = ref(false);
111
- const currRole = ref(0);
112
- const access = ref<number[]>([]);
113
- const origin = ref<number[]>([]);
114
-
115
- const tableHead = ref<TableHeadItem<NavArrItem>[]>([
116
- { label: '菜单名称', prop: 'title' },
117
- { label: '菜单id', prop: 'id' },
118
- { label: '父节点', prop: 'parentId' },
119
- { label: '页面路径', prop: 'component' },
120
- ]);
121
- const tableData = ref<TableDataItem<NavArrItem>[]>([]);
122
-
123
- const checkMap = ref<Record<number, boolean>>({});
124
-
125
- /**
126
- * 生成节点映射
127
- */
128
- const nodeMap = new Map<number, NavArrItem>();
129
- const generateNodeMap = (list: NavArrItem[]) => {
130
- for (const node of list) {
131
- nodeMap.set(node.id, node);
132
- if (node.children && node.children?.length > 0) {
133
- generateNodeMap(node.children);
134
- }
135
- }
136
- };
137
-
138
- /**
139
- * 多级联动选择
140
- */
141
- const selectChange = (item: NavArrItem) => {
142
- if (item.children && item.children?.length !== 0) {
143
- item.children.forEach((v) => {
144
- checkMap.value[v.id] = checkMap.value[item.id];
145
- selectChange(v);
146
- });
147
- }
148
- if (checkMap.value[item.id]) {
149
- while (item.parentId) {
150
- const tp = nodeMap.get(item.parentId);
151
- if (tp) {
152
- item = tp;
153
- checkMap.value[item.id] = true;
154
- } else {
155
- break;
156
- }
157
- }
158
- }
159
- };
160
-
161
- const edit = async (row: TableDataItem<RoleItem>) => {
162
- currRole.value = row.id;
163
- checkMap.value = {};
164
- nodeMap.clear();
165
-
166
- const { list, accessIds } = await apis.get.getRoleMenuTree(row.id);
167
- generateNodeMap(list);
168
- (Array.from(accessIds) as number[]).forEach((v) => {
169
- checkMap.value[v] = true;
170
- });
171
-
172
- tableData.value = deepClone(list);
173
- access.value = accessIds;
174
- origin.value = accessIds;
175
- showPriority.value = true;
176
- };
177
- const clear = () => {
178
- showPriority.value = false;
179
- currRole.value = 0;
180
- tableData.value.length = 0;
181
- };
182
-
183
- const sure = async () => {
184
- const before = origin.value.slice();
185
- const now = Object.entries(checkMap.value)
186
- .filter(([k, v]) => v)
187
- .map(([k, v]) => +k);
188
-
189
- const add = now.filter((v) => !before.includes(v));
190
- const del = before.filter((v) => !now.includes(v));
191
- await apis.patch.changeRoleMenu(currRole.value, add, del);
192
- ElMessage.success('修改成功!');
193
- clear();
194
- };
195
-
196
- return {
197
- showPriority,
198
- menu: reactive({
199
- checkMap,
200
- tableHead,
201
- tableData,
202
- edit,
203
- clear,
204
- sure,
205
- selectChange,
206
- }),
207
- };
208
- };
209
-
210
- export const useRoleApi = () => {
211
- const showApi = ref(false);
212
- const currRole = ref(0);
213
- const access = ref<number[]>([]);
214
- const origin = ref<number[]>([]);
215
-
216
- const tableHead = ref<TableHeadItem<ApiItem>[]>([
217
- { prop: 'desc', label: '接口描述' },
218
- { prop: 'id', label: '接口ID' },
219
- { prop: 'method', label: '接口方法' },
220
- { prop: 'path', label: '请求地址' },
221
- ]);
222
- const tableData = ref<TableDataItem<ApiItem>[]>([]);
223
-
224
- const checkMap = ref<Record<number, boolean>>({});
225
-
226
- const edit = async (row: TableDataItem<RoleItem>) => {
227
- currRole.value = row.id;
228
- checkMap.value = {};
229
-
230
- const { list, accessIds } = await apis.get.getRoleApis(row.id);
231
- (Array.from(accessIds) as number[]).forEach((v) => {
232
- checkMap.value[v] = true;
233
- });
234
-
235
- tableData.value = deepClone(
236
- Array.from(list)
237
- .map((item: any) => item.children)
238
- .flat(),
239
- );
240
-
241
- access.value = accessIds;
242
- origin.value = accessIds;
243
- showApi.value = true;
244
-
245
- isAll.value = tableData.value.length === access.value.length;
246
- };
247
- const clear = () => {
248
- showApi.value = false;
249
- currRole.value = 0;
250
- tableData.value.length = 0;
251
- };
252
-
253
- const sure = async () => {
254
- const before = origin.value.slice();
255
- const now = Object.entries(checkMap.value)
256
- .filter(([k, v]) => v)
257
- .map(([k, v]) => +k);
258
-
259
- const add = now.filter((v) => !before.includes(v));
260
- const del = before.filter((v) => !now.includes(v));
261
- await apis.patch.changeRoleApi(currRole.value, add, del);
262
- ElMessage.success('修改成功!');
263
- clear();
264
- };
265
-
266
- const isAll = ref(false);
267
- const changeAll = () => {
268
- tableData.value.forEach((i) => {
269
- checkMap.value[i.id] = isAll.value;
270
- });
271
- };
272
-
273
- return {
274
- showApi,
275
- api: reactive({
276
- checkMap,
277
- tableHead,
278
- tableData,
279
- edit,
280
- clear,
281
- sure,
282
- isAll,
283
- changeAll,
284
- }),
285
- };
286
- };