Skip to content

Commit

Permalink
fix: prettier code
Browse files Browse the repository at this point in the history
fix: set max cache with 1000
fix: add onebotV11 (call_api)
  • Loading branch information
lc-cn committed Jan 12, 2024
1 parent 6fa294f commit 8cc5361
Show file tree
Hide file tree
Showing 36 changed files with 3,903 additions and 3,056 deletions.
304 changes: 169 additions & 135 deletions client/App.vue

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions client/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {createApp} from "vue";
import { createApp } from "vue";
import App from "./App.vue";
createApp(App)
.mount('#app')
createApp(App).mount("#app");
69 changes: 34 additions & 35 deletions client/types.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
export interface BotInfo{
uin:string
status:string
avatar:string
platform:string
nickname:string
dependency:string
urls:string[]
export interface BotInfo {
uin: string;
status: string;
avatar: string;
platform: string;
nickname: string;
dependency: string;
urls: string[];
}
export type CPUInfo={
mode:string
speed:number
times:{user:number,irq:number,nice:number,sys:number,idle:number}

export type CPUInfo = {
mode: string;
speed: number;
times: { user: number; irq: number; nice: number; sys: number; idle: number };
};
export interface SystemInfo {
free_memory: number;
node_version: string;
process_cwd: string;
process_id: number;
process_parent_id: number;
process_use_memory: number;
sdk_version: string;
uptime: number;
system_arch: string;
system_cpus: CPUInfo[];
system_platform: string;
system_uptime: number;
system_version: string;
total_memory: number;
username: string;
}
export interface SystemInfo{
free_memory:number
node_version:string
process_cwd:string
process_id:number
process_parent_id:number
process_use_memory:number
sdk_version:string
uptime:number
system_arch:string
system_cpus:CPUInfo[]
system_platform:string
system_uptime:number
system_version:string
total_memory:number
username:string
}
export interface AdapterInfo{
platform:string
config:any,
icon:string
bots:BotInfo[]
export interface AdapterInfo {
platform: string;
config: any;
icon: string;
bots: BotInfo[];
}
53 changes: 27 additions & 26 deletions client/utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export function formatNum(num:number,toLen:number){
let result=''
const numStr=String(num)
for(let i=0;i<toLen;i++){
result=`${numStr[toLen-i]||'0'}${result}`
export function formatNum(num: number, toLen: number) {
let result = "";
const numStr = String(num);
for (let i = 0; i < toLen; i++) {
result = `${numStr[toLen - i] || "0"}${result}`;
}
return result
return result;
}
export function formatTime(ms:number):string{
export function formatTime(ms: number): string {
const seconds = Math.floor(ms / 1000);
const days = Math.floor(seconds / (24 * 60 * 60));
const hours = Math.floor((seconds % (24 * 60 * 60)) / (60 * 60));
const minutes = Math.floor((seconds % (60 * 60)) / 60);
const remainingSeconds = seconds % 60;

let result = '';
let result = "";
if (days > 0) {
result += `${days}天`;
}
Expand All @@ -29,25 +29,26 @@ export function formatTime(ms:number):string{

return result;
}
export function formatDate(datestamp:number,template?:string):string
export function formatDate(dateStr:string,template?:string):string
export function formatDate(date:Date,template?:string):string
export function formatDate(date:number|string|Date,template:string='YYYY-MM-DD hh:mm:ss'){
if(!(date instanceof Date)) date=new Date(date)
const year=date.getFullYear()
const month=date.getMonth()+1
const day=date.getDate()
const hour=date.getHours()
const minute=date.getMinutes()
const second=date.getSeconds()
return template.replace(/Y+/,(str)=>formatNum(year,str.length))
.replace('/M+/',(str)=>formatNum(month,str.length))
.replace('/D+/',(str)=>formatNum(day,str.length))
.replace('/h+/',(str)=>formatNum(hour,str.length))
.replace('/m+/',(str)=>formatNum(minute,str.length))
.replace('/s+/',(str)=>formatNum(second,str.length))
export function formatDate(datestamp: number, template?: string): string;
export function formatDate(dateStr: string, template?: string): string;
export function formatDate(date: Date, template?: string): string;
export function formatDate(date: number | string | Date, template: string = "YYYY-MM-DD hh:mm:ss") {
if (!(date instanceof Date)) date = new Date(date);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hour = date.getHours();
const minute = date.getMinutes();
const second = date.getSeconds();
return template
.replace(/Y+/, str => formatNum(year, str.length))
.replace("/M+/", str => formatNum(month, str.length))
.replace("/D+/", str => formatNum(day, str.length))
.replace("/h+/", str => formatNum(hour, str.length))
.replace("/m+/", str => formatNum(minute, str.length))
.replace("/s+/", str => formatNum(second, str.length));
}
export function formatSize(bytes:number){
export function formatSize(bytes: number) {
const operators = ["B", "KB", "MB", "GB", "TB"];
while (bytes > 1024 && operators.length > 1) {
bytes = bytes / 1024;
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import Theme from 'vitepress/theme'

export default {
...Theme,
}
}
Loading

0 comments on commit 8cc5361

Please sign in to comment.