mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
feat: 实验性支持alova
This commit is contained in:
@@ -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"),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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",
|
||||
|
||||
36
web/pnpm-lock.yaml
generated
36
web/pnpm-lock.yaml
generated
@@ -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
|
||||
|
||||
@@ -21,5 +21,6 @@
|
||||
"warning": "#F0A020",
|
||||
"error": "#D03050"
|
||||
},
|
||||
"locale": "zh_CN"
|
||||
"locale": "zh_CN",
|
||||
"name": "耗子面板"
|
||||
}
|
||||
|
||||
@@ -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<AxiosResponse<any>> => 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 } })
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { useThemeStore } from '@/store'
|
||||
import { useCssVar } from '@vueuse/core'
|
||||
import { kebabCase } from 'lodash-es'
|
||||
import type { GlobalThemeOverrides } from 'naive-ui'
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ export function setupI18n(app: App) {
|
||||
legacy: false,
|
||||
globalInjection: true,
|
||||
locale: themeStore.locale,
|
||||
missingWarn: false, // TODO 完成 i18n 之后需要去除
|
||||
fallbackWarn: false, // TODO 完成 i18n 之后需要去除
|
||||
fallbackLocale: 'zh_CN',
|
||||
messages: {
|
||||
en: en,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script lang="ts" setup>
|
||||
import { useFullscreen } from '@vueuse/core'
|
||||
|
||||
const { isFullscreen, toggle } = useFullscreen()
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import logo from '@/assets/images/logo.png'
|
||||
import { title } from '@/main'
|
||||
import { useThemeStore } from '@/store'
|
||||
|
||||
const themeStore = useThemeStore()
|
||||
@@ -13,7 +12,7 @@ const themeStore = useThemeStore()
|
||||
v-show="!themeStore.sider.collapsed"
|
||||
class="ml-10 max-w-140 flex-shrink-0 text-18 font-bold"
|
||||
>
|
||||
{{ title }}
|
||||
{{ themeStore.name }}
|
||||
</h2>
|
||||
</router-link>
|
||||
</template>
|
||||
|
||||
@@ -13,7 +13,7 @@ import { setupNaiveDiscreteApi } from './utils'
|
||||
|
||||
import { install as VueMonacoEditorPlugin } from '@guolao/vue-monaco-editor'
|
||||
|
||||
import dashboard from '@/api/panel/dashboard'
|
||||
import { panel } from '@/api/panel/dashboard'
|
||||
import CronNaivePlugin from '@vue-js-cron/naive-ui'
|
||||
|
||||
async function setupApp() {
|
||||
@@ -36,22 +36,17 @@ async function setupApp() {
|
||||
app.mount('#app')
|
||||
}
|
||||
|
||||
const title = ref(import.meta.env.VITE_APP_TITLE)
|
||||
|
||||
const setupPanel = async () => {
|
||||
const themeStore = useThemeStore()
|
||||
await dashboard
|
||||
.panel()
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
title.value = data.data.name || import.meta.env.VITE_APP_TITLE
|
||||
themeStore.setLocale(data.data.locale || 'zh_CN')
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
useRequest(panel, {
|
||||
initialData: {
|
||||
name: import.meta.env.VITE_APP_TITLE,
|
||||
locale: 'zh_CN'
|
||||
}
|
||||
}).onSuccess(({ data }: { data: any }) => {
|
||||
themeStore.setLocale(data.locale)
|
||||
themeStore.setName(data.name)
|
||||
})
|
||||
}
|
||||
|
||||
setupApp()
|
||||
|
||||
export { title }
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import type { Router } from 'vue-router'
|
||||
|
||||
import { trans } from '@/i18n/i18n'
|
||||
import { title } from '@/main'
|
||||
import { useThemeStore } from '@/store'
|
||||
|
||||
export function createPageTitleGuard(router: Router) {
|
||||
const themeStore = useThemeStore()
|
||||
router.afterEach((to) => {
|
||||
const pageTitle = String(to.meta.title)
|
||||
if (pageTitle) document.title = `${trans(pageTitle)} | ${title.value}`
|
||||
else document.title = title.value
|
||||
if (pageTitle) document.title = `${trans(pageTitle)} | ${themeStore.name}`
|
||||
else document.title = themeStore.name
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPinia } from 'pinia'
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||
import type { App } from 'vue'
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useAppStore = defineStore('app', {
|
||||
state() {
|
||||
return {}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { asyncRoutes, basicRoutes } from '@/router/routes'
|
||||
import { defineStore } from 'pinia'
|
||||
import type { RoutesType } from '~/types/router'
|
||||
import { filterAsyncRoutes } from './helpers'
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { router } from '@/router'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const WITHOUT_TAB_PATHS = ['/404', '/login']
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ export function defaultSettings(): Theme.Setting {
|
||||
error: '#f5222d'
|
||||
}
|
||||
const locale = themeSetting.locale || 'zh_CN'
|
||||
return { isMobile, darkMode, sider, header, tab, primaryColor, otherColor, locale }
|
||||
const name = themeSetting.name || import.meta.env.VITE_APP_TITLE
|
||||
return { isMobile, darkMode, sider, header, tab, primaryColor, otherColor, locale, name }
|
||||
}
|
||||
|
||||
/** 获取naive的主题颜色 */
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import {
|
||||
darkTheme,
|
||||
dateEnUS,
|
||||
dateZhCN,
|
||||
enUS,
|
||||
type GlobalThemeOverrides,
|
||||
type NDateLocale,
|
||||
type NLocale,
|
||||
zhCN
|
||||
} from 'naive-ui'
|
||||
import type { GlobalThemeOverrides, NDateLocale, NLocale } from 'naive-ui'
|
||||
import { darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from 'naive-ui'
|
||||
import type { BuiltInGlobalTheme } from 'naive-ui/es/themes/interface'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import { defaultSettings, getNaiveThemeOverrides } from './helpers'
|
||||
|
||||
type ThemeState = Theme.Setting
|
||||
@@ -65,6 +57,10 @@ export const useThemeStore = defineStore('theme', {
|
||||
/** 设置语言 */
|
||||
setLocale(locale: string) {
|
||||
this.locale = locale
|
||||
},
|
||||
/** 设置名称 */
|
||||
setName(name: string) {
|
||||
this.name = name
|
||||
}
|
||||
},
|
||||
persist: true
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { resetRouter } from '@/router'
|
||||
import { usePermissionStore, useTabStore } from '@/store'
|
||||
import { toLogin } from '@/utils'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export interface UserInfo {
|
||||
id?: string
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { resolveResError } from '@/utils/http/helpers'
|
||||
import { createAlova, Method } from 'alova'
|
||||
import adapterFetch from 'alova/fetch'
|
||||
import VueHook from 'alova/vue'
|
||||
import axios from 'axios'
|
||||
import { reqReject, reqResolve, resReject, resResolve } from './interceptors'
|
||||
|
||||
@@ -18,3 +22,54 @@ export function createAxios(options = {}) {
|
||||
export const request = createAxios({
|
||||
baseURL: import.meta.env.VITE_BASE_API
|
||||
})
|
||||
|
||||
export const http = createAlova({
|
||||
statesHook: VueHook,
|
||||
requestAdapter: adapterFetch(),
|
||||
baseURL: import.meta.env.VITE_BASE_API,
|
||||
responded: {
|
||||
onSuccess: async (response: Response, method: Method) => {
|
||||
const ct = response.headers.get('Content-Type')
|
||||
const json =
|
||||
ct && ct.includes('application/json')
|
||||
? await response.json()
|
||||
: { code: response.status, message: await response.text() }
|
||||
const { status, statusText } = response
|
||||
const { meta } = method
|
||||
if (status !== 200) {
|
||||
const code = json?.code ?? status
|
||||
const message = resolveResError(code, json?.message ?? statusText)
|
||||
const noAlert = meta?.noAlert
|
||||
if (!noAlert) {
|
||||
if (code === 422) {
|
||||
window.$message.error(message)
|
||||
} else if (code !== 401) {
|
||||
window.$dialog.error({
|
||||
title: '接口响应异常',
|
||||
content: message,
|
||||
maskClosable: false
|
||||
})
|
||||
}
|
||||
}
|
||||
throw new Error(message)
|
||||
}
|
||||
return json.data
|
||||
},
|
||||
onError: (error: any, method: Method) => {
|
||||
const { code, message } = error
|
||||
const { meta } = method
|
||||
const errorMessage = resolveResError(code, message)
|
||||
const noAlert = meta?.noAlert
|
||||
|
||||
if (!noAlert) {
|
||||
window.$dialog.error({
|
||||
title: '接口请求失败',
|
||||
content: errorMessage,
|
||||
maskClosable: false
|
||||
})
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { useStorage } from '@vueuse/core'
|
||||
|
||||
import user from '@/api/panel/user'
|
||||
import bgImg from '@/assets/images/login_bg.webp'
|
||||
import { title } from '@/main'
|
||||
import { addDynamicRoutes } from '@/router'
|
||||
import { useUserStore } from '@/store'
|
||||
import { useThemeStore, useUserStore } from '@/store'
|
||||
import { getLocal, removeLocal, setLocal } from '@/utils'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -29,6 +26,7 @@ if (localLoginInfo) {
|
||||
}
|
||||
|
||||
const userStore = useUserStore()
|
||||
const themeStore = useThemeStore()
|
||||
const loging = ref<boolean>(false)
|
||||
const isRemember = useStorage('isRemember', false)
|
||||
|
||||
@@ -89,7 +87,7 @@ onMounted(async () => {
|
||||
<div m-auto min-w-345 f-c-c rounded-10 bg-white bg-opacity-60 p-15 card-shadow dark:bg-dark>
|
||||
<div w-480 flex-col px-20 py-35>
|
||||
<h5 color="#6a6a6a" f-c-c text-24 font-normal>
|
||||
<img class="mr-10" height="50" src="@/assets/images/logo.png" />{{ title }}
|
||||
<img class="mr-10" height="50" src="@/assets/images/logo.png" />{{ themeStore.name }}
|
||||
</h5>
|
||||
<div mt-30>
|
||||
<n-input
|
||||
|
||||
2
web/types/theme.d.ts
vendored
2
web/types/theme.d.ts
vendored
@@ -46,5 +46,7 @@ declare namespace Theme {
|
||||
otherColor: OtherColor
|
||||
/** 语言 */
|
||||
locale: string
|
||||
/** 名称 */
|
||||
name: string
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user