Skip to content

Commit

Permalink
Merge pull request #27 from besscroft/dev
Browse files Browse the repository at this point in the history
v0.7.1
  • Loading branch information
besscroft authored May 18, 2024
2 parents a27eb6c + db701dd commit d60289c
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/admin/tag/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import React from 'react'
import TagAddSheet from '~/components/admin/tag/TagAddSheet'
import TagAddButton from '~/components/admin/tag/TagAddButton'
import TagEditSheet from '~/components/admin/tag/TagEditSheet'
import TagHelpSheet from '~/components/admin/tag/TagHelpSheet'
import TagHelp from '~/components/admin/tag/TagHelp'

export default async function List() {

Expand All @@ -30,6 +32,7 @@ export default async function List() {
</div>
</div>
<div className="flex items-center space-x-2">
<TagHelp />
<TagAddButton />
<RefreshButton {...props} />
</div>
Expand All @@ -38,6 +41,7 @@ export default async function List() {
<TagList {...props} />
<TagAddSheet {...props} />
<TagEditSheet {...props} />
<TagHelpSheet />
</div>
)
}
23 changes: 23 additions & 0 deletions components/admin/tag/TagHelp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use client'

import { Button } from '@nextui-org/react'
import React from 'react'
import { CircleHelp } from 'lucide-react'
import { useButtonStore } from '~/app/providers/button-store-Providers'

export default function TagHelp() {
const { setTagHelp } = useButtonStore(
(state) => state,
)
return (
<Button
isIconOnly
size="sm"
color="warning"
aria-label="帮助"
onClick={() => setTagHelp(true)}
>
<CircleHelp />
</Button>
)
}
37 changes: 37 additions & 0 deletions components/admin/tag/TagHelpSheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use client'

import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from '~/components/ui/Sheet'
import { useButtonStore } from '~/app/providers/button-store-Providers'

export default function TagHelpSheet() {
const { tagHelp, setTagHelp } = useButtonStore(
(state) => state,
)

return (
<Sheet
defaultOpen={false}
open={tagHelp}
onOpenChange={(open: boolean) => {
if (!open) {
setTagHelp(false)
}
}}
modal={false}
>
<SheetContent side="left">
<SheetHeader>
<SheetTitle>帮助</SheetTitle>
<SheetDescription className="space-y-2">
<p>
您要展示除⌈首页⌋外的其它相册,需要添加新的⌈标签⌋,并标记为可显示状态。
</p>
<p>
⌈标签⌋的⌈路由⌋需要带 / 前缀。
</p>
</SheetDescription>
</SheetHeader>
</SheetContent>
</Sheet>
)
}
1 change: 1 addition & 0 deletions components/admin/upload/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function FileUpload() {
async function loadExif(file: any) {
try {
const tags = await ExifReader.load(file)
console.log(tags)
const exifObj = {
make: '',
model: '',
Expand Down
9 changes: 8 additions & 1 deletion components/layout/DropMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ export const DropMenu = () => {
showDivider
>
<div onClick={async () => {
await loginOut()
try {
await loginOut()
setTimeout(() => {
location.replace('/login')
}, 1000);
} catch (e) {
console.log(e)
}
}}>
退出登录
</div>
Expand Down
9 changes: 8 additions & 1 deletion components/layout/VaulDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ export default function VaulDrawer() {
startContent={<LogOut size={20} className={iconClasses} />}
>
<div onClick={async () => {
await loginOut()
try {
await loginOut()
setTimeout(() => {
location.replace('/login')
}, 1000);
} catch (e) {
console.log(e)
}
}}>
退出登录
</div>
Expand Down
6 changes: 5 additions & 1 deletion components/login/UserFrom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ export const UserFrom = () => {
const { email, password } = parsedCredentials.data;
await authenticate(email, password)
toast.success('登录成功!')
setTimeout(() => {
location.replace('/admin')
}, 1000);
} else {
toast.error('请检查您的账号密码!')
}
} catch (e) {
toast.error('登录失败!')
} finally {
setIsLoading(false)
}
setIsLoading(false)
}}
aria-label="登录"
>
Expand Down
6 changes: 2 additions & 4 deletions server/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export async function authenticate(
await signIn('Credentials', {
email: email,
password: password,
redirect: true,
redirectTo: '/admin'
redirect: false,
});
} catch (error) {
throw error;
Expand All @@ -20,8 +19,7 @@ export async function authenticate(
export async function loginOut() {
try {
await signOut({
redirect: true,
redirectTo: '/login'
redirect: false,
});
} catch (error) {
throw error;
Expand Down
7 changes: 7 additions & 0 deletions stores/buttonStores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type ButtonState = {
aListData: Config[]
MasonryView: boolean
MasonryViewData: ImageType
tagHelp: boolean
}

export type ButtonActions = {
Expand All @@ -36,6 +37,7 @@ export type ButtonActions = {
setAListEditData: (aListData: Config[]) => void
setMasonryView: (masonryView: boolean) => void
setMasonryViewData: (masonryViewData: ImageType) => void
setTagHelp: (tagHelp: boolean) => void
}

export type ButtonStore = ButtonState & ButtonActions
Expand All @@ -57,6 +59,7 @@ export const initButtonStore = (): ButtonState => {
aListData: [] as Config[],
MasonryView: false,
MasonryViewData: {} as ImageType,
tagHelp: false,
}
}

Expand All @@ -76,6 +79,7 @@ export const defaultInitState: ButtonState = {
aListData: [] as Config[],
MasonryView: false,
MasonryViewData: {} as ImageType,
tagHelp: false,
}

export const createButtonStore = (
Expand Down Expand Up @@ -130,6 +134,9 @@ export const createButtonStore = (
setMasonryViewData: (masonryViewDataValue) => set(() => ({
MasonryViewData: masonryViewDataValue,
})),
setTagHelp: (tagHelpValue) => set(() => ({
tagHelp: tagHelpValue,
})),
}),
{
name: 'pic-impact-button-storage', // name of the item in the storage (must be unique)
Expand Down

0 comments on commit d60289c

Please sign in to comment.