ray-template/docs/assets/reference_store_setting.md.BHiWF4im.js

14 lines
10 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as t,o as s,c as a,a3 as i}from"./chunks/framework.DdJ92B9j.js";const k=JSON.parse('{"title":"Setting Store","description":"","frontmatter":{},"headers":[],"relativePath":"reference/store/setting.md","filePath":"reference/store/setting.md"}'),d={name:"reference/store/setting.md"};function o(n,e,c,r,h,l){return s(),a("div",null,[...e[0]||(e[0]=[i(`<h1 id="setting-store" tabindex="-1">Setting Store <a class="header-anchor" href="#setting-store" aria-label="Permalink to &quot;Setting Store&quot;">​</a></h1><p><code>useSettingGetters()</code> 返回计算引用,<code>useSettingActions()</code> 修改偏好及相关副作用。设置会在刷新后恢复。运行中切换时优先用已提供的动作,避免 UI、日期语言或 HTML 样式不同步。</p><h2 id="getters" tabindex="-1">Getters <a class="header-anchor" href="#getters" aria-label="Permalink to &quot;Getters&quot;">​</a></h2><table tabindex="0"><thead><tr><th>Getter</th><th>字段与默认行为</th></tr></thead><tbody><tr><td><code>getLayoutConfig</code></td><td><code>layoutConfig</code>,布局模式和工作区尺寸,见下表。</td></tr><tr><td><code>getDrawerPlacement</code></td><td><code>drawerPlacement</code>,设置抽屉方向,默认 <code>right</code>。</td></tr><tr><td><code>getPrimaryColorOverride</code></td><td><code>primaryColorOverride</code>,Naive UI 主题覆盖;默认主色 <code>#3b63d9</code>。</td></tr><tr><td><code>getAppTheme</code> / <code>getAppThemeStr</code></td><td><code>_appTheme</code> 为实际深色布尔值,<code>appTheme</code> 为 <code>light/dark/auto</code> 模式,初始 <code>light</code>。</td></tr><tr><td><code>getLocaleLanguage</code></td><td><code>localeLanguage</code>,应用语言,默认读取历史值或系统默认配置。</td></tr><tr><td><code>getMenuTagSwitch</code> / <code>getBreadcrumbSwitch</code></td><td><code>menuTagSwitch</code> / <code>breadcrumbSwitch</code>,默认显示标签和面包屑。</td></tr><tr><td><code>getLockScreenSwitch</code></td><td><code>lockScreenSwitch</code>,锁屏设置弹窗显隐,默认关,不持久化。</td></tr><tr><td><code>getCopyrightSwitch</code></td><td><code>copyrightSwitch</code>,默认显示版权区。</td></tr><tr><td><code>getContentTransition</code></td><td><code>contentTransition</code>,路由切换动画,默认 <code>scale</code>。</td></tr><tr><td><code>getWatermarkSwitch</code> / <code>getWatermarkConfig</code></td><td><code>watermarkSwitch</code> 默认关;配置包含文字、字体大小、行高、宽高、偏移、间隔、旋转和 <code>cross</code>。</td></tr><tr><td><code>getAppRootRoute</code></td><td><code>appRootRoute</code>,默认 <code>{ name: &#39;Dashboard&#39;, path: &#39;/dashboard&#39; }</code>。</td></tr><tr><td><code>getSideBarLogo</code></td><td><code>sideBarLogo</code>,<code>icon</code>、<code>title</code>、<code>url</code>、<code>jumpType</code>。默认 <code>logo/ray</code>,站内跳转到仪表盘。</td></tr><tr><td><code>getKeepAliveConfig</code></td><td><code>keepAliveConfig</code>,默认开启、最多 10 个、排除列表为空。</td></tr><tr><td><code>getMenuConfig</code></td><td><code>menuConfig</code>,侧栏、折叠、图标、手风琴与滚动配置。</td></tr><tr><td><code>getColorWeakness</code> / <code>getDynamicDocumentTitle</code></td><td><code>colorWeakness</code> 默认关,<code>dynamicDocumentTitle</code> 默认开。</td></tr></tbody></table><p><code>layoutConfig</code> 的 <code>mode</code> 为 <code>side</code>(默认)、<code>top</code>、<code>mixed</code>。<code>contentWidth</code> 默认 <code>fluid</code>,也可取 <code>fixed</code>。<code>contentMaxWidth</code> 默认 1200,限制在 640–2560;<code>contentPadding</code> 默认 16,限制在 0–48;<code>fixedHeader</code>、<code>fixedFooter</code> 默认开启。旧缓存水合时补齐字段并规范化范围。</p><p><code>menuConfig</code> 默认菜单宽 272、折叠宽 64、普通和折叠图标均为 16、缩进 24。<code>collapsedMode</code> 默认 <code>width</code>,<code>transform</code> 模式改变位置;<code>accordion</code>、<code>inverted</code>、<code>nativeScrollbar</code> 默认关,<code>menuSiderBarLogo</code> 默认开。<code>sideBarLogo.jumpType</code> 用 <code>station</code> 站内跳转或 <code>outsideStation</code> 打开外部地址,未传 <code>url</code> 时不跳转。缓存中的旧裸图标名会尝试映射成完整名称;需要持久化的 Logo 建议用图标名字符串,VNode 不适合作为缓存值。</p><h2 id="actions" tabindex="-1">Actions <a class="header-anchor" href="#actions" aria-label="Permalink to &quot;Actions&quot;">​</a></h2><table tabindex="0"><thead><tr><th>方法</th><th>行为</th></tr></thead><tbody><tr><td><code>updateSettingState(key, value, callback?)</code></td><td>更新已有字段。普通对象浅合并;<code>layoutConfig</code> 额外做格式与范围校验。成功后调用可选回调。</td></tr><tr><td><code>updateLocale(key)</code></td><td>更新 Vue I18n、Day.js、语言缓存和 Store,Naive UI 从 Store 同步语言。</td></tr><tr><td><code>changePrimaryColor(value, alpha = 0.85)</code></td><td>更新 Naive UI 主色、hover/pressed/supplement 和 HTML CSS 变量。</td></tr><tr><td><code>toggleColorWeakness(bool)</code></td><td>更新设置并切换 HTML 反色滤镜。</td></tr></tbody></table><p>切换主题使用 <a href="./../hooks/appearance.html#usetheme">useTheme</a>,切换首页使用 <a href="./../hooks/navigation.html#useapproot">useAppRoot</a>。修改嵌套配置时传入完整的下一级对象,浅合并不会递归保存更深层字段。</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { useSettingActions, useSettingGetters } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;@/store&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> useCompactWorkspace</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">getLayoutConfig</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> useSettingGetters</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">updateSettingState</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> useSettingActions</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> apply</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> () </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=&gt;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> updateSettingState</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;layoutConfig&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> mode: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;mixed&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> contentWidth: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;fixed&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> contentMaxWidth: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1200</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> })</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { config: getLayoutConfig, apply }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p><a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/40320207ac6649076457fdcf33fbe04181d6288a/apps/admin/src/store/hooks/useSettingStore.ts" target="_blank" rel="noreferrer">Getters 与 Actions</a> · <a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/40320207ac6649076457fdcf33fbe04181d6288a/apps/admin/src/store/modules/setting/types.ts" target="_blank" rel="noreferrer">状态类型</a> · <a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/40320207ac6649076457fdcf33fbe04181d6288a/apps/admin/src/store/modules/setting/constant.ts" target="_blank" rel="noreferrer">默认配置</a> · <a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/40320207ac6649076457fdcf33fbe04181d6288a/apps/admin/src/store/modules/setting/index.ts" target="_blank" rel="noreferrer">持久化实现</a></p>`,11)])])}const g=t(d,[["render",o]]);export{k as __pageData,g as default};