Skip to content

Commit

Permalink
feat: global default layout
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 27, 2023
1 parent 6d4f0a7 commit e3ab4e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/lang/en/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
"top": "Top",
"bottom": "Bottom",
"none": "None"
},
"global_default_layout": "Global default layout",
"global_default_layout_options": {
"list": "List View",
"grid": "Grid View",
"image": "Image View"
}
},
"package_download": {
Expand Down
6 changes: 6 additions & 0 deletions src/store/local_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export const initialLocalSettings = [
key: "aria2_rpc_secret",
default: "",
},
{
key: "global_default_layout",
default: "list",
type: "select",
options: ["list", "grid", "image"],
},
{
key: "show_folder_in_image_view",
default: "top",
Expand Down
5 changes: 3 additions & 2 deletions src/store/obj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createStore, produce } from "solid-js/store"
import { Obj, StoreObj } from "~/types"
import { bus, log } from "~/utils"
import { keyPressed } from "./key-event"
import { local } from "./local_settings"

export enum State {
Initial, // Initial state
Expand Down Expand Up @@ -185,11 +186,11 @@ const layoutRecord: Record<string, LayoutType> = (() => {

bus.on("pathname", (p) => setPathname(p))
const [_layout, _setLayout] = createSignal<LayoutType>(
layoutRecord[pathname()] || "list"
layoutRecord[pathname()] || local["global_default_layout"]
)
export const layout = () => {
const layout = layoutRecord[pathname()]
_setLayout(layout || "list")
_setLayout(layout || local["global_default_layout"])
return _layout()
}
export const setLayout = (layout: LayoutType) => {
Expand Down

1 comment on commit e3ab4e1

@xhofe
Copy link
Member Author

@xhofe xhofe commented on e3ab4e1 Jul 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.