@yyp92-cli/template-vue-mobile 1.2.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @yyp92-cli/template-vue-mobile
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 项目模板-二级路由修改
8
+
9
+ ## 1.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 模板修改
14
+
3
15
  ## 1.2.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yyp92-cli/template-vue-mobile",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%= projectName %>",
3
- "description": "脚手架创建的 <%= projectName %> 项目",
3
+ "description": "脚手架创建的<%= projectName %>项目",
4
4
  "private": true,
5
5
  "version": "0.0.0",
6
6
  "type": "module",
@@ -1,27 +1,24 @@
1
1
  <template>
2
2
  <div class="layout">
3
- <template v-if="route.meta.showFullScreen">
4
- <router-view></router-view>
5
- </template>
6
-
7
- <template v-else>
8
- <div class="layout-inner">
9
- <div class="header">
10
- <MyNavBar
11
- :title="title"
12
- :showLeftArrow="route.fullPath !== '/home'"
13
- />
14
- </div>
3
+ <div class="layout-inner">
4
+ <div class="header">
5
+ <MyNavBar
6
+ :title="title"
7
+ :showLeftArrow="route.fullPath !== '/home'"
8
+ />
9
+ </div>
15
10
 
16
- <div class="content">
17
- <router-view></router-view>
18
- </div>
11
+ <div class="content">
12
+ <router-view></router-view>
13
+ </div>
19
14
 
20
- <div class="footer">
21
- <MyTabBar />
22
- </div>
15
+ <div
16
+ class="footer"
17
+ v-if="!route.meta.showFullScreen"
18
+ >
19
+ <MyTabBar />
23
20
  </div>
24
- </template>
21
+ </div>
25
22
  </div>
26
23
  </template>
27
24
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="tab-bar">
3
3
  <van-tabbar
4
- v-model="active"
4
+ v-model="defaultActive"
5
5
  >
6
6
  <template
7
7
  v-for="item in loginStore.userMenus"
@@ -21,18 +21,21 @@
21
21
  lang="ts"
22
22
  name="MyTabBar"
23
23
  >
24
- import {ref, onMounted} from 'vue'
24
+ import {computed} from 'vue'
25
25
  import {useRoute} from 'vue-router'
26
26
  import useLoginStore from '@/store/login'
27
27
 
28
28
  const route = useRoute()
29
29
  const loginStore = useLoginStore()
30
- const active = ref(0)
31
- console.log('--loginStore.userMenus', loginStore.userMenus)
32
30
 
33
- onMounted(() => {
34
- const index = loginStore.userMenus.findIndex((item: any) => item.path === route.path)
35
- active.value = index || 0
31
+
32
+ const defaultActive = computed(() => {
33
+ const list = route.path?.split('/')
34
+ const newPath = list.length > 3 ? list?.slice(0, 3)?.join('/') : route.path
35
+
36
+ const index = loginStore.userMenus.findIndex((item: any) => newPath.indexOf(item.path) > -1)
37
+
38
+ return index
36
39
  })
37
40
  </script>
38
41
 
@@ -18,12 +18,19 @@ const router = createRouter({
18
18
  router.beforeEach((to, from, next) => {
19
19
  const permission = localCache.getCache(PERMISSION) ?? []
20
20
  const menus = localCache.getCache(MENUS) ?? []
21
-
21
+ const token = localCache.getCache(LOGIN_TOKEN)
22
22
 
23
23
  if (to.path === '/') {
24
- next({
25
- path: menus[0]?.path || '/'
26
- })
24
+ if (!token) {
25
+ next({
26
+ path: '/login'
27
+ })
28
+ }
29
+ else {
30
+ next({
31
+ path: menus[0]?.path || '/'
32
+ })
33
+ }
27
34
  }
28
35
  else if (!['/403', '/login'].includes(to.path) && !permission.includes(to.path) && getLocalPromission(routes).includes(to.path)) {
29
36
  return next('/403')
@@ -31,8 +38,6 @@ router.beforeEach((to, from, next) => {
31
38
  else {
32
39
  next()
33
40
  }
34
-
35
- next()
36
41
  })
37
42
 
38
43
  export default router
@@ -50,13 +50,24 @@ export const routes: any[] = [
50
50
  }
51
51
  },
52
52
  {
53
- path: '/detail',
54
- name: 'detail',
55
- component: () => import('@/views/detail/index.vue'),
53
+ path: '/home/detail',
54
+ name: '/home/detail',
55
+ component: () => import('@/views/home/detail/index.vue'),
56
56
  meta: {
57
57
  title: '详情',
58
58
  icon: '',
59
59
  hideMenu: true,
60
+ showFullScreen: false
61
+ }
62
+ },
63
+ {
64
+ path: '/home/screen-detail',
65
+ name: '/home/screen-detail',
66
+ component: () => import('@/views/home/screen-detail/index.vue'),
67
+ meta: {
68
+ title: '详情-全屏',
69
+ icon: '',
70
+ hideMenu: true,
60
71
  showFullScreen: true
61
72
  }
62
73
  },
@@ -24,6 +24,16 @@ const useLoginStore = defineStore(
24
24
  async loginAccountAction(account: any) {
25
25
  try {
26
26
  setTimeout(() => {
27
+ const userInfo = {
28
+ username: account.username
29
+ }
30
+ const token = '111'
31
+ this.userInfo = userInfo
32
+ this.token = token
33
+
34
+ localCache.setCache(USER_INFO, userInfo)
35
+ localCache.setCache(LOGIN_TOKEN, token)
36
+
27
37
  const menus = routes[0].children.filter((item: any) => !item.meta.hideMenu)
28
38
  const promissions = routes[0].children.map((item: any) => item.path)
29
39
  this.userMenus = menus
@@ -1,6 +1,18 @@
1
1
  <template>
2
2
  <div class="home">
3
3
  <h2>home</h2>
4
+
5
+ <div>
6
+ <van-button
7
+ type="primary"
8
+ @click="handleJump"
9
+ >详情</van-button>
10
+
11
+ <van-button
12
+ type="primary"
13
+ @click="handleJump1"
14
+ >详情-全屏</van-button>
15
+ </div>
4
16
  </div>
5
17
  </template>
6
18
 
@@ -9,6 +21,17 @@
9
21
  lang="ts"
10
22
  name="Home"
11
23
  >
24
+ import {useRouter} from 'vue-router'
25
+
26
+ const router = useRouter()
27
+
28
+ function handleJump() {
29
+ router.push('/home/detail')
30
+ }
31
+
32
+ function handleJump1() {
33
+ router.push('/home/screen-detail')
34
+ }
12
35
  </script>
13
36
 
14
37
  <style
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <div class="detail">
3
+ <h2>detail-screen</h2>
4
+ </div>
5
+ </template>
6
+
7
+ <script
8
+ setup
9
+ lang="ts"
10
+ name="Detail"
11
+ >
12
+ </script>
13
+
14
+ <style
15
+ scoped
16
+ lang="scss"
17
+ >
18
+ .detail {}
19
+ </style>
@@ -21,8 +21,13 @@
21
21
  </van-cell-group>
22
22
 
23
23
  <div style="margin: 16px;">
24
- <van-button round block type="primary" native-type="submit">
25
- 提交
24
+ <van-button
25
+ round
26
+ block
27
+ type="primary"
28
+ native-type="submit"
29
+ >
30
+ 提交
26
31
  </van-button>
27
32
  </div>
28
33
  </van-form>