feat: support auto login with url query parameter (#606)

This commit is contained in:
Dream Hunter
2025-03-16 14:20:24 +08:00
committed by GitHub
parent 908fc0cc86
commit 525f5e2dce
6 changed files with 42 additions and 17 deletions

View File

@@ -32,6 +32,7 @@ const { locale, t } = useI18n({
copied: 'Copied',
fetchAddressError: 'Mail address credential is invalid or account not exist, it may be network connection issue, please try again later.',
addressCredential: 'Mail Address Credential',
linkWithAddressCredential: 'Open to auto login email link',
addressCredentialTip: 'Please copy the Mail Address Credential and you can use it to login to your email account.',
userLogin: 'User Login',
},
@@ -43,6 +44,7 @@ const { locale, t } = useI18n({
copied: '已复制',
fetchAddressError: '邮箱地址凭证无效或邮箱地址不存在,也可能是网络连接异常,请稍后再尝试。',
addressCredential: '邮箱地址凭证',
linkWithAddressCredential: '打开即可自动登录邮箱的链接',
addressCredentialTip: '请复制邮箱地址凭证,你可以使用它登录你的邮箱。',
userLogin: '用户登录',
}
@@ -73,6 +75,10 @@ const copy = async () => {
}
}
const getUrlWithJwt = () => {
return `${window.location.origin}/?jwt=${jwt.value}`
}
const onUserLogin = async () => {
await router.push(getRouterPathWithLang("/user", locale.value))
}
@@ -140,9 +146,18 @@ onMounted(async () => {
<span>
<p>{{ t("addressCredentialTip") }}</p>
</span>
<n-card :bordered="false" embedded>
<n-card embedded>
<b>{{ jwt }}</b>
</n-card>
<n-card embedded>
<n-collapse>
<n-collapse-item :title='t("linkWithAddressCredential")'>
<n-card embedded>
<b>{{ getUrlWithJwt() }}</b>
</n-card>
</n-collapse-item>
</n-collapse>
</n-card>
</n-modal>
</div>
</template>

View File

@@ -22,7 +22,7 @@ const { t } = useI18n({
actions: 'Actions',
changeMailAddress: 'Change Mail Address',
unbindMailAddress: 'Unbind Mail Address credential',
bind: 'Bind',
create_or_bind: 'Create or Bind',
bindAddressSuccess: 'Bind Address Success',
},
zh: {
@@ -32,7 +32,7 @@ const { t } = useI18n({
actions: '操作',
changeMailAddress: '切换邮箱地址',
unbindMailAddress: '解绑邮箱地址',
bind: '绑定',
create_or_bind: '创建或绑定',
bindAddressSuccess: '绑定地址成功',
}
}
@@ -151,7 +151,7 @@ const columns = [
<n-tab-pane name="address" :tab="t('address')">
<n-data-table :columns="columns" :data="data" :bordered="false" embedded />
</n-tab-pane>
<n-tab-pane name="bind" :tab="t('bind')">
<n-tab-pane name="create_or_bind" :tab="t('create_or_bind')">
<Login :bindUserAddress="bindAddress" />
</n-tab-pane>
</n-tabs>