Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(constant): reposition EMQX_VERSION #3237

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"typescript": "~5.5.4",
"unplugin-auto-import": "^19.1.0",
"unplugin-vue-components": "^28.4.0",
"vite": "^5.0.0"
"vite": "^5.0.0",
"vue-tsc": "^2.2.4"
},
"husky": {
"hooks": {
Expand Down
91 changes: 91 additions & 0 deletions pnpm-lock.yaml

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

11 changes: 3 additions & 8 deletions src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ declare global {
const AUTH_PLACEHOLDERS: typeof import('./common/constants')['AUTH_PLACEHOLDERS']
const AUTH_PLACEHOLDER_CLIENT_ATTRS: typeof import('./common/constants')['AUTH_PLACEHOLDER_CLIENT_ATTRS']
const AUTO_RESTART_INTERVAL_DEFAULT: typeof import('./common/constants')['AUTO_RESTART_INTERVAL_DEFAULT']
const ArgumentType: typeof import('./hooks/useRuleFunc')['ArgumentType']
const AvroJsonToObject: typeof import('./hooks/Plugins/avroUtils')['AvroJsonToObject']
const BACKGROUND_CIRCLE_INNER_RADIUS: typeof import('./hooks/Overview/useNodesGraph')['BACKGROUND_CIRCLE_INNER_RADIUS']
const BACKGROUND_CIRCLE_OUTER_RADIUS: typeof import('./hooks/Overview/useNodesGraph')['BACKGROUND_CIRCLE_OUTER_RADIUS']
Expand All @@ -35,6 +34,7 @@ declare global {
const DEFAULT_SELECT: typeof import('./common/constants')['DEFAULT_SELECT']
const DEFAULT_SSL_VERIFY_VALUE: typeof import('./common/constants')['DEFAULT_SSL_VERIFY_VALUE']
const DEFAULT_ZONE: typeof import('./common/constants')['DEFAULT_ZONE']
const EMQX_VERSION: typeof import('./common/constants')['EMQX_VERSION']
const ENCRYPTED_PWD_REG: typeof import('./common/constants')['ENCRYPTED_PWD_REG']
const EffectScope: typeof import('vue')['EffectScope']
const ElMessage: typeof import('element-plus')['ElMessage']
Expand Down Expand Up @@ -343,7 +343,6 @@ declare global {
const useRouter: typeof import('vue-router')['useRouter']
const useRuleEvents: typeof import('./hooks/Rule/rule/useRuleEvents')['default']
const useRuleForm: typeof import('./hooks/Rule/rule/useRuleForm')['default']
const useRuleFunc: typeof import('./hooks/useRuleFunc')['default']
const useRuleInputs: typeof import('./hooks/Rule/rule/useRule')['useRuleInputs']
const useRuleMetrics: typeof import('./hooks/useMetrics')['useRuleMetrics']
const useRuleOutputs: typeof import('./hooks/Rule/rule/useRule')['useRuleOutputs']
Expand Down Expand Up @@ -427,11 +426,8 @@ declare global {
export type { TypeMapData, PieDataItem, TypeMetricDataItem } from './hooks/useMetrics'
import('./hooks/useMetrics')
// @ts-ignore
export type { FilterItem } from './hooks/usePaging'
export type { DataFilterItem } from './hooks/usePaging'
import('./hooks/usePaging')
// @ts-ignore
export type { ArgItem, FuncItem } from './hooks/useRuleFunc'
import('./hooks/useRuleFunc')
}

// for vue template auto import
Expand All @@ -448,7 +444,6 @@ declare module 'vue' {
readonly AUTH_PLACEHOLDERS: UnwrapRef<typeof import('./common/constants')['AUTH_PLACEHOLDERS']>
readonly AUTH_PLACEHOLDER_CLIENT_ATTRS: UnwrapRef<typeof import('./common/constants')['AUTH_PLACEHOLDER_CLIENT_ATTRS']>
readonly AUTO_RESTART_INTERVAL_DEFAULT: UnwrapRef<typeof import('./common/constants')['AUTO_RESTART_INTERVAL_DEFAULT']>
readonly ArgumentType: UnwrapRef<typeof import('./hooks/useRuleFunc')['ArgumentType']>
readonly AvroJsonToObject: UnwrapRef<typeof import('./hooks/Plugins/avroUtils')['AvroJsonToObject']>
readonly BACKGROUND_CIRCLE_INNER_RADIUS: UnwrapRef<typeof import('./hooks/Overview/useNodesGraph')['BACKGROUND_CIRCLE_INNER_RADIUS']>
readonly BACKGROUND_CIRCLE_OUTER_RADIUS: UnwrapRef<typeof import('./hooks/Overview/useNodesGraph')['BACKGROUND_CIRCLE_OUTER_RADIUS']>
Expand All @@ -468,6 +463,7 @@ declare module 'vue' {
readonly DEFAULT_SELECT: UnwrapRef<typeof import('./common/constants')['DEFAULT_SELECT']>
readonly DEFAULT_SSL_VERIFY_VALUE: UnwrapRef<typeof import('./common/constants')['DEFAULT_SSL_VERIFY_VALUE']>
readonly DEFAULT_ZONE: UnwrapRef<typeof import('./common/constants')['DEFAULT_ZONE']>
readonly EMQX_VERSION: UnwrapRef<typeof import('./common/constants')['EMQX_VERSION']>
readonly ENCRYPTED_PWD_REG: UnwrapRef<typeof import('./common/constants')['ENCRYPTED_PWD_REG']>
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly ElMessage: UnwrapRef<typeof import('element-plus')['ElMessage']>
Expand Down Expand Up @@ -776,7 +772,6 @@ declare module 'vue' {
readonly useRouter: UnwrapRef<typeof import('vue-router')['useRouter']>
readonly useRuleEvents: UnwrapRef<typeof import('./hooks/Rule/rule/useRuleEvents')['default']>
readonly useRuleForm: UnwrapRef<typeof import('./hooks/Rule/rule/useRuleForm')['default']>
readonly useRuleFunc: UnwrapRef<typeof import('./hooks/useRuleFunc')['default']>
readonly useRuleInputs: UnwrapRef<typeof import('./hooks/Rule/rule/useRule')['useRuleInputs']>
readonly useRuleMetrics: UnwrapRef<typeof import('./hooks/useMetrics')['useRuleMetrics']>
readonly useRuleOutputs: UnwrapRef<typeof import('./hooks/Rule/rule/useRule')['useRuleOutputs']>
Expand Down
8 changes: 6 additions & 2 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,14 @@ export const INFINITY_VALUE = 'infinity'

export const COMMON_ID_REG = /^[A-Za-z0-9]+[A-Za-z0-9-_]*$/

export const SEARCH_FORM_RES_PROPS = { sm: 12, md: 12, lg: 6 }

export const EMQX_VERSION = __EMQX_VERSION__

/**
* ‼️ Must be placed above a variable that is not being exported;
* the unplugin-auto-import bug will affect the auto import of variables below that variable!
*/
export const SEARCH_FORM_RES_PROPS = { sm: 12, md: 12, lg: 6 }

const defaultUnexposedConfig = {
zone: 'default',
access_rules: ['allow all'],
Expand Down
2 changes: 1 addition & 1 deletion src/components/PluginsForm/PluginFormKit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const saveLoading = ref(false)

const { t } = useI18n()

const { rules } = usePluginGenFormRules({
const { rules } = useGenPluginFormRules({
formConfigs: props.layouts.$form,
})

Expand Down
1 change: 1 addition & 0 deletions src/components/SchemaFormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import KeyAndValueEditor from './KeyAndValueEditor.vue'
import OneOf from './Oneof.vue'
import TimeInputWithUnitSelect from './TimeInputWithUnitSelect.vue'
import CustomInputPassword from './CustomInputPassword.vue'
import { SetupContext } from 'vue'

type FormItemType =
| 'string'
Expand Down
1 change: 1 addition & 0 deletions src/components/global-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ShowMoreButton,
LinkButton,
} from './Buttons'
import { App } from 'vue'

export default {
install(app: App): void {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/Auth/useDatabaseConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { SaltPosition } from '@/types/enum'
import { SetupContext } from 'vue'

export default function useDatabaseConfig(
props: {
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/usePaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface PageMeta {
limit: number
}

export interface FilterItem {
export interface DataFilterItem {
key: string
value: string | boolean | RegExp
}
Expand All @@ -24,13 +24,13 @@ export default (): {
setTotalData: (data: ListData) => void
getAPageData: (
pageMeta: PageMeta,
filters?: Array<FilterItem>,
filters?: Array<DataFilterItem>,
sortFrom?: SortFrom,
) => ListDataWithPagination<any>
} => {
const totalData: Ref<ListData> = ref([])
// Use the following six variables to do a cache-like operation to reduce computational overhead
let latestFilters: Array<FilterItem> = []
let latestFilters: Array<DataFilterItem> = []
const listAfterFilter: Ref<ListData> = ref([])
let latestSortFromString: string | undefined = undefined
const listAfterFilterNSort: Ref<ListData> = ref([])
Expand All @@ -57,7 +57,7 @@ export default (): {
return filterValue === value
}

const filterList = (filters: Array<FilterItem> = []) => {
const filterList = (filters: Array<DataFilterItem> = []) => {
latestFilters = cloneDeep(filters)
if (filters.length === 0) {
listAfterFilter.value = totalData.value
Expand Down Expand Up @@ -85,7 +85,7 @@ export default (): {

const getAPageData = (
pageMeta: PageMeta,
filters: Array<FilterItem> = [],
filters: Array<DataFilterItem> = [],
sortFrom?: SortFrom,
) => {
if (!isEqual(latestFilters, filters)) {
Expand Down
Loading
Loading