Skip to content

Commit

Permalink
feat: move modal/notify
Browse files Browse the repository at this point in the history
  • Loading branch information
hexqi committed Jun 14, 2024
1 parent 9417d03 commit 63141d4
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 35 deletions.
7 changes: 1 addition & 6 deletions designer-demo/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
// 导入@opentiny/tiny-engine时,内部的依赖包也会逐个导入,可能会执行useComplie,此时需要templateHashMap。所以需要先执行一次defineEntry
import { registry } from './defineEntry.js'
import { init } from '@opentiny/tiny-engine'
import { initHook, HOOK_NAME } from '@opentiny/tiny-engine-entry'
import { configurators } from './configurators/'
import 'virtual:svg-icons-register'
import '@opentiny/tiny-engine-theme'

const beforeAppCreate = () => {
initHook(HOOK_NAME.useEnv, import.meta.env)
}

init({ registry, configurators, lifeCycles: { beforeAppCreate } })
init({ registry, configurators })
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const confirm = ({ title, status, message, exec, cancel, showFooter = true }) =>
message: () => {
return (
<div class="modal-content">
<div class="wrap">
{typeof message === 'string' ? message : <message />}
</div>
<div class="wrap">{typeof message === 'string' ? message : <message />}</div>
</div>
)
}
Expand All @@ -32,11 +30,9 @@ const message = ({ title, status, message, exec, width = '400' }) => {
width: width,
message() {
return (
<div div class="modal-content" >
<div class="wrap">
{typeof message === 'string' ? message : <message />}
</div>
</div >
<div div class="modal-content">
<div class="wrap">{typeof message === 'string' ? message : <message />}</div>
</div>
)
}
}).then(() => {
Expand Down Expand Up @@ -67,10 +63,8 @@ const topbox = (options) => {
window.topbox = topbox
window.message = message

export default () => {
return {
confirm,
message,
topbox
}
export default {
confirm,
message,
topbox
}
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,6 @@ export {
MetaTableColumns,
SearchEmpty
}

export { default as Modal } from './component/Modal'
export { default as Notify } from './component/Notify'
3 changes: 1 addition & 2 deletions packages/controller/js/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
*/

import { useHttp } from '@opentiny/tiny-engine-http'
import useNotify from '../src/components/useNotify'
import { isVsCodeEnv } from './environments'
import { generateRouter, generatePage } from './vscodeGenerateFile'
import { usePage, useCanvas } from '@opentiny/tiny-engine-entry'
import { usePage, useCanvas, useNotify } from '@opentiny/tiny-engine-entry'

const http = useHttp()

Expand Down
3 changes: 1 addition & 2 deletions packages/controller/src/hooks/useDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { reactive } from 'vue'
import { utils } from '@opentiny/tiny-engine-utils'
import { isEqual } from '@opentiny/vue-renderless/common/object'
import { isEmptyObject } from '@opentiny/vue-renderless/common/type'
import useModal from '../components/useModal'
import { HOOK_NAME, initHook } from '@opentiny/tiny-engine-entry'
import { HOOK_NAME, initHook, useModal } from '@opentiny/tiny-engine-entry'

const dataSourceState = reactive({
dataSource: {},
Expand Down
3 changes: 1 addition & 2 deletions packages/controller/src/hooks/useEditorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

import { ref } from 'vue'
import { useHttp } from '@opentiny/tiny-engine-http'
import useModal from '../components/useModal'
import { HOOK_NAME, initHook } from '@opentiny/tiny-engine-entry'
import { HOOK_NAME, initHook, useModal } from '@opentiny/tiny-engine-entry'

// web版获取配置信息: 从url中获取
const _getWebData = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/controller/src/hooks/useResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { reactive } from 'vue'
import { useHttp } from '@opentiny/tiny-engine-http'
import { utils, constants } from '@opentiny/tiny-engine-utils'
import { meta as BuiltinComponentMaterials } from '@opentiny/tiny-engine-builtin-component'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'
import { getCanvasStatus } from '../../js/canvas'
import useNotify from '../components/useNotify'
import {
getMergeMeta,
useNotify,
HOOK_NAME,
initHook,
useApp,
Expand Down
8 changes: 3 additions & 5 deletions packages/controller/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import useData from './useData'
export { default as metaData } from '../meta'
import example from './example'

// 后续移入common包components
import useNotify from './components/useNotify'
import useModal from './components/useModal'

export const getExample = example

export {
Expand All @@ -38,7 +34,9 @@ export {
useBreadcrumb,
useProperty,
useHelp,
useModal,
useNotify,
useCustom
} from '@opentiny/tiny-engine-entry'

export { useNotify, useData, useMessage, useModal }
export { useData, useMessage }
8 changes: 6 additions & 2 deletions packages/design-core/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { createApp } from 'vue'
import initSvgs from '@opentiny/tiny-engine-svgs'
import i18n from '@opentiny/tiny-engine-controller/js/i18n'
import { initMonitor } from '@opentiny/tiny-engine-controller/js/monitor'
import { injectGlobalComponents } from '@opentiny/tiny-engine-common'
import { injectGlobalComponents, Modal, Notify } from '@opentiny/tiny-engine-common'
import { initHttp } from '@opentiny/tiny-engine-http'
import TinyThemeTool from '@opentiny/vue-theme/theme-tool'
import { tinySmbTheme } from '@opentiny/vue-theme/theme' // SMB 主题
import { defineEntry, mergeRegistry } from '@opentiny/tiny-engine-entry'
import { defineEntry, mergeRegistry, initHook, HOOK_NAME } from '@opentiny/tiny-engine-entry'
import App from './layout/App.vue'
import defaultRegistry from '../registry.js'
import { registerConfigurators } from './registerConfigurators'
Expand All @@ -35,6 +35,10 @@ const defaultLifeCycles = {
// 在common层注入合并后的注册表
defineEntry(newRegistry)

initHook(HOOK_NAME.useEnv, import.meta.env)
initHook(HOOK_NAME.useNotify, () => Notify)
initHook(HOOK_NAME.useModal, () => Modal)

// 加载主题样式,尽早加载
// import(`./theme/${newRegistry.config.theme}.js`)

Expand Down
6 changes: 6 additions & 0 deletions packages/entry/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const HOOK_NAME = {
useHelp: 'help',
useHttp: 'http',
useEnv: 'env',
useModal: 'modal',
useNotify: 'notify',
useCustom: 'custom'
}

Expand All @@ -37,6 +39,8 @@ const hooksState = {
[HOOK_NAME.useHelp]: {},
[HOOK_NAME.useHttp]: {},
[HOOK_NAME.useEnv]: {},
[HOOK_NAME.useNotify]: {},
[HOOK_NAME.useModal]: {},
[HOOK_NAME.useCustom]: {} // 自定义
}

Expand All @@ -57,6 +61,8 @@ export const useProperty = () => hooksState[HOOK_NAME.useProperty]
export const useHelp = () => hooksState[HOOK_NAME.useHelp]
export const useHttp = () => hooksState[HOOK_NAME.useHttp]
export const useEnv = () => hooksState[HOOK_NAME.useEnv]
export const useModal = () => hooksState[HOOK_NAME.useModal]
export const useNotify = () => hooksState[HOOK_NAME.useNotify]
export const useCustom = () => hooksState[HOOK_NAME.useCustom]

export function initHook(hookName, hookContent, { useDefaultExport } = {}) {
Expand Down

0 comments on commit 63141d4

Please sign in to comment.