-
Notifications
You must be signed in to change notification settings - Fork 244
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 #47 from Ray-D-Song/optimize
plugin optimize and add configuration for showing rencent saved page
- Loading branch information
Showing
23 changed files
with
472 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- main | ||
- hotfix | ||
- preview | ||
- read_mode | ||
- optimize | ||
|
||
jobs: | ||
deploy: | ||
|
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,6 +1,6 @@ | ||
{ | ||
"name": "web-archive", | ||
"version": "0.1.0", | ||
"version": "0.1.1-alpha.1", | ||
"packageManager": "[email protected]+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a", | ||
"description": "Self-host your own web archive, powered by Cloudflare Workers and React.", | ||
"author": "Ray-D-Song & banzhe", | ||
|
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,59 @@ | ||
import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@web-archive/shared/components/dialog' | ||
import { Button } from '@web-archive/shared/components/button' | ||
import { Input } from '@web-archive/shared/components/input' | ||
import { useState } from 'react' | ||
import toast from 'react-hot-toast' | ||
import { useRequest } from 'ahooks' | ||
import { sendMessage } from 'webext-bridge/popup' | ||
|
||
interface NewFolderProps { | ||
afterSubmit: (folder: { id: number, name: string }) => void | ||
open: boolean | ||
setOpen: (open: boolean) => void | ||
} | ||
|
||
async function createFolder(name: string): Promise<{ id: number, name: string }> { | ||
const newFolder = await sendMessage('create-folder', { name }) | ||
if (!newFolder) { | ||
throw new Error('Failed to create folder') | ||
} | ||
return newFolder | ||
} | ||
|
||
function NewFolderDialog({ afterSubmit, open, setOpen }: NewFolderProps) { | ||
const [name, setName] = useState('') | ||
const { run } = useRequest( | ||
createFolder, | ||
{ | ||
manual: true, | ||
onSuccess: (folder) => { | ||
toast.success('Folder created') | ||
setOpen(false) | ||
setName('') | ||
afterSubmit(folder) | ||
}, | ||
onError: (error) => { | ||
toast.error(error.message) | ||
}, | ||
}, | ||
) | ||
const handleSubmit = () => { | ||
if (name.length === 0) { | ||
toast.error('Folder name is required') | ||
return | ||
} | ||
run(name) | ||
} | ||
return ( | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogContent className="w-64"> | ||
<DialogTitle>Create New Folder</DialogTitle> | ||
<DialogDescription></DialogDescription> | ||
<Input value={name} onChange={e => setName(e.target.value)} placeholder="Folder Name" /> | ||
<Button onClick={handleSubmit}>Create</Button> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default NewFolderDialog |
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.