提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<div></div> |
|
3 |
</template> |
|
4 |
<script lang="ts" setup> |
|
5 |
defineOptions({ name: 'Redirect' }) |
|
6 |
|
|
7 |
const { currentRoute, replace } = useRouter() |
|
8 |
const { params, query } = unref(currentRoute) |
|
9 |
const { path, _redirect_type = 'path' } = params |
|
10 |
|
|
11 |
Reflect.deleteProperty(params, '_redirect_type') |
|
12 |
Reflect.deleteProperty(params, 'path') |
|
13 |
|
|
14 |
const _path = Array.isArray(path) ? path.join('/') : path |
|
15 |
|
|
16 |
if (_redirect_type === 'name') { |
|
17 |
replace({ |
|
18 |
name: _path, |
|
19 |
query, |
|
20 |
params |
|
21 |
}) |
|
22 |
} else { |
|
23 |
replace({ |
|
24 |
path: _path.startsWith('/') ? _path : '/' + _path, |
|
25 |
query |
|
26 |
}) |
|
27 |
} |
|
28 |
</script> |