@sv-print/plugin-cloud 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -258,6 +258,7 @@ interface CloudAPI {
258
258
  // ---- 云打印 ----
259
259
  cloudPrint(opts: CloudPrintOptions): Promise<CloudJob>;
260
260
  getDevices(): Promise<CloudDevice[]>;
261
+ getDevicePrinters(deviceId: string): Promise<CloudPrinter[]>;
261
262
  getJobs(params?: Record<string, any>): Promise<PageResult<CloudJob>>;
262
263
  cancelJob(id: string | number): Promise<any>;
263
264
  retryJob(id: string | number): Promise<any>;
@@ -329,9 +330,18 @@ const off = cloud.auth.onChange((t) => console.log("登录态变更", t));
329
330
  await cloud.auth.logout();
330
331
  off();
331
332
 
332
- // 云打印
333
+ // 云打印:选设备 → 选打印机 → 下发任务
333
334
  const devices = await cloud.getDevices();
334
- await cloud.cloudPrint({ device_id: devices[0].device_id });
335
+ const device = devices[0];
336
+ const devicePrinters = await cloud.getDevicePrinters(device.device_id);
337
+ const selectedPrinter = devicePrinters.find((p) => p.isDefault && !p.disabled)
338
+ || devicePrinters.find((p) => !p.disabled);
339
+ if (!selectedPrinter) throw new Error("设备暂无可用打印机");
340
+ await cloud.cloudPrint({
341
+ device_id: device.device_id,
342
+ print_type: "template",
343
+ print_options: { printer: selectedPrinter.name, copies: 1, duplexMode: "simplex" },
344
+ });
335
345
 
336
346
  // 中转打印:选客户端 → 选打印机 → 直发
337
347
  const clients = await cloud.getTransitClients(); // 仅 clientType=electron 可作为目标
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { PrintOptionsForm } from "../lib/print-options";
3
+ declare const __propDef: {
4
+ props: {
5
+ value: PrintOptionsForm;
6
+ disabled?: boolean;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type PrintOptionsFormProps = typeof __propDef.props;
14
+ export type PrintOptionsFormEvents = typeof __propDef.events;
15
+ export type PrintOptionsFormSlots = typeof __propDef.slots;
16
+ export default class PrintOptionsForm extends SvelteComponentTyped<PrintOptionsFormProps, PrintOptionsFormEvents, PrintOptionsFormSlots> {
17
+ }
18
+ export {};
@@ -1,3 +1,4 @@
1
1
  import type { HookOptions } from "sv-print";
2
- declare const newPrintTemplateHook: () => HookOptions;
2
+ import type { PluginConfig } from "../types";
3
+ declare const newPrintTemplateHook: (config: PluginConfig) => HookOptions;
3
4
  export default newPrintTemplateHook;