Private
Public Access
1
0
This commit is contained in:
2025-12-30 20:27:35 +08:00
commit 95d3a20292
24 changed files with 2145 additions and 0 deletions

13
web/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Go Desk</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

528
web/package-lock.json generated Normal file
View File

@@ -0,0 +1,528 @@
{
"name": "go-desk-web",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "go-desk-web",
"version": "1.0.0",
"dependencies": {
"@arco-design/web-vue": "^2.54.0",
"vue": "^3.4.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.0",
"vite": "^5.0.0"
}
},
"node_modules/@arco-design/color": {
"version": "0.4.0",
"license": "MIT",
"dependencies": {
"color": "^3.1.3"
}
},
"node_modules/@arco-design/web-vue": {
"version": "2.57.0",
"license": "MIT",
"dependencies": {
"@arco-design/color": "^0.4.0",
"b-tween": "^0.3.3",
"b-validate": "^1.5.3",
"compute-scroll-into-view": "^1.0.20",
"dayjs": "^1.11.13",
"number-precision": "^1.6.0",
"resize-observer-polyfill": "^1.5.1",
"scroll-into-view-if-needed": "^2.2.31",
"vue": "^3.1.0"
},
"peerDependencies": {
"vue": "^3.1.0"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.27.1",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.28.5",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/parser": {
"version": "7.28.5",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.28.5"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/types": {
"version": "7.28.5",
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.27.1",
"@babel/helper-validator-identifier": "^7.28.5"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.21.5",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.5",
"license": "MIT"
},
"node_modules/@rollup/rollup-win32-x64-gnu": {
"version": "4.54.0",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@rollup/rollup-win32-x64-msvc": {
"version": "4.54.0",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@types/estree": {
"version": "1.0.8",
"dev": true,
"license": "MIT"
},
"node_modules/@vitejs/plugin-vue": {
"version": "5.2.4",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.0.0 || >=20.0.0"
},
"peerDependencies": {
"vite": "^5.0.0 || ^6.0.0",
"vue": "^3.2.25"
}
},
"node_modules/@vue/compiler-core": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.28.5",
"@vue/shared": "3.5.26",
"entities": "^7.0.0",
"estree-walker": "^2.0.2",
"source-map-js": "^1.2.1"
}
},
"node_modules/@vue/compiler-dom": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@vue/compiler-core": "3.5.26",
"@vue/shared": "3.5.26"
}
},
"node_modules/@vue/compiler-sfc": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.28.5",
"@vue/compiler-core": "3.5.26",
"@vue/compiler-dom": "3.5.26",
"@vue/compiler-ssr": "3.5.26",
"@vue/shared": "3.5.26",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.21",
"postcss": "^8.5.6",
"source-map-js": "^1.2.1"
}
},
"node_modules/@vue/compiler-ssr": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@vue/compiler-dom": "3.5.26",
"@vue/shared": "3.5.26"
}
},
"node_modules/@vue/reactivity": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@vue/shared": "3.5.26"
}
},
"node_modules/@vue/runtime-core": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.5.26",
"@vue/shared": "3.5.26"
}
},
"node_modules/@vue/runtime-dom": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.5.26",
"@vue/runtime-core": "3.5.26",
"@vue/shared": "3.5.26",
"csstype": "^3.2.3"
}
},
"node_modules/@vue/server-renderer": {
"version": "3.5.26",
"license": "MIT",
"dependencies": {
"@vue/compiler-ssr": "3.5.26",
"@vue/shared": "3.5.26"
},
"peerDependencies": {
"vue": "3.5.26"
}
},
"node_modules/@vue/shared": {
"version": "3.5.26",
"license": "MIT"
},
"node_modules/b-tween": {
"version": "0.3.3",
"license": "MIT"
},
"node_modules/b-validate": {
"version": "1.5.3",
"license": "MIT"
},
"node_modules/color": {
"version": "3.2.1",
"license": "MIT",
"dependencies": {
"color-convert": "^1.9.3",
"color-string": "^1.6.0"
}
},
"node_modules/color-convert": {
"version": "1.9.3",
"license": "MIT",
"dependencies": {
"color-name": "1.1.3"
}
},
"node_modules/color-name": {
"version": "1.1.3",
"license": "MIT"
},
"node_modules/color-string": {
"version": "1.9.1",
"license": "MIT",
"dependencies": {
"color-name": "^1.0.0",
"simple-swizzle": "^0.2.2"
}
},
"node_modules/compute-scroll-into-view": {
"version": "1.0.20",
"license": "MIT"
},
"node_modules/csstype": {
"version": "3.2.3",
"license": "MIT"
},
"node_modules/dayjs": {
"version": "1.11.19",
"license": "MIT"
},
"node_modules/entities": {
"version": "7.0.0",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/esbuild": {
"version": "0.21.5",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=12"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.21.5",
"@esbuild/android-arm": "0.21.5",
"@esbuild/android-arm64": "0.21.5",
"@esbuild/android-x64": "0.21.5",
"@esbuild/darwin-arm64": "0.21.5",
"@esbuild/darwin-x64": "0.21.5",
"@esbuild/freebsd-arm64": "0.21.5",
"@esbuild/freebsd-x64": "0.21.5",
"@esbuild/linux-arm": "0.21.5",
"@esbuild/linux-arm64": "0.21.5",
"@esbuild/linux-ia32": "0.21.5",
"@esbuild/linux-loong64": "0.21.5",
"@esbuild/linux-mips64el": "0.21.5",
"@esbuild/linux-ppc64": "0.21.5",
"@esbuild/linux-riscv64": "0.21.5",
"@esbuild/linux-s390x": "0.21.5",
"@esbuild/linux-x64": "0.21.5",
"@esbuild/netbsd-x64": "0.21.5",
"@esbuild/openbsd-x64": "0.21.5",
"@esbuild/sunos-x64": "0.21.5",
"@esbuild/win32-arm64": "0.21.5",
"@esbuild/win32-ia32": "0.21.5",
"@esbuild/win32-x64": "0.21.5"
}
},
"node_modules/estree-walker": {
"version": "2.0.2",
"license": "MIT"
},
"node_modules/is-arrayish": {
"version": "0.3.4",
"license": "MIT"
},
"node_modules/magic-string": {
"version": "0.30.21",
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.5"
}
},
"node_modules/nanoid": {
"version": "3.3.11",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/number-precision": {
"version": "1.6.0",
"license": "MIT"
},
"node_modules/picocolors": {
"version": "1.1.1",
"license": "ISC"
},
"node_modules/postcss": {
"version": "8.5.6",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
"source-map-js": "^1.2.1"
},
"engines": {
"node": "^10 || ^12 || >=14"
}
},
"node_modules/resize-observer-polyfill": {
"version": "1.5.1",
"license": "MIT"
},
"node_modules/rollup": {
"version": "4.54.0",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.8"
},
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=18.0.0",
"npm": ">=8.0.0"
},
"optionalDependencies": {
"@rollup/rollup-android-arm-eabi": "4.54.0",
"@rollup/rollup-android-arm64": "4.54.0",
"@rollup/rollup-darwin-arm64": "4.54.0",
"@rollup/rollup-darwin-x64": "4.54.0",
"@rollup/rollup-freebsd-arm64": "4.54.0",
"@rollup/rollup-freebsd-x64": "4.54.0",
"@rollup/rollup-linux-arm-gnueabihf": "4.54.0",
"@rollup/rollup-linux-arm-musleabihf": "4.54.0",
"@rollup/rollup-linux-arm64-gnu": "4.54.0",
"@rollup/rollup-linux-arm64-musl": "4.54.0",
"@rollup/rollup-linux-loong64-gnu": "4.54.0",
"@rollup/rollup-linux-ppc64-gnu": "4.54.0",
"@rollup/rollup-linux-riscv64-gnu": "4.54.0",
"@rollup/rollup-linux-riscv64-musl": "4.54.0",
"@rollup/rollup-linux-s390x-gnu": "4.54.0",
"@rollup/rollup-linux-x64-gnu": "4.54.0",
"@rollup/rollup-linux-x64-musl": "4.54.0",
"@rollup/rollup-openharmony-arm64": "4.54.0",
"@rollup/rollup-win32-arm64-msvc": "4.54.0",
"@rollup/rollup-win32-ia32-msvc": "4.54.0",
"@rollup/rollup-win32-x64-gnu": "4.54.0",
"@rollup/rollup-win32-x64-msvc": "4.54.0",
"fsevents": "~2.3.2"
}
},
"node_modules/scroll-into-view-if-needed": {
"version": "2.2.31",
"license": "MIT",
"dependencies": {
"compute-scroll-into-view": "^1.0.20"
}
},
"node_modules/simple-swizzle": {
"version": "0.2.4",
"license": "MIT",
"dependencies": {
"is-arrayish": "^0.3.1"
}
},
"node_modules/source-map-js": {
"version": "1.2.1",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/vite": {
"version": "5.4.21",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"esbuild": "^0.21.3",
"postcss": "^8.4.43",
"rollup": "^4.20.0"
},
"bin": {
"vite": "bin/vite.js"
},
"engines": {
"node": "^18.0.0 || >=20.0.0"
},
"funding": {
"url": "https://github.com/vitejs/vite?sponsor=1"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
},
"peerDependencies": {
"@types/node": "^18.0.0 || >=20.0.0",
"less": "*",
"lightningcss": "^1.21.0",
"sass": "*",
"sass-embedded": "*",
"stylus": "*",
"sugarss": "*",
"terser": "^5.4.0"
},
"peerDependenciesMeta": {
"@types/node": {
"optional": true
},
"less": {
"optional": true
},
"lightningcss": {
"optional": true
},
"sass": {
"optional": true
},
"sass-embedded": {
"optional": true
},
"stylus": {
"optional": true
},
"sugarss": {
"optional": true
},
"terser": {
"optional": true
}
}
},
"node_modules/vue": {
"version": "3.5.26",
"license": "MIT",
"peer": true,
"dependencies": {
"@vue/compiler-dom": "3.5.26",
"@vue/compiler-sfc": "3.5.26",
"@vue/runtime-dom": "3.5.26",
"@vue/server-renderer": "3.5.26",
"@vue/shared": "3.5.26"
},
"peerDependencies": {
"typescript": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
}
}
}

