Skip to content

Commit

Permalink
refactor: remove lodash
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Nov 26, 2024
1 parent 7af2a78 commit 389f6b3
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 82 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@
"crossbell.js": "npm:[email protected]",
"date-fns": "3.6.0",
"ejs": "3.1.10",
"es-toolkit": "1.27.0",
"event-source-polyfill": "1.0.31",
"highlight.js": "11.10.0",
"js-cookie": "3.0.5",
"js-yaml": "4.1.0",
"json5": "2.2.3",
"lodash-es": "4.17.21",
"lodash.transform": "4.6.0",
"markdown-escape": "2.0.0",
"marked": "13.0.3",
"monaco-editor": "0.50.0",
Expand Down Expand Up @@ -103,7 +104,6 @@
"@types/ejs": "3.1.5",
"@types/event-source-polyfill": "1.0.5",
"@types/js-yaml": "4.0.9",
"@types/lodash-es": "4.17.12",
"@types/markdown-escape": "1.1.3",
"@types/qs": "6.9.17",
"@types/sortablejs": "1.15.8",
Expand Down
22 changes: 16 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/config-form/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get, set } from 'lodash-es'
import { get, set } from 'es-toolkit/compat'
import { marked } from 'marked'
import {
NCollapse,
Expand Down
2 changes: 1 addition & 1 deletion src/components/drawer/components/image-detail-section.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { decode } from 'blurhash'
import { uniqBy } from 'lodash-es'
import { uniqBy } from 'es-toolkit/compat'
import {
NButton,
NButtonGroup,
Expand Down
12 changes: 7 additions & 5 deletions src/components/drawer/text-base-drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { isURL } from 'class-validator'
import { JSONHighlight } from '~/components/json-highlight'
import { isObject, isUndefined } from 'lodash-es'
import { isObject, isUndefined } from 'es-toolkit/compat'
import {
NButton,
NCollapse,
Expand All @@ -20,13 +19,16 @@ import {
NSwitch,
NTooltip,
} from 'naive-ui'
import { JSONParseReturnOriginal } from '~/utils/json'
import { ImageDetailSection } from './components/image-detail-section'
import { JSONEditor } from './components/json-editor'
import type { Image } from '@mx-space/api-client'
import type { SelectOption } from 'naive-ui'
import type { PropType } from 'vue'

import { JSONHighlight } from '~/components/json-highlight'
import { JSONParseReturnOriginal } from '~/utils/json'

import { ImageDetailSection } from './components/image-detail-section'
import { JSONEditor } from './components/json-editor'

type ItemType = 'date-picker'
export const TextBaseDrawer = defineComponent({
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/kv-editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmpty } from 'lodash-es'
import { isEmpty } from 'es-toolkit/compat'
import { NDynamicInput, NInput, NSelect } from 'naive-ui'
import type { SelectMixedOption } from 'naive-ui/lib/select/src/interface'
import type { PropType } from 'vue'
Expand Down
10 changes: 6 additions & 4 deletions src/components/location/search-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SearchIcon } from '~/components/icons'
import { debounce } from 'lodash-es'
import { debounce } from 'es-toolkit/compat'
import {
NAutoComplete,
NButton,
Expand All @@ -9,13 +8,16 @@ import {
NModal,
NSpace,
} from 'naive-ui'
import { RESTManager } from '~/utils/rest'
import { defineComponent, ref, watch } from 'vue'
import { Icon } from '@vicons/utils'
import type { AMapSearch } from '~/models/amap'
import type { AutoCompleteOption } from 'naive-ui/lib/auto-complete/src/interface'
import type { PropType } from 'vue'

import { Icon } from '@vicons/utils'

import { SearchIcon } from '~/components/icons'
import { RESTManager } from '~/utils/rest'

export const SearchLocationButton = defineComponent({
props: {
placeholder: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/special-button/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce } from 'lodash-es'
import { debounce } from 'es-toolkit/compat'
import { NSplit } from 'naive-ui'

import { useUIStore } from '~/stores/ui'
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-storage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { instanceToPlain, plainToInstance } from 'class-transformer'
import { validateSync } from 'class-validator'
import { throttle } from 'lodash-es'
import { throttle } from 'es-toolkit/compat'
import { reactive, watch } from 'vue'

const key2reactive = new Map<string, any>()
Expand Down
2 changes: 1 addition & 1 deletion src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @FilePath: /admin-next/src/stores/ui.ts
* Mark: Coding with Love
*/
import { debounce } from 'lodash-es'
import { debounce } from 'es-toolkit/compat'
import { computed, onMounted, ref, watch } from 'vue'

import { useDark, useToggle } from '@vueuse/core'
Expand Down
3 changes: 2 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isEqual, isObject, transform } from 'lodash-es'
import { isEqual, isObject } from 'es-toolkit/compat'
import transform from 'lodash.transform'
import { toRaw } from 'vue'

export * from './auth'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/rest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPlainObject } from 'lodash-es'
import { isPlainObject } from 'es-toolkit/compat'
import { extend } from 'umi-request'
import type { RequestMethod, RequestOptionsInit } from 'umi-request'

Expand Down
13 changes: 7 additions & 6 deletions src/views/analyze/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { IpInfoPopover } from '~/components/ip-info'
import { ContentLayout } from '~/layouts/content'
import { isEmpty } from 'lodash-es'
import { isEmpty } from 'es-toolkit/compat'
import {
NButton,
NDataTable,
Expand All @@ -11,7 +9,6 @@ import {
NTabs,
useDialog,
} from 'naive-ui'
import { RESTManager } from '~/utils'
import {
defineComponent,
onBeforeMount,
Expand All @@ -20,16 +17,20 @@ import {
toRaw,
watch,
} from 'vue'
import type { IPAggregate, Month, Path, Today, Total, Week } from './types'

import { Chart } from '@antv/g2/esm'

import { IpInfoPopover } from '~/components/ip-info'
import { ContentLayout } from '~/layouts/content'
import { RESTManager } from '~/utils'

import { AnalyzeDataTable } from './components/analyze-data-table'
import { GuestActivity } from './components/guest-activity'
import { ReadingRank } from './components/reading-rank'
import type { IPAggregate, Month, Path, Today, Total, Week } from './types'

const SectionTitle = defineComponent((_, { slots }) => () => (
<div class="my-[12px] font-semibold text-gray-400 ">{slots.default?.()}</div>
<div class="my-[12px] font-semibold text-gray-400">{slots.default?.()}</div>
))
export default defineComponent({
setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pick } from 'lodash-es'
import { pick } from 'es-toolkit/compat'
import {
NButton,
NCard,
Expand Down
2 changes: 1 addition & 1 deletion src/views/extra-features/markdown-helper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce } from 'lodash-es'
import { debounce } from 'es-toolkit/compat'
import {
NButton,
NButtonGroup,
Expand Down
16 changes: 8 additions & 8 deletions src/views/extra-features/snippets/tabs/for-edit.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { HeaderActionButton } from '~/components/button/rounded-button'
import { CheckCircleOutlinedIcon } from '~/components/icons'
import { KVEditor } from '~/components/kv-editor'
import { omit } from 'es-toolkit/compat'
import { dump, load } from 'js-yaml'
import JSON5 from 'json5'
import { useLayout } from '~/layouts/content'
import { TwoColGridLayout } from '~/layouts/two-col'
import { omit } from 'lodash-es'
import {
NForm,
NFormItem,
Expand All @@ -17,18 +12,23 @@ import {
NSwitch,
useMessage,
} from 'naive-ui'
import { RESTManager } from '~/utils'
import { useRoute, useRouter } from 'vue-router'

import { useStorage } from '@vueuse/core'

import { HeaderActionButton } from '~/components/button/rounded-button'
import { CheckCircleOutlinedIcon } from '~/components/icons'
import { KVEditor } from '~/components/kv-editor'
import { useMountAndUnmount } from '~/hooks/use-lifecycle'
import { useLayout } from '~/layouts/content'
import { TwoColGridLayout } from '~/layouts/two-col'
import { RESTManager } from '~/utils'

import {
defaultServerlessFunction,
SnippetModel,
SnippetType,
SnippetTypeToLanguage,
defaultServerlessFunction,
} from '../../../../models/snippet'
import { CodeEditorForSnippet } from '../components/code-editor'
import { InstallDependencyButton } from '../components/install-dep-button'
Expand Down
2 changes: 1 addition & 1 deletion src/views/extra-features/webhook/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash-es'
import { cloneDeep } from 'es-toolkit/compat'
import {
NButton,
NButtonGroup,
Expand Down
23 changes: 12 additions & 11 deletions src/views/maintenance/pty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { GATEWAY_URL } from '~/constants/env'
import { HeaderActionButton } from '~/components/button/rounded-button'
import { RefreshIcon, StatusIcon } from '~/components/icons'
import { IpInfoPopover } from '~/components/ip-info'
import { Xterm } from '~/components/xterm'
import { ContentLayout } from '~/layouts/content'
import { merge } from 'lodash-es'
import { merge } from 'es-toolkit/compat'
import {
NButton,
NCard,
Expand All @@ -16,13 +10,20 @@ import {
useMessage,
} from 'naive-ui'
import Io from 'socket.io-client'
import { EventTypes } from '~/socket/types'
import { RESTManager, getToken, parseDate } from '~/utils'
import { bus } from '~/utils/event-bus'
import { useMountAndUnmount } from '~/hooks/use-lifecycle'
import type { IDisposable, Terminal } from '@xterm/xterm'
import type { PropType } from 'vue'

import { HeaderActionButton } from '~/components/button/rounded-button'
import { RefreshIcon, StatusIcon } from '~/components/icons'
import { IpInfoPopover } from '~/components/ip-info'
import { Xterm } from '~/components/xterm'
import { GATEWAY_URL } from '~/constants/env'
import { useMountAndUnmount } from '~/hooks/use-lifecycle'
import { ContentLayout } from '~/layouts/content'
import { EventTypes } from '~/socket/types'
import { getToken, parseDate, RESTManager } from '~/utils'
import { bus } from '~/utils/event-bus'

export default defineComponent({
name: 'PtyView',
setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/manage-notes/write.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { add } from 'date-fns'
import { isString } from 'lodash-es'
import { isString } from 'es-toolkit/compat'
import {
NButton,
NButtonGroup,
Expand Down
2 changes: 1 addition & 1 deletion src/views/manage-pages/write.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isString } from 'lodash-es'
import { isString } from 'es-toolkit/compat'
import { NFormItem, NInputNumber, useMessage } from 'naive-ui'
import { computed, defineComponent, onMounted, reactive, ref, toRaw } from 'vue'
import { useRoute, useRouter } from 'vue-router'
Expand Down
2 changes: 1 addition & 1 deletion src/views/manage-posts/write.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isString } from 'lodash-es'
import { isString } from 'es-toolkit/compat'
import {
NDynamicTags,
NFormItem,
Expand Down
16 changes: 9 additions & 7 deletions src/views/manage-project/edit.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { isString } from 'es-toolkit/compat'
import transform from 'lodash.transform'
import { NDynamicTags, NForm, NFormItem, NInput } from 'naive-ui'
import { computed, defineComponent, onMounted, reactive, toRaw } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import type { IGithubRepo } from '~/external/api/github-repo'
import type { ProjectModel } from '~/models/project'

import { HeaderActionButton } from '~/components/button/rounded-button'
import { Editor } from '~/components/editor/universal'
import { SendIcon } from '~/components/icons'
import { FetchGithubRepoButton } from '~/components/special-button/fetch-github-repo'
import { useParsePayloadIntoData } from '~/hooks/use-parse-payload'
import { ContentLayout } from '~/layouts/content'
import { isString, transform } from 'lodash-es'
import { NDynamicTags, NForm, NFormItem, NInput } from 'naive-ui'
import { RouteName } from '~/router/name'
import { RESTManager } from '~/utils'
import { computed, defineComponent, onMounted, reactive, toRaw } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Editor } from '~/components/editor/universal'
import type { IGithubRepo } from '~/external/api/github-repo'
import type { ProjectModel } from '~/models/project'

type ProjectReactiveType = {
name: string
Expand Down
Loading

0 comments on commit 389f6b3

Please sign in to comment.