Skip to content

Commit

Permalink
0.0.16
Browse files Browse the repository at this point in the history
优化 #22 : 提供设置项开关∶ “文档底部默认展开反链面板 ”
  • Loading branch information
Misuzu2027 committed Nov 10, 2024
1 parent 4b69dc5 commit 8ddbaaf
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 38 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "syplugin-backlink-panel",
"author": "Misuzu2027",
"url": "https://github.com/Misuzu2027/syplugin-backlink-panel",
"version": "0.0.15",
"version": "0.0.16",
"minAppVersion": "3.1.4",
"backends": [
"all"
Expand Down
7 changes: 6 additions & 1 deletion src/components/dock/backlink-filter-panel-dock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
let rootId: string;
let focusBlockId: string;
let panelBacklinkViewExpand: boolean = true;
let mobileSidebarObserver: MutationObserver;
Expand Down Expand Up @@ -95,6 +96,10 @@
</div>
{:else}
<div class="fn__flex-column">
<BacklinkFilterPanelPageSvelte {rootId} {focusBlockId} />
<BacklinkFilterPanelPageSvelte
{rootId}
{focusBlockId}
{panelBacklinkViewExpand}
/>
</div>
{/if}
12 changes: 10 additions & 2 deletions src/components/panel/backlink-filter-panel-page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@
/* 控制页面元素的 */
let panelFilterViewExpand: boolean = false;
let panelBacklinkViewExpand: boolean = true;
export let panelBacklinkViewExpand: boolean = true;
let displayHintPanelBaseDataCacheUsage: boolean = false;
let displayHintBacklinkBlockCacheUsage: boolean = false;
let hideBacklinkProtyleBreadcrumb: boolean = false;
let showSaveCriteriaInputBox: boolean = false;
let saveCriteriaInputText: string = "";
$: updateLastCriteria(queryParams, panelFilterViewExpand);
$: updateLastCriteria(
queryParams,
panelFilterViewExpand,
// panelBacklinkViewExpand,
);
onMount(async () => {
doubleClickTimeout =
Expand All @@ -120,13 +124,15 @@
function updateLastCriteria(
queryParams: IPanelRednerFilterQueryParams,
backlinkPanelFilterViewExpand: boolean,
// backlinkPanelBacklinkViewExpand: boolean,
) {
if (!rootId || !queryParams) {
return;
}
let criteria: BacklinkPanelFilterCriteria = {
queryParams,
backlinkPanelFilterViewExpand,
// backlinkPanelBacklinkViewExpand,
};
BacklinkFilterPanelAttributeService.ins.updatePanelCriteria(
rootId,
Expand Down Expand Up @@ -389,6 +395,8 @@
queryParams = defaultPanelCriteria.queryParams;
panelFilterViewExpand =
defaultPanelCriteria.backlinkPanelFilterViewExpand;
// panelBacklinkViewExpand =
// defaultPanelCriteria.backlinkPanelBacklinkViewExpand;
queryParams.pageNum = 1;
savedQueryParamMap =
Expand Down
1 change: 1 addition & 0 deletions src/models/backlink-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,5 +337,6 @@ export class BacklinkPanelFilterCriteria {
// backlinkPanelBaseDataQueryParams: BacklinkPanelBaseDataQueryParams;
queryParams: IPanelRednerFilterQueryParams;
backlinkPanelFilterViewExpand: boolean;
// backlinkPanelBacklinkViewExpand: boolean;

}
23 changes: 12 additions & 11 deletions src/models/setting-constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export function getSettingTabArray(): TabProperty[] {
];

tabProperties.push(
new TabProperty({
key: "plugin-setting", name: "插件设置", iconKey: "iconPlugin", props: [
new ItemProperty({ key: "dockDisplay", type: "switch", name: "显示反链面板 Dock", description: "", tips: "" }),
new ItemProperty({ key: "documentBottomDisplay", type: "switch", name: "文档底部显示反链面板", description: "", tips: "" }),
new ItemProperty({ key: "cacheAfterResponseMs", type: "number", name: "启用缓存门槛(毫秒)", description: "当接口响应时间超过这个数,就会把这次查询结果存入缓存,-1 不开启缓存", tips: "", min: -1 }),
new ItemProperty({ key: "cacheExpirationTime", type: "number", name: "缓存过期时间(秒)", description: "", tips: "缓存数据失效时间", min: -1, }),
new ItemProperty({ key: "doubleClickTimeout", type: "number", name: "双击时间阈值(毫秒)", description: "", tips: "", min: 0, }),
new ItemProperty({ key: "documentBottomBacklinkPaddingWidth", type: "number", name: "文档底部反链面板左右间距", description: "为空则跟文档宽度一致。", tips: "" }),
]
}),
new TabProperty({
key: "filter-panel-setting", name: "筛选面板", iconKey: "iconFilter", props: [
new ItemProperty({ key: "filterPanelViewExpand", type: "switch", name: "默认展开筛选面板", description: "", tips: "" }),
Expand All @@ -25,7 +35,7 @@ export function getSettingTabArray(): TabProperty[] {
}),
new TabProperty({
key: "backlink-panel-setting", name: "反链面板", iconKey: "iconLink", props: [

new ItemProperty({ key: "docBottomBacklinkPanelViewExpand", type: "switch", name: "文档底部默认展开反链面板", description: "", tips: "" }),
new ItemProperty({ key: "pageSize", type: "number", name: "每页反链块数量", description: "每页反链块显示的数量", tips: "", min: 1, max: 50 }),
new ItemProperty({ key: "backlinkBlockSortMethod", type: "select", name: "反链块排序方式", description: "", tips: "", options: getBacklinkBlockSortMethodOptions() }),
new ItemProperty({ key: "defaultExpandedListItemLevel", type: "number", name: "默认展开列表项层数", description: "如果反链所在是列表项,默认展开的子列表深度。", tips: "", min: 0, max: 10 }),
Expand All @@ -34,16 +44,7 @@ export function getSettingTabArray(): TabProperty[] {
]

}),
new TabProperty({
key: "plugin-setting", name: "插件设置", iconKey: "iconPlugin", props: [
new ItemProperty({ key: "dockDisplay", type: "switch", name: "显示反链面板 Dock", description: "", tips: "" }),
new ItemProperty({ key: "documentBottomDisplay", type: "switch", name: "文档底部显示反链面板", description: "", tips: "" }),
new ItemProperty({ key: "cacheAfterResponseMs", type: "number", name: "启用缓存门槛(毫秒)", description: "当接口响应时间超过这个数,就会把这次查询结果存入缓存,-1 不开启缓存", tips: "", min: -1 }),
new ItemProperty({ key: "cacheExpirationTime", type: "number", name: "缓存过期时间(秒)", description: "", tips: "缓存数据失效时间", min: -1, }),
new ItemProperty({ key: "doubleClickTimeout", type: "number", name: "双击时间阈值(毫秒)", description: "", tips: "", min: 0, }),
new ItemProperty({ key: "documentBottomBacklinkPaddingWidth", type: "number", name: "文档底部反链面板左右间距", description: "为空则跟文档宽度一致。", tips: "" }),
]
}),

);

return tabProperties;
Expand Down
27 changes: 15 additions & 12 deletions src/models/setting-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import { isStrNotBlank } from "@/utils/string-util";


export class SettingConfig {
// 插件设置
dockDisplay: Boolean;
documentBottomDisplay: boolean;
topBarDisplay: boolean;
// 缓存
cacheAfterResponseMs: number;
cacheExpirationTime: number;
usePraentIdIdx: boolean;
// 双击阈值
doubleClickTimeout: number;
// 文档底部反链面板宽度
documentBottomBacklinkPaddingWidth: number


// 筛选面板
filterPanelViewExpand: boolean;
queryParentDefBlock: boolean;
Expand All @@ -13,26 +27,15 @@ export class SettingConfig {


// 反链面板
docBottomBacklinkPanelViewExpand: boolean;
pageSize: number;
backlinkBlockSortMethod: BlockSortMethod;
hideBacklinkProtyleBreadcrumb: boolean;
defaultExpandedListItemLevel: number;
// queryAllContentUnderHeadline: boolean;


// 插件设置
dockDisplay: Boolean;
documentBottomDisplay: boolean;
topBarDisplay: boolean;
// 缓存
cacheAfterResponseMs: number;
cacheExpirationTime: number;
usePraentIdIdx: boolean;
// 双击阈值
doubleClickTimeout: number;

// 文档底部反链面板宽度
documentBottomBacklinkPaddingWidth: number
}


Expand Down
3 changes: 3 additions & 0 deletions src/service/plugin/DocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,14 @@ async function addBacklinkPanelToBottom(docuemntContentElement: HTMLElement, roo
let hrElement = document.createElement("hr");
backlinkPanelBottomElement.appendChild(hrElement);

let docBottomBacklinkPanelViewExpand = SettingService.ins.SettingConfig.docBottomBacklinkPanelViewExpand

let pageSvelte = new BacklinkFilterPanelPageSvelte({
target: backlinkPanelBottomElement,
props: {
rootId: rootId,
focusBlockId: null,
panelBacklinkViewExpand: docBottomBacklinkPanelViewExpand,
}
});
backlinkPanelBottomElement.parentElement.addEventListener(
Expand Down
2 changes: 2 additions & 0 deletions src/service/plugin/TabService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class TabService {
}
let backlinkFilterPanelPageSvelte: BacklinkFilterPanelPageSvelte;


let tabId = BACKLINK_TAB_PREFIX + docId;

EnvConfig.ins.plugin.addTab({
Expand All @@ -56,6 +57,7 @@ export class TabService {
props: {
rootId: docId,
focusBlockId: focusBlockId,
panelBacklinkViewExpand: true,
}
});

Expand Down
1 change: 1 addition & 0 deletions src/service/setting/BacklinkPanelFilterCriteriaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class BacklinkFilterPanelAttributeService {
queryParams = defaultQueryParams;
documentPanelCriteria = new BacklinkPanelFilterCriteria();
documentPanelCriteria.backlinkPanelFilterViewExpand = SettingService.ins.SettingConfig.filterPanelViewExpand;
// documentPanelCriteria.backlinkPanelBacklinkViewExpand = SettingService.ins.SettingConfig.backlinkPanelViewExpand;;
}
CacheManager.ins.setBacklinkFilterPanelLastCriteria(rootId, documentPanelCriteria);
}
Expand Down
28 changes: 17 additions & 11 deletions src/service/setting/SettingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,36 @@ function setKeyValue(settingConfig, key: any, value: any) {

function getDefaultSettingConfig() {
let defaultConfig = new SettingConfig();

defaultConfig.dockDisplay = true;
defaultConfig.documentBottomDisplay = true;
defaultConfig.topBarDisplay = true;

defaultConfig.cacheAfterResponseMs = -1;
defaultConfig.cacheExpirationTime = 5 * 60;
defaultConfig.usePraentIdIdx = false;
defaultConfig.doubleClickTimeout = 0;

defaultConfig.documentBottomBacklinkPaddingWidth = null;


// 筛选面板
defaultConfig.filterPanelViewExpand = false;
defaultConfig.queryParentDefBlock = true;
defaultConfig.querrChildDefBlockForListItem = true;
defaultConfig.queryChildDefBlockForHeadline = false;
defaultConfig.filterPanelCurDocDefBlockSortMethod = "typeAndContent";
defaultConfig.filterPanelRelatedDefBlockSortMethod = "modifiedDesc";
defaultConfig.filterPanelBacklinkDocumentSortMethod = "createdDesc";


// 反链面板
defaultConfig.docBottomBacklinkPanelViewExpand = true;
defaultConfig.pageSize = 8;
defaultConfig.backlinkBlockSortMethod = "modifiedDesc";
defaultConfig.hideBacklinkProtyleBreadcrumb = false;
defaultConfig.defaultExpandedListItemLevel = 0;
// defaultConfig.queryAllContentUnderHeadline = false;

defaultConfig.dockDisplay = true;
defaultConfig.documentBottomDisplay = true;
defaultConfig.topBarDisplay = true;

defaultConfig.cacheAfterResponseMs = -1;
defaultConfig.cacheExpirationTime = 5 * 60;
defaultConfig.usePraentIdIdx = false;
defaultConfig.doubleClickTimeout = 0;

defaultConfig.documentBottomBacklinkPaddingWidth = null;


return defaultConfig;
Expand Down

0 comments on commit 8ddbaaf

Please sign in to comment.