refac: SammoAPI에 타입 지정
This commit is contained in:
@@ -102,10 +102,11 @@ 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 type { OptionalFull } from "./defs";
|
||||
import { SammoAPI } from "./SammoAPI";
|
||||
import { unwrap } from "@/util/unwrap";
|
||||
import { StoredActionsHelper } from "./util/StoredActionsHelper";
|
||||
import type { ChiefResponse } from "./defs/API/NationCommand";
|
||||
|
||||
const props = defineProps({
|
||||
maxChiefTurn: VueTypes.number.isRequired,
|
||||
@@ -145,7 +146,7 @@ watch(viewTarget, (val) => {
|
||||
|
||||
async function reloadTable(): Promise<void> {
|
||||
try {
|
||||
const response = await SammoAPI.NationCommand.GetReservedCommand<ChiefResponse>();
|
||||
const response = await SammoAPI.NationCommand.GetReservedCommand();
|
||||
console.log(response);
|
||||
for (const [key, value] of entriesWithType(response)) {
|
||||
if (key === "result") {
|
||||
|
||||
@@ -206,6 +206,7 @@ import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import _ from "lodash";
|
||||
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
|
||||
import { SammoAPI } from "./SammoAPI";
|
||||
import type { inheritBuffType } from "./defs/API/InheritAction";
|
||||
|
||||
type InheritanceType =
|
||||
| "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: {
|
||||
[v in inheritBuffType]: number | undefined;
|
||||
@@ -481,7 +473,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
try {
|
||||
await SammoAPI.InheritAction[type]({});
|
||||
await SammoAPI.InheritAction[type]();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(`실패했습니다: ${e}`);
|
||||
|
||||
@@ -27,21 +27,18 @@
|
||||
<script lang="ts" setup>
|
||||
import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import BottomBar from "@/components/BottomBar.vue";
|
||||
import type { BettingInfo, ToastType } from "@/defs";
|
||||
import type { ToastType } from "@/defs";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { SammoAPI, type ValidResponse } from "./SammoAPI";
|
||||
import { SammoAPI } from "./SammoAPI";
|
||||
import { isString } from "lodash";
|
||||
import { parseYearMonth } from "@/util/parseYearMonth";
|
||||
import { joinYearMonth } from "./util/joinYearMonth";
|
||||
import BettingDetail from "@/components/BettingDetail.vue";
|
||||
import { BContainer, useToast } from "bootstrap-vue-3";
|
||||
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 year = ref<number>();
|
||||
@@ -58,7 +55,7 @@ function addToast(msg: ToastType) {
|
||||
console.log("시작!");
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const result = await SammoAPI.Betting.GetBettingList<BettingListResponse>();
|
||||
const result = await SammoAPI.Betting.GetBettingList();
|
||||
year.value = result.year;
|
||||
month.value = 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 { QueryActionHelper } from "./util/QueryActionHelper";
|
||||
import SimpleClock from "./components/SimpleClock.vue";
|
||||
|
||||
type ReservedCommandResponse = {
|
||||
result: true;
|
||||
turnTime: string;
|
||||
turnTerm: number;
|
||||
year: number;
|
||||
month: number;
|
||||
date: string;
|
||||
turn: TurnObj[];
|
||||
autorun_limit: null | number;
|
||||
};
|
||||
import type { ReservedCommandResponse } from "./defs/API/Command";
|
||||
|
||||
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";
|
||||
export type { ValidResponse, InvalidResponse };
|
||||
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 = {
|
||||
Betting: {
|
||||
@@ -10,11 +14,11 @@ const apiRealPath = {
|
||||
GetBettingDetail: NumVar('betting_id',
|
||||
GET as APICallT<undefined, BettingDetailResponse>
|
||||
),
|
||||
GetBettingList: GET,
|
||||
GetBettingList: GET as APICallT<undefined, BettingListResponse>,
|
||||
},
|
||||
Command: {
|
||||
GetReservedCommand: GET as APICallT<undefined>,
|
||||
PushCommand: PATCH,
|
||||
GetReservedCommand: GET as APICallT<undefined, ReservedCommandResponse>,
|
||||
PushCommand: PATCH as APICallT<{amount: number}>,
|
||||
RepeatCommand: PATCH,
|
||||
ReserveCommand: PUT,
|
||||
ReserveBulkCommand: PUT as APICallT<{
|
||||
@@ -27,17 +31,17 @@ const apiRealPath = {
|
||||
Join: POST,
|
||||
},
|
||||
InheritAction: {
|
||||
BuyHiddenBuff: PUT,
|
||||
BuyRandomUnique: PUT,
|
||||
BuyHiddenBuff: PUT as APICallT<{type: inheritBuffType, level: number}>,
|
||||
BuyRandomUnique: PUT as APICallT<undefined>,
|
||||
BuySpecificUnique: PUT,
|
||||
ResetSpecialWar: PUT,
|
||||
ResetTurnTime: PUT,
|
||||
ResetSpecialWar: PUT as APICallT<undefined>,
|
||||
ResetTurnTime: PUT as APICallT<undefined>,
|
||||
SetNextSpecialWar: PUT,
|
||||
},
|
||||
Misc: { UploadImage: POST },
|
||||
NationCommand: {
|
||||
GetReservedCommand: GET,
|
||||
PushCommand: PATCH,
|
||||
GetReservedCommand: GET as APICallT<undefined, ChiefResponse>,
|
||||
PushCommand: PATCH as APICallT<{amount: number}>,
|
||||
RepeatCommand: PATCH,
|
||||
ReserveCommand: PUT,
|
||||
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;
|
||||
};
|
||||
|
||||
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 = {
|
||||
name: string,
|
||||
color?: string,
|
||||
|
||||
Reference in New Issue
Block a user