* feat(plugin-map): add MapBlock * feat: improve implementation to better support multiple fields * feat: support click overlay * fix: the width of select is not 100% * fix: repeat MapBlock * fix: loss initializer * feat: support selected marker in map * feat: support select point use box * fix: fixedBlock not work * fix: template not work * feat: improve ui * feat: improve selecting * feat: update ui * feat: improve map readpretty * feat: support marker field
33 lines
907 B
TypeScript
33 lines
907 B
TypeScript
import { registerField, registerGroup, useCurrentAppInfo } from '@nocobase/client';
|
|
import React, { useEffect } from 'react';
|
|
import { fields } from './fields';
|
|
import { generateNTemplate } from './locale';
|
|
import './locale';
|
|
|
|
export const useRegisterInterface = () => {
|
|
const { data } = useCurrentAppInfo() || {};
|
|
useEffect(() => {
|
|
const dialect = data?.database.dialect;
|
|
if (!dialect) return;
|
|
|
|
registerGroup(fields[0].group, {
|
|
label: generateNTemplate('Map-based geometry'),
|
|
order: 51,
|
|
});
|
|
|
|
fields.forEach((field) => {
|
|
if (Array.isArray(field.dialects)) {
|
|
if (!field.dialects.includes(dialect)) {
|
|
return;
|
|
}
|
|
}
|
|
registerField(field.group, field.title, field);
|
|
});
|
|
}, [data]);
|
|
};
|
|
|
|
export const MapInitializer: React.FC = (props) => {
|
|
useRegisterInterface();
|
|
return <React.Fragment>{props.children}</React.Fragment>;
|
|
};
|