19
web/package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "go-desk-web",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.4.0",
"@arco-design/web-vue": "^2.54.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.0",
"vite": "^5.0.0"
}
}

1
web/package.json.md5 Normal file
View File

@@ -0,0 +1 @@
0e83a53f44aeb269f56998d3dfad9991

224
web/src/App.vue Normal file
View File

@@ -0,0 +1,224 @@
<template>
<a-layout class="layout">
<a-layout-header class="header">
<div class="header-content">
<h2>Go Desk</h2>
<a-tabs v-model:active-key="activeTab" class="header-tabs">
<a-tab-pane key="user" title="用户查询" />
<a-tab-pane key="device" title="设备调用测试" />
</a-tabs>
</div>
</a-layout-header>
<a-layout-content class="content">
<!-- 用户查询页面 -->
<div v-if="activeTab === 'user'">
<!-- 查询表单 -->
<a-card class="search-card">
<a-form :model="formModel" layout="inline">
<a-form-item label="关键字">
<a-input
v-model="formModel.keyword"
placeholder="姓名、账号、电话"
allow-clear
style="width: 200px"
/>
</a-form-item>
<a-form-item label="状态">
<a-select
v-model="formModel.status"
placeholder="选择状态"
style="width: 120px"
>
<a-option :value="0">全部</a-option>
<a-option :value="1">正常</a-option>
<a-option :value="2">停用</a-option>
<a-option :value="3">已删除</a-option>
</a-select>
</a-form-item>
<a-form-item>
<a-space>
<a-button type="primary" @click="handleSearch">
<template #icon>
<icon-search />
</template>
查询
</a-button>
<a-button @click="handleReset">
<template #icon>
<icon-refresh />
</template>
重置
</a-button>
</a-space>
</a-form-item>
</a-form>
</a-card>
<!-- 数据表格 -->
<a-card class="table-card">
<a-table
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
>
<template #status="{ record }">
<a-tag v-if="record.status === 1" color="green">正常</a-tag>
<a-tag v-else-if="record.status === 2" color="orange">停用</a-tag>
<a-tag v-else-if="record.status === 3" color="gray">已删除</a-tag>
</template>
</a-table>
</a-card>
</div>
<!-- 设备调用测试页面 -->
<DeviceTest v-if="activeTab === 'device'" />
</a-layout-content>
</a-layout>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { Message } from '@arco-design/web-vue'
import DeviceTest from './components/DeviceTest.vue'
const activeTab = ref('user')
const loading = ref(false)
const formModel = ref({
keyword: '',
status: 0,
role: 0,
organid: 0
})
const tableData = ref([])
const pagination = ref({
current: 1,
pageSize: 20,
total: 0,
showPageSize: true,
showTotal: true
})
const columns = [
{ title: '编号', dataIndex: 'memberid', width: 80 },
{ title: '姓名', dataIndex: 'membername', width: 120 },
{ title: '账号', dataIndex: 'account', width: 150 },
{ title: '联系电话', dataIndex: 'contactphone', width: 130 },
{ title: '机构ID', dataIndex: 'organid', width: 100 },
{ title: '状态', dataIndex: 'status', slotName: 'status', width: 80 },
{ title: '创建时间', dataIndex: 'createtime', width: 180 },
{ title: '修改时间', dataIndex: 'updatetime', width: 180 }
]
const loadData = async () => {
if (!window.go || !window.go.main || !window.go.main.App || !window.go.main.App.QueryUsers) {
console.error('Go 后端未就绪,请确保应用已启动')
loading.value = false
return
}
loading.value = true
try {
const result = await window.go.main.App.QueryUsers(
formModel.value.keyword || '',
formModel.value.status || 0,
formModel.value.role || 0,
formModel.value.organid || 0,
pagination.value.current,
pagination.value.pageSize,
'createtime',
'descend'
)
if (result && result.rows) {
tableData.value = result.rows
pagination.value.total = result.total || 0
}
} catch (error) {
console.error('查询失败:', error)
Message.error('查询失败: ' + (error.message || error))
} finally {
loading.value = false
}
}
const handleSearch = () => {
pagination.value.current = 1
loadData()
}
const handleReset = () => {
formModel.value = {
keyword: '',
status: 0,
role: 0,
organid: 0
}
pagination.value.current = 1
loadData()
}
const handlePageChange = (page) => {
pagination.value.current = page
loadData()
}
const handlePageSizeChange = (pageSize) => {
pagination.value.pageSize = pageSize
pagination.value.current = 1
loadData()
}
onMounted(() => {
loadData()
})
</script>
<style scoped>
.layout {
height: 100vh;
display: flex;
flex-direction: column;
}
.header {
background: var(--color-bg-2);
border-bottom: 1px solid var(--color-border);
}
.header-content {
display: flex;
align-items: center;
justify-content: space-between;
height: 100%;
padding: 0 20px;
}
.header-content h2 {
margin: 0;
font-size: 18px;
font-weight: 500;
}
.header-tabs {
flex: 1;
margin-left: 40px;
}
.content {
padding: 20px;
flex: 1;
overflow: auto;
background: var(--color-bg-1);
}
.search-card {
margin-bottom: 16px;
}
.table-card {
flex: 1;
}
</style>

