-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(status): move webui into status
- Loading branch information
Showing
19 changed files
with
195 additions
and
237 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<el-card v-if="status" header="负载"> | ||
<load-bar :status="status"/> | ||
</el-card> | ||
<el-card v-if="status" header="插件"> | ||
<ul class="plugin-list"> | ||
<plugin-view :data="data" v-for="(data, index) in status.plugins" :key="index"/> | ||
</ul> | ||
</el-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue' | ||
import PluginView from './components/plugin-view.vue' | ||
import LoadBar from './components/load-bar.vue' | ||
interface PluginData { | ||
name: string | ||
disposable: boolean | ||
children: PluginData[] | ||
} | ||
interface Status { | ||
plugins: PluginData[] | ||
} | ||
const status = ref<Status>(null) | ||
if (import.meta.hot) { | ||
import.meta.hot.on('update', (data) => { | ||
console.log('update', data) | ||
}) | ||
} | ||
onMounted(async () => { | ||
const res = await fetch(KOISHI_SERVER + '/_') | ||
const data = await res.json() | ||
status.value = data | ||
console.log('fetch', data) | ||
}) | ||
</script> | ||
|
||
<style lang="scss"> | ||
#app { | ||
font-family: Avenir, Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
color: #2c3e50; | ||
margin-top: 60px; | ||
} | ||
</style> |
File renamed without changes
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,82 @@ | ||
<template> | ||
<div> | ||
<div class="load"> | ||
<span class="type">CPU</span> | ||
<span class="bar"> | ||
<span class="used" :style="{ width: (status.cpu[1] - status.cpu[0]) * 100 + '%' }"/> | ||
<span class="app" :style="{ width: status.cpu[0] * 100 + '%' }"/> | ||
{{ (status.cpu[0] * 100).toFixed(1) }}% / {{ (status.cpu[1] * 100).toFixed(1) }}% | ||
</span> | ||
</div> | ||
<div class="load"> | ||
<span class="type">内存</span> | ||
<span class="bar"> | ||
<span class="used" :style="{ width: (status.memory[1] - status.memory[0]) * 100 + '%' }"> | ||
{{ (status.memory[0] * 100).toFixed(1) }}% / {{ (status.memory[1] * 100).toFixed(1) }}% | ||
</span> | ||
<span class="app" :style="{ width: status.memory[0] * 100 + '%' }"/> | ||
</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['status'], | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.load { | ||
margin: 1rem 0; | ||
padding: 0 2rem; | ||
display: flex; | ||
align-items: center; | ||
user-select: none; | ||
.type { | ||
min-width: 3rem; | ||
} | ||
.bar { | ||
width: 100%; | ||
height: 1.6rem; | ||
position: relative; | ||
display: inline; | ||
background-color: #f6f8fa; | ||
line-height: 1.6; | ||
> * { | ||
height: 100%; | ||
position: relative; | ||
float: left; | ||
transition: 0.3s ease; | ||
}; | ||
> *:hover { | ||
z-index: 10; | ||
cursor: pointer; | ||
box-shadow: 0 0 4px #000c; | ||
}; | ||
} | ||
.used { | ||
background-color: rgb(50,197,233); | ||
color: white; | ||
&:hover { | ||
background-color: rgb(55,216,255); | ||
}; | ||
} | ||
.app { | ||
background-color: rgb(255,159,127); | ||
&:hover { | ||
background-color: rgb(255,174,139); | ||
}; | ||
} | ||
&:first-of-type { | ||
margin-top: 2rem; | ||
} | ||
&:last-of-type { | ||
margin-bottom: 2rem; | ||
} | ||
} | ||
</style> |
File renamed without changes.
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,9 @@ | ||
// I don't know why do I need this | ||
// this should be provided by vue | ||
|
||
declare module '*.vue' { | ||
import { Component } from 'vue' | ||
|
||
const component: Component | ||
export default component | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.