From a9f34a57839ce51f9da28e164fafff61617f75c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 28 Oct 2024 23:44:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E9=AA=8C=E6=80=A7=E6=94=AF?= =?UTF-8?q?=E6=8C=81alova?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/dashboard.go | 4 +- web/.eslintrc-auto-import.json | 256 +++++++++++++++++- web/build/plugins/unplugin.ts | 32 ++- web/package.json | 1 + web/pnpm-lock.yaml | 36 +++ web/settings/theme.json | 3 +- web/src/api/panel/dashboard/index.ts | 6 +- web/src/components/common/AppProvider.vue | 1 - web/src/i18n/i18n.ts | 2 + .../layout/header/components/FullScreen.vue | 2 - .../layout/sidebar/components/SideLogo.vue | 3 +- web/src/main.ts | 25 +- web/src/router/guard/page-title-guard.ts | 7 +- web/src/store/index.ts | 1 - web/src/store/modules/app/index.ts | 2 - web/src/store/modules/permission/index.ts | 1 - web/src/store/modules/tab/index.ts | 1 - web/src/store/modules/theme/helpers.ts | 3 +- web/src/store/modules/theme/index.ts | 18 +- web/src/store/modules/user/index.ts | 1 - web/src/utils/http/index.ts | 55 ++++ web/src/views/login/IndexView.vue | 8 +- web/types/theme.d.ts | 2 + 23 files changed, 417 insertions(+), 53 deletions(-) diff --git a/internal/service/dashboard.go b/internal/service/dashboard.go index 25af2f7b..43898037 100644 --- a/internal/service/dashboard.go +++ b/internal/service/dashboard.go @@ -52,8 +52,8 @@ func (s *DashboardService) Panel(w http.ResponseWriter, r *http.Request) { } Success(w, chix.M{ - "name": name, - "language": app.Conf.MustString("app.locale"), + "name": name, + "locale": app.Conf.MustString("app.locale"), }) } diff --git a/web/.eslintrc-auto-import.json b/web/.eslintrc-auto-import.json index 7c8dc292..2e1307c9 100644 --- a/web/.eslintrc-auto-import.json +++ b/web/.eslintrc-auto-import.json @@ -74,6 +74,260 @@ "useTemplateRef": true, "DirectiveBinding": true, "MaybeRef": true, - "MaybeRefOrGetter": true + "MaybeRefOrGetter": true, + "acceptHMRUpdate": true, + "createPinia": true, + "defineStore": true, + "getActivePinia": true, + "mapActions": true, + "mapGetters": true, + "mapState": true, + "mapStores": true, + "mapWritableState": true, + "setActivePinia": true, + "setMapStoreSuffix": true, + "storeToRefs": true, + "asyncComputed": true, + "autoResetRef": true, + "computedAsync": true, + "computedEager": true, + "computedInject": true, + "computedWithControl": true, + "controlledComputed": true, + "controlledRef": true, + "createEventHook": true, + "createGlobalState": true, + "createInjectionState": true, + "createReactiveFn": true, + "createReusableTemplate": true, + "createSharedComposable": true, + "createTemplatePromise": true, + "createUnrefFn": true, + "debouncedRef": true, + "debouncedWatch": true, + "eagerComputed": true, + "extendRef": true, + "ignorableWatch": true, + "injectLocal": true, + "isDefined": true, + "makeDestructurable": true, + "onClickOutside": true, + "onKeyStroke": true, + "onLongPress": true, + "onStartTyping": true, + "pausableWatch": true, + "provideLocal": true, + "reactify": true, + "reactifyObject": true, + "reactiveComputed": true, + "reactiveOmit": true, + "reactivePick": true, + "refAutoReset": true, + "refDebounced": true, + "refDefault": true, + "refThrottled": true, + "refWithControl": true, + "resolveRef": true, + "resolveUnref": true, + "syncRef": true, + "syncRefs": true, + "templateRef": true, + "throttledRef": true, + "throttledWatch": true, + "toReactive": true, + "tryOnBeforeMount": true, + "tryOnBeforeUnmount": true, + "tryOnMounted": true, + "tryOnScopeDispose": true, + "tryOnUnmounted": true, + "unrefElement": true, + "until": true, + "useActiveElement": true, + "useAnimate": true, + "useArrayDifference": true, + "useArrayEvery": true, + "useArrayFilter": true, + "useArrayFind": true, + "useArrayFindIndex": true, + "useArrayFindLast": true, + "useArrayIncludes": true, + "useArrayJoin": true, + "useArrayMap": true, + "useArrayReduce": true, + "useArraySome": true, + "useArrayUnique": true, + "useAsyncQueue": true, + "useAsyncState": true, + "useBase64": true, + "useBattery": true, + "useBluetooth": true, + "useBreakpoints": true, + "useBroadcastChannel": true, + "useBrowserLocation": true, + "useCached": true, + "useClipboard": true, + "useClipboardItems": true, + "useCloned": true, + "useColorMode": true, + "useConfirmDialog": true, + "useCounter": true, + "useCssVar": true, + "useCurrentElement": true, + "useCycleList": true, + "useDark": true, + "useDateFormat": true, + "useDebounce": true, + "useDebounceFn": true, + "useDebouncedRefHistory": true, + "useDeviceMotion": true, + "useDeviceOrientation": true, + "useDevicePixelRatio": true, + "useDevicesList": true, + "useDisplayMedia": true, + "useDocumentVisibility": true, + "useDraggable": true, + "useDropZone": true, + "useElementBounding": true, + "useElementByPoint": true, + "useElementHover": true, + "useElementSize": true, + "useElementVisibility": true, + "useEventBus": true, + "useEventListener": true, + "useEventSource": true, + "useEyeDropper": true, + "useFavicon": true, + "useFetch": true, + "useFileDialog": true, + "useFileSystemAccess": true, + "useFocus": true, + "useFocusWithin": true, + "useFps": true, + "useFullscreen": true, + "useGamepad": true, + "useGeolocation": true, + "useIdle": true, + "useImage": true, + "useInfiniteScroll": true, + "useIntersectionObserver": true, + "useInterval": true, + "useIntervalFn": true, + "useKeyModifier": true, + "useLastChanged": true, + "useLocalStorage": true, + "useMagicKeys": true, + "useManualRefHistory": true, + "useMediaControls": true, + "useMediaQuery": true, + "useMemoize": true, + "useMemory": true, + "useMounted": true, + "useMouse": true, + "useMouseInElement": true, + "useMousePressed": true, + "useMutationObserver": true, + "useNavigatorLanguage": true, + "useNetwork": true, + "useNow": true, + "useObjectUrl": true, + "useOffsetPagination": true, + "useOnline": true, + "usePageLeave": true, + "useParallax": true, + "useParentElement": true, + "usePerformanceObserver": true, + "usePermission": true, + "usePointer": true, + "usePointerLock": true, + "usePointerSwipe": true, + "usePreferredColorScheme": true, + "usePreferredContrast": true, + "usePreferredDark": true, + "usePreferredLanguages": true, + "usePreferredReducedMotion": true, + "usePrevious": true, + "useRafFn": true, + "useRefHistory": true, + "useResizeObserver": true, + "useScreenOrientation": true, + "useScreenSafeArea": true, + "useScriptTag": true, + "useScroll": true, + "useScrollLock": true, + "useSessionStorage": true, + "useShare": true, + "useSorted": true, + "useSpeechRecognition": true, + "useSpeechSynthesis": true, + "useStepper": true, + "useStorage": true, + "useStorageAsync": true, + "useStyleTag": true, + "useSupported": true, + "useSwipe": true, + "useTemplateRefsList": true, + "useTextDirection": true, + "useTextSelection": true, + "useTextareaAutosize": true, + "useThrottle": true, + "useThrottleFn": true, + "useThrottledRefHistory": true, + "useTimeAgo": true, + "useTimeout": true, + "useTimeoutFn": true, + "useTimeoutPoll": true, + "useTimestamp": true, + "useTitle": true, + "useToNumber": true, + "useToString": true, + "useToggle": true, + "useTransition": true, + "useUrlSearchParams": true, + "useUserMedia": true, + "useVModel": true, + "useVModels": true, + "useVibrate": true, + "useVirtualList": true, + "useWakeLock": true, + "useWebNotification": true, + "useWebSocket": true, + "useWebWorker": true, + "useWebWorkerFn": true, + "useWindowFocus": true, + "useWindowScroll": true, + "useWindowSize": true, + "watchArray": true, + "watchAtMost": true, + "watchDebounced": true, + "watchDeep": true, + "watchIgnorable": true, + "watchImmediate": true, + "watchOnce": true, + "watchPausable": true, + "watchThrottled": true, + "watchTriggerable": true, + "watchWithFilter": true, + "whenever": true, + "[alias]": true, + "[import-names]": true, + "axios": true, + "useMyFetch": true, + "accessAction": true, + "actionDelegationMiddleware": true, + "createClientTokenAuthentication": true, + "createServerTokenAuthentication": true, + "updateState": true, + "useAutoRequest": true, + "useCaptcha": true, + "useFetcher": true, + "useForm": true, + "usePagination": true, + "useRequest": true, + "useRetriable": true, + "useSQRequest": true, + "useSSE": true, + "useSerialRequest": true, + "useSerialWatcher": true, + "useWatcher": true } } diff --git a/web/build/plugins/unplugin.ts b/web/build/plugins/unplugin.ts index ace006dc..36606853 100644 --- a/web/build/plugins/unplugin.ts +++ b/web/build/plugins/unplugin.ts @@ -12,11 +12,39 @@ import Icons from 'unplugin-icons/vite' export default [ AutoImport({ - imports: ['vue', 'vue-router'], + imports: [ + 'vue', + 'vue-router', + 'pinia', + '@vueuse/core', + { + 'alova/client': [ + 'actionDelegationMiddleware', + 'accessAction', + 'createClientTokenAuthentication', + 'createServerTokenAuthentication', + 'updateState', + 'useAutoRequest', + 'useCaptcha', + 'useFetcher', + 'useForm', + 'usePagination', + 'useRequest', + 'useRetriable', + 'useSQRequest', + 'useSSE', + 'useSerialRequest', + 'useSerialWatcher', + 'useWatcher' + ] + } + ], dts: 'types/auto-imports.d.ts', eslintrc: { enabled: true - } + }, + vueTemplate: true, + viteOptimizeDeps: true }), Icons({ compiler: 'vue3', diff --git a/web/package.json b/web/package.json index 5262a66c..da32ed40 100644 --- a/web/package.json +++ b/web/package.json @@ -31,6 +31,7 @@ "@xterm/addon-web-links": "^0.11.0", "@xterm/addon-webgl": "^0.18.0", "@xterm/xterm": "^5.5.0", + "alova": "^3.1.1", "axios": "^1.7.7", "cronstrue": "^2.50.0", "echarts": "^5.5.1", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 121812ca..fd4ce0c5 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: '@xterm/xterm': specifier: ^5.5.0 version: 5.5.0 + alova: + specifier: ^3.1.1 + version: 3.1.1 axios: specifier: ^1.7.7 version: 1.7.7 @@ -186,6 +189,9 @@ importers: packages: + '@alova/shared@1.0.7': + resolution: {integrity: sha512-yBCNbt+E2gOtNfx9dLXDcmjudnWrwlHJnMKFD6CLKe6KTc6G0QUFeIS/1Kn4+iBalD38nY8ckCMW98+hmjr7Bg==} + '@ampproject/remapping@2.3.0': resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} @@ -849,30 +855,35 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] + libc: [glibc] '@parcel/watcher-linux-arm64-glibc@2.4.1': resolution: {integrity: sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] '@parcel/watcher-linux-arm64-musl@2.4.1': resolution: {integrity: sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [musl] '@parcel/watcher-linux-x64-glibc@2.4.1': resolution: {integrity: sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [glibc] '@parcel/watcher-linux-x64-musl@2.4.1': resolution: {integrity: sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [musl] '@parcel/watcher-win32-arm64@2.4.1': resolution: {integrity: sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==} @@ -950,46 +961,55 @@ packages: resolution: {integrity: sha512-ArdGtPHjLqWkqQuoVQ6a5UC5ebdX8INPuJuJNWRe0RGa/YNhVvxeWmCTFQ7LdmNCSUzVZzxAvUznKaYx645Rig==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.24.2': resolution: {integrity: sha512-B6UHHeNnnih8xH6wRKB0mOcJGvjZTww1FV59HqJoTJ5da9LCG6R4SEBt6uPqzlawv1LoEXSS0d4fBlHNWl6iYw==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.24.2': resolution: {integrity: sha512-kr3gqzczJjSAncwOS6i7fpb4dlqcvLidqrX5hpGBIM1wtt0QEVtf4wFaAwVv8QygFU8iWUMYEoJZWuWxyua4GQ==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.24.2': resolution: {integrity: sha512-TDdHLKCWgPuq9vQcmyLrhg/bgbOvIQ8rtWQK7MRxJ9nvaxKx38NvY7/Lo6cYuEnNHqf6rMqnivOIPIQt6H2AoA==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.24.2': resolution: {integrity: sha512-xv9vS648T3X4AxFFZGWeB5Dou8ilsv4VVqJ0+loOIgDO20zIhYfDLkk5xoQiej2RiSQkld9ijF/fhLeonrz2mw==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.24.2': resolution: {integrity: sha512-tbtXwnofRoTt223WUZYiUnbxhGAOVul/3StZ947U4A5NNjnQJV5irKMm76G0LGItWs6y+SCjUn/Q0WaMLkEskg==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.24.2': resolution: {integrity: sha512-gc97UebApwdsSNT3q79glOSPdfwgwj5ELuiyuiMY3pEWMxeVqLGKfpDFoum4ujivzxn6veUPzkGuSYoh5deQ2Q==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.24.2': resolution: {integrity: sha512-jOG/0nXb3z+EM6SioY8RofqqmZ+9NKYvJ6QQaa9Mvd3RQxlH68/jcB/lpyVt4lCiqr04IyaC34NzhUqcXbB5FQ==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.24.2': resolution: {integrity: sha512-XAo7cJec80NWx9LlZFEJQxqKOMz/lX3geWs2iNT5CHIERLFfd90f3RYLLjiCBm1IMaQ4VOX/lTC9lWfzzQm14Q==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.24.2': resolution: {integrity: sha512-A+JAs4+EhsTjnPQvo9XY/DC0ztaws3vfqzrMNMKlwQXuniBKOIIvAAI8M0fBYiTCxQnElYu7mLk7JrhlQ+HeOw==} @@ -1368,6 +1388,10 @@ packages: alien-signals@0.2.0: resolution: {integrity: sha512-StlonZhBBrsPPwrDjiPAiVTf/rolxffLxVPT60Qv/t88BZ81BvUVzHgGqEFvJ1ii8HXtm1+zU2Icr59tfWEcag==} + alova@3.1.1: + resolution: {integrity: sha512-1LviUBEa6tNg4hVnnY0wtY7OGdzwl4uzASCTbMxXyiVkraJg3mt/e/5i0xGR6CeOkAS2hpmxDKsrE3rJEUnAKA==} + engines: {node: '>= 18.0.0'} + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -2676,6 +2700,9 @@ packages: queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + rate-limiter-flexible@5.0.4: + resolution: {integrity: sha512-ftYHrIfSqWYDIJZ4yPTrgOduByAp+86gUS9iklv0JoXVM8eQCAjTnydCj1hAT4MmhmkSw86NaFEJ28m/LC1pKA==} + rc9@2.1.2: resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==} @@ -3254,6 +3281,8 @@ packages: snapshots: + '@alova/shared@1.0.7': {} + '@ampproject/remapping@2.3.0': dependencies: '@jridgewell/gen-mapping': 0.3.5 @@ -4666,6 +4695,11 @@ snapshots: alien-signals@0.2.0: {} + alova@3.1.1: + dependencies: + '@alova/shared': 1.0.7 + rate-limiter-flexible: 5.0.4 + ansi-regex@5.0.1: {} ansi-styles@4.3.0: @@ -6081,6 +6115,8 @@ snapshots: queue-microtask@1.2.3: {} + rate-limiter-flexible@5.0.4: {} + rc9@2.1.2: dependencies: defu: 6.1.4 diff --git a/web/settings/theme.json b/web/settings/theme.json index 96fcc750..9fcd4c9e 100644 --- a/web/settings/theme.json +++ b/web/settings/theme.json @@ -21,5 +21,6 @@ "warning": "#F0A020", "error": "#D03050" }, - "locale": "zh_CN" + "locale": "zh_CN", + "name": "耗子面板" } diff --git a/web/src/api/panel/dashboard/index.ts b/web/src/api/panel/dashboard/index.ts index 5cf5c1c2..8a8485d0 100644 --- a/web/src/api/panel/dashboard/index.ts +++ b/web/src/api/panel/dashboard/index.ts @@ -1,4 +1,4 @@ -import { request } from '@/utils' +import { http, request } from '@/utils' import type { AxiosResponse } from 'axios' import type { RequestConfig } from '~/types/axios' @@ -28,3 +28,7 @@ export default { // 重启面板 restart: (): Promise> => request.post('/dashboard/restart') } + +export const panel = () => http.Get('/dashboard/panel') +export const current = (nets: string[], disks: string[]) => + http.Post('/dashboard/current', { nets, disks }, { meta: { noAlert: true } }) diff --git a/web/src/components/common/AppProvider.vue b/web/src/components/common/AppProvider.vue index e4764f35..10f03ee5 100644 --- a/web/src/components/common/AppProvider.vue +++ b/web/src/components/common/AppProvider.vue @@ -1,6 +1,5 @@ diff --git a/web/src/layout/sidebar/components/SideLogo.vue b/web/src/layout/sidebar/components/SideLogo.vue index fd5e2b8a..8af722d9 100644 --- a/web/src/layout/sidebar/components/SideLogo.vue +++ b/web/src/layout/sidebar/components/SideLogo.vue @@ -1,6 +1,5 @@