提交 5f0260f8 authored 作者: vipcxj's avatar vipcxj

1.修复根路由不能自动跳转快捷导航的错误

2.新增创建和删除历史记录的api
上级 c1e813ff
......@@ -7,6 +7,8 @@ const data = {
export async function initApp(app) {
data.app = app;
await histories.init();
await histories.createHistory('domain', 10);
await histories.createHistory('module', 50);
return data.app;
}
......
......@@ -158,7 +158,13 @@ function RouterConfig({ history, app }) {
path: `${contextPath}/`,
component: App,
indexRoute: {
onEnter: (nextState, replace) => replace(`${contextPath}/main`),
onEnter: (nextState, replace) => {
if (config.fastNavigationPage) {
replace(`${contextPath}/fastNav`);
} else {
replace(`${contextPath}/main`);
}
},
},
childRoutes: [
{
......
......@@ -110,6 +110,15 @@ export const histories = {
}
return history.data[prev(history.top, history.size)];
},
async createHistory(name, size) {
let history = db.get(`history.${name}`).value();
history = normHistory(history);
history.size = size;
return db.set(`history.${name}`, history).write();
},
async destroyHistory(name) {
return db.unset(`history.${name}`).write();
},
async getHistory(name) {
let history = db.get(`history.${name}`).value();
history = normHistory(history);
......
......@@ -18,10 +18,9 @@ const adapter = new LocalStorage('db');
/**
* @member {Function} DB~set
* @template {T}
* @param {Array.<string>|string} path
* @param {T} value
* @return {DB.<T>}
* @param value
* @return {DB}
*/
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论