拆分 EQPage 页面,新增分享码功能,修复 bug,优化性能
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { PeqEqUi } from "./types";
|
||||
|
||||
export type ShareApiAction = "create" | "query" | "accept" | "list";
|
||||
|
||||
export function resolveShareApiMessage(
|
||||
action: ShareApiAction,
|
||||
res: { code: number; msg?: string },
|
||||
eqUi: PeqEqUi,
|
||||
): string {
|
||||
if (res.code === 200) return "";
|
||||
|
||||
if (action === "list") {
|
||||
return eqUi.mySharesLoadFail ?? "Failed to load share list";
|
||||
}
|
||||
|
||||
if (res.code === 0) {
|
||||
if (action === "create") {
|
||||
return eqUi.shareActiveExists ?? eqUi.shareCreateFail ?? "Failed to generate share code";
|
||||
}
|
||||
return eqUi.importCodeNotFound ?? "Share code not found or expired";
|
||||
}
|
||||
|
||||
if (res.code === 400) {
|
||||
return eqUi.shareInvalidParams ?? eqUi.shareCreateFail ?? "Invalid request";
|
||||
}
|
||||
|
||||
if (res.code === 500) {
|
||||
return eqUi.shareSystemError ?? eqUi.shareCreateFail ?? "System error";
|
||||
}
|
||||
|
||||
if (action === "create") {
|
||||
return eqUi.shareCreateFail ?? "Failed to generate share code";
|
||||
}
|
||||
|
||||
if (action === "accept") {
|
||||
return eqUi.importFail ?? eqUi.importCodeNotFound ?? "Failed to import EQ";
|
||||
}
|
||||
|
||||
return eqUi.importCodeNotFound ?? "Share code not found or expired";
|
||||
}
|
||||
Reference in New Issue
Block a user