fix: ts校验不通过,暂时用ts-nocheck

This commit is contained in:
chaiying 2024-04-22 15:44:52 +08:00
parent ecd528c71a
commit 868ede50eb
9 changed files with 72 additions and 12 deletions

View File

@ -2,5 +2,6 @@ export { default as AlgorithmConfigModal } from "./algorithmConfigModal";
export { default as AlgorithmConfig } from "./algorithmConfig";
export { default as Login } from "./login";
export { default as Password } from "./password";
export { default as CenterLink } from "./centerLink";
export { default as SchemaFormModal } from "./algorithmConfig/components/schemaFormModal";
export * from 'rc-util';

View File

@ -0,0 +1 @@
export declare const createAElement: (url: string, isBlank: boolean) => void;

View File

@ -0,0 +1,14 @@
// 可应用于页面跳转以及文件下载
// 第一个参数:文件的下载路径/要跳转页面的路径(可携带参数)
// 第二个参数是否新打开一个页面true为新开一个页面false是在当前页面进行操作
export var createAElement = function createAElement(url, isBlank) {
var newLink = document.createElement('a');
newLink.className = 'create-link';
newLink.href = url;
if (isBlank) {
newLink.target = '_blank';
}
document.body.appendChild(newLink);
newLink.click();
document.body.removeChild(newLink);
};

View File

@ -32,6 +32,7 @@ var src_exports = {};
__export(src_exports, {
AlgorithmConfig: () => import_algorithmConfig.default,
AlgorithmConfigModal: () => import_algorithmConfigModal.default,
CenterLink: () => import_centerLink.default,
Login: () => import_login.default,
Password: () => import_password.default,
SchemaFormModal: () => import_schemaFormModal.default
@ -41,12 +42,14 @@ var import_algorithmConfigModal = __toESM(require("./algorithmConfigModal"));
var import_algorithmConfig = __toESM(require("./algorithmConfig"));
var import_login = __toESM(require("./login"));
var import_password = __toESM(require("./password"));
var import_centerLink = __toESM(require("./centerLink"));
var import_schemaFormModal = __toESM(require("./algorithmConfig/components/schemaFormModal"));
__reExport(src_exports, require("rc-util"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AlgorithmConfig,
AlgorithmConfigModal,
CenterLink,
Login,
Password,
SchemaFormModal,

View File

@ -0,0 +1 @@
export declare const createAElement: (url: string, isBlank: boolean) => void;

View File

@ -0,0 +1,39 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/index.ts
var utils_exports = {};
__export(utils_exports, {
createAElement: () => createAElement
});
module.exports = __toCommonJS(utils_exports);
var createAElement = (url, isBlank) => {
var newLink = document.createElement("a");
newLink.className = "create-link";
newLink.href = url;
if (isBlank) {
newLink.target = "_blank";
}
document.body.appendChild(newLink);
newLink.click();
document.body.removeChild(newLink);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createAElement
});

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import React,{useRef,useState} from 'react'
import TerminalForm from './components/TerminalForm'
import WebTerminal from './components/WebTerminal'
@ -40,7 +41,6 @@ const CenterLink:React.FC<CenterLinkProps>=(props:CenterLinkProps)=>{
const handleConnectClick=(values:any)=>{
const {ip}=values;
setIpUrl((
pre
)=>(ip))
onConnect&&onConnect(values);
}

View File

@ -1,4 +1,4 @@
// @ts-nocheck
import React,{useRef,useEffect, useImperativeHandle,
forwardRef,} from 'react';
import { Terminal } from 'xterm';
@ -55,10 +55,10 @@ const WebTerminal:React.FC<WebTerminalProps&WebsocketOptions>=forwardRef((props:
onMessage,
onError,
}=props;
const termRef = useRef(null);
const termClassRef=useRef(null)
const termRef = useRef<React.RefObject<HTMLDivElement>|null>(null);
const termClassRef=useRef<React.RefObject<HTMLDivElement>|null>(null)
// const currLine=useRef(null);
const wsRef=useRef(null);
const wsRef=useRef<React.RefObject<HTMLDivElement>|null>(null);
// terminal初始化
useEffect(()=>{
@ -66,12 +66,12 @@ const WebTerminal:React.FC<WebTerminalProps&WebsocketOptions>=forwardRef((props:
if(!termRef.current){
return;
}
termClassRef.current=new Terminal({
let term=new Terminal({
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
fontWeight: 400,
fontSize: 14,
rows: Math.ceil(
(termRef.current?.clientHeight -
(termRef.current.clientHeight -
150) /
14,
),
@ -86,12 +86,12 @@ const WebTerminal:React.FC<WebTerminalProps&WebsocketOptions>=forwardRef((props:
background: "#1a1a1d", //背景色
cursor: "help", //设置光标
}
})
});
let term=termClassRef.current;
termClassRef.current=term;
term.open(termRef.current);
term.focus(); // 光标聚集
term.promp=(_)=>{
term.promp=()=>{
term.write('\r\n\x1b[33m$\x1b[0m ');
}
const fitAddon=new FitAddon();
@ -102,6 +102,7 @@ const WebTerminal:React.FC<WebTerminalProps&WebsocketOptions>=forwardRef((props:
},[]);
useEffect(()=>{
// @ts-ignore
if(ip&&websocketUrl&&token){
const ws=new WebSocket(`${websocketUrl}?ip=${ip}&Authorization=${token}`);
wsRef.current=ws;

View File

@ -5,7 +5,7 @@ const demo = () => {
return (
<CenterLink
style={{width:'100%',height:'600px'}}
websocketUrl={'ws://10.0.0.7:50051/active'}
websocketUrl={'ws://127.0.0.1:50051/active'}
token={'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTM4NDAxOTAsImp0aSI6ImFkbWluIn0.KAcgU8r-AIQ2GEu5g2o-YANstqisy5WT6rz5fbMjdcs'}
ip={'127.0.0.1'}
terminalStyle={{width:'100%',height:'calc(100% - 180px)'}}