refac: SammoAPI에 타입 지정
This commit is contained in:
@@ -102,10 +102,11 @@ import { isString } from "lodash";
|
|||||||
import { entriesWithType } from "./util/entriesWithType";
|
import { entriesWithType } from "./util/entriesWithType";
|
||||||
import TopItem from "@/ChiefCenter/TopItem.vue";
|
import TopItem from "@/ChiefCenter/TopItem.vue";
|
||||||
import BottomItem from "@/ChiefCenter/BottomItem.vue";
|
import BottomItem from "@/ChiefCenter/BottomItem.vue";
|
||||||
import type { ChiefResponse, OptionalFull } from "./defs";
|
import type { OptionalFull } from "./defs";
|
||||||
import { SammoAPI } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
import { unwrap } from "@/util/unwrap";
|
import { unwrap } from "@/util/unwrap";
|
||||||
import { StoredActionsHelper } from "./util/StoredActionsHelper";
|
import { StoredActionsHelper } from "./util/StoredActionsHelper";
|
||||||
|
import type { ChiefResponse } from "./defs/API/NationCommand";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
maxChiefTurn: VueTypes.number.isRequired,
|
maxChiefTurn: VueTypes.number.isRequired,
|
||||||
@@ -145,7 +146,7 @@ watch(viewTarget, (val) => {
|
|||||||
|
|
||||||
async function reloadTable(): Promise<void> {
|
async function reloadTable(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const response = await SammoAPI.NationCommand.GetReservedCommand<ChiefResponse>();
|
const response = await SammoAPI.NationCommand.GetReservedCommand();
|
||||||
console.log(response);
|
console.log(response);
|
||||||
for (const [key, value] of entriesWithType(response)) {
|
for (const [key, value] of entriesWithType(response)) {
|
||||||
if (key === "result") {
|
if (key === "result") {
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ import TopBackBar from "@/components/TopBackBar.vue";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
|
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
|
||||||
import { SammoAPI } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
|
import type { inheritBuffType } from "./defs/API/InheritAction";
|
||||||
|
|
||||||
type InheritanceType =
|
type InheritanceType =
|
||||||
| "previous"
|
| "previous"
|
||||||
@@ -292,15 +293,6 @@ const inheritanceViewText: Record<InheritanceViewType, { title: string; info: st
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
type inheritBuffType =
|
|
||||||
| "warAvoidRatio"
|
|
||||||
| "warCriticalRatio"
|
|
||||||
| "warMagicTrialProb"
|
|
||||||
| "domesticSuccessProb"
|
|
||||||
| "domesticFailProb"
|
|
||||||
| "warAvoidRatioOppose"
|
|
||||||
| "warCriticalRatioOppose"
|
|
||||||
| "warMagicTrialProbOppose";
|
|
||||||
|
|
||||||
declare const currentInheritBuff: {
|
declare const currentInheritBuff: {
|
||||||
[v in inheritBuffType]: number | undefined;
|
[v in inheritBuffType]: number | undefined;
|
||||||
@@ -481,7 +473,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await SammoAPI.InheritAction[type]({});
|
await SammoAPI.InheritAction[type]();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
alert(`실패했습니다: ${e}`);
|
alert(`실패했습니다: ${e}`);
|
||||||
|
|||||||
@@ -27,21 +27,18 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
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 { BettingInfo, ToastType } from "@/defs";
|
import type { ToastType } from "@/defs";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { SammoAPI, type ValidResponse } from "./SammoAPI";
|
import { SammoAPI } from "./SammoAPI";
|
||||||
import { isString } from "lodash";
|
import { isString } from "lodash";
|
||||||
import { parseYearMonth } from "@/util/parseYearMonth";
|
import { parseYearMonth } from "@/util/parseYearMonth";
|
||||||
import { joinYearMonth } from "./util/joinYearMonth";
|
import { joinYearMonth } from "./util/joinYearMonth";
|
||||||
import BettingDetail from "@/components/BettingDetail.vue";
|
import BettingDetail from "@/components/BettingDetail.vue";
|
||||||
import { BContainer, useToast } from "bootstrap-vue-3";
|
import { BContainer, useToast } from "bootstrap-vue-3";
|
||||||
import { unwrap } from "./util/unwrap";
|
import { unwrap } from "./util/unwrap";
|
||||||
|
import type { BettingListResponse } from "./defs/API/Betting";
|
||||||
|
|
||||||
|
|
||||||
type BettingListResponse = ValidResponse & {
|
|
||||||
bettingList: Record<number, Omit<BettingInfo & { totalAmount: number }, "candidates">>;
|
|
||||||
year: number;
|
|
||||||
month: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
const toasts = unwrap(useToast());
|
const toasts = unwrap(useToast());
|
||||||
const year = ref<number>();
|
const year = ref<number>();
|
||||||
@@ -58,7 +55,7 @@ function addToast(msg: ToastType) {
|
|||||||
console.log("시작!");
|
console.log("시작!");
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
const result = await SammoAPI.Betting.GetBettingList<BettingListResponse>();
|
const result = await SammoAPI.Betting.GetBettingList();
|
||||||
year.value = result.year;
|
year.value = result.year;
|
||||||
month.value = result.month;
|
month.value = result.month;
|
||||||
yearMonth.value = joinYearMonth(result.year, result.month);
|
yearMonth.value = joinYearMonth(result.year, result.month);
|
||||||
|
|||||||
@@ -296,17 +296,7 @@ import type { TurnObj } from "@/defs";
|
|||||||
import type { Args } from "./processing/args";
|
import type { Args } from "./processing/args";
|
||||||
import { QueryActionHelper } from "./util/QueryActionHelper";
|
import { QueryActionHelper } from "./util/QueryActionHelper";
|
||||||
import SimpleClock from "./components/SimpleClock.vue";
|
import SimpleClock from "./components/SimpleClock.vue";
|
||||||
|
import type { ReservedCommandResponse } from "./defs/API/Command";
|
||||||
type ReservedCommandResponse = {
|
|
||||||
result: true;
|
|
||||||
turnTime: string;
|
|
||||||
turnTerm: number;
|
|
||||||
year: number;
|
|
||||||
month: number;
|
|
||||||
date: string;
|
|
||||||
turn: TurnObj[];
|
|
||||||
autorun_limit: null | number;
|
|
||||||
};
|
|
||||||
|
|
||||||
const { maxTurn, maxPushTurn, commandList } = staticValues;
|
const { maxTurn, maxPushTurn, commandList } = staticValues;
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -3,6 +3,10 @@ import type { Args } from "./processing/args";
|
|||||||
import { callSammoAPI, extractHttpMethod, GET, PATCH, POST, PUT, type APITail, type APICallT, type RawArgType, type ValidResponse, type InvalidResponse } from "./util/callSammoAPI";
|
import { callSammoAPI, extractHttpMethod, GET, PATCH, POST, PUT, type APITail, type APICallT, type RawArgType, type ValidResponse, type InvalidResponse } from "./util/callSammoAPI";
|
||||||
export type { ValidResponse, InvalidResponse };
|
export type { ValidResponse, InvalidResponse };
|
||||||
import { APIPathGen, NumVar } from "./util/APIPathGen.js";
|
import { APIPathGen, NumVar } from "./util/APIPathGen.js";
|
||||||
|
import type { BettingListResponse } from "./defs/API/Betting";
|
||||||
|
import type { ReservedCommandResponse } from "./defs/API/Command";
|
||||||
|
import type { ChiefResponse } from "./defs/API/NationCommand";
|
||||||
|
import type { inheritBuffType } from "./defs/API/InheritAction";
|
||||||
|
|
||||||
const apiRealPath = {
|
const apiRealPath = {
|
||||||
Betting: {
|
Betting: {
|
||||||
@@ -10,11 +14,11 @@ const apiRealPath = {
|
|||||||
GetBettingDetail: NumVar('betting_id',
|
GetBettingDetail: NumVar('betting_id',
|
||||||
GET as APICallT<undefined, BettingDetailResponse>
|
GET as APICallT<undefined, BettingDetailResponse>
|
||||||
),
|
),
|
||||||
GetBettingList: GET,
|
GetBettingList: GET as APICallT<undefined, BettingListResponse>,
|
||||||
},
|
},
|
||||||
Command: {
|
Command: {
|
||||||
GetReservedCommand: GET as APICallT<undefined>,
|
GetReservedCommand: GET as APICallT<undefined, ReservedCommandResponse>,
|
||||||
PushCommand: PATCH,
|
PushCommand: PATCH as APICallT<{amount: number}>,
|
||||||
RepeatCommand: PATCH,
|
RepeatCommand: PATCH,
|
||||||
ReserveCommand: PUT,
|
ReserveCommand: PUT,
|
||||||
ReserveBulkCommand: PUT as APICallT<{
|
ReserveBulkCommand: PUT as APICallT<{
|
||||||
@@ -27,17 +31,17 @@ const apiRealPath = {
|
|||||||
Join: POST,
|
Join: POST,
|
||||||
},
|
},
|
||||||
InheritAction: {
|
InheritAction: {
|
||||||
BuyHiddenBuff: PUT,
|
BuyHiddenBuff: PUT as APICallT<{type: inheritBuffType, level: number}>,
|
||||||
BuyRandomUnique: PUT,
|
BuyRandomUnique: PUT as APICallT<undefined>,
|
||||||
BuySpecificUnique: PUT,
|
BuySpecificUnique: PUT,
|
||||||
ResetSpecialWar: PUT,
|
ResetSpecialWar: PUT as APICallT<undefined>,
|
||||||
ResetTurnTime: PUT,
|
ResetTurnTime: PUT as APICallT<undefined>,
|
||||||
SetNextSpecialWar: PUT,
|
SetNextSpecialWar: PUT,
|
||||||
},
|
},
|
||||||
Misc: { UploadImage: POST },
|
Misc: { UploadImage: POST },
|
||||||
NationCommand: {
|
NationCommand: {
|
||||||
GetReservedCommand: GET,
|
GetReservedCommand: GET as APICallT<undefined, ChiefResponse>,
|
||||||
PushCommand: PATCH,
|
PushCommand: PATCH as APICallT<{amount: number}>,
|
||||||
RepeatCommand: PATCH,
|
RepeatCommand: PATCH,
|
||||||
ReserveCommand: PUT,
|
ReserveCommand: PUT,
|
||||||
ReserveBulkCommand: PUT as APICallT<{
|
ReserveBulkCommand: PUT as APICallT<{
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import type { ValidResponse, BettingInfo } from "@/defs";
|
||||||
|
|
||||||
|
export type BettingListResponse = ValidResponse & {
|
||||||
|
bettingList: Record<number, Omit<BettingInfo & { totalAmount: number }, "candidates">>;
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import type { TurnObj } from "@/defs";
|
||||||
|
|
||||||
|
export type ReservedCommandResponse = {
|
||||||
|
result: true;
|
||||||
|
turnTime: string;
|
||||||
|
turnTerm: number;
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
date: string;
|
||||||
|
turn: TurnObj[];
|
||||||
|
autorun_limit: null | number;
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export type inheritBuffType =
|
||||||
|
| "warAvoidRatio"
|
||||||
|
| "warCriticalRatio"
|
||||||
|
| "warMagicTrialProb"
|
||||||
|
| "domesticSuccessProb"
|
||||||
|
| "domesticFailProb"
|
||||||
|
| "warAvoidRatioOppose"
|
||||||
|
| "warCriticalRatioOppose"
|
||||||
|
| "warMagicTrialProbOppose";
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import type { CommandItem, TurnObj } from "@/defs";
|
||||||
|
|
||||||
|
export type ChiefResponse = {
|
||||||
|
result: true;
|
||||||
|
lastExecute: string;
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
turnTerm: number;
|
||||||
|
date: string;
|
||||||
|
chiefList: Record<
|
||||||
|
number,
|
||||||
|
{
|
||||||
|
name: string | undefined;
|
||||||
|
turnTime: string | undefined;
|
||||||
|
officerLevelText: string;
|
||||||
|
officerLevel: number;
|
||||||
|
npcType: number;
|
||||||
|
turn: TurnObj[];
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
isChief: boolean;
|
||||||
|
autorun_limit: number;
|
||||||
|
officerLevel: number;
|
||||||
|
commandList: {
|
||||||
|
category: string;
|
||||||
|
values: CommandItem[];
|
||||||
|
}[];
|
||||||
|
mapName: string,
|
||||||
|
unitSet: string,
|
||||||
|
};
|
||||||
@@ -200,36 +200,6 @@ export type CommandItem = {
|
|||||||
searchText?: string;
|
searchText?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChiefResponse = {
|
|
||||||
result: true;
|
|
||||||
lastExecute: string;
|
|
||||||
year: number;
|
|
||||||
month: number;
|
|
||||||
turnTerm: number;
|
|
||||||
date: string;
|
|
||||||
chiefList: Record<
|
|
||||||
number,
|
|
||||||
{
|
|
||||||
name: string | undefined;
|
|
||||||
turnTime: string | undefined;
|
|
||||||
officerLevelText: string;
|
|
||||||
officerLevel: number;
|
|
||||||
npcType: number;
|
|
||||||
turn: TurnObj[];
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
isChief: boolean;
|
|
||||||
autorun_limit: number;
|
|
||||||
officerLevel: number;
|
|
||||||
commandList: {
|
|
||||||
category: string;
|
|
||||||
values: CommandItem[];
|
|
||||||
}[];
|
|
||||||
mapName: string,
|
|
||||||
unitSet: string,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
type diplomacyInfo = {
|
type diplomacyInfo = {
|
||||||
name: string,
|
name: string,
|
||||||
color?: string,
|
color?: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user