Compare commits

..

4 commits

Author SHA1 Message Date
Vincent BRIDIER
1303e35981
Merge branch 'develop' 2025-09-30 15:15:24 +02:00
Vincent BRIDIER
ecd58d1fb1
Merge branch 'develop' 2025-09-25 15:17:38 +02:00
Vincent BRIDIER
7c9c3ffc0d
Merge branch 'develop' 2024-09-11 17:14:01 +02:00
Jérémy Munsch
cbf01630f6
Merge branch 'develop' 2024-01-19 11:34:15 +01:00
8 changed files with 19 additions and 118 deletions

View file

@ -168,13 +168,3 @@ bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
###NB
## Showroom BO preview (duplicated code)
/!\ The display code of this project is duplicated in `showroom-bo`, in `resources/expo/`
(used by the BO preview).
If you change a **template**, a **style** or a **component** here, report **the same change in the BO**,
otherwise the preview will no longer match the application.

38
app.vue
View file

@ -1,8 +1,6 @@
<template>
<div
class="app-component"
:class="{ 'has-custom-background': Object.keys(backgroundStyle).length > 0 }"
:style="backgroundStyle"
@mousemove="setTimeout"
@mousedown="setTimeout"
@mouseup="setTimeout"
@ -48,7 +46,6 @@ export default defineComponent({
activeRange: TypeRange|null;
chickenRun: boolean;
konami: KonamiCode|null;
backgroundStyle: Record<string, string>;
} {
return {
timeout: undefined,
@ -58,7 +55,6 @@ export default defineComponent({
activeRange: null,
chickenRun: false,
konami: null,
backgroundStyle: {},
};
},
computed: {
@ -87,7 +83,6 @@ export default defineComponent({
// * INIT STATES
window.ipcRendererObject.getJsonData().then((dataJson) => {
useAppStore().setupAppData(dataJson, this.$i18n.locale, String(this.$i18n.fallbackLocale));
this.backgroundStyle = this.buildBackgroundStyle(dataJson.settings);
this.loading = false;
this.setTimeout();
dataJson.fonts.forEach(font => this.injectFontFace(font.font_name, font.font));
@ -148,21 +143,6 @@ export default defineComponent({
}, useAppStore().getSettings().home_timeout * 1000);
});
},
/** Fond de la borne : image en prio si elle existe, couleur sinon */
buildBackgroundStyle(settings: TypeSettings): Record<string, string> {
const style: Record<string, string> = {};
if (settings.background_color) {
style.backgroundColor = settings.background_color;
}
if (settings.background_image) {
style.backgroundImage = `url("/data/${settings.background_image}")`;
style.backgroundSize = "cover";
style.backgroundPosition = "center";
style.backgroundRepeat = "no-repeat";
style.backgroundAttachment = "fixed";
}
return style;
},
}
});
</script>
@ -182,22 +162,4 @@ export default defineComponent({
opacity: 0;
filter: blur(1rem);
}
.app-component.has-custom-background {
min-height: 100vh;
.text-bg-light {
background-color: transparent !important;
}
// remove border
#product-list-component {
.btn.bg-body {
background-color: transparent !important;
}
.img-thumbnail {
background-color: transparent;
border-color: transparent;
}
}
}
</style>

View file

@ -9,8 +9,7 @@ import packageJson from "./../package.json";
const isDev = process.env.NODE_ENV === "development";
const root = path.join(__dirname, "..");
const sourcePublicPath = path.join(root, "public");
const runtimePublicPath = isDev ? sourcePublicPath : path.join(root, ".output/public");
const publicPath = isDev ? path.join(root, "public") : path.join(root, ".output/public");
/**
* In charge to unzip data from showroom Bo,
@ -19,15 +18,6 @@ const runtimePublicPath = isDev ? sourcePublicPath : path.join(root, ".output/pu
export default abstract class UnzipData {
static zipFileToUse: string|null;
private static resolvePublicPath(relativePath: string): string {
const runtimePath = path.join(runtimePublicPath, relativePath) as fs.PathLike;
if (fs.existsSync(runtimePath)) {
return runtimePath as string;
}
return path.join(sourcePublicPath, relativePath);
}
/**
* Init zipFileToUse if not already inited
*/
@ -35,11 +25,8 @@ export default abstract class UnzipData {
if (!UnzipData.zipFileToUse) {
// * Try to locate last zip file and load it.
const zipFile = fs.readdirSync("static/data")
.map((entryPath) => {
const fullPath = path.join("static/data", entryPath);
return { path: fullPath, stat: fs.lstatSync(fullPath) };
})
.filter((entry) => entry.stat.isFile() && entry.path.endsWith(".zip"))
.map(path => { return {path: `static/data/${path}`, "stat": fs.lstatSync(`static/data/${path}`)}; })
.filter(obj => obj.stat.isFile() && obj.path.endsWith(".zip"))
.sort((objA, objB) => objB.stat.mtime.getTime() - objA.stat.mtime.getTime())
.at(0) ?? null;
@ -61,26 +48,30 @@ export default abstract class UnzipData {
const zip = new AdmZip(fs.readFileSync(UnzipData.zipFileToUse));
UnzipData.removeOldExtractedFiles();
zip.extractAllTo("public/data");
zip.extractAllTo(publicPath + "/data");
// * Schemas Copy for production build
if (!isDev) {
fs.cpSync(path.join(root, "public/schemas"), path.join(publicPath, "schemas"), { recursive: true });
}
}
private static removeOldExtractedFiles() {
// * Clear export dir
fs.rmSync("public/data/pictures", { recursive: true, force: true });
fs.rmSync("public/data/data.json", { force: true });
fs.rmSync(publicPath + "/data/pictures", { recursive: true, force: true });
fs.rmSync(publicPath + "/data/data.json", { recursive: true, force: true });
}
/**
* Load json data file that was extracted
*/
public static loadJsonDataFile(): TypeApp | null {
const jsonDataPath = UnzipData.resolvePublicPath("data/data.json");
const jsonSchemaPath = UnzipData.resolvePublicPath("schemas");
const jsonData = fs.readFileSync(
jsonDataPath,
path.join(publicPath, "data/data.json"),
{ encoding: "utf8", flag: "r" }
);
const jsonSchemaPath = path.join(publicPath, "schemas");
if (!UnzipData.validateAgainstJsonSchema(jsonSchemaPath, jsonData)) {
log.warn(`Data for file ${UnzipData.zipFileToUse} is not valid JSON`);

4
index.d.ts vendored
View file

@ -31,10 +31,6 @@ type SettingsModel = {
logo: string;
/** Couleur de l'application (hex color) */
color: string;
/** Couleur de fond de toutes les pages de la borne (hex color, optionnelle) */
background_color?: string | null;
/** Image de fond de toutes les pages de la borne (optionnelle), chemin tel que présent dans le zip */
background_image?: string | null;
/** Temps en secondes avant retour sur la page home lorsque inactif */
home_timeout: number;
created_at: string;

View file

@ -2,6 +2,8 @@ import { resolve } from "path";
import log from "electron-log/main";
import UnzipData from "./electron/UnzipData";
UnzipData.loadZipFileContent();
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
hooks: {
@ -71,7 +73,7 @@ export default defineNuxtConfig({
pinia: "/node_modules/@pinia/nuxt/node_modules/pinia/dist/pinia.mjs"
},
i18n: {
locales: UnzipData.loadJsonDataFile()?.settings.locales ?? ["fr"],
locales: UnzipData.loadJsonDataFile()?.settings.locales,
defaultLocale: "fr",
// * Ajouter aussi la locale dans ce fichier
vueI18n: "./i18n.config.ts"

View file

@ -14,13 +14,12 @@
"static/**/*"
],
"scripts": {
"data:prepare": "node scripts/prepare-data.mjs",
"build": "npm run data:prepare && nuxi build --prerender && electron-builder -w",
"dev": "npm run data:prepare && cross-env NODE_ENV=development nuxt dev",
"build": "nuxi build --prerender && electron-builder -w",
"dev": "cross-env NODE_ENV=development nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"cleanup": "nuxt cleanup",
"typecheck": "npm run data:prepare && nuxt typecheck",
"typecheck": "nuxt typecheck",
"postinstall": "nuxt prepare",
"lint:ts": "npm run typecheck",
"lint:js": "eslint --ext \".js,.ts,.vue\" --ignore-path .gitignore .",

View file

@ -48,20 +48,6 @@
"description": "Couleur de l'application",
"$ref": "#/$defs/hexcolor"
},
"background_color": {
"description": "Couleur de fond de toutes les pages de la borne",
"anyOf": [
{ "$ref": "#/$defs/hexcolor" },
{ "type": "null" }
]
},
"background_image": {
"description": "Image de fond de toutes les pages de la borne",
"anyOf": [
{ "type": "string" },
{ "type": "null" }
]
},
"home_timeout": {
"description": "Temps en secondes avant retour sur la page home lorsque inactif",
"type": "integer",

View file

@ -1,25 +0,0 @@
import fs from "node:fs";
import path from "node:path";
import AdmZip from "adm-zip";
const root = process.cwd();
const dataDir = path.join(root, "static", "data");
const publicDataDir = path.join(root, "public", "data");
const zipFiles = fs.readdirSync(dataDir, { withFileTypes: true })
.filter((entry) => entry.isFile() && entry.name.endsWith(".zip"))
.map((entry) => path.join(dataDir, entry.name))
.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
const latestZip = zipFiles.at(0);
if (!latestZip) {
throw new Error("No zip data to load in static/data");
}
fs.rmSync(path.join(publicDataDir, "pictures"), { recursive: true, force: true });
fs.rmSync(path.join(publicDataDir, "data.json"), { force: true });
const zip = new AdmZip(latestZip);
zip.extractAllTo(publicDataDir);
console.info(`Prepared data from: ${latestZip}`);