-
Notifications
You must be signed in to change notification settings - Fork 57.2k
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 #29 from Yidadaa/bugfix-0325
v1.2 bug fix, ui improvement and access control by code
- Loading branch information
Showing
17 changed files
with
227 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import md5 from "spark-md5"; | ||
|
||
export function getAccessCodes(): Set<string> { | ||
const code = process.env.CODE; | ||
|
||
try { | ||
const codes = (code?.split(",") ?? []) | ||
.filter((v) => !!v) | ||
.map((v) => md5.hash(v.trim())); | ||
return new Set(codes); | ||
} catch (e) { | ||
return new Set(); | ||
} | ||
} | ||
|
||
export const ACCESS_CODES = getAccessCodes(); |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
import { create } from "zustand"; | ||
import { persist } from "zustand/middleware"; | ||
import { queryMeta } from "../utils"; | ||
|
||
export interface AccessControlStore { | ||
accessCode: string; | ||
|
||
updateCode: (_: string) => void; | ||
enabledAccessControl: () => boolean; | ||
} | ||
|
||
export const ACCESS_KEY = "access-control"; | ||
|
||
export const useAccessStore = create<AccessControlStore>()( | ||
persist( | ||
(set, get) => ({ | ||
accessCode: "", | ||
enabledAccessControl() { | ||
return queryMeta("access") === "enabled"; | ||
}, | ||
updateCode(code: string) { | ||
set((state) => ({ accessCode: code })); | ||
}, | ||
}), | ||
{ | ||
name: ACCESS_KEY, | ||
version: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./app"; | ||
export * from "./update"; | ||
export * from "./access"; |
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
Oops, something went wrong.
5cdcaac
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:
chat-gpt-next-web – ./
chat-gpt-next-web.vercel.app
chat-gpt-next-web-git-main-yidadaa.vercel.app
chat-gpt-next-web-yidadaa.vercel.app
chat.simplenaive.cn