cleanup
This commit is contained in:
@@ -19,7 +19,9 @@ const model = defineModel<{ [key: string]: CommandParameterData }>({
|
||||
required: true,
|
||||
});
|
||||
|
||||
const { data: command_info } = useCommand(props.command_name);
|
||||
const { data: command_info, error: command_error } = useCommand(
|
||||
props.command_name,
|
||||
);
|
||||
|
||||
watch([command_info], ([cmd_info]) => {
|
||||
if (cmd_info == null) {
|
||||
@@ -97,6 +99,9 @@ watch([command_info], ([cmd_info]) => {
|
||||
></CommandParameterDataConfigurator>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else-if="command_error">
|
||||
<span>Error: {{ command_error }}</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span> Loading... </span>
|
||||
</template>
|
||||
|
||||
@@ -41,8 +41,13 @@ export function useCommand(name: MaybeRefOrGetter<string>) {
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/cmd/${name_value}`);
|
||||
data.value = await res.json();
|
||||
error.value = null;
|
||||
if (res.ok) {
|
||||
data.value = await res.json();
|
||||
error.value = null;
|
||||
} else {
|
||||
data.value = null;
|
||||
error.value = await res.text();
|
||||
}
|
||||
} catch (e) {
|
||||
data.value = null;
|
||||
error.value = e;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
export function toJsonString(data: any): string {
|
||||
return JSON.stringify(data, (_key, value) => {
|
||||
if (typeof value == 'bigint') {
|
||||
// @ts-expect-error TS2339
|
||||
return JSON.rawJSON(value.toString());
|
||||
}
|
||||
return value;
|
||||
@@ -10,6 +11,7 @@ export function toJsonString(data: any): string {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function parseJsonString(data: string): any {
|
||||
// @ts-expect-error TS2345, TS7006
|
||||
return JSON.parse(data, (key, value, context) => {
|
||||
if (key === 'Int64' || key == 'Unsigned64') {
|
||||
// Or use the constructor of your custom high-precision number library
|
||||
|
||||
Reference in New Issue
Block a user