@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 +12 -2
- package/dist/components/print-options-form.svelte.d.ts +18 -0
- package/dist/hooks/newPrintTemplate.d.ts +2 -1
- package/dist/index.js +9 -7
- package/dist/index.mjs +3515 -2447
- package/dist/index.umd.js +9 -7
- package/dist/lib/cloud-api.d.ts +3 -1
- package/dist/lib/cloud-context.d.ts +5 -4
- package/dist/lib/print-options.d.ts +17 -0
- package/dist/lib/transit-client.d.ts +8 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +19 -1
- package/package.json +1 -1
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
|
-
|
|
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 {};
|