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

@ -383,7 +383,7 @@ import MessageOperationsBottomSheet from "./MessageOperationsBottomSheet";
import StickerPickerBottomSheet from "./StickerPickerBottomSheet";
import UserProfileDialog from "./UserProfileDialog.vue"
import BottomSheet from "./BottomSheet.vue";
import ImageResize from "image-resize";
import imageResize from "image-resize";
import CreatePollDialog from "./CreatePollDialog.vue";
import chatMixin, { ROOM_READ_MARKER_EVENT_PLACEHOLDER } from "./chatMixin";
import sendAttachmentsMixin from "./sendAttachmentsMixin";
@ -394,8 +394,7 @@ import roomMembersMixin from "./roomMembersMixin";
import PurgeRoomDialog from "../components/PurgeRoomDialog";
import MessageErrorHandler from "./MessageErrorHandler";
import MessageOperationsChannel from './messages/channel/MessageOperationsChannel.vue';
import sizeOf from "image-size";
import dataUriToBuffer from "data-uri-to-buffer";
import { imageSize } from "image-size";
import prettyBytes from "pretty-bytes";
import RoomExport from "./RoomExport.vue";
import { VEmojiPicker } from 'v-emoji-picker';
@ -1470,8 +1469,9 @@ export default {
fileObj.actualSize = file.size;
fileObj.actualFile = file
try {
fileObj.dimensions = sizeOf(dataUriToBuffer(evt.target.result));
const buffer = Uint8Array.from(window.atob(evt.target.result.replace(/^data[^,]+,/,'')), v => v.charCodeAt(0));
fileObj.dimensions = imageSize(buffer);
// Need to resize?
const w = fileObj.dimensions.width;
const h = fileObj.dimensions.height;
@ -1479,14 +1479,12 @@ export default {
var aspect = w / h;
var newWidth = parseInt((w > h ? 640 : 640 * aspect).toFixed());
var newHeight = parseInt((w > h ? 640 / aspect : 640).toFixed());
var imageResize = new ImageResize({
imageResize(evt.target.result, {
format: "png",
width: newWidth,
height: newHeight,
outputType: "blob",
});
imageResize
.play(evt.target.result)
})
.then((img) => {
Vue.set(
fileObj,

View file

@ -43,7 +43,7 @@
</template>
<script>
import RoomList from "../components/RoomList";
import RoomList from "../components/RoomList.vue";
import YouAre from "../components/YouAre.vue";
import logoMixin from "../components/logoMixin";
export default {

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";
},

View file

@ -94,10 +94,10 @@ import BottomSheet from "./BottomSheet.vue";
import CreatePollDialog from "./CreatePollDialog.vue";
import chatMixin from "./chatMixin";
import util from "../plugins/utils";
import JSZip from "jszip";
import { saveAs } from "file-saver";
import { EventTimelineSet } from "matrix-js-sdk";
import axios from 'axios';
import "../services/jszip.min";
import "../services/filesaver.cjs";
export default {
name: "RoomExport",
@ -168,7 +168,7 @@ export default {
},
watch: {
processedEvents() {
this.statusText = this.$t("export.processed_n_of_total_events", {
this.statusText = this.$t("room_export.processed_n_of_total_events", {
count: this.processedEvents,
total: this.totalEvents,
});
@ -176,7 +176,7 @@ export default {
},
computed: {
exportDate() {
return this.$t("export.exported_date", { date: util.formatDay(Date.now().valueOf()) });
return this.$t("room_export.exported_date", { date: util.formatDay(Date.now().valueOf()) });
},
},
methods: {
@ -214,13 +214,13 @@ export default {
if (result.chunk.length === 0) break;
if (nToFetch != null) {
nToFetch -= result.chunk.length;
this.statusText = this.$t("export.fetched_n_of_total_events", {
this.statusText = this.$t("room_export.fetched_n_of_total_events", {
count: this.totalEvents - nToFetch,
total: this.totalEvents,
});
} else {
this.totalEvents += result.chunk.length;
this.statusText = this.$t("export.fetched_n_events", { count: this.totalEvents });
this.statusText = this.$t("room_export.fetched_n_events", { count: this.totalEvents });
}
fetchedEvents.push(...result.chunk.map(eventMapper));
@ -254,7 +254,7 @@ export default {
.then((events) => {
// Create a timeline and add the events to that, so that relations etc are aggregated correctly!
this.timelineSet = new EventTimelineSet(null, { unstableClientRelationAggregation: true });
this.timelineSet.addEventsToTimeline(events.reverse(), true, this.timelineSet.getLiveTimeline(), "");
this.timelineSet.addEventsToTimeline(events.reverse(), true, false, this.timelineSet.getLiveTimeline(), "");
this.events = events;
// Need to set thread root events and replyEvents so stuff is rendered correctly.
@ -538,7 +538,7 @@ export default {
zip.generateAsync({ type: "blob" }).then((content) => {
saveAs(
content,
this.$t("export.export_filename", { date: util.formatDay(Date.now().valueOf()) }) + ".zip"
this.$t("room_export.export_filename", { date: util.formatDay(Date.now().valueOf()) }) + ".zip"
);
this.status = "";
this.$emit("close");