chore: add frontend types

This commit is contained in:
gaoshuaixing
2025-01-11 15:47:15 +08:00
parent 2fe71b0f27
commit 13f6d16598
16 changed files with 73 additions and 75 deletions

View File

@@ -36,13 +36,13 @@ import { message } from 'ant-design-vue';
const serverUrl = ref('');
function info() {
ipc.invoke(ipcApiRoute.cross.crossInfo, {}).then(res => {
ipc.invoke(ipcApiRoute.cross.crossInfo, {}).then((res: any) => {
console.log('res:', res);
})
}
function getUrl() {
ipc.invoke(ipcApiRoute.cross.getCrossUrl, {name: 'goapp'}).then(url => {
ipc.invoke(ipcApiRoute.cross.getCrossUrl, {name: 'goapp'}).then((url: string) => {
serverUrl.value = url;
message.info(`服务地址: ${url}`);
})
@@ -57,14 +57,14 @@ function create() {
ipc.invoke(ipcApiRoute.cross.createCrossServer, { program: 'go' })
}
function request(type) {
function request(type: number) {
if (type == 1 && serverUrl.value == "") {
message.info("请先获取服务地址");
return
}
if (type == 1) {
const testApi = serverUrl.value + '/api/hello';
const cfg = {
const cfg: Record<string, any> = {
method: 'get',
url: testApi,
params: { id: '111'},
@@ -76,7 +76,7 @@ function request(type) {
message.info(`服务返回: ${data}`);
})
} else {
ipc.invoke(ipcApiRoute.cross.requestApi, {name: 'goapp', urlPath: '/api/hello'}).then(res => {
ipc.invoke(ipcApiRoute.cross.requestApi, {name: 'goapp', urlPath: '/api/hello'}).then((res: any) => {
console.log('res:', res);
if (res) {
const { data} = res;

View File

@@ -36,13 +36,13 @@ import { message } from 'ant-design-vue';
const serverUrl = ref('');
function info() {
ipc.invoke(ipcApiRoute.cross.crossInfo, {}).then(res => {
ipc.invoke(ipcApiRoute.cross.crossInfo, {}).then((res: any) => {
console.log('res:', res);
})
}
function getUrl() {
ipc.invoke(ipcApiRoute.cross.getCrossUrl, {name: 'javaapp'}).then(url => {
ipc.invoke(ipcApiRoute.cross.getCrossUrl, {name: 'javaapp'}).then((url: string) => {
serverUrl.value = url;
message.info(`服务地址: ${url}`);
})
@@ -57,7 +57,7 @@ function create() {
ipc.invoke(ipcApiRoute.cross.createCrossServer, { program: 'java' })
}
function request(type) {
function request(type: number) {
if (type == 1 && serverUrl.value == "") {
message.info("请先获取服务地址");
return
@@ -65,7 +65,7 @@ function request(type) {
if (type == 1) {
const testApi = serverUrl.value + '/test1/get';
const cfg = {
const cfg: Record<string, any> = {
method: 'get',
url: testApi,
params: { id: '1111111'},
@@ -77,7 +77,7 @@ function request(type) {
message.info(`服务返回: ${data}`);
})
} else {
ipc.invoke(ipcApiRoute.cross.requestApi, {name: 'javaapp', urlPath: '/test1/get', params: { id: '1111111'}}).then(res => {
ipc.invoke(ipcApiRoute.cross.requestApi, {name: 'javaapp', urlPath: '/test1/get', params: { id: '1111111'}}).then((res: any) => {
console.log('res:', res);
const data = res || null;
message.info(`服务返回: ${data}`);

View File

@@ -36,13 +36,13 @@ import { message } from 'ant-design-vue';
const serverUrl = ref('');
function info() {
ipc.invoke(ipcApiRoute.cross.crossInfo, {}).then(res => {
ipc.invoke(ipcApiRoute.cross.crossInfo, {}).then((res: any) => {
console.log('res:', res);
})
}
function getUrl() {
ipc.invoke(ipcApiRoute.cross.getCrossUrl, {name: 'pyapp'}).then(url => {
ipc.invoke(ipcApiRoute.cross.getCrossUrl, {name: 'pyapp'}).then((url: string) => {
serverUrl.value = url;
message.info(`服务地址: ${url}`);
})
@@ -57,14 +57,14 @@ function create() {
ipc.invoke(ipcApiRoute.cross.createCrossServer, { program: 'python' })
}
function request(type) {
function request(type: number) {
if (type == 1 && serverUrl.value == "") {
message.info("请先获取服务地址");
return
}
if (type == 1) {
const testApi = serverUrl.value + '/api/hello';
const cfg = {
const cfg: Record<string, any> = {
method: 'get',
url: testApi,
params: { id: '111'},
@@ -76,7 +76,7 @@ function request(type) {
message.info(`服务返回: ${JSON.stringify(data)}`);
})
} else {
ipc.invoke(ipcApiRoute.cross.requestApi, {name: 'pyapp', urlPath: '/api/hello'}).then(res => {
ipc.invoke(ipcApiRoute.cross.requestApi, {name: 'pyapp', urlPath: '/api/hello'}).then((res: any) => {
console.log('res:', res);
const data = res || null;
message.info(`服务返回: ${JSON.stringify(data)}`);

View File

@@ -84,7 +84,7 @@ function init() {
ipc.removeAllListeners(ipcApiRoute.framework.createPoolNotice);
// 监听任务进度
ipc.on(ipcApiRoute.framework.timerJobProgress, (event, result) => {
ipc.on(ipcApiRoute.framework.timerJobProgress, (event: any, result: Record<string, any>) => {
const { jobId, pid, number} = result;
switch (jobId) {
case 1:
@@ -115,18 +115,18 @@ function init() {
})
// 监听pool
ipc.on(ipcApiRoute.framework.createPoolNotice, (event, result) => {
ipc.on(ipcApiRoute.framework.createPoolNotice, (event: any, result: any) => {
processPids.value = JSON.stringify(result);
})
}
function runJob(jobId, operation) {
function runJob(jobId: number, operation: string) {
const params = {
jobId,
type: 'timer',
action: operation
}
ipc.invoke(ipcApiRoute.framework.someJob, params).then(data => {
ipc.invoke(ipcApiRoute.framework.someJob, params).then((data: any) => {
if (operation != 'create') return;
switch (data.jobId) {
case 1:
@@ -146,13 +146,13 @@ function createPool() {
ipc.send(ipcApiRoute.framework.createPool, params);
}
function runJobByPool(jobId, operation) {
function runJobByPool(jobId: number, operation: string) {
const params = {
jobId,
type: 'timer',
action: operation
}
ipc.invoke(ipcApiRoute.framework.someJobByPool, params).then(data => {
ipc.invoke(ipcApiRoute.framework.someJobByPool, params).then((data: any) => {
const { jobId, result} = data;
switch (jobId) {
case 3:

View File

@@ -41,7 +41,7 @@ onMounted(() => {
})
function init() {
ipc.invoke(ipcApiRoute.framework.checkHttpServer, {}).then(r => {
ipc.invoke(ipcApiRoute.framework.checkHttpServer, {}).then((r: any) => {
if (r.enable) {
currentStatus.value = '开启';
servicAddress.value = r.server;
@@ -50,21 +50,19 @@ function init() {
})
}
function sendRequest(id) {
function sendRequest(id: string) {
if (currentStatus.value == '关闭') {
message.error('http服务未开启');
return;
}
requestHttp(ipcApiRoute.framework.doHttpRequest, {id}).then(res => {
//console.log('res:', res)
})
requestHttp(ipcApiRoute.framework.doHttpRequest, {id})
}
/**
* Accessing built-in HTTP services
*/
function requestHttp(uri, parameter) {
function requestHttp(uri: string, parameter: any) {
// URL conversion
const config = storage.get('httpServiceConfig');
const host = config.server || 'http://localhost:7071';
@@ -84,7 +82,7 @@ function requestHttp(uri, parameter) {
*/
function backendRequest() {
console.log('GO_URL:', import.meta.env.VITE_GO_URL);
const cfg = {
const cfg: Record<string, any> = {
baseURL: import.meta.env.VITE_GO_URL,
method: 'get',
url: '/hello',
@@ -93,7 +91,7 @@ function backendRequest() {
axios(cfg).then(res => {
console.log('res:', res);
const data = res.data || null;
this.$message.info(`go服务返回: ${data}`, );
message.info(`go服务返回: ${data}`, );
})
}
</script>

View File

@@ -78,7 +78,7 @@ onMounted(() => {
function init() {
// 避免重复监听,或者将 on 功能写到一个统一的地方,只加载一次
ipc.removeAllListeners(ipcApiRoute.framework.ipcSendMsg);
ipc.on(ipcApiRoute.framework.ipcSendMsg, (event, result) => {
ipc.on(ipcApiRoute.framework.ipcSendMsg, (event: any, result: string) => {
console.log('[ipcRenderer] [socketMsgStart] result:', result);
messageString.value = result;
@@ -88,7 +88,7 @@ function init() {
// 监听 窗口2 发来的消息
ipc.removeAllListeners(ipcApiRoute.os.window2ToWindow1);
ipc.on(ipcApiRoute.os.window2ToWindow1, (event, arg) => {
ipc.on(ipcApiRoute.os.window2ToWindow1, (event: any, arg: any) => {
message.info(arg);
})
}
@@ -110,7 +110,7 @@ function sendMsgStop() {
}
function handleInvoke() {
ipc.invoke(ipcApiRoute.framework.ipcInvokeMsg, '异步-回调').then(r => {
ipc.invoke(ipcApiRoute.framework.ipcInvokeMsg, '异步-回调').then((r: any) => {
console.log('r:', r);
message1.value = r;
});
@@ -128,7 +128,7 @@ function handleSendSync() {
}
function createWindow() {
ipc.invoke(ipcApiRoute.os.createWindow, vueItem).then(wcid => {
ipc.invoke(ipcApiRoute.os.createWindow, vueItem).then((wcid: number | string) => {
console.log('[createWindow] wcid:', wcid);
})
}

View File

@@ -32,7 +32,7 @@ import { message } from 'ant-design-vue';
const currentStatus = ref('关闭');
const servicAddress = ref('ws://localhost:7070');
const client = {
socket: null
socket: null as any,
};
onMounted(() => {
@@ -47,14 +47,14 @@ function init() {
});
}
function sendRequest(id) {
function sendRequest(id: string) {
if (currentStatus.value == '关闭') {
message.error('socketio服务未开启');
return;
}
const method = ipcApiRoute.framework.doSocketRequest;
client.socket.emit('c1', { cmd: method, args: {id} }, (response) => {
client.socket.emit('c1', { cmd: method, args: {id} }, (response: any) => {
// response为返回值
console.log('response:', response)
});

View File

@@ -26,7 +26,7 @@ import { message } from 'ant-design-vue';
const soft = ref('powershell.exe');
function openSoft() {
ipc.invoke(ipcApiRoute.framework.openSoftware, {softName: soft.value}).then(result => {
ipc.invoke(ipcApiRoute.framework.openSoftware, {softName: soft.value}).then((result: any) => {
if (!result) {
message.error('程序不存在');
}

View File

@@ -183,7 +183,7 @@ function init() {
const params = {
action: 'getDataDir',
}
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then(res => {
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then((res: any) => {
if (res.code == -1) {
message.error('请检查sqlite是否正确安装', 5);
return
@@ -198,7 +198,7 @@ function getAllTestData () {
const params = {
action: 'all',
}
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then(res => {
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then((res: any) => {
if (res.all_list.length == 0) {
return false;
}
@@ -207,10 +207,10 @@ function getAllTestData () {
}
function selectDir() {
ipc.invoke(ipcApiRoute.os.selectFolder, '').then(r => {
data_dir.value = r;
ipc.invoke(ipcApiRoute.os.selectFolder, '').then((res: any) => {
data_dir.value = res;
// 修改数据目录
modifyDataDir(r);
modifyDataDir(res);
})
}
@@ -219,32 +219,32 @@ function openDir() {
ipc.invoke(ipcApiRoute.os.openDirectory, {id: data_dir.value})
}
function modifyDataDir(dir) {
function modifyDataDir(dir: string) {
const params = {
action: 'setDataDir',
data_dir: dir
}
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then(res => {
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then((res: any) => {
all_list.value = res.all_list;
})
}
function sqlitedbOperation (ac) {
function sqlitedbOperation (ac: string) {
const params = {
action: ac,
info: {
name: name.value,
age: parseInt(age.value)
age: age.value
},
search_age: parseInt(search_age.value),
search_age: search_age.value,
update_name: update_name.value,
update_age: parseInt(update_age.value),
update_age: update_age.value,
delete_name: delete_name.value,
}
if (ac == 'add' && name.value.length == 0) {
message.error(`请填写数据`);
}
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then(res => {
ipc.invoke(ipcApiRoute.framework.sqlitedbOperation, params).then((res: any) => {
console.log('res:', res);
if (ac == 'get') {
if (res.result.length == 0) {

View File

@@ -40,7 +40,7 @@ onMounted(() => {
function init() {
ipc.removeAllListeners(specialIpcRoute.appUpdater);
ipc.on(specialIpcRoute.appUpdater, (event, result) => {
ipc.on(specialIpcRoute.appUpdater, (event: any, result: any) => {
result = JSON.parse(result);
status.value = result.status;
if (result.status == 3) {
@@ -53,8 +53,8 @@ function init() {
}
function checkForUpdater () {
ipc.invoke(ipcApiRoute.framework.checkForUpdater).then(r => {
console.log(r);
ipc.invoke(ipcApiRoute.framework.checkForUpdater).then((res: any) => {
console.log(res);
})
}
@@ -63,8 +63,8 @@ function download () {
message.info('没有可用版本');
return
}
ipc.invoke(ipcApiRoute.framework.downloadApp).then(r => {
console.log(r);
ipc.invoke(ipcApiRoute.framework.downloadApp).then((res: any) => {
console.log(res);
})
}
</script>

View File

@@ -78,26 +78,26 @@ const fileList = [
const dir_path = ref('D:\\www\\ee');
function openDirectry (id) {
function openDirectry (id: string) {
ipc.invoke(ipcApiRoute.os.openDirectory, {id: id})
}
function selectDir() {
ipc.invoke(ipcApiRoute.os.selectFolder).then(r => {
dir_path.value = r;
message.info(r);
ipc.invoke(ipcApiRoute.os.selectFolder).then((res: any) => {
dir_path.value = res;
message.info(res);
})
}
function messageShow() {
ipc.invoke(ipcApiRoute.os.messageShow).then(r => {
message.info(r);
ipc.invoke(ipcApiRoute.os.messageShow).then((res: any) => {
message.info(res);
})
}
function messageShowConfirm() {
ipc.invoke(ipcApiRoute.os.messageShowConfirm).then(r => {
message.info(r);
ipc.invoke(ipcApiRoute.os.messageShowConfirm).then((res: any) => {
message.info(res);
})
}
</script>

View File

@@ -7,7 +7,7 @@
</div>
<div class="one-block-2">
<a-space>
<a-button @click="selectPic(0)">选择图片</a-button>
<a-button @click="selectPic()">选择图片</a-button>
</a-space>
<p></p>
<a-image
@@ -25,8 +25,8 @@ import { ref } from 'vue';
const picPath = ref('https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png');
function selectPic() {
ipc.invoke(ipcApiRoute.os.selectPic).then(r => {
picPath.value = r;
ipc.invoke(ipcApiRoute.os.selectPic).then((res: any) => {
picPath.value = res;
})
}
</script>

View File

@@ -59,14 +59,14 @@ onMounted(() => {
function init() {
// Avoid duplicate monitoring, or write the on function to a unified place and load it only once
ipc.removeAllListeners(ipcApiRoute.os.sendNotification);
ipc.on(ipcApiRoute.os.sendNotification, (event, result) => {
ipc.on(ipcApiRoute.os.sendNotification, (event: any, result: any) => {
if (Object.prototype.toString.call(result) == '[object Object]') {
message.info(result.msg);
}
})
}
function sendNotification (index) {
function sendNotification (index: number) {
ipc.send(ipcApiRoute.os.sendNotification, views[index]);
}
</script>

View File

@@ -68,7 +68,7 @@ onMounted(() => {
})
function init() {
ipc.on(ipcApiRoute.framework.ipcSendMsg, (event, result) => {
ipc.on(ipcApiRoute.framework.ipcSendMsg, (event: any, result: any) => {
console.log('[ipcRenderer] [socketMsgStart] result:', result);
messageString.value = result;
@@ -78,7 +78,7 @@ function init() {
// 监听主窗口发来的消息
ipc.removeAllListeners(ipcApiRoute.os.window1ToWindow2);
ipc.on(ipcApiRoute.os.window1ToWindow2, (event, arg) => {
ipc.on(ipcApiRoute.os.window1ToWindow2, (event: any, arg: any) => {
message.info(arg);
})
}
@@ -100,9 +100,9 @@ function sendMsgStop() {
}
function handleInvoke () {
ipc.invoke(ipcApiRoute.framework.ipcInvokeMsg, '异步-回调').then(r => {
console.log('r:', r);
message1.value = r;
ipc.invoke(ipcApiRoute.framework.ipcInvokeMsg, '异步-回调').then((res: any) => {
console.log('r:', res);
message1.value = res;
});
}

View File

@@ -57,7 +57,7 @@ const views = [
},
];
function createWindow(index) {
function createWindow(index: number) {
ipc.invoke(ipcApiRoute.os.createWindow, views[index])
}
</script>

View File

@@ -23,11 +23,11 @@
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
"./src/*"
],
}
},
"include":["src/**/*.ts", "src/**/*.vue", "src/**/*.tsx", "src/**/*.d.ts", "*.d.ts"],
"include":["./src/**/*.ts", "./src/**/*.vue", "./src/**/*.tsx", "./src/**/*.d.ts", "*.d.ts"],
"exclude": [
"node_modules",
"dist"