vg-print 1.1.306 → 1.1.309
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 +15 -5
- package/dist/style.css +1 -1
- package/dist/vg-print.es.js +27370 -27516
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1026,12 +1026,22 @@ await exportImage(tpl, printData, {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
})
|
|
1028
1028
|
|
|
1029
|
-
// 6) 客户端直连打印(需要本地客户端)
|
|
1030
|
-
setHiwebSocket('http://127.0.0.1:17521', 'your-token') // 遵循 autoConnect 状态
|
|
1031
|
-
// 或者使用标准 API(设置即连接)
|
|
1032
|
-
// setHost('http://127.0.0.1:17521', 'your-token')
|
|
1033
1029
|
|
|
1034
|
-
|
|
1030
|
+
// 6) 页面层次的重新设置链接 -使用下面前提是主程序main.js中注入的scoket的时候需要先取消自动连接
|
|
1031
|
+
// a) 先关掉自动连接开关(防止又被拉起)
|
|
1032
|
+
/* import { disAutoConnect, setSocketIo } from 'vg-print'
|
|
1033
|
+
import { io } from 'socket.io-client'
|
|
1034
|
+
|
|
1035
|
+
disAutoConnect() // 关键:先把 window.autoConnect 置 false
|
|
1036
|
+
setSocketIo(io) // 再注入 io(这一步不会触发连接了)*/
|
|
1037
|
+
|
|
1038
|
+
// b) 然后页面重新设置链接-页面里需要连接/切换端口时,需要重新设置链接
|
|
1039
|
+
setHiwebSocket('http://127.0.0.1:8091', 'token') // 这里只设置并不会自动连(因为你 main.js 已经 disAutoConnect 了)
|
|
1040
|
+
connect()
|
|
1041
|
+
|
|
1042
|
+
// c)或者使用标准 API(设置即连接)-页面层次的重新设置链接-这种一般会自动链接页面初始化的时候
|
|
1043
|
+
setHost('http://127.0.0.1:17521', 'your-token') // setHost 内部会 stop + start(若你已 disAutoConnect,可改为 setHiwebSocket + connect)
|
|
1044
|
+
|
|
1035
1045
|
|
|
1036
1046
|
// 6.1) 获取打印机列表
|
|
1037
1047
|
// 方式 A: 异步获取 (推荐) - 会触发刷新并等待返回
|