项目备份

This commit is contained in:
林觅
2026-04-09 10:37:51 +08:00
parent 7ed8d2dcb4
commit 4eab443148
32 changed files with 9468 additions and 0 deletions

49
static/dexieParse.js Normal file
View File

@@ -0,0 +1,49 @@
// dexie文档https://dexie.org/docs/API-Reference https://www.npmrc.cn/en/Dexie-js.html
class dexieDemo {
dbName = "jafar";
dbVersion = 1;
constructor(dbName, dbVersion) {
if (dbName) {
this.dbName = dbName;
}
if (dbVersion) {
this.dbVersion = dbVersion;
}
this.db = new Dexie(this.dbName);
this.db.version(this.dbVersion).stores(
{ tabName: "++id,nKey,nValue,nTime" }, // 创建表已有表则建立链接id为自增主键仅需要列举需要索引的字段即可
);
}
async get() {
const getLastData = await this.db.tabName.orderBy("id").last();
return getLastData;
}
async post(nKey, nValue) {
await this.db.tabName.add({
nKey: nKey,
nValue: nValue,
nTime: Date.now(),
});
const getLastData = await this.db.tabName.orderBy("id").last();
}
async put(id) {
await this.db.tabName.put({
id: 1,
userName: "zhangsan",
});
}
async del(id) {
await this.db.tabName.delete(id);
}
}
export const myDexie = new dexieDemo();
// document.querySelector("#goto_indexedDB_post").addEventListener("click",async () => {
// let nKey = Math.random()
// let nValue = new Date().getTime();
// await myDexieDemo.post( nKey,nValue );
// })
// document.querySelector("#goto_indexedDB_get").addEventListener("click",async () => {
// console.log( await myDexieDemo.get() )
// })