-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(DockView): add DockViewRenderMode.Partial parameter #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
76233bf
714d065
bba9ec2
b574b1a
0be570d
883d3ae
1508c5f
bf1ed6f
0574a5b
3293550
b21f909
3b11cb0
0c381bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,31 @@ | ||
| // Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
| // Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
| // Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| /// <summary> | ||
| /// DockViewRenderMode 渲染模式枚举类型 | ||
| /// <para lang="zh">DockViewRenderMode 渲染模式枚举类型</para> | ||
| /// <para lang="en">DockViewRenderMode render mode enumeration type</para> | ||
| /// </summary> | ||
| [JsonEnumConverter(true)] | ||
| public enum DockViewRenderMode | ||
| { | ||
| /// <summary> | ||
| /// 可见时渲染 | ||
| /// <para lang="zh">可见时渲染</para> | ||
| /// <para lang="en">Render when visible</para> | ||
| /// </summary> | ||
| OnlyWhenVisible, | ||
|
|
||
| /// <summary> | ||
| /// 始终渲染 | ||
| /// <para lang="zh">始终渲染</para> | ||
| /// <para lang="en">Always render</para> | ||
| /// </summary> | ||
| Always | ||
| Always, | ||
|
|
||
| /// <summary> | ||
| /// <para lang="zh">部分渲染 可见版面渲染 不可见版面异步渲染</para> | ||
| /// <para lang="en"></para> | ||
| /// </summary> | ||
| Partial | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||
| // Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||||||||||||||||||||||
| // Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||||||||||||||||||||||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||||||||||||||||||||||
| // Website: https://www.blazor.zone or https://argozhang.github.io/ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -201,7 +201,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender) | |||||||||||||||||||||
| PanelVisibleChangedCallback = nameof(PanelVisibleChangedCallbackAsync), | ||||||||||||||||||||||
| LockChangedCallback = nameof(LockChangedCallbackAsync), | ||||||||||||||||||||||
| SplitterCallback = nameof(SplitterCallbackAsync), | ||||||||||||||||||||||
| Contents = _components | ||||||||||||||||||||||
| Contents = _components, | ||||||||||||||||||||||
| LoadTabs = nameof(LoadTabs) | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private string GetVersion() => Version ?? _options.Version ?? "v1"; | ||||||||||||||||||||||
|
|
@@ -258,6 +259,41 @@ public async Task PanelVisibleChangedCallbackAsync(string title, bool status) | |||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private HashSet<string> _loadTabs = new(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||
| /// <param name="tabs"></param> | ||||||||||||||||||||||
|
||||||||||||||||||||||
| /// | |
| /// </summary> | |
| /// <param name="tabs"></param> | |
| /// 标签页加载回调方法,由 JavaScript 在激活标签变化或需重新渲染时调用,用于更新当前需要渲染的标签集合。 | |
| /// Tab loading callback invoked from JavaScript when the set of active/visible tabs changes, updating which tabs should be rendered. | |
| /// </summary> | |
| /// <param name="tabs"> | |
| /// 需要在服务器端渲染的标签标识列表,由客户端脚本传入。每一项为一个标签的唯一标识。 | |
| /// List of tab identifiers that should currently be rendered on the server, provided by client-side script. Each item represents a single tab id. | |
| /// </param> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,7 +278,7 @@ const getGroupNode = (contentItem, size, boxSize, parent, panels, getGroupId, op | |
| title: item.title, | ||
| tabComponent: item.componentName, | ||
| contentComponent: item.componentName, | ||
| renderer: item.renderer || options.renderer, | ||
| // renderer: item.renderer || options.renderer, | ||
| params: { ...item, parentId: parent.id } | ||
| } | ||
|
Comment on lines
278
to
283
|
||
| return item.id | ||
|
|
@@ -303,7 +303,7 @@ const getLeafNode = (contentItem, size, boxSize, parent, panels, getGroupId, opt | |
| panels[contentItem.id] = { | ||
| id: contentItem.id, | ||
| title: contentItem.title, | ||
| renderer: contentItem.renderer || options.renderer, | ||
| // renderer: contentItem.renderer || options.renderer, | ||
| tabComponent: contentItem.componentName, | ||
| contentComponent: contentItem.componentName, | ||
| params: { ...contentItem, parentId: parent.id } | ||
|
Comment on lines
303
to
309
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| import { saveConfig } from "./dockview-config.js"; | ||||||
| import { saveConfig } from "./dockview-config.js"; | ||||||
| import { getIcon } from "./dockview-icon.js" | ||||||
| import { setDrawerTitle } from "./dockview-group.js" | ||||||
|
|
||||||
|
|
@@ -23,6 +23,13 @@ const observePanelActiveChange = panel => { | |||||
| moveAlwaysRenderPanel(panel) | ||||||
| }, 0) | ||||||
| }) | ||||||
| panel.api.onDidVisibilityChange(({ isVisible }) => { | ||||||
| const dockview = panel.accessor; | ||||||
| if (dockview.params.options.renderer === 'onlyWhenVisible' && dockview._inited && isVisible) { | ||||||
| const visiblePanels = dockview.groups.map(g => g.panels.find(p => p.params.isActive) || g.panels.find(p => p.api.isVisible)) | ||||||
| dockview._loadTabs?.fire(visiblePanels.filter(p => Boolean(p)).map(p => p.params.key)); | ||||||
| } | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| const moveAlwaysRenderPanel = panel => { | ||||||
|
|
@@ -136,7 +143,7 @@ const getPanels = (contentItem, options, parent = {}, panels = []) => { | |||||
| id: contentItem.id, | ||||||
| groupId: contentItem.groupId, | ||||||
| title: contentItem.title, | ||||||
| renderer: contentItem.renderer || options.renderer, | ||||||
| // renderer: contentItem.renderer || options.renderer, | ||||||
|
||||||
| // renderer: contentItem.renderer || options.renderer, | |
| renderer: contentItem.renderer || options.renderer, |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||
| import { DockviewComponent } from "./dockview-core.esm.js" | ||||||||||
| import { DockviewComponent } from "./dockview-core.esm.js" | ||||||||||
| import { DockviewPanelContent } from "./dockview-content.js" | ||||||||||
| import { onAddGroup, addGroupWithPanel, toggleLock, observeFloatingGroupLocationChange, observeOverlayChange, createDrawerHandle } from "./dockview-group.js" | ||||||||||
| import { onAddPanel, onRemovePanel, getPanelsFromOptions, findContentFromPanels } from "./dockview-panel.js" | ||||||||||
|
|
@@ -8,6 +8,7 @@ import './dockview-extensions.js' | |||||||||
| const cerateDockview = (el, options) => { | ||||||||||
| const theme = options.theme || "dockview-theme-light"; | ||||||||||
| const template = el.querySelector('template'); | ||||||||||
| options.renderer ??= 'onlyWhenVisible'; // onlyWhenVisible | partial | always | ||||||||||
| const dockview = new DockviewComponent(el, { | ||||||||||
| parentElement: el, | ||||||||||
| theme: { | ||||||||||
|
|
@@ -86,10 +87,22 @@ const initDockview = (dockview, options, template) => { | |||||||||
| dockview.onDidLayoutFromJSON(() => { | ||||||||||
| const handler = setTimeout(() => { | ||||||||||
| clearTimeout(handler); | ||||||||||
|
|
||||||||||
| const panels = dockview.panels | ||||||||||
| const delPanelsStr = localStorage.getItem(dockview.params.options.localStorageKey + '-panels') | ||||||||||
| const delPanels = delPanelsStr && JSON.parse(delPanelsStr) || [] | ||||||||||
| const panels = dockview.panels; | ||||||||||
| const groups = dockview.groups; | ||||||||||
| const delPanelsStr = localStorage.getItem(dockview.params.options.localStorageKey + '-panels'); | ||||||||||
| const delPanels = delPanelsStr && JSON.parse(delPanelsStr) || []; | ||||||||||
| if (options.renderer === 'always') { | ||||||||||
|
|
||||||||||
|
||||||||||
| if (dockview.panels.length > 0) { | |
| dockview._loadTabs?.fire(dockview.panels.map(p => p.params.key)); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DockViewRenderMode.Partialhas an empty English<para lang="en">doc. Please fill it in to match the bilingual XML doc convention used for the rest of the enum values.