Skip to content

Commit

Permalink
feat: edit header of meta
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Oct 2, 2023
1 parent 39186de commit 99e757a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/lang/en/metas.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"write": "Write",
"hide": "Hide",
"readme": "Readme",
"readme_help": "Render a markdown at the bottom, support content or link",
"header": "Header",
"header_help": "Render a markdown at the top, support content or link",
"apply_sub": "Apply to sub folder",
"hide_help": "One regular expression per line",
"readme_help": "Support markdown content or markdown link"
"hide_help": "One regular expression per line"
}
23 changes: 13 additions & 10 deletions src/pages/manage/metas/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const AddOrEdit = () => {
h_sub: false,
readme: "",
r_sub: false,
header: "",
header_sub: false,
})
const [metaLoading, loadMeta] = useFetch(
(): PResp<Meta> => r.get(`/admin/meta/get?id=${id}`),
Expand Down Expand Up @@ -137,12 +139,15 @@ const AddOrEdit = () => {
/>
</FormControl> */}
<For
each={[
{ name: "password", type: "string" },
{ name: "write", type: "bool" },
{ name: "hide", type: "text", help: true },
{ name: "readme", type: "text", help: true },
]}
each={
[
{ name: "password", type: "string", sub: "p_sub" },
{ name: "write", type: "bool", sub: "w_sub" },
{ name: "hide", type: "text", sub: "h_sub", help: true },
{ name: "header", type: "text", sub: "header_sub", help: true },
{ name: "readme", type: "text", sub: "r_sub", help: true },
] as const
}
>
{(item) => {
return (
Expand All @@ -154,10 +159,8 @@ const AddOrEdit = () => {
onChange={(val: any): void =>
setMeta(item.name as keyof Meta, val)
}
sub={meta[`${item.name[0]}_sub` as keyof Meta] as boolean}
onSub={(val: boolean): void =>
setMeta(`${item.name[0]}_sub` as keyof Meta, val)
}
sub={meta[item.sub] as boolean}
onSub={(val: boolean): void => setMeta(item.sub, val)}
help={item.help}
/>
)
Expand Down
2 changes: 2 additions & 0 deletions src/types/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export interface Meta {
h_sub: boolean
readme: string
r_sub: boolean
header: string
header_sub: boolean
}

0 comments on commit 99e757a

Please sign in to comment.