From f8d2c26c641571e6cf05d07ea27cbdfff00a811e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E8=AF=97=E9=9B=85?= Date: Wed, 5 Dec 2018 11:35:39 +0800 Subject: [PATCH] =?UTF-8?q?!207=20=E5=91=BD=E4=BB=A4=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=EF=BC=9A=E5=91=BC=E5=87=BA=E6=97=B6=E6=BB=9A=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E6=AC=A1=E9=80=89=E6=8B=A9=EF=BC=8C=E5=A4=B1?= =?UTF-8?q?=E5=8E=BB=E7=84=A6=E7=82=B9=E5=90=8E=E6=B6=88=E5=A4=B1=20Merge?= =?UTF-8?q?=20pull=20request=20!207=20from=20=E8=82=96=E8=AF=97=E9=9B=85/c?= =?UTF-8?q?mdPanel=5Frestore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DatabaseServices/CommandServer.ts | 15 ++++++++++ .../Components/CommandPanel/commandPanel.tsx | 28 +++++++++++++++++-- src/UI/Components/Modal/MaskManage.tsx | 3 ++ .../Modal/ModalStyle/CommandModal.less | 4 +++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/DatabaseServices/CommandServer.ts b/src/DatabaseServices/CommandServer.ts index efbbd370a..fc101cfdf 100644 --- a/src/DatabaseServices/CommandServer.ts +++ b/src/DatabaseServices/CommandServer.ts @@ -32,4 +32,19 @@ export class CommandServer let store = await IndexedDbStore.CADStore(); return await store.Get(StoreName.Command, c) as ICommand; } + + //保存滚动条高度 + m_LastScrollTop: number; + async SetLastScrollTop(scrollTop: number) + { + this.m_LastScrollTop = scrollTop; + let store = await IndexedDbStore.CADStore(); + store.Put(StoreName.FileId, "scrollTop", scrollTop); + } + async GetLastScrollTop() + { + let store = await IndexedDbStore.CADStore(); + this.m_LastScrollTop = await store.Get(StoreName.FileId, "scrollTop"); + return this.m_LastScrollTop; + } } diff --git a/src/UI/Components/CommandPanel/commandPanel.tsx b/src/UI/Components/CommandPanel/commandPanel.tsx index a2e00c697..28e66fea2 100644 --- a/src/UI/Components/CommandPanel/commandPanel.tsx +++ b/src/UI/Components/CommandPanel/commandPanel.tsx @@ -6,6 +6,8 @@ import { ICommand, CommandList } from './CommandList'; import { CommandItem } from './CommandItem'; import { Singleton } from '../../../Common/Singleton'; import { CommandServer } from '../../../DatabaseServices/CommandServer'; +import { app } from '../../../ApplicationServices/Application'; +import { end } from 'xaop'; interface CommandPanelState { @@ -35,10 +37,28 @@ export class CommandPanel extends React.Component<{}, CommandPanelState> ] }; } + //获取最后一次滚动条位置 + GetLastScrollTop() + { + let cserver = Singleton.GetInstance(CommandServer); + if (cserver.m_LastScrollTop) + this.scrollCard.scrollTop = cserver.m_LastScrollTop; + } + componentDidUpdate() + { + this.GetLastScrollTop(); + } componentDidMount() { this.initCommandData(); this.inputEl.focus(); + this.GetLastScrollTop(); + app.m_Editor.m_MaskManage.events.push( + end(app.m_Editor.m_MaskManage, app.m_Editor.m_MaskManage.OnFocusEvent, () => + { + app.m_Editor.m_ModalManage.Clear(); + }) + ) } async initCommandData() { @@ -54,11 +74,13 @@ export class CommandPanel extends React.Component<{}, CommandPanelState> this.searchList.push(c); } } - handleTabsClick = () => + handleTabsClick = async () => { + let cserver = Singleton.GetInstance(CommandServer); let elc = this.ulRef.querySelector(`#${this.id}`) as HTMLElement; if (elc) this.scrollCard.scrollTop = elc.offsetTop - elc.offsetHeight * 2 - 55; + await cserver.SetLastScrollTop(this.scrollCard.scrollTop); } render() { @@ -138,10 +160,12 @@ export class CommandPanel extends React.Component<{}, CommandPanelState>
this.scrollCard = el} className="bp3-card bp3-elevation-0" - onScroll={() => + onScroll={async () => { + let cserver = Singleton.GetInstance(CommandServer); let index = Math.floor(this.scrollCard.scrollTop / 60); this.id = this.searchRes[index].typeId; + await cserver.SetLastScrollTop(this.scrollCard.scrollTop); }} >