Skip to content

Commit f7b04b9

Browse files
committed
fix: solved multiple session storage conflicts
1 parent eae7847 commit f7b04b9

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ A front-end code playground tool right in your browser. It's intended for use wh
1111

1212
## Features
1313

14-
- Easy to use
1514
- Minimal and fast
1615
- Live updates and preview
17-
- Builtin IDE with syntax highlighting, suggestions, and more
16+
- Fullscreen mode
17+
- Theme: Light/Dark/System
18+
- Export as single HTML page or ZIP file
19+
- Multiple Layouts - editor only, preview only or split (vertical/horizontal)
20+
- Builtin IDE with syntax highlighting, suggestions/autocomplete, and more
1821
- Local storage for backup (CTRL + S to save and automatic restore)
1922

2023
## Demo

source/components/BaseHeader.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const store = useAppStore();
3232
3333
const switchTheme = (v) => (store.theme = v);
3434
const switchView = (v) => (store.layout = v);
35-
const newTab = () => window.open(window.location.href);
35+
const newTab = () =>
36+
window.open(window.location.href + `?session=${Date.now().toString(32)}`);
3637
const closeTab = () => window.close();
3738
const reloadTab = () => window.location.reload();
3839
const downloadAsPage = () => exportAsPage(store.code);

source/helpers/storage.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export const template = {
2525
'let count = 0;\n\nconst btn = document.querySelector("button");\n\nbtn.onclick = () => {\n btn.textContent = `Count: ${++count}`;\n};\n\nbtn.click();\n'
2626
};
2727

28-
const STORAGE_KEY = "livecode-backup";
28+
// storage key for a new session in a different window or tab
29+
const sessionKey = new URLSearchParams(window.location.search).get("session");
30+
31+
const STORAGE_KEY = sessionKey
32+
? `livecode-window-${sessionKey}`
33+
: "livecode-backup";
2934

3035
export function restore() {
3136
const data = getData(STORAGE_KEY);

0 commit comments

Comments
 (0)