feat: 保存导航链接侧边栏折叠状态和搜索类型

This commit is contained in:
2024-09-01 18:01:04 +08:00
parent c2d6fa1c86
commit 7c0fb75913
2 changed files with 23 additions and 2 deletions

View File

@@ -3,5 +3,11 @@
/** 储存 key 前缀 */
const PREFIX = 'frost-navigation/';
/** 导航链接侧边栏折叠状态 */
export const SKEY_NAV_LINK_ASIDE_COLLAPSED = PREFIX + 'nav-link-aside-collapsed';
/** 导航链接搜索类型 */
export const SKEY_NAV_LINK_SEARCH_TYPE = PREFIX + 'nav-link-search-type';
/** 当前使用的搜索引擎名称 */
export const SKEY_SEARCH_ENGINE_NAME = PREFIX + 'search-engine-name';

View File

@@ -143,6 +143,11 @@ import {
NAV_MODULE_TITLE,
} from '@/config/modules';
import {
SKEY_NAV_LINK_ASIDE_COLLAPSED,
SKEY_NAV_LINK_SEARCH_TYPE,
} from '@/config/storage';
import {
$dialog, $message,
} from '@/assets/js/naive-ui';
@@ -151,6 +156,10 @@ import {
formatNavLinks,
} from '@/assets/js/nav-links';
import {
useLocalStorage,
} from '@vueuse/core';
/** 链接详情 */
const detailDrawer = reactive({
@@ -163,7 +172,10 @@ const detailDrawer = reactive({
});
/** 分类列表是否折叠 */
const isCollapsed = shallowRef(false);
const isCollapsed = useLocalStorage(
SKEY_NAV_LINK_ASIDE_COLLAPSED,
false
);
/** 完整的链接列表 */
const navLinksAll = formatNavLinks(true);
@@ -194,7 +206,10 @@ const navLinksTitle = shallowRef('');
const searchKeyword = shallowRef('');
/** 搜索类型 */
const searchType = shallowRef('all');
const searchType = useLocalStorage(
SKEY_NAV_LINK_SEARCH_TYPE,
'all'
);
/**
* @desc 搜索类型列表