Ben Lin
2025-03-11 2beada4c5b6d529b985c680a4672fa7e9a0587df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<template>
  <div></div>
</template>
<script lang="ts" setup>
  import { unref } from 'vue';
  import { useRouter } from 'vue-router';
 
  const { currentRoute, replace } = useRouter();
 
  const { params, query } = unref(currentRoute);
  const { path, _redirect_type = 'path' } = params;
 
  Reflect.deleteProperty(params, '_redirect_type');
  Reflect.deleteProperty(params, 'path');
 
  const _path = Array.isArray(path) ? path.join('/') : path;
 
  if (_redirect_type === 'name') {
    replace({
      name: _path,
      query,
      params: JSON.parse((params._origin_params as string) ?? '{}'),
    });
  } else {
    replace({
      path: _path.startsWith('/') ? _path : '/' + _path,
      query,
    });
  }
</script>