@yyp92-cli/template-vue-mobile 1.3.0 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @yyp92-cli/template-vue-mobile
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 路由修改
8
+
3
9
  ## 1.3.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yyp92-cli/template-vue-mobile",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,20 +20,30 @@ router.beforeEach((to, from, next) => {
20
20
  const menus = localCache.getCache(MENUS) ?? []
21
21
  const token = localCache.getCache(LOGIN_TOKEN)
22
22
 
23
- if (to.path === '/') {
24
- if (!token) {
25
- next({
26
- path: '/login'
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
- return next('/403')
45
+ next('/403')
46
+ return
37
47
  }
38
48
  else {
39
49
  next()
@@ -23,7 +23,7 @@ const useLoginStore = defineStore(
23
23
  actions: {
24
24
  async loginAccountAction(account: any) {
25
25
  try {
26
- setTimeout(() => {
26
+ await new Promise((resolve) => {
27
27
  const userInfo = {
28
28
  username: account.username
29
29
  }
@@ -40,7 +40,11 @@ const useLoginStore = defineStore(
40
40
 
41
41
  localCache.setCache(MENUS, menus)
42
42
  localCache.setCache(PERMISSION, promissions)
43
- }, 3000)
43
+
44
+ setTimeout(() => {
45
+ resolve(true)
46
+ }, 5000)
47
+ })
44
48
  }
45
49
  catch(error) {
46
50
  return error
@@ -41,8 +41,8 @@
41
41
  >
42
42
  import { ref } from 'vue'
43
43
  import {useRoute} from 'vue-router'
44
- import { showLoadingToast, closeToast } from 'vant'
45
44
  import useLoginStore from '@/store/login'
45
+
46
46
  import router from '@/router'
47
47
 
48
48
  const route = useRoute()
@@ -19,6 +19,8 @@
19
19
  "include": [
20
20
  "src/**/*.ts",
21
21
  "src/**/*.tsx",
22
- "src/**/*.vue"
22
+ "src/**/*.vue",
23
+ "src/**/*.d.ts", // 关键:包含所有 .d.ts 类型文件
24
+ "auto-imports.d.ts"
23
25
  ]
24
26
  }
@@ -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: [VantResolver()],
35
+ resolvers: [
36
+ VantResolver({
37
+ importStyle: 'css'
38
+ })
39
+ ],
40
+ dts: 'auto-imports.d.ts',
35
41
  }),
36
42
  Components({
37
- resolvers: [VantResolver()],
43
+ resolvers: [
44
+ VantResolver({
45
+ importStyle: 'css'
46
+ })
47
+ ],
48
+ dts: 'components.d.ts',
38
49
  })
39
50
  ],
40
51