forked from anse-app/chatgpt-demo
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ddiu8081/main
master update 2
- Loading branch information
Showing
13 changed files
with
175 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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,12 @@ | ||
import type { APIRoute } from 'astro' | ||
|
||
const realPassword = import.meta.env.SITE_PASSWORD | ||
|
||
export const post: APIRoute = async (context) => { | ||
const body = await context.request.json() | ||
|
||
const { pass } = body | ||
return new Response(JSON.stringify({ | ||
code: (!realPassword || pass === realPassword) ? 0 : -1, | ||
})) | ||
} |
This file contains 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 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 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,72 @@ | ||
--- | ||
import Layout from '../layouts/Layout.astro' | ||
--- | ||
|
||
<Layout title="Password Protection"> | ||
<main class="h-screen flex flex-col items-center justify-center"> | ||
<div class="op-30">Please input password</div> | ||
<div id="input_container" class="flex mt-4"> | ||
<input id="password_input" type="password" class="px-4 py-3 h-12 rounded-sm bg-slate bg-op-15 focus:bg-op-20 focus:ring-0 focus:outline-none" /> | ||
<div id="submit" class="flex items-center justify-center h-12 w-12 bg-slate cursor-pointer bg-op-20 hover:bg-op-50"> | ||
<div class="i-carbon-arrow-right" /> | ||
</div> | ||
</div> | ||
</main> | ||
</Layout> | ||
|
||
<script> | ||
const inputContainer = document.getElementById('input_container') as HTMLDivElement | ||
const input = document.getElementById('password_input') as HTMLInputElement | ||
const submitButton = document.getElementById('submit') as HTMLDivElement | ||
|
||
input.onkeydown = async (event) => { | ||
if (event.key === 'Enter') { | ||
handleSubmit() | ||
} | ||
} | ||
submitButton.onclick = handleSubmit | ||
|
||
async function handleSubmit() { | ||
const password = input.value | ||
const response = await fetch('/api/auth', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
pass: password, | ||
}), | ||
}) | ||
const responseJson = await response.json() | ||
if (responseJson.code === 0) { | ||
localStorage.setItem('pass', password) | ||
window.location.href = '/' | ||
} else { | ||
inputContainer.classList.add('invalid') | ||
setTimeout(() => { | ||
inputContainer.classList.remove('invalid') | ||
}, 300) | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
@keyframes shake { | ||
0% { | ||
transform: translateX(0); | ||
} | ||
25% { | ||
transform: translateX(0.5rem); | ||
} | ||
75% { | ||
transform: translateX(-0.5rem); | ||
} | ||
100% { | ||
transform: translateX(0); | ||
} | ||
} | ||
|
||
.invalid { | ||
animation: shake 0.2s ease-in-out 0s 2; | ||
} | ||
</style> |
fd5abb7
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.
Successfully deployed to the following URLs:
chatgpt-fork-update – ./
chatgpt-fork-update-6102yk.vercel.app
chatgpt-experience.vercel.app
chatgpt-fork-update-git-main-6102yk.vercel.app
ai.chunkiu.hk
chatgpt-chunkiu.vercel.app
chat.chunkiu.hk
chatgpt.chunkiu.hk