diff --git a/src/lang/en/home.json b/src/lang/en/home.json index 0a96caed8..a9f0f3c5e 100644 --- a/src/lang/en/home.json +++ b/src/lang/en/home.json @@ -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": { diff --git a/src/store/local_settings.ts b/src/store/local_settings.ts index 1f216105c..fead91731 100644 --- a/src/store/local_settings.ts +++ b/src/store/local_settings.ts @@ -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", diff --git a/src/store/obj.ts b/src/store/obj.ts index 2bfa2f79e..843e90f22 100644 --- a/src/store/obj.ts +++ b/src/store/obj.ts @@ -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 @@ -185,11 +186,11 @@ const layoutRecord: Record = (() => { bus.on("pathname", (p) => setPathname(p)) const [_layout, _setLayout] = createSignal( - 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) => {