systeme de themes qui fonctionnouille
All checks were successful
Deploy XIP / deploy (push) Successful in 34s

This commit is contained in:
raphael.thieffry
2026-05-31 18:41:39 +02:00
parent 942fcaa4d1
commit c0b82222bd
8 changed files with 334 additions and 82 deletions

View File

@@ -65,57 +65,17 @@
</template>
<script setup lang="ts">
import type { Message, Reply, GeoInfo } from '@/composables/useMessages';
import { getIpColorWithPerks, getIpGlowWithPerks, getIpColor, getIpGlow } from '@/composables/ipColor';
import { usePerks } from '@/composables/usePerks';
import type { Message } from '@/composables/useMessages';
import { openContextMenu } from '@/composables/useContextMenu';
import { useCustomStyles, IP_COLOR_OPTIONS } from '@/composables/useCustomStyles';
import { useMyPerks } from '@/composables/useMessages';
import { IP_COLOR_OPTIONS } from '@/composables/useCustomStyles';
import { useMessageItem } from '@/composables/useMessageItem';
import RichContent from './RichContent.vue';
import MessageAttachments from './MessageAttachments.vue';
const props = defineProps<{ message: Message; myIp?: string }>();
defineEmits<{ reply: [payload: { id: string; authorIp: string }] }>();
const { perksFor } = usePerks();
const { myPerks } = useMyPerks();
const { prefs } = useCustomStyles();
function perksOf(m: Reply): any {
return m.authorPerks ?? perksFor(m.authorIp);
}
function ipStyle(m: Reply) {
const ip = m.authorIp;
const colorOverride = prefs.ipColors[ip];
if (colorOverride && colorOverride !== 'auto') {
return { color: colorOverride, textShadow: getIpGlow(colorOverride) };
}
const p = perksOf(m);
return {
color: getIpColorWithPerks(ip, p),
textShadow: getIpGlowWithPerks(ip, p),
};
}
function petsLeft(m: Reply): string {
const ip = m.authorIp;
if (ip in prefs.ipPets) return prefs.ipPets[ip]; // '' = aucun pet
const pets = perksOf(m)?.pets ?? [];
return pets
.filter((x: any) => x.position === 'left' || x.position === 'both')
.map((x: any) => x.char)
.join('');
}
function petsRight(m: Reply): string {
const ip = m.authorIp;
if (ip in prefs.ipPets) return ''; // override = pet gauche uniquement
const pets = perksOf(m)?.pets ?? [];
return pets
.filter((x: any) => x.position === 'right' || x.position === 'both')
.map((x: any) => x.char)
.join('');
}
const { ipStyle, petsLeft, petsRight, fmt, geoLabel, geoLink, myPerks, prefs } = useMessageItem();
function openIpMenu(e: MouseEvent, ip: string): void {
if (ip !== props.myIp) return;
@@ -171,26 +131,6 @@ function openIpMenu(e: MouseEvent, ip: string): void {
});
}
function fmt(date: string): string {
return new Date(date).toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
}
function geoLabel(geo?: GeoInfo | null): string {
if (!geo) return '';
if (!geo.countryCode) return 'Local';
const place = geo.city || geo.country;
if (geo.lat != null && geo.lon != null) {
const lat = geo.lat.toFixed(4);
const lon = geo.lon.toFixed(4);
return `${place} · ${lat}, ${lon}`;
}
return place;
}
function geoLink(geo?: GeoInfo | null): string {
if (!geo || geo.lat == null || geo.lon == null) return 'https://maps.google.com';
return `https://www.google.com/maps/search/?api=1&query=${geo.lat},${geo.lon}`;
}
</script>
<style scoped>