@yyp92-cli/template-vue-mobile 1.2.1 → 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,11 @@
1
1
  # @yyp92-cli/template-vue-mobile
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 项目模板-二级路由修改
8
+
3
9
  ## 1.2.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yyp92-cli/template-vue-mobile",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -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
 
@@ -38,8 +38,6 @@ router.beforeEach((to, from, next) => {
38
38
  else {
39
39
  next()
40
40
  }
41
-
42
- next()
43
41
  })
44
42
 
45
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>