-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
2,079 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="data:;base64,=" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + Vue</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<script setup> | ||
import { ref, watch, toRaw } from "vue"; | ||
const count = ref(0); | ||
const res = ref([``]); | ||
watch(res, async (newVal, oldVal) => { | ||
newVal = toRaw(newVal) | ||
if (typeof newVal === `object`) { | ||
let [a, b] = newVal; | ||
res.value = [`是否执行失败: ${a}`, `返回值: ${b}`].join(`\n`); | ||
} | ||
}); | ||
const list = ref([]); | ||
const ws = window.main.ws; | ||
list.value = [ | ||
{ | ||
name: `创建目录`, | ||
async fn() { | ||
const dir = "C:/my/"; | ||
res.value = await ws.call(`run`, [ | ||
` | ||
var arg = ... | ||
fsys.createDir(arg) | ||
`, | ||
dir, | ||
]); | ||
console.log(`res.value`, res.value); | ||
}, | ||
}, | ||
{ | ||
name: `下载文件`, | ||
async fn() { | ||
const url = | ||
"https://download.microsoft.com/download/7/4/A/74A33AB3-B6F3-435D-8E3E-0A9FD574347F/services-on-server-install-worksheet.xlsx"; | ||
res.value = await ws.call(`run`, [ | ||
` | ||
var arg = ... | ||
var remoteFile = inet.httpFile(arg ,"C:/my/") | ||
return remoteFile.download() | ||
`, | ||
url, | ||
]); | ||
}, | ||
}, | ||
{ | ||
name: `定位文件`, | ||
async fn() { | ||
const url = "C:/my/services-on-server-install-worksheet.xlsx"; | ||
res.value = await ws.call(`run`, [ | ||
` | ||
var arg = ... | ||
process.exploreSelect(arg); | ||
`, | ||
url, | ||
]); | ||
}, | ||
}, | ||
{ | ||
name: `上传文件`, | ||
async fn() { | ||
res.value = await ws.call(`run`, [ | ||
` | ||
var http = inet.http(); | ||
http.addHeaders = "Name1:value1"; | ||
var formData = web.multipartFormData(); | ||
formData.add("file1","@C:/my/services-on-server-install-worksheet.xlsx") | ||
var data = http.post("http://httpbin.org/post" | ||
, formData.readAll() | ||
, formData.contentHeader() | ||
); | ||
return data | ||
`, | ||
]); | ||
}, | ||
}, | ||
{ | ||
name: `打开文件`, | ||
async fn() { | ||
res.value = await ws.call(`run`, [ | ||
` | ||
process.execute("C:/my/services-on-server-install-worksheet.xlsx") | ||
`, | ||
]); | ||
}, | ||
}, | ||
{ | ||
name: `打开记事本`, | ||
async fn() { | ||
res.value = await ws.call(`run`, [ | ||
` | ||
process.execute("notepad") | ||
`, | ||
]); | ||
}, | ||
}, | ||
{ | ||
name: `删除目录`, | ||
async fn() { | ||
res.value = await ws.call(`run`, [ | ||
` | ||
import process.popen | ||
process.popen("cmd /k rd /s /q C:\\my") | ||
`, | ||
]); | ||
}, | ||
}, | ||
{ | ||
name: `弹窗`, | ||
async fn() { | ||
main.win.msgbox(`hello`); | ||
}, | ||
}, | ||
{ | ||
name: `退出`, | ||
async fn() { | ||
main.win.quitMessage(); | ||
}, | ||
}, | ||
]; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div>sys-shim</div> | ||
<button v-for="(item, index) in list" :key="index" @click="item.fn"> | ||
{{ item.name }} | ||
</button> | ||
<hr /> | ||
<textarea disabled id="" cols="50" rows="10" :value="res"></textarea> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import './browser.js' | ||
|
||
const ws = window.ext.wsUrl ? undefined : `ws://127.0.0.1:7788` | ||
new Sys(ws).then(async main => { | ||
console.log(`初始化完成`, main) | ||
window.main = main | ||
createApp(App).mount('#app') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
const RPCWebSocket = require(`rpc-websockets`) | ||
import * as RPCWebSocket from 'rpc-websockets' | ||
import SysRef from './sys.js' | ||
|
||
global.ext = global.ext || JSON.parse(global.process.env.ext || `{}`) | ||
globalThis.ext = globalThis.ext || JSON.parse(globalThis.process.env.ext || `{}`) | ||
class Sys extends SysRef { | ||
constructor(wsUrl) { | ||
return new Promise(async (resolve) => { | ||
wsUrl = wsUrl || `${await global.ext.wsUrl}?token=${await global.ext.token }` | ||
wsUrl = wsUrl || `${await globalThis.ext.wsUrl}?token=${await globalThis.ext.token }` | ||
const ws = new RPCWebSocket.Client(await wsUrl) | ||
const that = await super(ws) | ||
resolve(that) | ||
}) | ||
} | ||
} | ||
global.Sys = Sys | ||
globalThis.Sys = Sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
css: { | ||
devSourcemap: true // this one | ||
}, | ||
define: { | ||
// By default, Vite doesn't include shims for NodeJS/ | ||
// necessary for segment analytics lib to work | ||
global: {}, | ||
}, | ||
}) |
Oops, something went wrong.