An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/18016
Danielfef72d896aee
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex de9536a339..e4999d0336 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -1,7 +1,7 @@import {Menu} from "../../../plugin/Menu";import {transaction} from "../../wysiwyg/transaction";import {fetchPost, fetchSyncPost} from "../../../util/fetch";-import {getDefaultOperatorByType, getEditableFilters} from "./filter";+import {getDefaultOperatorByType, getEditableFilters, hasFilterForColumn} from "./filter";import {genCellValue} from "./cell";import {getPropertiesHTML, openMenuPanel} from "./openMenuPanel";import {getLabelByNumberFormat} from "./number";@@ -855,33 +855,39 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemenclick() {fetchPost("/api/av/renderAttributeView", {id: avID,+ viewID,+ ignoreRows: true,}, (response) => {const avData = response.data as IAV;- // 始终新建一个占位条件(允许同列多条件,支持“主键包含111 OR 主键包含222”等组合)- const filter: IAVFilter = {- column: colId,- operator: getDefaultOperatorByType(type),- value: genCellValue(type, ""),- };- // 深拷贝旧值用于 undo,撤销时恢复完整筛选状态而非清空全部- const oldFilters = JSON.parse(JSON.stringify(avData.view.filters));- getEditableFilters(avData).push(filter);- transaction(protyle, [{- action: "setAttrViewFilters",- avID,- data: avData.view.filters,- blockID: blockElement.getAttribute("data-node-id")- }], [{- action: "setAttrViewFilters",- avID,- data: oldFilters,- blockID: blockElement.getAttribute("data-node-id")- }]);- // 打开筛选面板,用户在内联控件中编辑(替代原 setFilter 弹层)+ // 该字段还没有筛选条件时,创建它的默认筛选条件(其它字段的筛选不影响);+ // 已有该字段筛选时直接打开总筛选配置面板,避免每次重复新建+ if (!hasFilterForColumn(avData.view.filters, colId)) {+ const filter: IAVFilter = {+ column: colId,+ operator: getDefaultOperatorByType(type),+ value: genCellValue(type, ""),+ };+ // 深拷贝旧值用于 undo,撤销时恢复完整筛选状态而非清空全部+ const oldFilters = JSON.parse(JSON.stringify(avData.view.filters));+ getEditableFilters(avData).push(filter);+ transaction(protyle, [{+ action: "setAttrViewFilters",+ avID,+ data: avData.view.filters,+ blockID: blockElement.getAttribute("data-node-id")+ }], [{+ action: "setAttrViewFilters",+ avID,+ data: oldFilters,+ blockID: blockElement.getAttribute("data-node-id")+ }]);+ }+ // 打开总筛选配置面板,复用已含新筛选条件的 avData,避免 openMenuPanel 二次 fetch 与刚提交的事务竞争而读到旧数据openMenuPanel({protyle,blockElement,type: "filters",+ data: avData,});});}diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.tsindex 44dc0cb892..53c6a2fdcf 100644--- a/app/src/protyle/render/av/filter.ts+++ b/app/src/protyle/render/av/filter.ts@@ -491,7 +491,12 @@ const genInlineDateHTML = (filter: IAVFilter, valueType: TAVCol, path: string):const isBetween = filter.operator === "Is between";// formatAbsDate 把时间戳格式化为 yyyy-MM-dd;空值/非法值返回 "",避免 <input type="date"> 报 "Invalid Date"。+ // 0 也视作空值:created/updated 类型的 content 经后端 int64 往返后 null 会变成 0,+ // 否则 dayjs(0) 会渲染成 1970-01-01(与 date 类型 isNotEmpty:false 时的空白表现对齐)。const formatAbsDate = (timestamp: any): string => {+ if (!timestamp) {+ return "";+ }const dayObj = dayjs(timestamp);return dayObj.isValid() ? dayObj.format("YYYY-MM-DD") : "";};diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex ebf47887e9..fb2fe73e8c 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -85,6 +85,8 @@ export const openMenuPanel = (options: {colData: IAVColumn,},cellElements?: HTMLElement[], // for select & date & relation & asset+ // 复用调用方已构造好的视图数据,跳过内部 fetch,避免与刚提交的事务产生读写时序竞争+ data?: IAV,cb?: (avPanelElement: Element) => void}) => {let avPanelElement = document.querySelector(".av__panel");@@ -96,14 +98,17 @@ export const openMenuPanel = (options: {const avPageSize = getPageSize(options.blockElement);// config/properties/sorts/filters/switcher 菜单只需要字段/视图元数据,不需要行数据,跳过行渲染以提升大体量视图下的响应速度const ignoreRows = ["config", "properties", "sorts", "filters", "switcher"].includes(options.type);- fetchPost("/api/av/renderAttributeView", {+ const fetchPayload = {id: avID,query: options.blockElement.querySelector('[data-type="av-search"]')?.textContent.trim() || "",pageSize: avPageSize.unGroupPageSize,groupPaging: avPageSize.groupPageSize,viewID: options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),ignoreRows,- }, (response) => {+ };+ // 接收视图数据并构建面板 DOM、绑定事件。fetch 回调与 options.data 复用两条路径都走这里+ const renderData = (responseData: IAV) => {+ const response = {data: responseData} as IWebSocketData;avPanelElement = document.querySelector(".av__panel");if (avPanelElement) {avPanelElement.remove();@@ -1883,7 +1888,13 @@ export const openMenuPanel = (options: {target = target.parentElement;}});- });+ };+ // 复用调用方传入的数据时直接渲染,跳过 fetch,避免与刚提交的事务产生读写竞争(拿到旧数据)+ if (options.data) {+ renderData(options.data);+ } else {+ fetchPost("/api/av/renderAttributeView", fetchPayload, response => renderData(response.data as IAV));+ }};export const getPropertiesHTML = (fields: IAVColumn[]) => {