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

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

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