Fix vite build release version

Also, make sure "export" strings are not removed (rename to "room_export") and import quotes in the QuoteView correctly.
This commit is contained in:
N-Pex 2025-04-22 13:01:18 +02:00
parent 4c364f93e6
commit ec992bb14d
34 changed files with 621 additions and 284 deletions

View file

@ -99,21 +99,26 @@ export default {
};
},
mounted() {
var quotes;
try {
quotes = require("@/assets/quotes/" + this.$i18n.locale + "/quotes");
const quotes = import.meta.glob('@/assets/quotes/*/*.json', {eager: false});
let quoteImport = undefined;
Object.keys(quotes).forEach(path => {
// Remove"./"
const parts = path.split("/");
const locale = parts[parts.length - 2];
if (locale == this.$i18n.locale) {
quoteImport = quotes[path];
}
});
if (quoteImport) {
quoteImport().then((quotes) => this.selectQuote(quotes));
return;
}
} catch (error) {
console.error("No quotes for language");
quotes = undefined;
}
if (!quotes) {
quotes = require("@/assets/quotes/en/quotes"); // Default fallback
}
const n = quotes.quotes.length;
const quote = quotes.quotes[Math.floor(Math.random() * n)];
this.quote = quote.quote;
this.author = quote.author;
this.mounted = true;
import("@/assets/quotes/en/quotes") // Default fallback
.then((quotes) => this.selectQuote(quotes));
},
computed: {
@ -127,6 +132,17 @@ export default {
},
methods: {
selectQuote(quotes) {
const n = quotes.quotes.length;
if (n > 0) {
const quote = quotes.quotes[Math.floor(Math.random() * n)];
this.quote = quote.quote;
this.author = quote.author;
this.mounted = true;
} else {
this.mounted = true;
}
},
closeBrowserTab() {
window.location.href = "about:blank";
},