refac: defineComponent => vue3 setup

This commit is contained in:
2022-07-13 22:37:37 +09:00
parent 08e43bed71
commit e5c50e48d3
12 changed files with 452 additions and 635 deletions
+34 -49
View File
@@ -34,64 +34,49 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import ColorSelect from "@/processing/SelectColor.vue"; declare const staticValues: {
import { defineComponent, ref } from "vue"; commandName: string;
import { unwrap } from "@/util/unwrap"; };
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import type { procNationTypeList } from "../processingRes";
declare const commandName: string;
declare const procRes: { declare const procRes: {
available건국: boolean; available건국: boolean;
colors: string[]; colors: string[];
nationTypes: procNationTypeList; nationTypes: procNationTypeList;
}; };
</script>
<script setup lang="ts">
import ColorSelect from "@/processing/SelectColor.vue";
import { ref } from "vue";
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import type { procNationTypeList } from "../processingRes";
export default defineComponent({ const commandName = staticValues.commandName;
components: { const { nationTypes, available건국, colors } = procRes;
ColorSelect,
TopBackBar,
BottomBar,
},
setup() {
const destNationName = ref("");
const selectedColorID = ref(0);
const selectedNationType = ref(Object.values(procRes.nationTypes)[0].type); const destNationName = ref("");
const selectedColorID = ref(0);
async function submit(e: Event) { const selectedNationType = ref(Object.values(procRes.nationTypes)[0].type);
const event = new CustomEvent<Args>("customSubmit", {
detail: {
colorType: selectedColorID.value,
nationName: destNationName.value,
nationType: selectedNationType.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
const nationTypesOption: { html: string; value: string }[] = []; async function submit(e: Event) {
for (const nationType of Object.values(procRes.nationTypes)) { const event = new CustomEvent<Args>("customSubmit", {
nationTypesOption.push({ detail: {
html: nationType.name, colorType: selectedColorID.value,
value: nationType.type, nationName: destNationName.value,
}); nationType: selectedNationType.value,
} },
});
unwrap(e.target).dispatchEvent(event);
}
return { const nationTypesOption: { html: string; value: string }[] = [];
available건국: procRes.available건국, for (const nationType of Object.values(procRes.nationTypes)) {
selectedColorID, nationTypesOption.push({
selectedNationType, html: nationType.name,
colors: procRes.colors, value: nationType.type,
nationTypes: procRes.nationTypes, });
nationTypesOption, }
destNationName,
commandName,
submit,
};
},
});
</script> </script>
+26 -36
View File
@@ -25,49 +25,39 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import SelectAmount from "@/processing/SelectAmount.vue"; declare const staticValues: {
import { defineComponent, ref } from "vue"; commandName: string;
import { unwrap } from "@/util/unwrap"; };
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
declare const commandName: string;
declare const procRes: { declare const procRes: {
minAmount: number; minAmount: number;
maxAmount: number; maxAmount: number;
amountGuide: number[]; amountGuide: number[];
}; };
</script>
<script setup lang="ts">
import SelectAmount from "@/processing/SelectAmount.vue";
import { ref } from "vue";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
export default defineComponent({ const commandName = staticValues.commandName;
components: { const { minAmount, maxAmount, amountGuide } = procRes;
SelectAmount,
TopBackBar,
BottomBar,
},
setup() {
const amount = ref(1000);
const buyRice = ref(true);
async function submit(e: Event) { const amount = ref(1000);
const event = new CustomEvent<Args>("customSubmit", { const buyRice = ref(true);
detail: {
amount: amount.value,
buyRice: buyRice.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return { async function submit(e: SubmitEvent) {
buyRice, if(!e.target){
amount, return;
minAmount: ref(procRes.minAmount), }
maxAmount: ref(procRes.maxAmount), const event = new CustomEvent<Args>("customSubmit", {
amountGuide: procRes.amountGuide, detail: {
commandName, amount: amount.value,
submit, buyRice: buyRice.value,
}; },
}, });
}); e.target.dispatchEvent(event);
}
</script> </script>
+34 -44
View File
@@ -28,8 +28,19 @@
</template> </template>
<script lang="ts"> <script lang="ts">
declare const staticValues: {
commandName: string;
};
declare const procRes: {
generals: procGeneralRawItemList;
generalsKey: procGeneralKey[];
nationList: procNationList;
};
</script>
<script setup lang="ts">
import SelectGeneral from "@/processing/SelectGeneral.vue"; import SelectGeneral from "@/processing/SelectGeneral.vue";
import { defineComponent, ref } from "vue"; import { onMounted, ref } from "vue";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
@@ -44,54 +55,33 @@ import {
type procNationList, type procNationList,
} from "../processingRes"; } from "../processingRes";
import { getNpcColor } from "@/common_legacy"; import { getNpcColor } from "@/common_legacy";
declare const commandName: string;
declare const procRes: { const commandName = staticValues.commandName;
generals: procGeneralRawItemList; const searchable = getProcSearchable();
generalsKey: procGeneralKey[]; const generalList = ref(convertGeneralList(procRes.generalsKey, procRes.generals));
nationList: procNationList;
};
export default defineComponent({ const selectedGeneralID = ref(generalList.value[0].no);
components: {
SelectGeneral,
TopBackBar,
BottomBar,
},
setup() {
const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
const selectedGeneralID = ref(generalList[0].no); function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return name;
}
function textHelpGeneral(gen: procGeneralItem): string { async function submit(e: Event) {
const nameColor = getNpcColor(gen.npc); const event = new CustomEvent<Args>("customSubmit", {
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name; detail: {
return name; destGeneralID: selectedGeneralID.value,
} },
});
unwrap(e.target).dispatchEvent(event);
}
async function submit(e: Event) { const nationList = ref(new Map<number, procNationItem>());
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destGeneralID: selectedGeneralID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
const nationList = new Map<number, procNationItem>(); onMounted(() => {
for (const nationItem of procRes.nationList) { for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem); nationList.value.set(nationItem.id, nationItem);
} }
return {
searchable: getProcSearchable(),
selectedGeneralID,
generalList,
nationList,
commandName,
textHelpGeneral,
submit,
};
},
}); });
</script> </script>
+29 -40
View File
@@ -31,8 +31,19 @@
</template> </template>
<script lang="ts"> <script lang="ts">
declare const staticValues: {
commandName: string;
};
declare const procRes: {
generals: procGeneralRawItemList;
generalsKey: procGeneralKey[];
};
</script>
<script lang="ts" setup>
import SelectGeneral from "@/processing/SelectGeneral.vue"; import SelectGeneral from "@/processing/SelectGeneral.vue";
import { defineComponent, ref } from "vue"; import { ref } from "vue";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
@@ -45,47 +56,25 @@ import {
type procGeneralRawItemList, type procGeneralRawItemList,
} from "../processingRes"; } from "../processingRes";
import { getNpcColor } from "@/common_legacy"; import { getNpcColor } from "@/common_legacy";
declare const commandName: string;
declare const procRes: { const commandName = staticValues.commandName;
generals: procGeneralRawItemList; const searchable = getProcSearchable();
generalsKey: procGeneralKey[]; const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
};
export default defineComponent({ const selectedGeneralID = ref(generalList[0].no);
components: {
SelectGeneral,
TopBackBar,
BottomBar,
},
setup() {
const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
const selectedGeneralID = ref(generalList[0].no); function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc);
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
return `${name} (${gen.leadership}/${gen.strength}/${gen.intel})`;
}
function textHelpGeneral(gen: procGeneralItem): string { async function submit(e: Event) {
const nameColor = getNpcColor(gen.npc); const event = new CustomEvent<Args>("customSubmit", {
const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name; detail: {
return `${name} (${gen.leadership}/${gen.strength}/${gen.intel})`; destGeneralID: selectedGeneralID.value,
} },
});
async function submit(e: Event) { unwrap(e.target).dispatchEvent(event);
const event = new CustomEvent<Args>("customSubmit", { }
detail: {
destGeneralID: selectedGeneralID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return {
searchable: getProcSearchable(),
selectedGeneralID,
generalList,
commandName,
textHelpGeneral,
submit,
};
},
});
</script> </script>
+87 -111
View File
@@ -92,143 +92,119 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref } from "vue"; type DexInfo = {
import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
declare const commandName: string;
type dexInfo = {
amount: number; amount: number;
color: string; color: string;
name: string; name: string;
}; };
declare const staticValues: {
commandName: string;
};
declare const procRes: { declare const procRes: {
ownDexList: { ownDexList: {
armType: number; armType: number;
name: string; name: string;
amount: number; amount: number;
}[]; }[];
dexLevelList: dexInfo[]; dexLevelList: DexInfo[];
decreaseCoeff: number; decreaseCoeff: number;
convertCoeff: number; convertCoeff: number;
}; };
</script>
export default defineComponent({ <script lang="ts" setup>
components: { import { ref } from "vue";
TopBackBar, import { unwrap } from "@/util/unwrap";
BottomBar, import type { Args } from "@/processing/args";
}, import TopBackBar from "@/components/TopBackBar.vue";
setup() { import BottomBar from "@/components/BottomBar.vue";
const srcArmTypeID = ref(procRes.ownDexList[0].armType);
const destArmTypeID = ref(procRes.ownDexList[0].armType);
async function submit(e: Event) { const commandName = staticValues.commandName;
const event = new CustomEvent<Args>("customSubmit", {
detail: { const srcArmTypeID = ref(procRes.ownDexList[0].armType);
srcArmType: srcArmTypeID.value, const destArmTypeID = ref(procRes.ownDexList[0].armType);
destArmType: destArmTypeID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
function getDexCall(dex: number): { color: string; name: string } { async function submit(e: Event) {
if (dex < 0) { const event = new CustomEvent<Args>("customSubmit", {
throw `올바르지 않은 수치: ${dex}`; detail: {
} srcArmType: srcArmTypeID.value,
destArmType: destArmTypeID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
let color = ""; function getDexCall(dex: number): { color: string; name: string } {
let name = ""; if (dex < 0) {
for (const nextDexLevel of procRes.dexLevelList) { throw `올바르지 않은 수치: ${dex}`;
if (dex < nextDexLevel.amount) { }
break;
}
color = nextDexLevel.color;
name = nextDexLevel.name;
}
return { let color = "";
color, let name = "";
name, for (const nextDexLevel of procRes.dexLevelList) {
}; if (dex < nextDexLevel.amount) {
break;
} }
color = nextDexLevel.color;
const dexFullInfo = new Map< name = nextDexLevel.name;
number, }
{
armType: number;
name: string;
amount: number;
decresedAmount: number;
currentInfo: dexInfo;
decreasedInfo: dexInfo;
afterInfo: Map<number, dexInfo>;
}
>();
for (const dexItem of procRes.ownDexList) { return {
const amount = dexItem.amount; color,
const currentInfo = { ...getDexCall(amount), amount }; name,
};
}
const decresedAmount = amount * procRes.decreaseCoeff; const dexFullInfo = new Map<
const decresedAfterAmount = amount - decresedAmount; number,
const decreasedInfo = { {
...getDexCall(decresedAfterAmount), armType: number;
amount: decresedAfterAmount, name: string;
}; amount: number;
decresedAmount: number;
currentInfo: DexInfo;
decreasedInfo: DexInfo;
afterInfo: Map<number, DexInfo>;
}
>();
dexFullInfo.set(dexItem.armType, { for (const dexItem of procRes.ownDexList) {
...dexItem, const amount = dexItem.amount;
decresedAmount, const currentInfo = { ...getDexCall(amount), amount };
currentInfo,
decreasedInfo,
afterInfo: new Map(),
});
}
for (const [armType, dexItem] of dexFullInfo.entries()) { const decresedAmount = amount * procRes.decreaseCoeff;
for (const [fromArmType, fromDexItem] of dexFullInfo.entries()) { const decresedAfterAmount = amount - decresedAmount;
let afterAmount = fromDexItem.decresedAmount * procRes.convertCoeff; const decreasedInfo = {
if (armType != fromArmType) { ...getDexCall(decresedAfterAmount),
afterAmount += dexItem.amount; amount: decresedAfterAmount,
} else { };
afterAmount += dexItem.decresedAmount;
}
dexItem.afterInfo.set(fromArmType, { dexFullInfo.set(dexItem.armType, {
amount: afterAmount, ...dexItem,
...getDexCall(afterAmount), decresedAmount,
}); currentInfo,
} decreasedInfo,
} afterInfo: new Map(),
});
}
function convDexFormat(value: dexInfo): string { for (const [armType, dexItem] of dexFullInfo.entries()) {
const amount = convNumberFormat(value.amount); for (const [fromArmType, fromDexItem] of dexFullInfo.entries()) {
return `<span class="f_tnum" style="color:${value.color}">${value.name}</span>,${"\xa0".repeat( let afterAmount = fromDexItem.decresedAmount * procRes.convertCoeff;
Math.max(0, 3 - value.name.length) if (armType != fromArmType) {
)} ${amount}`; afterAmount += dexItem.amount;
} else {
afterAmount += dexItem.decresedAmount;
} }
function convNumberFormat(value: number): string { dexItem.afterInfo.set(fromArmType, {
return Math.floor(value).toLocaleString(); amount: afterAmount,
} ...getDexCall(afterAmount),
});
}
}
return { function convNumberFormat(value: number): string {
unwrap, return Math.floor(value).toLocaleString();
...procRes, }
srcArmTypeID,
destArmTypeID,
dexFullInfo,
getDexCall,
commandName,
submit,
convDexFormat,
convNumberFormat,
};
},
});
</script> </script>
+31 -48
View File
@@ -3,13 +3,13 @@
<div class="bg0"> <div class="bg0">
<div> <div>
국가에 임관합니다. 국가에 임관합니다.
<br> <br />
이미 임관/등용되었던 국가는 다시 임관할 없습니다. 이미 임관/등용되었던 국가는 다시 임관할 없습니다.
<br> <br />
바로 군주의 위치로 이동합니다. 바로 군주의 위치로 이동합니다.
<br> <br />
임관할 국가를 목록에서 선택하세요. 임관할 국가를 목록에서 선택하세요.
<br> <br />
</div> </div>
<div class="row"> <div class="row">
<div class="col-6 col-md-3"> <div class="col-6 col-md-3">
@@ -64,60 +64,43 @@
</template> </template>
<script lang="ts"> <script lang="ts">
declare const staticValues: {
commandName: string;
};
declare const procRes: {
nationList: procNationList;
};
</script>
<script lang="ts" setup>
import SelectNation from "@/processing/SelectNation.vue"; import SelectNation from "@/processing/SelectNation.vue";
import { defineComponent, ref } from "vue"; import { ref } from "vue";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue"; import BottomBar from "@/components/BottomBar.vue";
import { type procNationItem, type procNationList, getProcSearchable } from "../processingRes"; import { type procNationItem, type procNationList, getProcSearchable } from "../processingRes";
import { isBrightColor } from "@/util/isBrightColor"; import { isBrightColor } from "@/util/isBrightColor";
declare const commandName: string;
declare const procRes: { const commandName = staticValues.commandName;
nationList: procNationList; const searchable = getProcSearchable();
};
export default defineComponent({ const nationList = new Map<number, procNationItem>();
components: { for (const nationItem of procRes.nationList) {
SelectNation, nationList.set(nationItem.id, nationItem);
TopBackBar, }
BottomBar,
},
setup() {
const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem);
}
const toggleZoom = ref(true); const toggleZoom = ref(true);
const selectedNationID = ref(procRes.nationList[0].id); const selectedNationID = ref(procRes.nationList[0].id);
function selectedNation(nationID: number) { async function submit(e: Event) {
selectedNationID.value = nationID; const event = new CustomEvent<Args>("customSubmit", {
} detail: {
destNationID: selectedNationID.value,
async function submit(e: Event) { },
const event = new CustomEvent<Args>("customSubmit", { });
detail: { unwrap(e.target).dispatchEvent(event);
destNationID: selectedNationID.value, }
},
});
unwrap(e.target).dispatchEvent(event);
}
return {
searchable: getProcSearchable(),
nationList: ref(nationList),
selectedNationID,
commandName,
toggleZoom,
isBrightColor,
selectedNation,
submit,
};
},
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -181,4 +164,4 @@ export default defineComponent({
} }
} }
} }
</style> </style>
@@ -1,14 +1,11 @@
<template> <template>
<TopBackBar <TopBackBar v-model:searchable="searchable" :title="commandName" />
v-model:searchable="searchable"
:title="commandName"
/>
<div class="bg0"> <div class="bg0">
<div> <div>
장수를 따라 임관합니다.<br> 장수를 따라 임관합니다.<br />
이미 임관/등용되었던 국가는 다시 임관할 없습니다.<br> 이미 임관/등용되었던 국가는 다시 임관할 없습니다.<br />
바로 군주의 위치로 이동합니다.<br> 바로 군주의 위치로 이동합니다.<br />
임관할 국가를 목록에서 선택하세요.<br> 임관할 국가를 목록에서 선택하세요.<br />
</div> </div>
<div class="row"> <div class="row">
<div class="col-8 col-md-4"> <div class="col-8 col-md-4">
@@ -22,10 +19,7 @@
/> />
</div> </div>
<div class="col-4 col-md-2 d-grid"> <div class="col-4 col-md-2 d-grid">
<b-button <b-button variant="primary" @click="submit">
variant="primary"
@click="submit"
>
{{ commandName }} {{ commandName }}
</b-button> </b-button>
</div> </div>
@@ -73,8 +67,20 @@
</template> </template>
<script lang="ts"> <script lang="ts">
declare const staticValues: {
commandName: string;
};
declare const procRes: {
generals: procGeneralRawItemList;
generalsKey: procGeneralKey[];
nationList: procNationList;
};
</script>
<script lang="ts" setup>
import SelectGeneral from "@/processing/SelectGeneral.vue"; import SelectGeneral from "@/processing/SelectGeneral.vue";
import { defineComponent, ref } from "vue"; import { ref } from "vue";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
@@ -90,64 +96,34 @@ import {
} from "../processingRes"; } from "../processingRes";
import { getNpcColor } from "@/common_legacy"; import { getNpcColor } from "@/common_legacy";
import { isBrightColor } from "@/util/isBrightColor"; import { isBrightColor } from "@/util/isBrightColor";
declare const commandName: string;
declare const procRes: { const commandName = staticValues.commandName;
generals: procGeneralRawItemList; const searchable = getProcSearchable();
generalsKey: procGeneralKey[];
nationList: procNationList;
};
export default defineComponent({ const generalList = convertGeneralList(procRes.generalsKey, procRes.generals);
components: {
SelectGeneral,
TopBackBar,
BottomBar,
},
setup() {
const generalList = convertGeneralList(
procRes.generalsKey,
procRes.generals
);
const toggleZoom = ref(true); const toggleZoom = ref(true);
const selectedGeneralID = ref(generalList[0].no); const selectedGeneralID = ref(generalList[0].no);
function textHelpGeneral(gen: procGeneralItem): string { function textHelpGeneral(gen: procGeneralItem): string {
const nameColor = getNpcColor(gen.npc); const nameColor = getNpcColor(gen.npc);
const name = nameColor const name = nameColor ? `<span style="color:${nameColor}">${gen.name}</span>` : gen.name;
? `<span style="color:${nameColor}">${gen.name}</span>` return name;
: gen.name; }
return name;
}
const nationList = new Map<number, procNationItem>(); const nationList = new Map<number, procNationItem>();
for (const nationItem of procRes.nationList) { for (const nationItem of procRes.nationList) {
nationList.set(nationItem.id, nationItem); nationList.set(nationItem.id, nationItem);
} }
async function submit(e: Event) { async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", { const event = new CustomEvent<Args>("customSubmit", {
detail: { detail: {
destGeneralID: selectedGeneralID.value, destGeneralID: selectedGeneralID.value,
}, },
}); });
unwrap(e.target).dispatchEvent(event); unwrap(e.target).dispatchEvent(event);
} }
return {
searchable: getProcSearchable(),
nationList: ref(nationList),
selectedGeneralID,
generalList,
commandName,
toggleZoom,
isBrightColor,
textHelpGeneral,
submit,
};
},
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -211,4 +187,4 @@ export default defineComponent({
} }
} }
} }
</style> </style>
+26 -34
View File
@@ -230,14 +230,9 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import CrewTypeItem from "@/processing/CrewTypeItem.vue"; declare const staticValues: {
import { defineComponent, ref } from "vue"; commandName: string;
import { unwrap } from "@/util/unwrap"; };
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import type { procArmTypeItem, procCrewTypeItem } from "../processingRes";
declare const commandName: string;
declare const procRes: { declare const procRes: {
relYear: number; relYear: number;
@@ -253,15 +248,30 @@ declare const procRes: {
crew: number; crew: number;
gold: number; gold: number;
}; };
</script>
export default defineComponent({ <script lang="ts" setup>
components: { import CrewTypeItem from "@/processing/CrewTypeItem.vue";
CrewTypeItem, import { ref } from "vue";
TopBackBar, import { unwrap } from "@/util/unwrap";
BottomBar, import type { Args } from "@/processing/args";
}, import TopBackBar from "@/components/TopBackBar.vue";
setup() { import BottomBar from "@/components/BottomBar.vue";
const amount = ref(procRes.fullLeadership - Math.floor(procRes.crew / 100)); import type { procArmTypeItem, procCrewTypeItem } from "../processingRes";
const commandName = staticValues.commandName;
const {
techLevel,
goldCoeff,
leadership,
fullLeadership,
armCrewTypes,
currentCrewType,
crew,
gold,
} = procRes;
const amount = ref(procRes.fullLeadership - Math.floor(procRes.crew / 100));
async function submit(e: Event) { async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", { const event = new CustomEvent<Args>("customSubmit", {
@@ -317,24 +327,6 @@ export default defineComponent({
!(showNotAvailable.value.get(armType) ?? 0) !(showNotAvailable.value.get(armType) ?? 0)
); );
} }
return {
destCrewType,
amount,
showNotAvailable,
...procRes,
crewTypeMap,
commandName,
beHalf,
beFilled,
beFull,
submit,
toggleShowNotAvailable,
trySubmit,
unwrap,
};
},
});
</script> </script>
<style lang="scss"> <style lang="scss">
+29 -61
View File
@@ -1,41 +1,21 @@
<template> <template>
<TopBackBar :title="commandName" /> <TopBackBar :title="commandName" />
<div class="bg0"> <div class="bg0">
<div> <div>자신의 자금이나 군량을 국가 재산으로 헌납합니다.</div>
자신의 자금이나 군량을 국가 재산으로 헌납합니다.
</div>
<div class="row"> <div class="row">
<div class="col-2 col-md-1"> <div class="col-2 col-md-1">
자원 : 자원 :
<b-button-group> <b-button-group>
<b-button <b-button :pressed="isGold" @click="isGold = true"> </b-button>
:pressed="isGold" <b-button :pressed="!isGold" @click="isGold = false"> </b-button>
@click="isGold = true"
>
</b-button>
<b-button
:pressed="!isGold"
@click="isGold = false"
>
</b-button>
</b-button-group> </b-button-group>
</div> </div>
<div class="col-7 col-md-4"> <div class="col-7 col-md-4">
금액 : 금액 :
<SelectAmount <SelectAmount v-model="amount" :amountGuide="amountGuide" :maxAmount="maxAmount" :minAmount="minAmount" />
v-model="amount"
:amountGuide="amountGuide"
:maxAmount="maxAmount"
:minAmount="minAmount"
/>
</div> </div>
<div class="col-3 col-md-2 d-grid"> <div class="col-3 col-md-2 d-grid">
<b-button <b-button variant="primary" @click="submit">
variant="primary"
@click="submit"
>
{{ commandName }} {{ commandName }}
</b-button> </b-button>
</div> </div>
@@ -45,50 +25,38 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import SelectAmount from "@/processing/SelectAmount.vue"; declare const staticValues: {
import { defineComponent, ref } from "vue"; commandName: string;
import { unwrap } from "@/util/unwrap"; };
import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
declare const commandName: string;
declare const procRes: { declare const procRes: {
minAmount: number; minAmount: number;
maxAmount: number; maxAmount: number;
amountGuide: number[]; amountGuide: number[];
}; };
</script>
export default defineComponent({ <script lang="ts" setup>
components: { import SelectAmount from "@/processing/SelectAmount.vue";
SelectAmount, import { ref } from "vue";
TopBackBar, import { unwrap } from "@/util/unwrap";
BottomBar, import type { Args } from "@/processing/args";
}, import TopBackBar from "@/components/TopBackBar.vue";
setup() { import BottomBar from "@/components/BottomBar.vue";
const amount = ref(1000);
const isGold = ref(true);
const commandName = staticValues.commandName;
const { minAmount, maxAmount, amountGuide } = procRes;
async function submit(e: Event) { const amount = ref(1000);
const event = new CustomEvent<Args>("customSubmit", { const isGold = ref(true);
detail: {
amount: amount.value,
isGold: isGold.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return { async function submit(e: Event) {
amount, const event = new CustomEvent<Args>("customSubmit", {
isGold, detail: {
minAmount: ref(procRes.minAmount), amount: amount.value,
maxAmount: ref(procRes.maxAmount), isGold: isGold.value,
amountGuide: procRes.amountGuide, },
commandName, });
submit, unwrap(e.target).dispatchEvent(event);
}; }
},
});
</script> </script>
+26 -47
View File
@@ -1,19 +1,11 @@
<template> <template>
<TopBackBar <TopBackBar :title="commandName" type="chief" />
:title="commandName"
type="chief"
/>
<div class="bg0"> <div class="bg0">
<div> <div>국기를 변경합니다. 1 가능합니다.<br /></div>
국기를 변경합니다. 1 가능합니다.<br>
</div>
<div class="row"> <div class="row">
<div class="col-6 col-md-3"> <div class="col-6 col-md-3">
색상 : 색상 :
<ColorSelect <ColorSelect v-model="selectedColorID" :colors="colors" />
v-model="selectedColorID"
:colors="colors"
/>
</div> </div>
<div class="col-4 col-md-2 d-grid"> <div class="col-4 col-md-2 d-grid">
<b-button @click="submit"> <b-button @click="submit">
@@ -22,51 +14,38 @@
</div> </div>
</div> </div>
</div> </div>
<BottomBar <BottomBar :title="commandName" type="chief" />
:title="commandName"
type="chief"
/>
</template> </template>
<script lang="ts"> <script lang="ts">
declare const staticValues: {
commandName: string;
};
declare const procRes: {
colors: string[];
};
</script>
<script lang="ts" setup>
import ColorSelect from "@/processing/SelectColor.vue"; import ColorSelect from "@/processing/SelectColor.vue";
import { defineComponent, ref } from "vue"; import { ref } from "vue";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue"; import BottomBar from "@/components/BottomBar.vue";
declare const commandName: string; const commandName = staticValues.commandName;
const { colors } = procRes;
declare const procRes: { const selectedColorID = ref(0);
colors: string[],
};
export default defineComponent({ async function submit(e: Event) {
components: { const event = new CustomEvent<Args>("customSubmit", {
ColorSelect, detail: {
TopBackBar, colorType: selectedColorID.value,
BottomBar, },
}, });
setup() { unwrap(e.target).dispatchEvent(event);
}
const selectedColorID = ref(0);
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
colorType: selectedColorID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return {
selectedColorID,
colors: procRes.colors,
commandName,
submit,
};
},
});
</script> </script>
+21 -40
View File
@@ -1,19 +1,11 @@
<template> <template>
<TopBackBar <TopBackBar :title="commandName" type="chief" />
:title="commandName"
type="chief"
/>
<div class="bg0"> <div class="bg0">
<div> <div>나라의 이름을 바꿉니다. 황제가 1 가능합니다.<br /></div>
나라의 이름을 바꿉니다. 황제가 1 가능합니다.<br>
</div>
<div class="row"> <div class="row">
<div class="col-6 col-md-3"> <div class="col-6 col-md-3">
국명 : 국명 :
<b-form-input <b-form-input v-model="destNationName" maxlength="18" />
v-model="destNationName"
maxlength="18"
/>
</div> </div>
<div class="col-4 col-md-2 d-grid"> <div class="col-4 col-md-2 d-grid">
<b-button @click="submit"> <b-button @click="submit">
@@ -22,43 +14,32 @@
</div> </div>
</div> </div>
</div> </div>
<BottomBar <BottomBar :title="commandName" type="chief" />
:title="commandName"
type="chief"
/>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref } from "vue"; declare const staticValues: {
commandName: string;
};
</script>
<script lang="ts" setup>
import { ref } from "vue";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import type { Args } from "@/processing/args"; import type { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue"; import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue"; import BottomBar from "@/components/BottomBar.vue";
declare const commandName: string; const commandName = staticValues.commandName;
export default defineComponent({ const destNationName = ref("");
components: {
TopBackBar,
BottomBar,
},
setup() {
const destNationName = ref("");
async function submit(e: Event) { async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", { const event = new CustomEvent<Args>("customSubmit", {
detail: { detail: {
nationName: destNationName.value, nationName: destNationName.value,
}, },
}); });
unwrap(e.target).dispatchEvent(event); unwrap(e.target).dispatchEvent(event);
} }
return {
destNationName,
commandName,
submit,
};
},
});
</script> </script>
+67 -59
View File
@@ -16,32 +16,32 @@
:maxHeight="400" :maxHeight="400"
:searchable="searchable" :searchable="searchable"
> >
<template #option="props"> <template #option="prop">
<span <span
:style="{ :style="{
color: props.option.notAvailable ? 'red' : undefined, color: prop.option.notAvailable ? 'red' : undefined,
}" }"
> >
{{ props.option.title }} {{ prop.option.title }}
<span v-if="props.option.info">({{ props.option.info }})</span> <span v-if="prop.option.info">({{ prop.option.info }})</span>
{{ props.option.notAvailable ? "(불가)" : undefined }} {{ prop.option.notAvailable ? "(불가)" : undefined }}
</span> </span>
</template> </template>
<template #singleLabel="props"> <template #singleLabel="prop">
<span <span
:style="{ :style="{
color: props.option.notAvailable ? 'red' : undefined, color: prop.option.notAvailable ? 'red' : undefined,
}" }"
> >
{{ props.option.simpleName }} {{ prop.option.simpleName }}
{{ props.option.notAvailable ? "(불가)" : undefined }}</span {{ prop.option.notAvailable ? "(불가)" : undefined }}</span
> >
</template> </template>
</v-multiselect> </v-multiselect>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import { convertSearch초성 } from "@/util/convertSearch초성"; import { convertSearch초성 } from "@/util/convertSearch초성";
import { defineComponent, type PropType } from "vue"; import { onMounted, ref, watch, toRef, type PropType } from "vue";
import type { procNationItem } from "./processingRes"; import type { procNationItem } from "./processingRes";
type SelectedNation = { type SelectedNation = {
@@ -53,56 +53,64 @@ type SelectedNation = {
notAvailable?: boolean; notAvailable?: boolean;
}; };
export default defineComponent({ const props = defineProps({
props: { modelValue: {
modelValue: { type: Number,
type: Number, required: true,
required: true,
},
nations: {
type: Map as PropType<Map<number, procNationItem>>,
required: true,
},
searchable: {
type: Boolean,
required: false,
default: true,
},
}, },
emits: ["update:modelValue"], nations: {
data() { type: Map as PropType<Map<number, procNationItem>>,
const forFind = []; required: true,
const targets = new Map<number, SelectedNation>();
let selectedNation;
for (const nationItem of this.nations.values()) {
const obj: SelectedNation = {
value: nationItem.id,
title: nationItem.name,
info: nationItem.info,
simpleName: nationItem.name,
notAvailable: nationItem.notAvailable,
searchText: convertSearch초성(nationItem.name).join("|"),
};
if (nationItem.id == this.modelValue) {
selectedNation = obj;
}
forFind.push(obj);
targets.set(nationItem.id, obj);
}
return {
selectedNation,
forFind,
targets,
};
}, },
watch: { searchable: {
modelValue(val: number) { type: Boolean,
const target = this.targets.get(val); required: false,
this.selectedNation = target; default: true,
},
selectedNation(val: SelectedNation) {
this.$emit("update:modelValue", val.value);
},
}, },
}); });
const modelValue = toRef(props, 'modelValue');
watch(
modelValue,
(val: number) => {
const target = targets.value.get(val);
selectedNation.value = target;
}
);
const emit = defineEmits<{
(event: "update:modelValue", value: number): void;
}>();
const forFind = ref<SelectedNation[]>([]);
const targets = ref(new Map<number, SelectedNation>());
const selectedNation = ref<SelectedNation>();
watch(selectedNation, (val) => {
if (val === undefined) {
return;
}
emit("update:modelValue", val.value);
});
onMounted(() => {
forFind.value = [];
targets.value.clear();
for (const nationItem of props.nations.values()) {
const obj: SelectedNation = {
value: nationItem.id,
title: nationItem.name,
info: nationItem.info,
simpleName: nationItem.name,
notAvailable: nationItem.notAvailable,
searchText: convertSearch초성(nationItem.name).join("|"),
};
if (nationItem.id == props.modelValue) {
selectedNation.value = obj;
}
forFind.value.push(obj);
targets.value.set(nationItem.id, obj);
}
});
</script> </script>