feat(dev): add /__dev/session to paste UC JWT + sudo for local browser QA
Production build omits route via import.meta.env.DEV guard. Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<div class="wrap">
|
||||||
|
<h2>仅开发:写入会话</h2>
|
||||||
|
<p class="hint">
|
||||||
|
将已从后端拿到的 JWT 与 sudo token 写入 localStorage,再跳转首页。生产构建不包含本页。
|
||||||
|
</p>
|
||||||
|
<van-field v-model="auth" label="Authorization" type="textarea" rows="3" placeholder="login2_with_unionid 返回的 d" />
|
||||||
|
<van-field v-model="sudo" label="HtySudoerToken" type="textarea" rows="2" placeholder="sudo2 返回的 d" />
|
||||||
|
<van-button type="primary" block class="btn" @click="apply">写入并去首页</van-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, ref } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { Button, Field, showFailToast, showSuccessToast } from 'vant'
|
||||||
|
import { HtyAuthToken, HtySudoToken } from '~/utils'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SessionSeed',
|
||||||
|
components: {
|
||||||
|
[Button.name!]: Button,
|
||||||
|
[Field.name!]: Field,
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const router = useRouter()
|
||||||
|
const auth = ref('')
|
||||||
|
const sudo = ref('')
|
||||||
|
const apply = () => {
|
||||||
|
const a = auth.value.trim()
|
||||||
|
const s = sudo.value.trim()
|
||||||
|
if (!a || !s) {
|
||||||
|
showFailToast('两项都要填')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.localStorage.setItem(HtyAuthToken, a)
|
||||||
|
window.localStorage.setItem(HtySudoToken, s)
|
||||||
|
showSuccessToast('已写入')
|
||||||
|
void router.replace('/')
|
||||||
|
}
|
||||||
|
return { auth, sudo, apply }
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.wrap {
|
||||||
|
padding: 1rem;
|
||||||
|
max-width: 36rem;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
.hint {
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -249,5 +249,14 @@ export default [
|
|||||||
props: ({query}: RouteQueryAndHash) => ({params: query})
|
props: ({query}: RouteQueryAndHash) => ({params: query})
|
||||||
},
|
},
|
||||||
{path: '/user-settings', component: UserSettings, meta: {title: "个性化设置"}},
|
{path: '/user-settings', component: UserSettings, meta: {title: "个性化设置"}},
|
||||||
|
...(import.meta.env.DEV
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
path: '/__dev/session',
|
||||||
|
component: () => import('~/pages/dev/SessionSeed.vue'),
|
||||||
|
meta: {title: 'Dev 会话'},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound, meta: {title: "404"}},
|
{path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound, meta: {title: "404"}},
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user