Add config option to configure chat background

This commit is contained in:
天クマ 2026-07-17 16:06:29 -03:00
commit 36f8448bf9
5 changed files with 37 additions and 6 deletions

View file

@ -13,6 +13,10 @@ document.addEventListener('DOMContentLoaded', async () => {
elements.inputApiKey.value = config.apiKey;
elements.inputWahaUrl.value = config.wahaUrl;
elements.inputSession.value = config.session;
elements.inputBackgroundImage.value = config.bgImg;
elements.inputBackgroundOpacity.value = config.bgOpacity;
elements.activeChatContainer.style.setProperty('--background-image', `URL("${config.bgImg}")`);
elements.activeChatContainer.style.setProperty('--background-opacity', `${config.bgOpacity}`);
await updateOnlineStatus();
setupEventListeners();
try {
@ -369,7 +373,9 @@ function saveSettings() {
config.save(
elements.inputWahaUrl.value,
elements.inputSession.value,
elements.inputApiKey.value
elements.inputApiKey.value,
elements.inputBackgroundImage.value,
elements.inputBackgroundOpacity.value
);
location.reload();
loadChats();

View file

@ -4,14 +4,20 @@ export const config = {
wahaUrl: localStorage.getItem('waha_url') || 'http://inspiran.beetal-castor.ts.net:3100',
session: localStorage.getItem('waha_session') || 'session_01kxc62bk5fs8vh4v127k88a7j',
apiKey: localStorage.getItem('waha_api_key') || '',
bgImg: localStorage.getItem('background_image') || '',
bgOpacity: localStorage.getItem('background_opacity') || '0.4',
save(url, session, apiKey) {
save(url, session, apiKey, bgImg, bgOpacity) {
this.wahaUrl = url.trim().replace(/\/$/, "");
this.session = session.trim();
this.apiKey = apiKey.trim();
this.bgImg = bgImg.trim();
this.bgOpacity = bgOpacity.trim();
localStorage.setItem('waha_url', this.wahaUrl);
localStorage.setItem('waha_session', this.session);
localStorage.setItem('waha_api_key', this.apiKey);
localStorage.setItem('background_image', this.bgImg);
localStorage.setItem('background_opacity', this.bgOpacity);
}
};

View file

@ -24,6 +24,8 @@ export const elements = {
inputWahaUrl: document.getElementById('settings-waha-url'),
inputSession: document.getElementById('settings-session'),
inputApiKey: document.getElementById('settings-api-key'),
inputBackgroundImage: document.getElementById('settings-background-image'),
inputBackgroundOpacity: document.getElementById('settings-background-opacity'),
loggedUserName: document.getElementById('pandora-username'),
chatBottomBar: document.getElementById('chat-bottom-bar'),
chatBottomBarBtn: document.getElementById('chat-bottom-bar-btn'),