mirror of
https://github.com/JosunLP/BrowserExtensionTemplate.git
synced 2025-10-14 08:00:11 +00:00

feat: Refactor Session class to use LocalStorageService for session management feat: Enhance BasicButton component with configuration options and event handling style: Update SASS variables to CSS custom properties for better theming support style: Modify app.sass to include Bootstrap with legacy import chore: Update settings.ts to handle session initialization and error notifications fix: Improve buttonType definition for better readability chore: Refactor parse.ts for cleaner file handling and keyword replacement chore: Enhance syncConfig.ts with TypeScript interfaces and async file operations chore: Update v2.ts to modify manifest.json for compatibility with manifest version 2 chore: Revise tsconfig.json for stricter type checking and improved module resolution chore: Refactor vite.config.ts for better build configuration and asset management
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { Session } from './classes/session';
|
|
import './sass/app.sass';
|
|
|
|
class App {
|
|
private static readonly CONTENT_ENTRY = 'content';
|
|
private session: Session | null = null;
|
|
|
|
constructor() {
|
|
this.init();
|
|
}
|
|
|
|
private async init(): Promise<void> {
|
|
try {
|
|
this.session = await Session.getInstance();
|
|
await this.drawData();
|
|
await this.main();
|
|
} catch (error) {
|
|
console.error('Failed to initialize app:', error);
|
|
this.handleError('Failed to initialize application');
|
|
}
|
|
}
|
|
|
|
private async main(): Promise<void> {
|
|
console.log('Hello World');
|
|
}
|
|
|
|
private async drawData(): Promise<void> {
|
|
if (!this.session) {
|
|
throw new Error('Session not initialized');
|
|
}
|
|
|
|
const contentRoot = document.getElementById(App.CONTENT_ENTRY) as HTMLDivElement | null;
|
|
if (!contentRoot) {
|
|
throw new Error(`Element with id '${App.CONTENT_ENTRY}' not found`);
|
|
}
|
|
|
|
const body = document.createElement('div');
|
|
body.className = 'app-content';
|
|
|
|
const title = document.createElement('h1');
|
|
title.innerText = 'Hello World';
|
|
|
|
const text = document.createElement('p');
|
|
text.innerText = this.session.contentTest;
|
|
|
|
body.appendChild(title);
|
|
body.appendChild(text);
|
|
contentRoot.appendChild(body);
|
|
}
|
|
|
|
private handleError(message: string): void {
|
|
console.error(message);
|
|
const contentRoot = document.getElementById(App.CONTENT_ENTRY);
|
|
if (contentRoot) {
|
|
contentRoot.innerHTML = `<div class="error-message">${message}</div>`;
|
|
}
|
|
}
|
|
}
|
|
|
|
new App();
|