Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/9371

Vanessac16091332f6f
diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js
index e377d2d7d5..96b19ac8da 100644
--- a/app/appearance/icons/ant/icon.js
+++ b/app/appearance/icons/ant/icon.js
@@ -1,5 +1,9 @@
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>
+ <symbol id="iconClock" viewBox="0 0 32 32">
+ <path d="M16 1c-8.283 0-15 6.717-15 15s6.717 15 15 15 15-6.717 15-15-6.717-15-15-15zM16 28.455c-6.877 0-12.455-5.578-12.455-12.455s5.578-12.455 12.455-12.455 12.455 5.578 12.455 12.455-5.578 12.455-12.455 12.455z"></path>
+ <path d="M21.849 20.239l-4.775-3.452v-8.287c0-0.147-0.12-0.268-0.268-0.268h-1.61c-0.147 0-0.268 0.12-0.268 0.268v9.221c0 0.087 0.040 0.167 0.11 0.218l5.538 4.038c0.12 0.087 0.288 0.060 0.375-0.057l0.958-1.306c0.087-0.124 0.060-0.291-0.060-0.375z"></path>
+ </symbol>
<symbol id="iconAttr" viewBox="0 0 32 32">
<path d="M4.75 31q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM19.75 31q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM12.25 23.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM27.25 23.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM4.75 16q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM19.75 16q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM12.25 8.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM27.25 8.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102z"></path>
</symbol>
diff --git a/app/appearance/icons/ant/icon.json b/app/appearance/icons/ant/icon.json
index 88aff836f6..330897d63c 100644
--- a/app/appearance/icons/ant/icon.json
+++ b/app/appearance/icons/ant/icon.json
@@ -2,5 +2,5 @@
"name": "ant",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
- "version": "1.23.1"
+ "version": "1.24.0"
}
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index 80222a6686..4471095326 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -28,6 +28,12 @@
<body>
<h2>SiYuan</h2>
<div class="fn__clear">
+ <div>
+ <svg>
+ <use xlink:href="#iconClock"></use>
+ </svg>
+ iconClock
+ </div>
<div>
<svg>
<use xlink:href="#iconAttr"></use>
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js
index 752c15c21b..4bb6b75d8a 100644
--- a/app/appearance/icons/material/icon.js
+++ b/app/appearance/icons/material/icon.js
@@ -1,5 +1,8 @@
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>
+ <symbol id="iconClock" viewBox="0 0 32 32">
+ <path d="M20.95 23.050l2.1-2.1-5.55-5.55v-6.9h-3v8.1l6.45 6.45zM16 31q-3.113 0-5.85-1.181t-4.763-3.206-3.206-4.762-1.181-5.85 1.181-5.85 3.206-4.763 4.763-3.206 5.85-1.181 5.85 1.181 4.762 3.206 3.206 4.763 1.181 5.85-1.181 5.85-3.206 4.762-4.762 3.206-5.85 1.181zM16 28q4.988 0 8.494-3.506t3.506-8.494-3.506-8.494-8.494-3.506-8.494 3.506-3.506 8.494 3.506 8.494 8.494 3.506z"></path>
+ </symbol>
<symbol id="iconAttr" viewBox="0 0 32 32">
<path d="M4.75 31q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM19.75 31q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM12.25 23.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM27.25 23.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM4.75 16q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM19.75 16q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM12.25 8.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102zM27.25 8.5q-1.547 0-2.648-1.102t-1.102-2.648 1.102-2.648 2.648-1.102 2.648 1.102 1.102 2.648-1.102 2.648-2.648 1.102z"></path>
</symbol>
diff --git a/app/appearance/icons/material/icon.json b/app/appearance/icons/material/icon.json
index 3d8ce70884..2aac528675 100644
--- a/app/appearance/icons/material/icon.json
+++ b/app/appearance/icons/material/icon.json
@@ -2,5 +2,5 @@
"name": "material",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
- "version": "1.23.1"
+ "version": "1.24.0"
}
diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts
index 3202914dd0..43c2ed0836 100644
--- a/app/src/protyle/render/av/addCol.ts
+++ b/app/src/protyle/render/av/addCol.ts
@@ -255,5 +255,55 @@ export const addCol = (protyle: IProtyle, blockElement: Element) => {
});
}
});
+ menu.addItem({
+ icon: "iconClock",
+ label: window.siyuan.languages.creationDate,
+ click() {
+ const id = Lute.NewNodeID();
+ transaction(protyle, [{
+ action: "addAttrViewCol",
+ name: window.siyuan.languages.creationDate,
+ avID,
+ type: "created",
+ id
+ }], [{
+ action: "removeAttrViewCol",
+ id,
+ avID,
+ }]);
+ addAttrViewColAnimation({
+ blockElement: blockElement,
+ protyle: protyle,
+ type: "created",
+ name: window.siyuan.languages.creationDate,
+ id
+ });
+ }
+ });
+ menu.addItem({
+ icon: "iconClock",
+ label: window.siyuan.languages.modificationDate,
+ click() {
+ const id = Lute.NewNodeID();
+ transaction(protyle, [{
+ action: "addAttrViewCol",
+ name: window.siyuan.languages.modificationDate,
+ avID,
+ type: "updated",
+ id
+ }], [{
+ action: "removeAttrViewCol",
+ id,
+ avID,
+ }]);
+ addAttrViewColAnimation({
+ blockElement: blockElement,
+ protyle: protyle,
+ type: "updated",
+ name: window.siyuan.languages.modificationDate,
+ id
+ });
+ }
+ });
return menu;
};
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 03b163e314..5d0f6afda5 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -12,8 +12,8 @@ export const getCalcValue = (column: IAVColumn) => {
}
let resultCalc: any = column.calc.result.number;
if (column.calc.operator === "Earliest" || column.calc.operator === "Latest" ||
- (column.calc.operator === "Range" && column.type === "date")) {
- resultCalc = column.calc.result.date;
+ (column.calc.operator === "Range" && ["date", "created", "updated"].includes(column.type))) {
+ resultCalc = column.calc.result[column.type as "date"];
}
let value = "";
switch (column.calc.operator) {
@@ -101,10 +101,10 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
color: ""
}]
};
- } else if (colType === "date" && value === "") {
+ } else if (["date", "created", "updated"].includes(colType) && value === "") {
cellValue = {
type: colType,
- date: {
+ [colType]: {
content: null,
isNotEmpty: false,
content2: null,
@@ -119,10 +119,10 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
type: colType,
mSelect: value as IAVCellSelectValue[]
};
- } else if (colType === "date") {
+ } else if (["date", "created", "updated"].includes(colType)) {
cellValue = {
type: colType,
- date: value as IAVCellDateValue
+ [colType]: value as IAVCellDateValue
};
} else if (colType === "mAsset") {
cellValue = {
@@ -309,7 +309,7 @@ export const openCalcMenu = (protyle: IProtyle, calcElement: HTMLElement) => {
operator: "Range",
label: window.siyuan.languages.calcOperatorRange
});
- } else if (type === "date") {
+ } else if (["date", "created", "updated"].includes(type)) {
calcItem({
menu,
protyle,
@@ -346,7 +346,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
if (!type) {
type = cellElements[0].parentElement.parentElement.firstElementChild.querySelector(`[data-col-id="${cellElements[0].getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol;
}
- if (type === "template") {
+ if (type === "template" || type === "updated" || type === "created") {
return;
}
if (type === "block" && (cellElements.length > 1 || !cellElements[0].getAttribute("data-detached"))) {
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index ea0367d222..d63ed6eab2 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -290,6 +290,9 @@ export const getColIconByType = (type: TAVCol) => {
return "iconList";
case "date":
return "iconCalendar";
+ case "updated":
+ case "created":
+ return "iconClock";
case "url":
return "iconLink";
case "mAsset":
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index b7076d11ae..657fab8ae3 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -96,11 +96,19 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
}
} else if (cell.valueType === "date") {
text = '<span class="av__celltext av__celltext--date">';
- if (cell.value?.date.isNotEmpty) {
- text += dayjs(cell.value.date.content).format("YYYY-MM-DD HH:mm");
+ const dataValue = cell.value ? cell.value.date : null;
+ if (dataValue && dataValue.isNotEmpty) {
+ text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm");
}
- if (cell.value?.date.hasEndDate && cell.value?.date.isNotEmpty && cell.value?.date.isNotEmpty2) {
- text += `<svg><use xlink:href="#iconForward"></use></svg>${dayjs(cell.value.date.content2).format("YYYY-MM-DD HH:mm")}`;
+ if (dataValue && dataValue.hasEndDate && dataValue.isNotEmpty && dataValue.isNotEmpty2) {
+ text += `<svg><use xlink:href="#iconForward"></use></svg>${dayjs(dataValue.content2).format("YYYY-MM-DD HH:mm")}`;
+ }
+ text += "</span>";
+ } else if (["created", "updated"].includes(cell.valueType)) {
+ text = '<span class="av__celltext av__celltext--date">';
+ const dataValue = cell.value ? cell.value[cell.valueType as "date"] : null;
+ if (dataValue && dataValue.content) {
+ text += dayjs(dataValue.content).format("YYYY-MM-DD HH:mm");
}
text += "</span>";
} else if (cell.valueType === "mAsset") {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 02c98f5292..54b09d781d 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -65,6 +65,8 @@ type TAVCol =
| "phone"
| "mAsset"
| "template"
+ | "created"
+ | "updated"
type THintSource = "search" | "av" | "hint";
type TAVFilterOperator =
"="
@@ -1078,6 +1080,8 @@ interface IAVCellValue {
content: string
}
date?: IAVCellDateValue
+ created?: IAVCellDateValue
+ updated?: IAVCellDateValue
}
interface IAVCellDateValue {