mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
30 lines
720 B
TypeScript
30 lines
720 B
TypeScript
import { EnumStorageKey } from '@/enum';
|
|
import { setLocal, getLocal } from '../storage';
|
|
|
|
/** 缓存多页签数据 */
|
|
export function setTabRoutes(data: GlobalTabRoute[]) {
|
|
setLocal(EnumStorageKey['multi-tab-routes'], data);
|
|
}
|
|
|
|
/** 获取缓存的多页签数据 */
|
|
export function getTabRoutes() {
|
|
const routes: GlobalTabRoute[] = [];
|
|
const data = getLocal<GlobalTabRoute[]>(EnumStorageKey['multi-tab-routes']);
|
|
if (data) {
|
|
const defaultTabRoutes = data.map(item => ({
|
|
...item,
|
|
scrollPosition: {
|
|
left: 0,
|
|
top: 0
|
|
}
|
|
}));
|
|
routes.push(...defaultTabRoutes);
|
|
}
|
|
return routes;
|
|
}
|
|
|
|
/** 清空多页签数据 */
|
|
export function clearTabRoutes() {
|
|
setTabRoutes([]);
|
|
}
|