View File

@@ -0,0 +1,306 @@
<template>
<div class="device-test">
<!-- 系统信息 -->
<a-card class="test-card" title="系统信息">
<a-space direction="vertical" :size="16" style="width: 100%">
<a-button type="primary" @click="refreshSystemInfo">刷新系统信息</a-button>
<a-row :gutter="16">
<a-col :span="8">
<a-card size="small" title="CPU 信息">
<div v-if="cpuInfo">
<p>核心数: {{ cpuInfo.cores }}</p>
<p>型号: {{ cpuInfo.model }}</p>
<p>使用率: {{ cpuInfo.usage }}</p>
</div>
<div v-else>加载中...</div>
</a-card>
</a-col>
<a-col :span="8">
<a-card size="small" title="内存信息">
<div v-if="memoryInfo">
<p>总内存: {{ memoryInfo.total_str }}</p>
<p>已用: {{ memoryInfo.used_str }}</p>
<p>可用: {{ memoryInfo.available_str }}</p>
<p>使用率: {{ memoryInfo.usage }}</p>
</div>
<div v-else>加载中...</div>
</a-card>
</a-col>
<a-col :span="8">
<a-card size="small" title="系统信息">
<div v-if="systemInfo">
<p>操作系统: {{ systemInfo.os }}</p>
<p>架构: {{ systemInfo.arch }}</p>
<p>主机名: {{ systemInfo.hostname }}</p>
<p>平台: {{ systemInfo.platform }}</p>
</div>
<div v-else>加载中...</div>
</a-card>
</a-col>
</a-row>
<a-card size="small" title="磁盘信息" v-if="diskInfo && diskInfo.length > 0">
<a-table
:columns="diskColumns"
:data="diskInfo"
:pagination="false"
size="small"
/>
</a-card>
</a-space>
</a-card>
<!-- 文件系统操作 -->
<a-card class="test-card" title="文件系统操作">
<a-space direction="vertical" :size="16" style="width: 100%">
<a-input-group>
<a-input
v-model="filePath"
placeholder="输入文件或目录路径"
style="flex: 1"
/>
<a-button @click="browseDirectory">浏览</a-button>
<a-button type="primary" @click="listDirectory">列出目录</a-button>
</a-input-group>
<a-row :gutter="16">
<a-col :span="12">
<a-card size="small" title="文件列表">
<a-list
:data="fileList"
:loading="fileLoading"
style="max-height: 300px; overflow-y: auto"
>
<template #item="{ item }">
<a-list-item>
<a-list-item-meta>
<template #title>
<a-space>
<span>{{ item.is_dir ? '📁' : '📄' }}</span>
<a @click="selectFile(item.path)">{{ item.name }}</a>
</a-space>
</template>
<template #description>
<span v-if="!item.is_dir">大小: {{ formatBytes(item.size) }}</span>
<span>修改时间: {{ item.mod_time }}</span>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-card>
</a-col>
<a-col :span="12">
<a-card size="small" title="文件内容">
<a-space direction="vertical" :size="8" style="width: 100%">
<a-textarea
v-model="fileContent"
:rows="10"
placeholder="文件内容将显示在这里"
/>
<a-space>
<a-button type="primary" @click="readFile" :loading="fileLoading">读取文件</a-button>
<a-button @click="writeFile" :loading="fileLoading">写入文件</a-button>
<a-button danger @click="deleteFile" :loading="fileLoading">删除</a-button>
</a-space>
</a-space>
</a-card>
</a-col>
</a-row>
</a-space>
</a-card>
<!-- 环境变量 -->
<a-card class="test-card" title="环境变量">
<a-button @click="loadEnvVars" :loading="envLoading">加载环境变量</a-button>
<a-table
v-if="envVars"
:columns="envColumns"
:data="envTableData"
:pagination="{ pageSize: 20 }"
style="margin-top: 16px"
size="small"
/>
</a-card>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { Message } from '@arco-design/web-vue'
const systemInfo = ref(null)
const cpuInfo = ref(null)
const memoryInfo = ref(null)
const diskInfo = ref(null)
const filePath = ref('')
const fileContent = ref('')
const fileList = ref([])
const fileLoading = ref(false)
const envVars = ref(null)
const envLoading = ref(false)
const diskColumns = [
{ title: '设备', dataIndex: 'device', width: 120 },
{ title: '挂载点', dataIndex: 'mountpoint', width: 200 },
{ title: '总容量', dataIndex: 'total_str', width: 100 },
{ title: '已用', dataIndex: 'used_str', width: 100 },
{ title: '可用', dataIndex: 'free_str', width: 100 },
{ title: '使用率', dataIndex: 'usage', width: 80 }
]
const envColumns = [
{ title: '变量名', dataIndex: 'key', width: 200 },
{ title: '值', dataIndex: 'value' }
]
const envTableData = computed(() => {
if (!envVars.value) return []
return Object.keys(envVars.value).map(key => ({
key,
value: envVars.value[key]
}))
})
const refreshSystemInfo = async () => {
try {
if (window.go?.main?.App) {
systemInfo.value = await window.go.main.App.GetSystemInfo()
cpuInfo.value = await window.go.main.App.GetCPUInfo()
memoryInfo.value = await window.go.main.App.GetMemoryInfo()
diskInfo.value = await window.go.main.App.GetDiskInfo()
}
} catch (error) {
console.error('获取系统信息失败:', error)
Message.error('获取系统信息失败: ' + (error.message || error))
}
}
const listDirectory = async () => {
if (!filePath.value) {
Message.error('请输入目录路径')
return
}
fileLoading.value = true
try {
if (window.go?.main?.App) {
fileList.value = await window.go.main.App.ListDir(filePath.value)
}
} catch (error) {
console.error('列出目录失败:', error)
Message.error('列出目录失败: ' + (error.message || error))
} finally {
fileLoading.value = false
}
}
const readFile = async () => {
if (!filePath.value) {
Message.error('请输入文件路径')
return
}
fileLoading.value = true
try {
if (window.go?.main?.App) {
fileContent.value = await window.go.main.App.ReadFile(filePath.value)
}
} catch (error) {
console.error('读取文件失败:', error)
Message.error('读取文件失败: ' + (error.message || error))
} finally {
fileLoading.value = false
}
}
const writeFile = async () => {
if (!filePath.value) {
Message.error('请输入文件路径')
return
}
fileLoading.value = true
try {
if (window.go?.main?.App) {
await window.go.main.App.WriteFile(filePath.value, fileContent.value)
Message.success('文件写入成功')
}
} catch (error) {
console.error('写入文件失败:', error)
Message.error('写入文件失败: ' + (error.message || error))
} finally {
fileLoading.value = false
}
}
const deleteFile = async () => {
if (!filePath.value) {
Message.error('请输入文件路径')
return
}
if (!confirm('确定要删除 ' + filePath.value + ' 吗?')) {
return
}
fileLoading.value = true
try {
if (window.go?.main?.App) {
await window.go.main.App.DeletePath(filePath.value)
Message.success('删除成功')
filePath.value = ''
fileContent.value = ''
fileList.value = []
}
} catch (error) {
console.error('删除失败:', error)
Message.error('删除失败: ' + (error.message || error))
} finally {
fileLoading.value = false
}
}
const selectFile = (path) => {
filePath.value = path
}
const browseDirectory = () => {
const path = prompt('请输入目录路径(例如: C:\\Users')
if (path) {
filePath.value = path
listDirectory()
}
}
const loadEnvVars = async () => {
envLoading.value = true
try {
if (window.go?.main?.App) {
envVars.value = await window.go.main.App.GetEnvVars()
}
} catch (error) {
console.error('加载环境变量失败:', error)
Message.error('加载环境变量失败: ' + (error.message || error))
} finally {
envLoading.value = false
}
}
const formatBytes = (bytes) => {
if (!bytes) return '0 B'
const unit = 1024
if (bytes < unit) return bytes + ' B'
const exp = Math.floor(Math.log(bytes) / Math.log(unit))
return (bytes / Math.pow(unit, exp)).toFixed(2) + ' ' + 'KMGTPE'[exp - 1] + 'B'
}
onMounted(() => {
refreshSystemInfo()
})
</script>
<style scoped>
.device-test {
display: flex;
flex-direction: column;
gap: 16px;
}
.test-card {
margin-bottom: 16px;
}
</style>

10
web/src/main.js Normal file
View File

@@ -0,0 +1,10 @@
import { createApp } from 'vue'
import ArcoVue from '@arco-design/web-vue'
import '@arco-design/web-vue/dist/arco.css'
import './style.css'
import App from './App.vue'
const app = createApp(App)
app.use(ArcoVue)
app.mount('#app')

17
web/src/style.css Normal file
View File

@@ -0,0 +1,17 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#app {
width: 100%;
height: 100vh;
}

11
web/vite.config.js Normal file
View File

@@ -0,0 +1,11 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
build: {
outDir: 'dist',
emptyOutDir: true
}
})