vue: NPCControl(WIP)

This commit is contained in:
2021-09-07 03:03:25 +09:00
parent 28ad1b6c9d
commit c4a6735d60
10 changed files with 427 additions and 813 deletions
+10 -10
View File
@@ -1,28 +1,28 @@
import { isArray, isString, isNumber, isBoolean } from "lodash";
export function convertFormData(values: Record<string, null|number[]|string[]|boolean[]|number|string|boolean>): FormData{
export function convertFormData(values: Record<string, null | number[] | string[] | boolean[] | number | string | boolean>): FormData {
const formData = new FormData();
const simpleConv = (v: unknown, key: string):string=>{
if(isString(v)){
const simpleConv = (v: unknown, key: string): string => {
if (isString(v)) {
return v;
}
if(isNumber(v)){
if (isNumber(v)) {
return v.toString();
}
if(isBoolean(v)){
return v?'true':'false';
if (isBoolean(v)) {
return v ? 'true' : 'false';
}
if(v===null){
if (v === null) {
return '';
}
throw new TypeError(`지원하지 않는 formData Type: ${key}`);
}
for(const [key, value] of Object.entries(values)){
if(isArray(value)){
for (const [key, value] of Object.entries(values)) {
if (isArray(value)) {
const arrKey = `${key}[]`;
for(const subValue of value){
for (const subValue of value) {
formData.append(arrKey, simpleConv(subValue, key));
}
continue;