Commit 7345d09d by qinjianhui

fix: C-lodop 问题修改

parent 28c24885
import { onMounted } from 'vue' import { onMounted } from 'vue'
export interface LODOPObject extends HTMLObjectElement { export interface LODOPObject extends HTMLObjectElement {
VERSION: string; VERSION: string
CVERSION: string; CVERSION: string
SET_LICENSES: (companyName: string, licenseA: string, licenseB: string, licenseC: string) => void; SET_LICENSES: (
GET_PRINTER_COUNT: () => number; companyName: string,
GET_PRINTER_NAME: (index: number) => string; licenseA: string,
PRINT_INIT: (printName: string) => void; licenseB: string,
SET_PRINTER_INDEX: (printerName: string) => void | string | number | boolean; licenseC: string,
SET_PRINT_MODE: (mode: string, value: boolean) => void; ) => void
On_Return: (id: string, value: string) => void; GET_PRINTER_COUNT: () => number
On_Return_Remain: boolean; GET_PRINTER_NAME: (index: number) => string
PRINT_INIT: (printName: string) => void
SEND_PRINT_RAWDATA: (data: string) => void; SET_PRINTER_INDEX: (printerName: string) => void | string | number | boolean
ADD_PRINT_PDF: (x: number, y: number, width: string, height: string, url: string) => void; SET_PRINT_MODE: (mode: string, value: boolean) => void
ADD_PRINT_IMAGE: (x: number, y: number, width: string, height: string, url: string) => void; On_Return: (id: string, value: string) => void
GET_VALUE: (valueType: string, valueIndex: string | unknown) => string; On_Return_Remain: boolean
PRINT: () => string;
PRINTA: () => string; SEND_PRINT_RAWDATA: (data: string) => void
ADD_PRINT_PDF: (
x: number,
y: number,
width: string,
height: string,
url: string,
) => void
ADD_PRINT_IMAGE: (
x: number,
y: number,
width: string,
height: string,
url: string,
) => void
GET_VALUE: (valueType: string, valueIndex: string | unknown) => string
PRINT: () => string
PRINTA: () => string
} }
export interface CLodopObject { export interface CLodopObject {
CVERSION: string; CVERSION: string
GET_STATUS: () => number; GET_STATUS: () => number
GET_VALUE: (valueType: string, valueIndex: string | unknown) => string; GET_VALUE: (valueType: string, valueIndex: string | unknown) => string
} }
declare global { declare global {
interface Window { interface Window {
LODOP: new () => LODOPObject; LODOP: new () => LODOPObject
_lodop:LODOPObject | null; _lodop: LODOPObject | null
_lodopCallback:{ [key: string]: Function }; _lodopCallback: { [key: string]: Function }
CLODOP: CLodopObject; CLODOP: CLodopObject
getCLodop: () => LODOPObject; getCLodop: () => LODOPObject
} }
} }
...@@ -92,13 +109,13 @@ export default function useLodop() { ...@@ -92,13 +109,13 @@ export default function useLodop() {
const JS1 = document.createElement('script') const JS1 = document.createElement('script')
const JS2 = document.createElement('script') const JS2 = document.createElement('script')
if (window.location.protocol == 'https:') { // if (window.location.protocol == 'https:') {
JS1.src = 'https://localhost.lodop.net:8443/CLodopfuncs.js' // JS1.src = 'https://localhost.lodop.net:8443/CLodopfuncs.js'
JS2.src = 'https://localhost.lodop.net:8444/CLodopfuncs.js' // JS2.src = 'https://localhost.lodop.net:8444/CLodopfuncs.js'
} else { // } else {
JS1.src = 'http://localhost:8000/CLodopfuncs.js' JS1.src = 'http://localhost:8000/CLodopfuncs.js'
JS2.src = 'http://localhost:18000/CLodopfuncs.js' JS2.src = 'http://localhost:18000/CLodopfuncs.js'
} // }
JS1.onload = JS2.onload = function () { JS1.onload = JS2.onload = function () {
CLodopJsState = 'complete' CLodopJsState = 'complete'
} }
...@@ -109,7 +126,10 @@ export default function useLodop() { ...@@ -109,7 +126,10 @@ export default function useLodop() {
head.insertBefore(JS2, head.firstChild) head.insertBefore(JS2, head.firstChild)
CLodopIsLocal = !!(JS1.src + JS2.src).match(/\/\/localho|\/\/127.0.0./i) CLodopIsLocal = !!(JS1.src + JS2.src).match(/\/\/localho|\/\/127.0.0./i)
} }
const getCLodop = (oOBJECT: LODOPObject | null, oEMBED: LODOPObject | null): LODOPObject | null => { const getCLodop = (
oOBJECT: LODOPObject | null,
oEMBED: LODOPObject | null,
): LODOPObject | null => {
const strFontTag = '<font _#_>打印控件' const strFontTag = '<font _#_>打印控件'
const strLodopInstall = const strLodopInstall =
strFontTag + strFontTag +
...@@ -157,9 +177,11 @@ export default function useLodop() { ...@@ -157,9 +177,11 @@ export default function useLodop() {
/Trident/i.test(navigator.userAgent) /Trident/i.test(navigator.userAgent)
const isWinIE64 = isWinIE && /x64/i.test(navigator.userAgent) const isWinIE64 = isWinIE && /x64/i.test(navigator.userAgent)
const isLinuxX86 = const isLinuxX86 =
/Linux/i.test(navigator.userAgent) && /x86_64/i.test(navigator.userAgent) /Linux/i.test(navigator.userAgent) &&
/x86_64/i.test(navigator.userAgent)
const isLinuxARM = const isLinuxARM =
/Linux/i.test(navigator.userAgent) && /aarch64/i.test(navigator.userAgent) /Linux/i.test(navigator.userAgent) &&
/aarch64/i.test(navigator.userAgent)
if (needCLodop || isLinuxX86 || isLinuxARM) { if (needCLodop || isLinuxX86 || isLinuxARM) {
try { try {
...@@ -168,9 +190,9 @@ export default function useLodop() { ...@@ -168,9 +190,9 @@ export default function useLodop() {
console.error(err) console.error(err)
} }
if (!LODOP && CLodopJsState !== 'complete') { if (!LODOP && CLodopJsState !== 'complete') {
if (CLodopJsState == 'loading'){ if (CLodopJsState == 'loading') {
console.log('网页还没下载完毕,请稍等一下再操作.') console.log('网页还没下载完毕,请稍等一下再操作.')
}else{ } else {
console.log('未曾加载Lodop主JS文件,请先调用loadCLodop过程.') console.log('未曾加载Lodop主JS文件,请先调用loadCLodop过程.')
} }
return null return null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment