remove unused codes and update
This commit is contained in:
@@ -28,6 +28,11 @@ export interface INativeBridgeResult<T = unknown> {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface INativeBridgeDeviceInfo {
|
||||
deviceName: string;
|
||||
androidId: string;
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class NativeBridgeService {
|
||||
private readonly toastService = inject(ToastService);
|
||||
@@ -108,6 +113,19 @@ export class NativeBridgeService {
|
||||
return this.invokePrint(request);
|
||||
}
|
||||
|
||||
async getDeviceInfo(): Promise<INativeBridgeResult<INativeBridgeDeviceInfo>> {
|
||||
if (!this.isEnabled()) {
|
||||
return { success: false, error: 'متاسفانه ارتباط با دستگاه برقرار نیست.' };
|
||||
}
|
||||
try {
|
||||
// @ts-ignore
|
||||
const deviceInfo = await window.NativeBridge.deviceInfo();
|
||||
return { success: true, data: JSON.parse(deviceInfo) };
|
||||
} catch (error) {
|
||||
return { success: false, error: (error as Error).message };
|
||||
}
|
||||
}
|
||||
|
||||
private invokePrint(payload: INativePrintRequest): INativeBridgeResult {
|
||||
if (!this.isEnabled() || !this.canPrint()) {
|
||||
this.toastService.warn({ text: 'متاسفانه ارتباط با چاپگر برقرار نیست.' });
|
||||
|
||||
Reference in New Issue
Block a user