chore: minor stock generator improvements; code cleanup

This commit is contained in:
2025-03-09 16:20:58 +01:00
parent 862aebb158
commit 1eb5f3de9e
6 changed files with 56 additions and 47 deletions
+1 -28
View File
@@ -22,12 +22,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { useStore } from '../../store';
import imageMixin from '../../mixins/imageMixin';
import stockPreviewMixin from '../../mixins/stockPreviewMixin';
import stockMixin from '../../mixins/stockMixin';
import StockActions from './stock-list/StockActions.vue';
import StockSpecs from './stock-list/StockSpecs.vue';
import StockSpawnSettings from './stock-list/StockSpawnSettings.vue';
@@ -36,6 +30,7 @@ import StockList from './stock-list/StockList.vue';
export default defineComponent({
name: 'stock-list',
components: {
StockActions,
StockSpecs,
@@ -43,28 +38,6 @@ export default defineComponent({
StockWarnings,
StockList,
},
mixins: [imageMixin, stockMixin, stockPreviewMixin],
setup() {
const store = useStore();
return {
store,
};
},
data: () => ({}),
// computed: {
// chosenStockVehicle() {
// return this.store.chosenStockListIndex == -1
// ? undefined
// : this.store.stockList[this.store.chosenStockListIndex];
// },
// },
methods: {},
});
</script>
+3
View File
@@ -110,6 +110,7 @@ export default defineComponent({
delete this.store.storageStockData[stockName];
this.store.chosenStorageStockName = '';
this.store.chosenStorageStockString = '';
try {
localStorage.setItem('savedStockData', JSON.stringify(this.store.storageStockData));
@@ -122,6 +123,8 @@ export default defineComponent({
try {
this.loadStockFromString(this.store.storageStockData[stockName].stockString);
this.store.chosenStorageStockName = stockName;
this.store.chosenStorageStockString = this.store.storageStockData[stockName].stockString;
this.$router.push('/');
} catch (error) {
console.log(error);
@@ -247,8 +247,6 @@ export default defineComponent({
if (!entryName) return;
let updatedAt: number | undefined = undefined;
if (entryName in this.store.storageStockData) {
const overwriteDataConfirm = confirm(this.$t('stocklist.prompt-bookmark-overwrite'));
@@ -267,6 +265,7 @@ export default defineComponent({
try {
localStorage.setItem('savedStockData', JSON.stringify(this.store.storageStockData));
this.store.chosenStorageStockName = entryName;
this.store.chosenStorageStockString = this.store.stockString;
} catch (error) {
console.error('Wystąpił błąd podczas zapisywania składu do localStorage!', error);
}
+32 -14
View File
@@ -1,20 +1,25 @@
<template>
<div class="stock_specs">
<b class="real-stock-info" v-if="store.chosenStorageStockName">
<span class="text--accent">
<BookmarkIcon />
{{ store.chosenStorageStockName }}
</span>
|
</b>
<div v-if="store.chosenStorageStockName || chosenRealComposition">
<b class="bookmarked-stock-info" v-if="store.chosenStorageStockName">
<span
class="text--accent"
:title="store.chosenStorageStockName.length > 41 ? store.chosenStorageStockName : ''"
>
<BookmarkIcon />
{{ store.chosenStorageStockName.slice(0, 40) }}
{{ store.chosenStorageStockName.length > 41 ? '...' : '' }}
</span>
|
</b>
<!-- <b class="real-stock-info" v-if="store.chosenRealComposition">
<span class="text--accent">
<img :src="getIconURL(chosenRealComposition.type)" :alt="chosenRealComposition.type" />
{{ chosenRealComposition.number }} {{ chosenRealComposition.name }}
</span>
|
</b> -->
<b class="real-stock-info" v-if="chosenRealComposition">
<span class="text--accent">
<img :src="getIconURL(chosenRealComposition.type)" :alt="chosenRealComposition.type" />
{{ chosenRealComposition.number }} {{ chosenRealComposition.name }}
</span>
</b>
</div>
<span>
{{ $t('stocklist.mass') }}
@@ -36,18 +41,31 @@
import { defineComponent } from 'vue';
import { useStore } from '../../../store';
import imageMixin from '../../../mixins/imageMixin';
import { BookmarkIcon } from '@heroicons/vue/20/solid';
export default defineComponent({
components: { BookmarkIcon },
mixins: [imageMixin],
data: () => ({
store: useStore(),
}),
computed: {
chosenRealComposition() {
const currentStockString = this.store.stockList.map((s) => s.vehicleRef.type).join(';');
return this.store.realCompositionList.find((rc) => rc.stockString == currentStockString);
},
},
});
</script>
<style scoped>
.bookmarked-stock-info,
.real-stock-info {
svg,
img {
height: 1.3ch;
}