@yyp92-cli/template-vue-mobile 1.2.1 → 1.4.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 +12 -0
- package/package.json +1 -1
- package/template/src/components/layout/index.vue +16 -19
- package/template/src/components/layout/tabBar/index.vue +10 -7
- package/template/src/router/index.ts +21 -13
- package/template/src/router/routes.tsx +14 -3
- package/template/src/store/login/index.ts +16 -2
- package/template/src/views/home/index.vue +23 -0
- package/template/src/views/home/screen-detail/index.vue +19 -0
- package/template/src/views/login/index.vue +8 -3
- package/template/tsconfig.app.json +3 -1
- package/template/vite.config.ts +13 -2
- /package/template/src/views/{detail → home/detail}/index.vue +0 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="layout">
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
<div class="content">
|
|
12
|
+
<router-view></router-view>
|
|
13
|
+
</div>
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
<div
|
|
16
|
+
class="footer"
|
|
17
|
+
v-if="!route.meta.showFullScreen"
|
|
18
|
+
>
|
|
19
|
+
<MyTabBar />
|
|
23
20
|
</div>
|
|
24
|
-
</
|
|
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="
|
|
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 {
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
|
@@ -20,26 +20,34 @@ router.beforeEach((to, from, next) => {
|
|
|
20
20
|
const menus = localCache.getCache(MENUS) ?? []
|
|
21
21
|
const token = localCache.getCache(LOGIN_TOKEN)
|
|
22
22
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
next({
|
|
31
|
-
path: menus[0]?.path || '/'
|
|
32
|
-
})
|
|
23
|
+
if (!token) {
|
|
24
|
+
// 直接允许通过,不重复重定向
|
|
25
|
+
if (to.path === '/login') {
|
|
26
|
+
next()
|
|
27
|
+
return
|
|
33
28
|
}
|
|
29
|
+
|
|
30
|
+
next({
|
|
31
|
+
path: '/login',
|
|
32
|
+
query: {
|
|
33
|
+
redirect: to.path
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
else if (to.path === '/') {
|
|
39
|
+
next({
|
|
40
|
+
path: menus[0]?.path || '/'
|
|
41
|
+
})
|
|
42
|
+
return
|
|
34
43
|
}
|
|
35
44
|
else if (!['/403', '/login'].includes(to.path) && !permission.includes(to.path) && getLocalPromission(routes).includes(to.path)) {
|
|
36
|
-
|
|
45
|
+
next('/403')
|
|
46
|
+
return
|
|
37
47
|
}
|
|
38
48
|
else {
|
|
39
49
|
next()
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
next()
|
|
43
51
|
})
|
|
44
52
|
|
|
45
53
|
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
|
},
|
|
@@ -23,14 +23,28 @@ const useLoginStore = defineStore(
|
|
|
23
23
|
actions: {
|
|
24
24
|
async loginAccountAction(account: any) {
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
await new Promise((resolve) => {
|
|
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
|
|
30
40
|
|
|
31
41
|
localCache.setCache(MENUS, menus)
|
|
32
42
|
localCache.setCache(PERMISSION, promissions)
|
|
33
|
-
|
|
43
|
+
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
resolve(true)
|
|
46
|
+
}, 5000)
|
|
47
|
+
})
|
|
34
48
|
}
|
|
35
49
|
catch(error) {
|
|
36
50
|
return error
|
|
@@ -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
|
|
@@ -21,8 +21,13 @@
|
|
|
21
21
|
</van-cell-group>
|
|
22
22
|
|
|
23
23
|
<div style="margin: 16px;">
|
|
24
|
-
<van-button
|
|
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>
|
|
@@ -36,8 +41,8 @@
|
|
|
36
41
|
>
|
|
37
42
|
import { ref } from 'vue'
|
|
38
43
|
import {useRoute} from 'vue-router'
|
|
39
|
-
import { showLoadingToast, closeToast } from 'vant'
|
|
40
44
|
import useLoginStore from '@/store/login'
|
|
45
|
+
|
|
41
46
|
import router from '@/router'
|
|
42
47
|
|
|
43
48
|
const route = useRoute()
|
package/template/vite.config.ts
CHANGED
|
@@ -9,6 +9,7 @@ import Components from 'unplugin-vue-components/vite'
|
|
|
9
9
|
import { VantResolver } from '@vant/auto-import-resolver'
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
// https://vite.dev/config/
|
|
13
14
|
export default defineConfig({
|
|
14
15
|
base:'./',
|
|
@@ -31,10 +32,20 @@ export default defineConfig({
|
|
|
31
32
|
plugins: [
|
|
32
33
|
vue(),
|
|
33
34
|
AutoImport({
|
|
34
|
-
resolvers: [
|
|
35
|
+
resolvers: [
|
|
36
|
+
VantResolver({
|
|
37
|
+
importStyle: 'css'
|
|
38
|
+
})
|
|
39
|
+
],
|
|
40
|
+
dts: 'auto-imports.d.ts',
|
|
35
41
|
}),
|
|
36
42
|
Components({
|
|
37
|
-
resolvers: [
|
|
43
|
+
resolvers: [
|
|
44
|
+
VantResolver({
|
|
45
|
+
importStyle: 'css'
|
|
46
|
+
})
|
|
47
|
+
],
|
|
48
|
+
dts: 'components.d.ts',
|
|
38
49
|
})
|
|
39
50
|
],
|
|
40
51
|
|
|
File without changes
|