Skip to content

Commit

Permalink
refactor: update deps and refactor types
Browse files Browse the repository at this point in the history
一些用户想要修改这个主题以用于 ServerStatus-Hotaru 的自定义前端,由于包管理器的更新,加强了对 peerDependencies 的要求,可能会导致一些用户依赖无法安装成功。
由于 vue-cli 的废弃,并且本项目已时间久远,一些代码并不规范。如果你有一定前端基础,需要修改此项目用于其他用途(如移植主题等),推荐使用 Vite 作为打包工具并参考此处的代码:https://github.com/cokemine/nodestatus/tree/master/web/hotaru-theme
  • Loading branch information
cokemine committed Aug 7, 2022
1 parent 1ac96ec commit ae80618
Show file tree
Hide file tree
Showing 14 changed files with 11,044 additions and 17,774 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"object-curly-spacing": [
1,
"always"
]
],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
28,693 changes: 10,979 additions & 17,714 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
"axios": "^0.21.1",
"core-js": "^3.8.3",
"semantic-ui-css": "^2.4.1",
"vue": "^3.0.0"
"vue": "^3.2.37"
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "~4.5.11",
"@vue/cli-plugin-eslint": "~4.5.11",
"@vue/cli-plugin-typescript": "^4.5.11",
"@vue/cli-service": "~4.5.11",
"@vue/compiler-sfc": "^3.0.5",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-plugin-eslint": "^5.0.8",
"@vue/cli-plugin-typescript": "^5.0.8",
"@vue/cli-service": "^5.0.8",
"@vue/eslint-config-typescript": "^7.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.19.0",
"eslint-plugin-vue": "^7.5.0",
"svg-sprite-loader": "^6.0.7",
"typescript": "~4.1.3"
"typescript": "^4.1.3"
},
"browserslist": [
"> 1%",
Expand Down
3 changes: 2 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ServersTable from '@/components/ServersTable.vue';
import UpdateTime from '@/components/UpdateTime.vue';
import ServersCard from '@/components/ServersCard.vue';
import TheFooter from '@/components/TheFooter.vue';
import { BoxItem, StatusItem } from '@/types';
export default defineComponent({
name: 'App',
Expand All @@ -41,7 +42,7 @@ export default defineComponent({
updated.value = Number(res.data.updated);
})
.catch(err => console.log(err));
onMounted(() => runFetch() && (timer = setInterval(runFetch, interval * 1000)));
onMounted(() => (runFetch(), true) && (timer = setInterval(runFetch, interval * 1000)));
onBeforeUnmount(() => clearInterval(timer));
return {
servers,
Expand Down
3 changes: 2 additions & 1 deletion src/components/CardItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import useStatus from './useStatus';
import { StatusItem } from '@/types';
export default defineComponent({
name: 'CardItem',
props: {
server: {
type: Object as PropType<StatusItem | BoxItem>,
type: Object as PropType<StatusItem>,
default: () => ({})
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/ServersCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import CardItem from '@/components/CardItem.vue';
import { StatusItem } from '@/types';
export default defineComponent({
name: 'ServersCard',
props: {
servers: Array as PropType<Array<StatusItem | BoxItem>>
servers: Array as PropType<Array<StatusItem>>
},
components: {
CardItem
Expand Down
3 changes: 2 additions & 1 deletion src/components/ServersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import TableItem from '@/components/TableItem.vue';
import { StatusItem } from '@/types';
export default defineComponent({
name: 'ServersTable',
props: {
servers: {
type: Array as PropType<Array<StatusItem | BoxItem>>,
type: Array as PropType<Array<StatusItem>>,
default: () => ([])
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/TableItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@
<script lang="ts">
import { defineComponent, ref, PropType } from 'vue';
import useStatus from './useStatus';
import { StatusItem } from '@/types';
export default defineComponent({
name: 'TableItem',
props: {
server: {
type: Object as PropType<StatusItem | BoxItem>,
type: Object as PropType<StatusItem>,
default: () => ({})
}
},
Expand Down
1 change: 1 addition & 0 deletions src/components/useStatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { computed } from 'vue';
import { BoxItem, StatusItem } from '@/types';

interface Props {
server: StatusItem | BoxItem;
Expand Down
37 changes: 37 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export interface BoxItem {
name: string;
host: string;
type: string;
online4: boolean;
online6: boolean;
location: string;
region: string;
}

export interface StatusItem extends BoxItem {
uptime: string;
load: number;
cpu: number;
network_rx: number;
network_tx: number;
network_in: number;
network_out: number;
memory_total: number;
memory_used: number;
swap_total: number;
swap_used: number;
hdd_total: number;
hdd_used: number;
custom: string;
}

declare global {
interface Window {
__PRE_CONFIG__: {
header: string;
subHeader: string;
interval: number;
footer: string;
};
}
}
10 changes: 5 additions & 5 deletions types/shims-vue.d.ts → src/types/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
declare module '*.vue' {
import type {DefineComponent} from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
/* eslint-disable */
declare module '*.vue' {
import type {DefineComponent} from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
]
},
"include": [
"types/**/*.ts",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
Expand Down
39 changes: 0 additions & 39 deletions types/servers.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const resolve = d => require('path').resolve(__dirname, d);

module.exports = {
publicPath: './',
pages: {
Expand Down

0 comments on commit ae80618

Please sign in to comment.