Files
core/hwe/ts/PageChiefCenter.vue
T
Hide_D 4f4533e533 refac: linter 관련 설정 변경 및 적용, map_theme 변수 제거
- eslint에 prettier 조합
- prettierrc에 width 120, tabWidth 2
- gameStor->map_theme 제거
- map_theme, mapTheme를 GameConst::$mapName으로 대체
- eslint에서 vue/vue3-essential 대신 vue3-recommended 적용
  - vue/max-attributes-per-line 완화
  - vue/v-on-event-hyphenation 해제
  - vue/attribute-hyphenation 해제
- 일부 tsc import type warning 해결
- 일부 vue template type warning 해결
- 일부 vue SFC를 script setup으로 변경
  - TipTap
  - TopBackBar
  - BottomBackBar
  - BoardArticle
  - ProcessCity
2022-03-29 02:06:47 +09:00

209 lines
6.3 KiB
Vue

<template>
<div id="container" class="pageChiefCenter">
<TopBackBar title="사령부" reloadable @reload="reloadTable" />
<div v-if="chiefList !== undefined" id="mainTable" :class="`${targetIsMe ? 'targetIsMe' : 'targetIsNotMe'}`">
<template v-for="(chiefLevel, vidx) in [12, 10, 8, 6, 11, 9, 7, 5]" :key="chiefLevel">
<div v-if="vidx % 4 == 0" :class="['turnIdx', vidx == 0 && !targetIsMe ? undefined : 'only1000px']">
<div :class="['subRows', 'bg0']" :style="mainTableGridRows">
<div class="bg1">&nbsp;</div>
<div v-for="idx in maxChiefTurn" :key="idx" :class="[`turnIdxLeft`, 'align-self-center', 'center']">
{{ idx }}
</div>
</div>
</div>
<div
v-for="(officer, idx) in [chiefList[chiefLevel]]"
:key="idx"
:class="[`${viewTarget == chiefLevel ? '' : 'only1000px'}`]"
>
<TopItem
v-if="officerLevel != chiefLevel"
:style="mainTableGridRows"
:officer="officer"
:maxTurn="maxChiefTurn"
:turnTerm="turnTerm"
/>
<ChiefReservedCommand
v-else
:key="idx"
:targetIsMe="targetIsMe"
:year="year"
:month="month"
:turn="officer.turn"
:turnTerm="turnTerm"
:commandList="unwrap(commandList)"
:turnTime="officer.turnTime"
:maxTurn="maxChiefTurn"
:maxPushTurn="Math.floor(maxChiefTurn / 2)"
:date="date"
:officer="officer"
@raiseReload="reloadTable()"
/>
</div>
<div v-if="vidx % 4 == 3" :class="['turnIdx', vidx == 7 && !targetIsMe ? undefined : 'only1000px']">
<div :class="['subRows', 'bg0']" :style="mainTableGridRows">
<div class="bg1">&nbsp;</div>
<div v-for="idx in maxChiefTurn" :key="idx" :class="[`turnIdxRight`, 'align-self-center', 'center']">
{{ idx }}
</div>
</div>
</div>
</template>
</div>
</div>
<div v-if="chiefList" id="bottomChiefBox">
<div id="bottomChiefList" class="c-bg2">
<template v-for="(chiefLevel, vidx) in [12, 10, 8, 6, 11, 9, 7, 5]" :key="chiefLevel">
<div v-if="vidx % 4 == 0" class="turnIdx subRows bg0" :style="subTableGridRows">
<div class="bg1" style="grid-row: 1/3" />
<div v-for="idx in maxChiefTurn" :key="idx" :class="[`turnIdxLeft`]">
{{ idx }}
</div>
</div>
<BottomItem
:chiefLevel="chiefLevel"
:chiefList="chiefList"
:style="subTableGridRows"
:isMe="chiefLevel == officerLevel"
@click="viewTarget = chiefLevel"
/>
<div v-if="vidx % 4 == 3" class="turnIdx subRows bg0" :style="subTableGridRows">
<div class="bg1" style="grid-row: 1/3" />
<div v-for="idx in maxChiefTurn" :key="idx" :class="`turnIdxRight`">
{{ idx }}
</div>
</div>
</template>
</div>
</div>
<div id="bottomBar">
<BottomBar />
</div>
</template>
<script lang="ts">
declare const staticValues: {
serverNick: string;
mapName: string;
unitSet: string;
};
</script>
<script lang="ts" setup>
import "@scss/common/bootstrap5.scss";
import "@scss/game_bg.scss";
import "../../css/config.css";
import { computed, provide, reactive, ref, toRefs, watch } from "vue";
import ChiefReservedCommand from "@/components/ChiefReservedCommand.vue";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import VueTypes from "vue-types";
import { isString } from "lodash";
import { entriesWithType } from "./util/entriesWithType";
import TopItem from "@/ChiefCenter/TopItem.vue";
import BottomItem from "@/ChiefCenter/BottomItem.vue";
import type { ChiefResponse, OptionalFull } from "./defs";
import { SammoAPI } from "./SammoAPI";
import { unwrap } from "@/util/unwrap";
import { StoredActionsHelper } from "./util/StoredActionsHelper";
const props = defineProps({
maxChiefTurn: VueTypes.number.isRequired,
});
const tableObj = reactive<Omit<OptionalFull<ChiefResponse>, "result">>({
lastExecute: undefined,
year: undefined,
month: undefined,
turnTerm: undefined,
date: undefined,
chiefList: undefined,
isChief: undefined,
autorun_limit: undefined,
officerLevel: undefined,
commandList: undefined,
mapName: undefined,
unitSet: undefined,
});
const { year, month, turnTerm, date, chiefList, officerLevel, commandList } = toRefs(tableObj);
const viewTarget = ref<number | undefined>();
const targetIsMe = ref<boolean>(false);
watch(viewTarget, (val) => {
console.log("targetChange!", val, targetIsMe);
if (val === undefined) {
targetIsMe.value = false;
return;
}
if (tableObj.officerLevel === undefined) {
targetIsMe.value = false;
}
targetIsMe.value = val === tableObj.officerLevel;
});
async function reloadTable(): Promise<void> {
try {
const response = await SammoAPI.NationCommand.GetReservedCommand<ChiefResponse>();
console.log(response);
for (const [key, value] of entriesWithType(response)) {
if (key === "result") {
continue;
}
if (key === "officerLevel") {
if (value < 5) {
tableObj.officerLevel = undefined;
} else {
tableObj.officerLevel = value as number;
}
continue;
}
//HACK:
tableObj[key as unknown as "year"] = value as unknown as undefined;
}
if (viewTarget.value === undefined) {
if (!tableObj.officerLevel) {
viewTarget.value = 12;
} else {
viewTarget.value = tableObj.officerLevel;
}
}
} catch (e) {
if (isString(e)) {
alert(e);
}
console.error(e);
return;
}
}
const mainTableGridRows = computed(() => {
return {
gridTemplateRows: `24px repeat(${props.maxChiefTurn}, 30px)`,
};
});
const subTableGridRows = computed(() => {
return {
gridTemplateRows: `36px repeat(${props.maxChiefTurn + 1}, 1fr)`,
};
});
void reloadTable();
const storedActionsHelper = new StoredActionsHelper(
staticValues.serverNick,
"nation",
staticValues.mapName,
staticValues.unitSet
);
provide("storedNationActionsHelper", storedActionsHelper);
</script>
<style lang="scss">
@import "@scss/chiefCenter.scss";
</style>