diff --git a/src/lang/en/home.json b/src/lang/en/home.json index c817204e2..0a96caed8 100644 --- a/src/lang/en/home.json +++ b/src/lang/en/home.json @@ -91,7 +91,13 @@ "local_settings": { "aria2_rpc_url": "Aria2 RPC URL", "aria2_rpc_secret": "Aria2 RPC secret", - "aria2_dir": "Aria2 download directory" + "aria2_dir": "Aria2 download directory", + "show_folder_in_image_view": "Show folder in image view", + "show_folder_in_image_view_options": { + "top": "Top", + "bottom": "Bottom", + "none": "None" + } }, "package_download": { "current_status": "Current Status", diff --git a/src/pages/home/folder/Images.tsx b/src/pages/home/folder/Images.tsx index 9ef54a586..533e4a239 100644 --- a/src/pages/home/folder/Images.tsx +++ b/src/pages/home/folder/Images.tsx @@ -1,18 +1,41 @@ -import { Flex } from "@hope-ui/solid" -import { For } from "solid-js" +import { Flex, Grid, VStack } from "@hope-ui/solid" +import { For, Show, createMemo } from "solid-js" import { ImageItem } from "./ImageItem" -import { objStore } from "~/store" +import { local, objStore } from "~/store" +import { GridItem } from "./GridItem" -const GridLayout = () => { - return ( - - +const ImageLayout = () => { + const folders = createMemo(() => ( + + obj.is_dir)}> {(obj, i) => { - return + return }} - + + )) + return ( + + + {folders()} + + + + {(obj, i) => { + return + }} + + + + {folders()} + + ) } -export default GridLayout +export default ImageLayout diff --git a/src/pages/home/toolbar/LocalSettings.tsx b/src/pages/home/toolbar/LocalSettings.tsx index 583c71be5..c07ae5e0e 100644 --- a/src/pages/home/toolbar/LocalSettings.tsx +++ b/src/pages/home/toolbar/LocalSettings.tsx @@ -11,25 +11,67 @@ import { FormLabel, HStack, Input, + Select, + SelectContent, + SelectIcon, + SelectListbox, + SelectOption, + SelectOptionIndicator, + SelectOptionText, + SelectPlaceholder, + SelectTrigger, + SelectValue, VStack, } from "@hope-ui/solid" -import { For, onCleanup } from "solid-js" +import { For, Match, onCleanup, Switch } from "solid-js" import { SwitchLanguageWhite, SwitchColorMode } from "~/components" import { useT } from "~/hooks" -import { initialLocalSettings, local, setLocal } from "~/store" +import { initialLocalSettings, local, LocalSetting, setLocal } from "~/store" import { bus } from "~/utils" -const LocalSettingsInput = (props: { name: string }) => { +function LocalSettingEdit(props: LocalSetting) { const t = useT() return ( - {t(`home.local_settings.${props.name}`)} - { - setLocal(props.name, e.currentTarget.value) - }} - /> + {t(`home.local_settings.${props.key}`)} + { + setLocal(props.key, e.currentTarget.value) + }} + /> + } + > + + + + ) } @@ -56,8 +98,8 @@ export const LocalSettings = () => { - - {(name) => } + + {(setting) => }
diff --git a/src/store/local_settings.ts b/src/store/local_settings.ts index eb9cf3400..1f216105c 100644 --- a/src/store/local_settings.ts +++ b/src/store/local_settings.ts @@ -1,21 +1,33 @@ import { createLocalStorage } from "@solid-primitives/storage" const [local, setLocal, { remove, clear, toJSON }] = createLocalStorage() -export function isValidKey( - key: string | number | symbol, - object: object -): key is keyof typeof object { - return key in object -} +// export function isValidKey( +// key: string | number | symbol, +// object: object +// ): key is keyof typeof object { +// return key in object +// } -export const initialLocalSettings = { - aria2_rpc_url: "http://localhost:6800/jsonrpc", - aria2_rpc_secret: "", - // aria2_dir: "/downloads/alist", -} -for (const key in initialLocalSettings) { - if (!local[key] && isValidKey(key, initialLocalSettings)) { - setLocal(key, initialLocalSettings[key]) +export const initialLocalSettings = [ + { + key: "aria2_rpc_url", + default: "http://localhost:6800/jsonrpc", + }, + { + key: "aria2_rpc_secret", + default: "", + }, + { + key: "show_folder_in_image_view", + default: "top", + type: "select", + options: ["top", "bottom", "none"], + }, +] +export type LocalSetting = (typeof initialLocalSettings)[number] +for (const setting of initialLocalSettings) { + if (!local[setting.key]) { + setLocal(setting.key, setting.default) } }