antares/src/renderer/stores/scratchpad.ts

27 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-05-28 18:43:56 +02:00
import * as Store from 'electron-store';
import { defineStore } from 'pinia';
const persistentStore = new Store({ name: 'notes' });
export interface ConnectionNote {
uid: string;
2023-12-06 08:44:07 +01:00
cUid: string;
title?: string;
note: string;
date: Date;
}
2022-04-30 00:47:37 +02:00
export const useScratchpadStore = defineStore('scratchpad', {
state: () => ({
/** Global notes */
notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/antares-sql/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n') as string,
/** Connection specific notes */
2023-12-06 08:44:07 +01:00
connectionNotes: persistentStore.get('connectionNotes', {}) as ConnectionNote[]
2022-04-30 00:47:37 +02:00
}),
actions: {
2023-12-06 08:44:07 +01:00
changeNotes (notes: ConnectionNote[]) {
this.connectionNotes = notes;
persistentStore.set('connectionNotes', this.connectionNotes);
}
}
2022-04-30 00:47:37 +02:00
});