Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
2234839 committed May 16, 2024
1 parent 6f27aac commit 96d8ee3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"vite": "^4.5.3",
"vite-plugin-static-copy": "^0.15.0",
"vite-plugin-zip-pack": "^1.2.3"
},
"dependencies": {
"@llej/js_util":"github:2234839/ts-util"
}
}
50 changes: 36 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
import { Plugin } from "siyuan";
import { sql } from "./api";
import { hash_time33 } from "@llej/js_util/src/hash";

export default class OceanPress extends Plugin {
private btn_selector = "oceanpress_widget_button";
private timeID: ReturnType<typeof setInterval> | null = null;
type attribute = {
block_id: "id";
box: "id";
id: "id";
name: "bookmark";
path: "/id/id.sy";
root_id: "id";
type: "b";
value: "expr";
};

async onLayoutReady() {
console.log("启动");

}
async onunload() {
}

async addButton() {
export default class expr extends Plugin {
async onload() {
/** 查询所有 bookmark = 'expr' or name = "custom-expr" 的属性 */
const attr: attribute[] = await sql(`
SELECT * FROM attributes
WHERE
name = "custom-expr"
OR
(name = "bookmark" AND VALUE ="expr")`);
console.log("启动", hash_time33("dfadfa"), attr, filterNotInitBlock(attr));
}
previewCurrentPage() {}
async onunload() {}
}
function sleep(time: number) {
return new Promise((s) => setTimeout(s, time));
function filterNotInitBlock(attrs: attribute[]) {
const idCount: { [block_id: string]: { count: number; attrs: attribute[] } } = {};
attrs.forEach(async (attr: attribute) => {
if (idCount[attr.block_id] === undefined) {
idCount[attr.block_id] = { count: 0, attrs: [] };
}
idCount[attr.block_id].count += 1;
idCount[attr.block_id].attrs.push(attr);
});
return Object.keys(idCount)
.filter((block_id: string) => idCount[block_id].count === 1)
.map((block_id: string) => idCount[block_id].attrs[0]);
}
async function exprBlockInit(block: any) {}

0 comments on commit 96d8ee3

Please sign in to comment.