mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-21 02:43:34 +08:00
14 lines
8.2 KiB
JavaScript
14 lines
8.2 KiB
JavaScript
import{_ as i,o as e,c as t,a3 as a}from"./chunks/framework.D8G7yXPy.js";const c=JSON.parse('{"title":"Runtime 与 Lock Screen Store","description":"","frontmatter":{},"headers":[],"relativePath":"reference/store/runtime.md","filePath":"reference/store/runtime.md"}'),n={name:"reference/store/runtime.md"};function l(r,s,h,d,p,k){return e(),t("div",null,[...s[0]||(s[0]=[a(`<h1 id="runtime-与-lock-screen-store" tabindex="-1">Runtime 与 Lock Screen Store <a class="header-anchor" href="#runtime-与-lock-screen-store" aria-label="Permalink to "Runtime 与 Lock Screen Store""></a></h1><h2 id="runtime-store" tabindex="-1">Runtime Store <a class="header-anchor" href="#runtime-store" aria-label="Permalink to "Runtime Store""></a></h2><p><code>useRuntimeGetters()</code> 提供只读 ref;<code>useRuntimeActions()</code> 返回 <code>setRuntimeState(key, value)</code>、<code>reloadContent(wait = 800)</code>。这些 UI 状态不持久化。</p><table tabindex="0"><thead><tr><th>字段</th><th>默认</th><th>用途</th></tr></thead><tbody><tr><td><code>globalSpinning</code></td><td><code>false</code></td><td>全局 Spin。</td></tr><tr><td><code>globalDrawerValue</code></td><td><code>false</code></td><td>窄屏菜单抽屉。</td></tr><tr><td><code>globalMainLayoutLoad</code></td><td><code>true</code></td><td>默认布局是否挂载页面内容。</td></tr><tr><td><code>layoutContentMaximize</code></td><td><code>false</code></td><td>工作区最大化。</td></tr><tr><td><code>layoutContentMaximizeVersion</code></td><td><code>0</code></td><td>最大化状态变动序号,用于过滤过期回调,业务代码不直接更新。</td></tr><tr><td><code>layoutContentSpinning</code></td><td><code>false</code></td><td>布局内容区 Spin。</td></tr><tr><td><code>layoutContentMaximizeStyle</code></td><td><code>{ zIndex: 999 }</code></td><td>最大化的层级、背景、过渡样式。</td></tr></tbody></table><p><code>reloadContent</code> 暂时卸载当前内容并等待恢复;多次调用只保留最后一个计时,Store 卸载时清理计时。<code>useSpinning().reload()</code> 是同一动作。控制最大化时用 <a href="./../hooks/layout.html#usemaximize">useMaximize</a> 来保留回调和退出逻辑。全局 Spin 和内容 Spin 互相独立。</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;"> { useRuntimeActions } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '@/store'</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;"> useGlobalLoading</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;">setRuntimeState</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;"> useRuntimeActions</span><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:#D73A49;--shiki-dark:#F97583;"> async</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> <</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">T</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">>(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">task</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;">=></span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Promise</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"><</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">T</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">>) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
|
||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> setRuntimeState</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'globalSpinning'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><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:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> task</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">finally</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
|
||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> setRuntimeState</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'globalSpinning'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</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:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>全局状态是布尔值,不对并发任务计数。如果多个独立请求同时使用,先由调用方统一协调开关。</p><h2 id="lock-screen-store" tabindex="-1">Lock Screen Store <a class="header-anchor" href="#lock-screen-store" aria-label="Permalink to "Lock Screen Store""></a></h2><p><code>useLockScreenGetters().getLocked</code> 是实际锁屏状态。<code>useLockScreenActions().setLocked(value)</code> 写入同一个状态,默认 <code>false</code>,通过 <code>isAppLockScreen</code> 在 Local Storage 保存历史布尔格式并跨标签同步。</p><p>实际锁定与 <code>setting.lockScreenSwitch</code> 分开,后者只控制锁屏设置弹窗。默认锁屏组件处理本地口令和解锁逻辑;业务按钮应打开设置弹窗,直接写锁定布尔值不会为用户建立口令。它是本机界面遮挡,与服务端会话和授权独立。</p><p><a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/82511cf6f52b5c902f566ccde62f3fcd976c3084/apps/admin/src/store/modules/runtime/index.ts" target="_blank" rel="noreferrer">Runtime 实现</a> · <a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/82511cf6f52b5c902f566ccde62f3fcd976c3084/apps/admin/src/store/modules/lock-screen/index.ts" target="_blank" rel="noreferrer">Lock Screen 实现</a> · <a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/82511cf6f52b5c902f566ccde62f3fcd976c3084/apps/admin/src/app-components/app/AppLockScreen/components/LockScreen/index.tsx" target="_blank" rel="noreferrer">锁屏流程</a></p>`,11)])])}const E=i(n,[["render",l]]);export{c as __pageData,E as default};
|