First commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import Dexie, { type EntityTable } from "dexie";
|
||||
|
||||
export interface Settings {
|
||||
id: number;
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Server {
|
||||
id: number;
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export default class extends Dexie {
|
||||
server!: EntityTable<Server, "id">;
|
||||
settings!: EntityTable<Settings, "id">;
|
||||
|
||||
constructor() {
|
||||
super("lynq-chat");
|
||||
|
||||
this.version(1).stores({
|
||||
server: "++id,&name",
|
||||
settings: "++id,&name",
|
||||
});
|
||||
|
||||
/*(async () => {
|
||||
await this.open();
|
||||
|
||||
await this.transaction("rw", this.settings, async () => {
|
||||
const defaults = {
|
||||
"key": "value",
|
||||
};
|
||||
|
||||
for (const [name, value] of Object.entries(defaults)) {
|
||||
const exists = await this.settings
|
||||
.where("name")
|
||||
.equals(name)
|
||||
.first();
|
||||
|
||||
if (!exists) {
|
||||
await this.settings.add({ name, value });
|
||||
}
|
||||
}
|
||||
});
|
||||
})();*/
|
||||
};
|
||||
}
|
||||
|
||||
export async function getByIndex<T>(
|
||||
table: EntityTable<T, any>,
|
||||
index: string,
|
||||
indexValue: any
|
||||
): Promise<T | undefined> {
|
||||
return await table.where(index).equals(indexValue).first();
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
import { reactive } from "vue";
|
||||
|
||||
const routerStatus = reactive<{
|
||||
isLoad: boolean;
|
||||
}>({
|
||||
isLoad: false,
|
||||
});
|
||||
|
||||
export default routerStatus;
|
||||
Reference in New Issue
Block a user