-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Socialabc #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
leoaiagent
wants to merge
18
commits into
miantiao-me:master
Choose a base branch
from
leoaiagent:socialabc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Socialabc #183
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9f7101e
Update wrangler.jsonc
leoaiagent 0eafba3
Update wrangler.jsonc
leoaiagent 46cc8d6
Update wrangler.jsonc
leoaiagent 6fa416e
Update wrangler.jsonc
leoaiagent 2144816
Update wrangler.jsonc
leoaiagent 9605990
Update wrangler.jsonc
leoaiagent 4456019
Update wrangler.jsonc
leoaiagent 36fce22
Update wrangler.jsonc add log
leoaiagent 1924845
Update wrangler.jsonc -sink
leoaiagent 1349865
Update wrangler.jsonc - update dataset
leoaiagent 4dd5ae0
Update wrangler.jsonc=
leoaiagent 72d8b14
Update wrangler.jsonc delete dataset
leoaiagent 0c38d63
Update wrangler.jsonc - dataset
leoaiagent 416866a
Update wrangler.jsonc sink dataset
leoaiagent 6e6be25
Update wrangler.jsonc
leoaiagent 0bccc07
Update wrangler.jsonc
leoaiagent 1d81526
Update wrangler.jsonc
leoaiagent f33975f
提交当前分支的所有修改和新增内容
leoaiagent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,33 +2,49 @@ | |
| import { AlertCircle } from 'lucide-vue-next' | ||
| import { toast } from 'vue-sonner' | ||
| import { z } from 'zod' | ||
| // 导入UI组件 | ||
| import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card' | ||
| import { Button } from '@/components/ui/button' | ||
| import { AutoForm } from '@/components/ui/auto-form' | ||
|
|
||
| const { t } = useI18n() | ||
|
|
||
| const LoginSchema = z.object({ | ||
| token: z.string().describe('SiteToken'), | ||
| email: z.string().email(), | ||
| password: z.string().min(8), | ||
| }) | ||
| const loginFieldConfig = { | ||
| token: { | ||
| email: { | ||
| inputProps: { | ||
| type: 'email', | ||
| placeholder: '[email protected]', | ||
| }, | ||
| }, | ||
| password: { | ||
| inputProps: { | ||
| type: 'password', | ||
| placeholder: '********', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const { previewMode } = useRuntimeConfig().public | ||
|
|
||
| async function onSubmit(form) { | ||
| try { | ||
| localStorage.setItem('SinkSiteToken', form.token) | ||
| await useAPI('/api/verify') | ||
| const response = await useAPI('/api/auth/login', { | ||
| method: 'POST', | ||
| body: form, | ||
| }) | ||
|
|
||
| // 存储用户信息和token | ||
| localStorage.setItem('SinkUser', JSON.stringify(response.user)) | ||
| localStorage.setItem('SinkSiteToken', response.token) | ||
|
|
||
| navigateTo('/dashboard') | ||
| } | ||
| catch (e) { | ||
| console.error(e) | ||
| toast.error(t('login.failed'), { | ||
| description: e.message, | ||
| description: e.message || t('login.invalid_credentials'), | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -51,16 +67,15 @@ async function onSubmit(form) { | |
| :field-config="loginFieldConfig" | ||
| @submit="onSubmit" | ||
| > | ||
| <Alert v-if="previewMode"> | ||
| <AlertCircle class="w-4 h-4" /> | ||
| <AlertTitle>{{ $t('login.tips') }}</AlertTitle> | ||
| <AlertDescription> | ||
| {{ $t('login.preview_token') }} <code class="font-mono text-green-500">SinkCool</code> . | ||
| </AlertDescription> | ||
| </Alert> | ||
| <Button class="w-full"> | ||
| {{ $t('login.submit') }} | ||
| </Button> | ||
| <div class="text-center text-sm text-muted-foreground"> | ||
| {{ $t('login.dont_have_account') }} | ||
| <a href="/dashboard/register" class="text-primary hover:underline"> | ||
| {{ $t('login.register_link') }} | ||
| </a> | ||
| </div> | ||
| </AutoForm> | ||
| </CardContent> | ||
| </Card> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| <script setup> | ||
| import { AlertCircle } from 'lucide-vue-next' | ||
| import { toast } from 'vue-sonner' | ||
| import { z } from 'zod' | ||
| // 导入UI组件 | ||
| import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card' | ||
| import { Button } from '@/components/ui/button' | ||
| import { AutoForm } from '@/components/ui/auto-form' | ||
|
|
||
| const { t } = useI18n() | ||
|
|
||
| const RegisterSchema = z.object({ | ||
| username: z.string().min(3).max(50), | ||
| email: z.string().email(), | ||
| password: z.string().min(8), | ||
| }) | ||
|
|
||
| const registerFieldConfig = { | ||
| username: { | ||
| inputProps: { | ||
| type: 'text', | ||
| placeholder: 'JohnDoe', | ||
| }, | ||
| }, | ||
| email: { | ||
| inputProps: { | ||
| type: 'email', | ||
| placeholder: '[email protected]', | ||
| }, | ||
| }, | ||
| password: { | ||
| inputProps: { | ||
| type: 'password', | ||
| placeholder: '********', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const { previewMode } = useRuntimeConfig().public | ||
|
|
||
| async function onSubmit(form) { | ||
| try { | ||
| const response = await useAPI('/api/auth/register', { | ||
| method: 'POST', | ||
| body: form, | ||
| }) | ||
|
|
||
| // 注册成功后,自动登录用户 | ||
| try { | ||
| // 调用登录API自动登录 | ||
| const loginResponse = await useAPI('/api/auth/login', { | ||
| method: 'POST', | ||
| body: { | ||
| email: form.email, | ||
| password: form.password | ||
| }, | ||
| }) | ||
|
|
||
| // 存储用户信息和token | ||
| localStorage.setItem('SinkUser', JSON.stringify(loginResponse.user)) | ||
| localStorage.setItem('SinkSiteToken', loginResponse.token) | ||
|
|
||
| toast.success(t('register.success'), { | ||
| description: t('register.success_and_logged_in'), | ||
| }) | ||
|
|
||
| navigateTo('/dashboard') | ||
| } catch (loginError) { | ||
| // 如果自动登录失败,提示用户手动登录 | ||
| toast.success(t('register.success'), { | ||
| description: t('register.success_manual_login'), | ||
| }) | ||
|
|
||
| navigateTo('/dashboard/login') | ||
| } | ||
| } | ||
| catch (e) { | ||
| console.error(e) | ||
| toast.error(t('register.failed'), { | ||
| description: e.message, | ||
| }) | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <Card class="w-full max-w-sm"> | ||
| <CardHeader> | ||
| <CardTitle class="text-2xl"> | ||
| {{ $t('register.title') }} | ||
| </CardTitle> | ||
| <CardDescription> | ||
| {{ $t('register.description') }} | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent class="grid gap-4"> | ||
| <AutoForm | ||
| class="space-y-6" | ||
| :schema="RegisterSchema" | ||
| :field-config="registerFieldConfig" | ||
| @submit="onSubmit" | ||
| > | ||
| <Button class="w-full"> | ||
| {{ $t('register.submit') }} | ||
| </Button> | ||
| <div class="text-center text-sm text-muted-foreground"> | ||
| {{ $t('register.already_have_account') }} | ||
| <a href="/dashboard/login" class="text-primary hover:underline"> | ||
| {{ $t('register.login_link') }} | ||
| </a> | ||
| </div> | ||
| </AutoForm> | ||
| </CardContent> | ||
| </Card> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use TypeScript in new Vue SFCs
Repository guideline: “Use TypeScript for all new code.” Switch the script to TS.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents