2023-02-11 00:44:00 +08:00
|
|
|
<template>
|
|
|
|
<div></div>
|
|
|
|
</template>
|
2023-06-21 19:35:11 +08:00
|
|
|
<script lang="ts" setup>
|
2023-06-21 19:14:34 +08:00
|
|
|
defineOptions({ name: 'Redirect' })
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
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
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
replace({
|
|
|
|
path: _path.startsWith('/') ? _path : '/' + _path,
|
|
|
|
query
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|