🚨 修复 qodana 报错

This commit is contained in:
BTMuli
2023-12-21 00:30:42 +08:00
parent 100cb96dac
commit 88d2e6126a
3 changed files with 7 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
/** /**
* @file types/BBS/Response.d.ts * @file types/BBS/Response.d.ts
* @description BBS 返回数据类型定义文件 * @description BBS 返回数据类型定义文件
* @since Beta v0.3.6 * @since Beta v0.3.9
*/ */
/** /**
@@ -14,14 +14,14 @@ declare namespace TGApp.BBS.Response {
/** /**
* @description 基础返回类型,设计米游社接口请求都是这个类型 * @description 基础返回类型,设计米游社接口请求都是这个类型
* @interface Base * @interface Base
* @since Beta v0.3.5 * @since Beta v0.3.9
* @property {never} retcode - 响应代码 * @property {never} retcode - 响应代码
* @property {string} message - 响应消息 * @property {string} message - 响应消息
* @property {never} data - 响应数据 * @property {never} data - 响应数据
* @return Base * @return Base
*/ */
interface Base { interface Base {
retcode: never; retcode: number;
message: string; message: string;
data: never; data: never;
} }

View File

@@ -35,14 +35,6 @@ declare namespace TGApp.Plugins.JSBridge {
*/ */
type NullArg = Arg<null>; type NullArg = Arg<null>;
/**
* @description 通用 arg 参数-未知参数
* @since Beta v0.3.9
* @interface UnknownArg
* @return UnknownArg
*/
type UnknownArg = Arg<unknown>;
/** /**
* @description configShare 方法参数 * @description configShare 方法参数
* @since Beta v0.3.9 * @since Beta v0.3.9

View File

@@ -173,7 +173,7 @@ class TGClient {
* @returns {Promise<void>} - 返回值 * @returns {Promise<void>} - 返回值
*/ */
async handleCallback(arg: Event<string>): Promise<void> { async handleCallback(arg: Event<string>): Promise<void> {
const argParse: TGApp.Plugins.JSBridge.UnknownArg = JSON.parse(<string>arg.payload); const argParse: TGApp.Plugins.JSBridge.Arg<any> = JSON.parse(<string>arg.payload);
if (argParse.method.startsWith("teyvat")) { if (argParse.method.startsWith("teyvat")) {
await this.handleCustomCallback(argParse); await this.handleCustomCallback(argParse);
return; return;
@@ -271,16 +271,16 @@ class TGClient {
* @func handleCustomCallback * @func handleCustomCallback
* @since Beta v0.3.9 * @since Beta v0.3.9
* @desc 处理自定义的 callback * @desc 处理自定义的 callback
* @param {TGApp.Plugins.JSBridge.UnknownArg} arg - 事件参数 * @param {TGApp.Plugins.JSBridge.Arg<any>} arg - 事件参数
* @returns {Promise<void>} - 返回值 * @returns {Promise<void>} - 返回值
*/ */
async handleCustomCallback(arg: TGApp.Plugins.JSBridge.UnknownArg): Promise<void> { async handleCustomCallback(arg: TGApp.Plugins.JSBridge.Arg<any>): Promise<void> {
switch (arg.method) { switch (arg.method) {
case "teyvat_open": case "teyvat_open":
createPost(<string>arg.payload); createPost(<string>arg.payload);
break; break;
default: default:
console.warn(`[customCallback] ${arg.payload}`); console.warn(`[customCallback] ${arg.method}`);
} }
} }