diff --git a/packages/core/src/create-plugin/constant/plugin-list.ts b/packages/core/src/create-plugin/constant/plugin-list.ts index 4e819cf2d6c2dc855a5e5f5fcbf3523d837d6edf..09b350013594bc188873dbadcda62aa4929e0d73 100644 --- a/packages/core/src/create-plugin/constant/plugin-list.ts +++ b/packages/core/src/create-plugin/constant/plugin-list.ts @@ -27,26 +27,26 @@ export const PluginList: IPluginType[] = [ { name: 'UILOGICNODE', caption: '界面逻辑节点' }, { name: 'VIEW_CUSTOM', caption: '实体视图绘制插件' }, { name: 'DEMETHOD', caption: '应用实体方法插件' }, - { name: 'APPUTIL', caption: '应用功能插件' }, + // { name: 'APPUTIL', caption: '应用功能插件' }, 未支持 { name: 'APPCOUNTER', caption: '应用计数器插件' }, - { name: 'DEDATAIMPORT', caption: '应用实体数据导入' }, - { name: 'DEDATAEXPORT', caption: '应用实体数据导出' }, - { name: 'DEFVALUERULE', caption: '应用实体属性值规则' }, - { name: 'APPVALUERULE', caption: '应用值规则' }, - { name: 'SEARCHBAR_ITEM', caption: '搜索栏项绘制插件' }, + // { name: 'DEDATAIMPORT', caption: '应用实体数据导入' }, 未支持 + // { name: 'DEDATAEXPORT', caption: '应用实体数据导出' }, 未支持 + // { name: 'DEFVALUERULE', caption: '应用实体属性值规则' }, 未支持 + // { name: 'APPVALUERULE', caption: '应用值规则' }, 未支持 + // { name: 'SEARCHBAR_ITEM', caption: '搜索栏项绘制插件' }, 未支持 { name: 'SEARCHBAR_RENDER', caption: '搜索栏绘制插件' }, { name: 'WIZARDPANEL_RENDER', caption: '向导面板绘制插件' }, { name: 'DEUIACTION', caption: '应用实体界面行为' }, - { name: 'CALENDAR_ITEM', caption: '日历部件项绘制插件' }, - { name: 'CALENDAR_RENDER', caption: '日历部件绘制插件' }, - { name: 'MAPVIEW_ITEM', caption: '地图部件项绘制插件' }, - { name: 'MAPVIEW_RENDER', caption: '地图部件绘制插件' }, - { name: 'PANEL_ITEM', caption: '面板部件成员绘制插件' }, - { name: 'PANEL_RENDER', caption: '面板部件绘制插件' }, - { name: 'DASHBOARD_ITEM', caption: '数据看板成员绘制插件' }, - { name: 'DASHBOARD_RENDER', caption: '数据看板绘制插件' }, - { name: 'APPUILOGIC', caption: '系统界面逻辑插件' }, - { name: 'APPMENU_ITEM', caption: '应用菜单项绘制插件' }, - { name: 'APPMENU_RENDER', caption: '应用菜单绘制插件' }, - { name: 'TITLEBAR_RENDER', caption: '标题栏绘制插件' }, + // { name: 'CALENDAR_ITEM', caption: '日历部件项绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'CALENDAR_RENDER', caption: '日历部件绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'MAPVIEW_ITEM', caption: '地图部件项绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'MAPVIEW_RENDER', caption: '地图部件绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'PANEL_ITEM', caption: '面板部件成员绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'PANEL_RENDER', caption: '面板部件绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'DASHBOARD_ITEM', caption: '数据看板成员绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'DASHBOARD_RENDER', caption: '数据看板绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'APPUILOGIC', caption: '系统界面逻辑插件' }, modeling建模平台没有此类型的插件 + // { name: 'APPMENU_ITEM', caption: '应用菜单项绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'APPMENU_RENDER', caption: '应用菜单绘制插件' }, modeling建模平台没有此类型的插件 + // { name: 'TITLEBAR_RENDER', caption: '标题栏绘制插件' }, modeling建模平台没有此类型的插件 ]; diff --git a/packages/core/src/create-plugin/template/global/README.md b/packages/core/src/create-plugin/template/global/README.md index 8e6b64a23d01f65333ced53096199590397deb1d..6c6e052e92c7ffa5d73c7d25b5d1b17fb9eca7a6 100644 --- a/packages/core/src/create-plugin/template/global/README.md +++ b/packages/core/src/create-plugin/template/global/README.md @@ -1,66 +1,88 @@ # 全局插件 -## 新建自定义部件插件 +全局插件可替换标准的组件和功能,当标准组件或者功能无法满足要求时,可以通过全局插件来实现。modeling建模平台创建全局插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) -新建自定义部件插件,需要注意的是插件标识需设置为GLOBAL_APP_UTIL,除此之外,运行时插件模式同时支持远程运行时插件,在实际运用的时候需根据当前项目所选择的插件模式来定义。详情参见 [运行时插件模式](./RUNTIME-PLUGIN-MODE.md) 篇。 +## 插件结构 - - -## 插件机制 - -应用初始化的时候,如果应用配置了应用插件,则会去加载应用插件,然后替换标准的组件和功能,详情如下: - -```tsx -// 加载应用插件 -async loadGlobalAppUtil(): Promise { - const appUtilTag: string = 'GLOBAL_APP_UTIL'; - const globalAppUtilPlugin = ibiz.hub.getPlugin( - appUtilTag.toLowerCase(), - this.appId, - ); - if (!globalAppUtilPlugin) return; - if ( - globalAppUtilPlugin.refMode !== 'APP' || - globalAppUtilPlugin.refTag !== appUtilTag - ) - return; - await ibiz.plugin.loadPlugin(globalAppUtilPlugin as ISysPFPlugin); -} +``` +|─ ─ {{pluginName}} 全局插件顶层目录 + |─ ─ src 全局插件源代码目录 +​ |─ ─ control 部件目录 +​ |─ ─ {{pluginName}}-control.provider.ts 部件适配器 +​ |─ ─ {{pluginName}}-control.scss 部件样式 +​ |─ ─ {{pluginName}}-control.tsx 部件组件 +​ |─ ─ index.ts 部件入口文件,替换标准部件逻辑 +​ |─ ─ editor 编辑器目录 +​ |─ ─ {{pluginName}}-editor.provider.ts 编辑器适配器 +​ |─ ─ {{pluginName}}-editor.scss 编辑器样式 +​ |─ ─ {{pluginName}}-editor.tsx 编辑器组件 +​ |─ ─ index.ts 编辑器入口文件,替换标准编辑器逻辑 +​ |─ ─ form-detail 表单成员目录 +​ |─ ─ {{pluginName}}-form-detail.provider.ts 表单成员适配器 +​ |─ ─ {{pluginName}}-form-detail.scss 表单成员样式 +​ |─ ─ {{pluginName}}-form-detail.tsx 表单成员组件 +​ |─ ─ index.ts 表单成员入口文件,替换标准表单成员逻辑 + |─ ─ grid-column 表格列目录 + ​ |─ ─ {{pluginName}}-grid-column.provider.ts 表格列适配器 + ​ |─ ─ {{pluginName}}-grid-column.scss 表格列样式 + ​ |─ ─ {{pluginName}}-grid-column.tsx 表格列组件 + ​ |─ ─ index.ts 表格列入口文件,替换标准表格列逻辑 + |─ ─ method 实体行为目录 + ​ |─ ─ {{pluginName}}-method.provider.ts 实体行为适配器 + ​ |─ ─ {{pluginName}}-method.ts 实体行为实现类 + ​ |─ ─ index.ts 实体行为入口文件,替换标准实体行为逻辑 + |─ ─ panel-item 面板项目录 + ​ |─ ─ {{pluginName}}-panel-item.provider.ts 面板项适配器 + ​ |─ ─ {{pluginName}}-panel-item.scss 面板项样式 + ​ |─ ─ {{pluginName}}-panel-item.tsx 面板项组件 + ​ |─ ─ index.ts 面板项入口文件,替换标准面板项逻辑 + |─ ─ ui-action 界面行为目录 + ​ |─ ─ {{pluginName}}-ui-action.provider.ts 界面行为适配器 + ​ |─ ─ index.ts 界面行为入口文件,替换标准界面行为逻辑 + |─ ─ view 视图目录 + ​ |─ ─ {{pluginName}}-view.provider.ts 视图适配器 + ​ |─ ─ {{pluginName}}-view.scss 视图样式 + ​ |─ ─ {{pluginName}}-view.tsx 视图组件 + ​ |─ ─ index.ts 视图入口文件,替换标准视图逻辑 +​ |─ ─ index.ts 全局插件入口文件,替换标准组件和功能 ``` -## 插件示例 +## 本地开发 -### 插件效果 +1. 安装依赖并link至全局 -表格加载数据后会弹出自定义提示 +```sh +// 安装依赖 +pnpm i - +// link底包 +./scripts/link.sh -### 插件结构 +// 启动 +pnpm dev +// link到全局 +pnpm link --global ``` -|─ ─ global 全局插件顶层目录,可根据实际业务命名 - |─ ─ src 全局插件源代码目录 -​ |─ ─ grid-view-engine.ts 表格视图引擎 -​ |─ ─ index.ts 全局插件入口文件 -``` -### 全局插件入口文件 +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` -全局插件入口文件会换标准的组件和功能,供外部使用。 +3. 主项目包中注册插件 -```typescript +```ts import { App } from 'vue'; -import { IViewController } from '@ibiz-template/runtime'; -import { GridViewEngine } from './grid-view-engine'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' export default { - install(_app: App) { - // 替换标准的表格视图引擎 - ibiz.engine.register( - 'VIEW_GridView', - (c: IViewController) => new GridViewEngine(c), - ); + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); }, }; ``` diff --git a/packages/core/src/create-plugin/template/global/RUNTIME-PLUGIN-MODE.md b/packages/core/src/create-plugin/template/global/RUNTIME-PLUGIN-MODE.md deleted file mode 100644 index dbe8a2b8aeeecb3d044d6a44a2ba70f24afe1ed1..0000000000000000000000000000000000000000 --- a/packages/core/src/create-plugin/template/global/RUNTIME-PLUGIN-MODE.md +++ /dev/null @@ -1,74 +0,0 @@ -# 运行时插件模式 - -| 插件模式 | 是否已支持 | -| :------------: | :--------: | -| 非运行时插件 | 是 | -| 本地运行时插件 | 否 | -| 远程运行时插件 | 是 | - -## 非运行时插件 - -非运行时插件与主项目一起编译打包,主项目中可以直接引用该插件,并且通过vue插件的形式挂载。 - -```typescript -import { App } from 'vue'; -import plugin from '@ibiz-template-plugin-example/example-one'; - -// 挂载插件 -export default { - install(app: App): void { - app.use(plugin); - }, -}; -``` - -## 远程运行时插件 - -远程运行时插件单独部署在cdn上。主项目中不能直接引用该插件,在使用到时才会去远程加载该插件。cdn请求基础路径pluginBaseUrl可在environment.js中配置。运行时插件仓库配置填写需参照[unpkg规范](https://unpkg.com); - -```typescript -// 加载远程插件 -async loadPluginRef( - rtObjectName: string, - rtObjectRepo: string, - ): Promise { - if (this.isIgnore(rtObjectRepo)) { - return true; - } - if (this.pluginCache.has(rtObjectName)) { - return true; - } - let configData: unknown = null; - { - const pluginPath: string = rtObjectRepo; - const configUrl = this.urlReg.test(pluginPath) - ? `${pluginPath}/package.json` - : `${ibiz.env.pluginBaseUrl}/${join(pluginPath, 'package.json')}`; - const res = await ibiz.net.axios({ - method: 'get', - headers: { 'Access-Control-Allow-Origin': '*' }, - url: configUrl, - }); - if (res.status !== 200) { - throw new Error(`配置加载失败`); - } - configData = res.data; - } - const remotePlugin = new RemotePluginItem( - rtObjectName, - rtObjectRepo, - configData as RemotePluginConfig, - ); - if (remotePlugin) { - await this.loadPluginExternal(remotePlugin.config); - try { - await this.loadScript(remotePlugin); - this.pluginCache.set(rtObjectName, remotePlugin); - return true; - } catch (error) { - ibiz.log.error(error); - } - } - return false; - } -``` diff --git a/packages/core/src/create-plugin/template/global/package.json b/packages/core/src/create-plugin/template/global/package.json index 09acb5215002c31c68eefbde3b3ea86c46a33049..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/global/package.json +++ b/packages/core/src/create-plugin/template/global/package.json @@ -15,7 +15,6 @@ "files": [ "dist", "public", - "RUNTIME-PLUGIN-MODE.md", "CHANGELOG.md", "README.md" ], @@ -29,36 +28,68 @@ }, "devDependencies": { "@floating-ui/dom": "^1.5.3", - "@ibiz-template/core": "0.7.40-alpha.13", - "@ibiz-template/model-helper": "0.7.40-alpha.13", - "@ibiz-template/runtime": "0.7.40-alpha.13", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", "@ibiz-template/theme": "^0.7.39", - "@ibiz-template/vue3-util": "0.7.40-alpha.13", - "@ibiz/model-core": "^0.1.71", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", "@types/lodash-es": "^4.17.12", "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", "async-validator": "^4.2.5", "axios": "^1.6.2", "dayjs": "^1.11.10", "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", "lodash-es": "^4.17.21", "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", "qs": "^6.11.2", "qx-util": "^0.4.8", "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", "vite-plugin-libcss": "^1.1.1", "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", "vuedraggable": "^4.1.0" }, "peerDependencies": { "@floating-ui/dom": "^1.5.1", - "@ibiz-template/core": "0.7.40-alpha.13", - "@ibiz-template/model-helper": "0.7.40-alpha.13", - "@ibiz-template/runtime": "0.7.40-alpha.13", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", "@ibiz-template/theme": "^0.7.39", - "@ibiz-template/vue3-util": "0.7.40-alpha.13", - "@ibiz/model-core": "^0.1.71", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", "async-validator": "^4.2.5", "axios": "^1.6.2", "dayjs": "^1.11.10", diff --git a/packages/core/src/create-plugin/template/global/public/docs/image.png b/packages/core/src/create-plugin/template/global/public/docs/image.png deleted file mode 100644 index 0b6ef77af346457ecee219a9c1c60d57ebc5493b..0000000000000000000000000000000000000000 Binary files a/packages/core/src/create-plugin/template/global/public/docs/image.png and /dev/null differ diff --git a/packages/core/src/create-plugin/template/global/public/docs/image2.png b/packages/core/src/create-plugin/template/global/public/docs/image2.png deleted file mode 100644 index 7b8b15983914faf0c4a046692bebb15241714b9a..0000000000000000000000000000000000000000 Binary files a/packages/core/src/create-plugin/template/global/public/docs/image2.png and /dev/null differ diff --git a/packages/core/src/create-plugin/template/global/src/control/index.ts b/packages/core/src/create-plugin/template/global/src/control/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..685ad49e79d4e944064af4e748dd531c3c78a04a --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/control/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { ControlType, registerControlProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Control } from './{{pluginName}}-control'; +import { {{ pascalCasePluginName }}ControlProvider } from './{{pluginName}}-control.provider'; + +export default { + install(app: App) { + // 替换标准逻辑 + app.component({{ pascalCasePluginName }}Control.name!, {{ pascalCasePluginName }}Control); + registerControlProvider(ControlType.FORM, () => new {{ pascalCasePluginName }}ControlProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.provider.ts b/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d99552a54bf460741f83eaa5f7e0a5b8271b0fc --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.provider.ts @@ -0,0 +1,5 @@ +import { IControlProvider } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}ControlProvider implements IControlProvider { + component: string = 'IBiz{{ pascalCasePluginName }}Control'; +} diff --git a/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.scss b/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.scss new file mode 100644 index 0000000000000000000000000000000000000000..fb057c94037beac4f836f6e0a9644d83b5cc1869 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}-control) { + // 样式 +} diff --git a/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.tsx b/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.tsx new file mode 100644 index 0000000000000000000000000000000000000000..b874b7876bbe897f111e145f6cc5ebdf477a2a25 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/control/{{pluginName}}-control.tsx @@ -0,0 +1,40 @@ +import { defineComponent, PropType } from 'vue'; +import { ControlController, IControlProvider } from '@ibiz-template/runtime'; +import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { IControl } from '@ibiz/model-core'; +import './{{pluginName}}-control.scss'; + +export const {{ pascalCasePluginName }}Control = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}Control', + props: { + /** + * @description 模型数据 + */ + modelData: { type: Object as PropType, required: true }, + /** + * @description 应用上下文对象 + */ + context: { type: Object as PropType, required: true }, + /** + * @description 视图参数对象 + * @default {} + */ + params: { type: Object as PropType, default: () => ({}) }, + /** + * @description 部件适配器 + */ + provider: { type: Object as PropType }, + }, + setup() { + const c = useControlController((...args) => new ControlController(...args)); + const ns = useNamespace('{{pluginName}}-control'); + + return { + c, + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/global/src/editor/index.ts b/packages/core/src/create-plugin/template/global/src/editor/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a7f8833401096b6dc2a81adecd105d2ff6d2270 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/editor/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { registerEditorProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Editor } from './{{pluginName}}-editor'; +import { {{ pascalCasePluginName }}EditorProvider } from './{{pluginName}}-editor.provider'; + +export default { + install(app: App) { + // 替换标准逻辑 + app.component({{ pascalCasePluginName }}Editor.name!, {{ pascalCasePluginName }}Editor); + registerEditorProvider('SPAN', () => new {{ pascalCasePluginName }}EditorProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.provider.ts b/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0f211d9566f7a1b09624946c4d47c89430a8bbf --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.provider.ts @@ -0,0 +1,21 @@ +import { IEditor } from '@ibiz/model-core'; +import { + IEditorContainerController, + IEditorProvider, + EditorController, +} from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}EditorProvider implements IEditorProvider { + formEditor: string = 'IBiz{{ pascalCasePluginName }}Editor'; + + gridEditor: string = 'IBiz{{ pascalCasePluginName }}Editor'; + + async createController( + editorModel: IEditor, + parentController: IEditorContainerController, + ): Promise { + const c = new EditorController(editorModel, parentController); + await c.init(); + return c; + } +} diff --git a/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.scss b/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.scss new file mode 100644 index 0000000000000000000000000000000000000000..d4b85aa38416096234accdb56bcff89fde773bd5 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}-editor) { + // 样式 +} diff --git a/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.tsx b/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.tsx new file mode 100644 index 0000000000000000000000000000000000000000..802f1b78a34e7f3d6998867fc807f04647c6a6b3 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/editor/{{pluginName}}-editor.tsx @@ -0,0 +1,21 @@ +import { defineComponent } from 'vue'; +import { getEditorProps, useNamespace } from '@ibiz-template/vue3-util'; +import { EditorController } from '@ibiz-template/runtime'; +import './{{pluginName}}-editor.scss'; + +export const {{ pascalCasePluginName }}Editor = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}Editor', + props: getEditorProps(), + setup(props) { + const c = props.controller; + const ns = useNamespace('{{pluginName}}-editor'); + + return { + c, + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/global/src/form-detail/index.ts b/packages/core/src/create-plugin/template/global/src/form-detail/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..dbeb121422927d9565df4518af95e74b3bb89f81 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/form-detail/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { registerFormDetailProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}FormDetail } from './{{pluginName}}-form-detail'; +import { {{ pascalCasePluginName }}FormDetailProvider } from './{{pluginName}}-form-detail.provider'; + +export default { + install(app: App) { + // 替换标准逻辑 + app.component({{ pascalCasePluginName }}FormDetail.name!, {{ pascalCasePluginName }}FormDetail); + registerFormDetailProvider('FORMITEM', () => new {{ pascalCasePluginName }}FormDetailProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.provider.ts b/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..035133217557e274ed3961c821da34f5379503d5 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.provider.ts @@ -0,0 +1,21 @@ +import { + FormController, + FormDetailController, + IFormDetailContainerController, + IFormDetailProvider, +} from '@ibiz-template/runtime'; +import { IDEFormDetail } from '@ibiz/model-core'; + +export class {{ pascalCasePluginName }}FormDetailProvider implements IFormDetailProvider { + component: string = 'IBiz{{ pascalCasePluginName }}FormDetail'; + + async createController( + detailModel: IDEFormDetail, + form: FormController, + parent: IFormDetailContainerController | undefined, + ): Promise { + const c = new FormDetailController(detailModel, form, parent); + await c.init(); + return c; + } +} diff --git a/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.scss b/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.scss new file mode 100644 index 0000000000000000000000000000000000000000..fe0405b514e4f3058c7d5d4d80f1d981479598d3 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}-form-detail) { + // 样式 +} diff --git a/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.tsx b/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.tsx new file mode 100644 index 0000000000000000000000000000000000000000..d95d8fafa82320e57d8e4f8b316ed3ee2ff8126e --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/form-detail/{{pluginName}}-form-detail.tsx @@ -0,0 +1,28 @@ +import { defineComponent, PropType } from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { IDEFormDetail } from '@ibiz/model-core'; +import { FormDetailController } from '@ibiz-template/runtime'; +import './{{pluginName}}-form-detail.scss'; + +export const {{ pascalCasePluginName }}FormDetail = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}FormDetail', + props: { + modelData: { + type: Object as PropType, + required: true, + }, + controller: { + type: Object as PropType, + required: true, + }, + }, + setup(props) { + const c = props.controller; + const ns = useNamespace('{{pluginName}}-form-detail'); + + return { c, ns }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/global/src/grid-column/index.ts b/packages/core/src/create-plugin/template/global/src/grid-column/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..34fb796e1c37050326986945e13c237263763f89 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/grid-column/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { registerGridColumnProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}GridColumn } from './{{pluginName}}-grid-column'; +import { {{ pascalCasePluginName }}GridColumnProvider } from './{{pluginName}}-grid-column.provider'; + +export default { + install(app: App) { + // 替换标准逻辑 + app.component({{ pascalCasePluginName }}GridColumn.name!, {{ pascalCasePluginName }}GridColumn); + registerGridColumnProvider('DEFGRIDCOLUMN', () => new {{ pascalCasePluginName }}GridColumnProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.provider.ts b/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..9714adc014136429101a1e1823144ebe8201cba5 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.provider.ts @@ -0,0 +1,19 @@ +import { + GridController, + GridFieldColumnController, + IGridColumnProvider, +} from '@ibiz-template/runtime'; +import { IDEGridColumn } from '@ibiz/model-core'; + +export class {{ pascalCasePluginName }}GridColumnProvider implements IGridColumnProvider { + component: string = 'IBiz{{ pascalCasePluginName }}GridColumn'; + + async createController( + columnModel: IDEGridColumn, + grid: GridController, + ): Promise { + const c = new GridFieldColumnController(columnModel, grid); + await c.init(); + return c; + } +} diff --git a/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.scss b/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.scss new file mode 100644 index 0000000000000000000000000000000000000000..f8230efad0e69d9a90ce8452417f8a28cf2947db --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}-grid-column) { + // 样式 +} diff --git a/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.tsx b/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.tsx new file mode 100644 index 0000000000000000000000000000000000000000..7c4ef5f8e0bfecd1ddbb7acb08cd8b0a3f35223e --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/grid-column/{{pluginName}}-grid-column.tsx @@ -0,0 +1,31 @@ +import { defineComponent } from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { + GridFieldColumnController, + GridRowState, +} from '@ibiz-template/runtime'; +import './{{pluginName}}-grid-column.scss'; + +export const {{ pascalCasePluginName }}GridColumn = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}GridColumn', + props: { + controller: { + type: GridFieldColumnController, + required: true, + }, + row: { + type: GridRowState, + required: true, + }, + }, + setup() { + const ns = useNamespace('{{pluginName}}-grid-column'); + + return { + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/global/src/index.ts b/packages/core/src/create-plugin/template/global/src/index.ts index 4cf22d22350253b5d94fa3b000edc841de2746a8..6b9562cf2fb4393b2bf469262b63bbb9e8804e08 100644 --- a/packages/core/src/create-plugin/template/global/src/index.ts +++ b/packages/core/src/create-plugin/template/global/src/index.ts @@ -1,7 +1,30 @@ import { App } from 'vue'; +import view from './view'; +import control from './control'; +import formDetail from './form-detail'; +import gridColumn from './grid-column'; +import panelItem from './panel-item'; +import editor from './editor'; +import method from './method'; +import uiAction from './ui-action'; export default { - install(_app: App) { - // todo 替换标准逻辑 + install(app: App) { + // 替换标准视图逻辑 + app.use(view); + // 替换标准部件逻辑 + app.use(control); + // 替换标准表单成员逻辑 + app.use(formDetail); + // 替换标准表格列逻辑 + app.use(gridColumn); + // 替换标准面板成员逻辑 + app.use(panelItem); + // 替换标准编辑器逻辑 + app.use(editor); + // 替换标准实体行为逻辑 + app.use(method); + // 替换标准界面行为逻辑 + app.use(uiAction); }, }; diff --git a/packages/core/src/create-plugin/template/global/src/method/index.ts b/packages/core/src/create-plugin/template/global/src/method/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ef1c3ea8895b8c74f6faa05451cdbe8bdb59d93 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/method/index.ts @@ -0,0 +1,10 @@ +import { App } from 'vue'; +import { registerDEMethodProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}MethodProvider } from './{{pluginName}}-method.provider'; + +export default { + install(_app: App) { + // 替换标准逻辑 + registerDEMethodProvider('DEACTION', () => new {{ pascalCasePluginName }}MethodProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/method/{{pluginName}}-method.provider.ts b/packages/core/src/create-plugin/template/global/src/method/{{pluginName}}-method.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbaf6438036a1e596a5d97bdcaa5ec47444a4b5b --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/method/{{pluginName}}-method.provider.ts @@ -0,0 +1,19 @@ +import { IAppDataEntity, IAppDEMethod } from '@ibiz/model-core'; +import { + IAppDEService, + IDEMethodCreateOptions, + IDEMethodProvider, +} from '@ibiz-template/runtime'; +import { Method } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Method } from './{{pluginName}}-method'; + +export class {{ pascalCasePluginName }}MethodProvider implements IDEMethodProvider { + create( + service: IAppDEService, + entity: IAppDataEntity, + method: IAppDEMethod, + opts: IDEMethodCreateOptions, + ): Method { + return new {{ pascalCasePluginName }}Method(service, entity, method, opts.localMode); + } +} diff --git a/packages/core/src/create-plugin/template/global/src/method/{{pluginName}}-method.ts b/packages/core/src/create-plugin/template/global/src/method/{{pluginName}}-method.ts new file mode 100644 index 0000000000000000000000000000000000000000..137ff28521425507805e5ee49603f3df0d62283d --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/method/{{pluginName}}-method.ts @@ -0,0 +1,14 @@ +import { HttpResponse } from '@ibiz-template/core'; +import { Method } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}Method extends Method { + async exec( + context: IContext, + data?: IData | IData[], + params?: IParams, + header?: IData, + ): Promise> { + // 处理逻辑 + return new HttpResponse({}); + } +} diff --git a/packages/core/src/create-plugin/template/global/src/panel-item/index.ts b/packages/core/src/create-plugin/template/global/src/panel-item/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3bfdeffb0824b18800ff46e1f80c77ab02c57ba --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/panel-item/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { registerPanelItemProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}PanelItem } from './{{pluginName}}-panel-item'; +import { {{ pascalCasePluginName }}PanelItemProvider } from './{{pluginName}}-panel-item.provider'; + +export default { + install(app: App) { + // 替换标准逻辑 + app.component({{ pascalCasePluginName }}PanelItem.name!, {{ pascalCasePluginName }}PanelItem); + registerPanelItemProvider('CONTAINER_ViewHeader', () => new {{ pascalCasePluginName }}PanelItemProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.provider.ts b/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..338f1c08817c4ba78a8dd929a13354cd8a2a747c --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.provider.ts @@ -0,0 +1,20 @@ +import { + IPanelItemProvider, + PanelController, + PanelItemController, +} from '@ibiz-template/runtime'; +import { IPanelContainer } from '@ibiz/model-core'; + +export class {{ pascalCasePluginName }}PanelItemProvider implements IPanelItemProvider { + component: string = 'IBiz{{ pascalCasePluginName }}PanelItem'; + + async createController( + panelItem: IPanelContainer, + panel: PanelController, + parent: PanelItemController | undefined, + ): Promise { + const c = new PanelItemController(panelItem, panel, parent); + await c.init(); + return c; + } +} diff --git a/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.scss b/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.scss new file mode 100644 index 0000000000000000000000000000000000000000..da472b6de7f14f73de7c7ed076e58d2c7487592c --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}-panel-item) { + // 样式 +} diff --git a/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.tsx b/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.tsx new file mode 100644 index 0000000000000000000000000000000000000000..8b9f9e57f9d98866786aa28fa868fbcbf7ce4277 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/panel-item/{{pluginName}}-panel-item.tsx @@ -0,0 +1,33 @@ +import { defineComponent, PropType } from 'vue'; +import { useNamespace } from '@ibiz-template/vue3-util'; +import { IPanelItem } from '@ibiz/model-core'; +import { PanelItemController } from '@ibiz-template/runtime'; +import './{{pluginName}}-panel-item.scss'; + +export const {{ pascalCasePluginName }}PanelItem = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}PanelItem', + props: { + /** + * @description 模型数据 + */ + modelData: { + type: Object as PropType, + required: true, + }, + /** + * @description 控制器 + */ + controller: { + type: PanelItemController, + required: true, + }, + }, + setup() { + const ns = useNamespace('{{pluginName}}-panel-item'); + + return { ns }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/global/src/ui-action/index.ts b/packages/core/src/create-plugin/template/global/src/ui-action/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..12f940db611b752671c1487273667096515dfb36 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/ui-action/index.ts @@ -0,0 +1,10 @@ +import { App } from 'vue'; +import { registerUIActionProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}UIActionProvider } from './{{pluginName}}-ui-action.provider'; + +export default { + install(_app: App) { + // 替换标准逻辑 + registerUIActionProvider('FRONT', () => new {{ pascalCasePluginName }}UIActionProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/ui-action/{{pluginName}}-ui-action.provider.ts b/packages/core/src/create-plugin/template/global/src/ui-action/{{pluginName}}-ui-action.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f159c7f4c76c5697dbd64b737d3a90f2c91db40 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/ui-action/{{pluginName}}-ui-action.provider.ts @@ -0,0 +1,17 @@ +import { IAppDEUIAction } from '@ibiz/model-core'; +import { + UIActionProviderBase, + IUILogicParams, + IUIActionResult, +} from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}UIActionProvider extends UIActionProviderBase { + async execAction( + action: IAppDEUIAction, + args: IUILogicParams, + ): Promise { + const actionResult: IUIActionResult = {}; + // 处理逻辑 + return actionResult; + } +} diff --git a/packages/core/src/create-plugin/template/global/src/view/index.ts b/packages/core/src/create-plugin/template/global/src/view/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..71086711e7c4b986dad3e48d0f9ff93440998577 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/view/index.ts @@ -0,0 +1,12 @@ +import { App } from 'vue'; +import { registerViewProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}View } from './{{pluginName}}-view'; +import { {{ pascalCasePluginName }}ViewProvider } from './{{pluginName}}-view.provider'; + +export default { + install(app: App) { + // 替换标准逻辑 + app.component({{ pascalCasePluginName }}View.name!, {{ pascalCasePluginName }}View); + registerViewProvider('DEFAULT', () => new {{ pascalCasePluginName }}ViewProvider()); + }, +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.provider.ts b/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..93720fc7b7903ea4682168d5f22c3ed2c0805f77 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.provider.ts @@ -0,0 +1,5 @@ +import { IViewProvider } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}ViewProvider implements IViewProvider { + component: string = 'IBiz{{ pascalCasePluginName }}View'; +} diff --git a/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.scss b/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.scss new file mode 100644 index 0000000000000000000000000000000000000000..44ac0a7cc2a2706582c2cfe1b4fb13d0725b9854 --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}-view) { + // 样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.tsx b/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.tsx new file mode 100644 index 0000000000000000000000000000000000000000..833aa77452b94591b373be612360596acf7d789f --- /dev/null +++ b/packages/core/src/create-plugin/template/global/src/view/{{pluginName}}-view.tsx @@ -0,0 +1,48 @@ +import { defineComponent, PropType } from 'vue'; +import { IModal, IViewProvider, ViewController } from '@ibiz-template/runtime'; +import { useNamespace, useViewController } from '@ibiz-template/vue3-util'; +import { IAppView } from '@ibiz/model-core'; +import './{{pluginName}}-view.scss'; + +export const {{ pascalCasePluginName }}View = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}View', + props: { + /** + * @description 应用上下文 + */ + context: { type: Object as PropType }, + /** + * @description 视图参数 + * @default {} + */ + params: { type: Object as PropType, default: () => ({}) }, + /** + * @description 视图模型 + */ + modelData: { type: Object as PropType, required: true }, + /** + * @description 视图模态操作对象,在模态等形式打开视图时,需给视图注入此对象 + */ + modal: { type: Object as PropType }, + /** + * @description 视图状态 + */ + state: { type: Object as PropType }, + /** + * @description 视图适配器 + */ + provider: { type: Object as PropType }, + }, + setup() { + const ns = useNamespace('{{pluginName}}-view'); + const c = useViewController((...args) => new ViewController(...args)); + + return { + c, + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/platform/appcounter/.eslintrc.cjs b/packages/core/src/create-plugin/template/platform/appcounter/.eslintrc.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c6e5a1dd5b2fa946548b00254225469f2f15bee9 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/.eslintrc.cjs @@ -0,0 +1,52 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + }, + extends: ['airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['prettier', '@typescript-eslint', 'unused-imports'], + rules: { + 'prettier/prettier': 'error', + 'arrow-body-style': 'off', + 'prefer-arrow-callback': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-new': [0], + 'no-continue': [0], + '@typescript-eslint/no-empty-interface': 'off', + 'no-use-before-define': [0], + 'no-restricted-syntax': [0], + 'no-empty-function': [0], + 'no-useless-constructor': [0], // 禁止空的构造函数 + 'no-param-reassign': [0], // 禁止修改传入函数的参数 + 'no-underscore-dangle': [0], // 禁止使用下划线开头的变量名 + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // 禁止使用 ++,-- + 'consistent-return': [0], // 函数可以有不同类型返回值 + 'class-methods-use-this': [0], // 方法内未使用此方法时,强制定义为静态方法 + 'import/prefer-default-export': [0], // 一个模块只能有默认导出,不可以有多个导出 + 'import/no-unresolved': [0], // 不允许未解决的模块 + 'import/extensions': [0], // 不允许导入文件时不带后缀 + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-inferrable-types': [0], + '@typescript-eslint/no-non-null-assertion': [0], + '@typescript-eslint/no-explicit-any': ['error'], + '@typescript-eslint/explicit-function-return-type': 'error', // 要求函数和类方法的显式返回类型 + '@typescript-eslint/explicit-module-boundary-types': 'error', // 要求导出函数和类的公共类方法的显式返回和参数类型 + 'import/no-extraneous-dependencies': [ + 0, + { + devDependencies: true, + peerDependencies: true, + // optionalDependencies: true, + // bundledDependencies: true + }, + ], + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/appcounter/CHANGELOG.md b/packages/core/src/create-plugin/template/platform/appcounter/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8ac8e7f05d173977a1ad060d18e7f0b6a5f23cf5 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/CHANGELOG.md @@ -0,0 +1,3 @@ +# 版本变更日志 + +添加变更日志 \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/appcounter/README.md b/packages/core/src/create-plugin/template/platform/appcounter/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b953295a06fa7342b9127174b5ca7ea4b8a6f492 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/README.md @@ -0,0 +1,65 @@ +# 计数器插件 + +计数器插件可自定义计数器数据加载逻辑,当标准逻辑无法满足要求时,可以通过计数器插件来实现。modeling建模平台创建计数器插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) + +## 插件结构 + +``` +|─ ─ {{pluginName}} 计数器插件顶层目录 + |─ ─ src 计数器插件源代码目录 +​ |─ ─ {{pluginName}}.provider.ts 计数器插件适配器 +​ |─ ─ {{pluginName}}.ts 计数器插件实现类 +​ |─ ─ index.ts 计数器插件入口文件 +``` + +- 计数器插件入口文件 + +计数器插件入口文件会全局注册计数器插件适配器,供外部使用。 + +- 计数器插件实现类 + +计数器插件实现类可继承基础应用计数器AppCounter,重写对应的处理逻辑。 + +- 计数器插件适配器 + +计数器插件适配器的createCounter方法返回对应计数器插件实现类的实例。 + +## 本地开发 + +1. 安装依赖并link至全局 + +```sh +// 安装依赖 +pnpm i + +// link底包 +./scripts/link.sh + +// 启动 +pnpm dev + +// link到全局 +pnpm link --global +``` + +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` + +3. 主项目包中注册插件 + +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' + +export default { + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); + }, +}; +``` diff --git a/packages/core/src/create-plugin/template/platform/appcounter/package.json b/packages/core/src/create-plugin/template/platform/appcounter/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7bcf063680ec82aa96d7b56a1d83dbed72f592da --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/package.json @@ -0,0 +1,106 @@ +{ + "name": "{{pluginGroup}}/{{pluginName}}", + "version": "0.0.1", + "description": "{{pluginDescription}}", + "author": "iBiz", + "license": "MIT", + "type": "module", + "main": "dist/index.es.js", + "module": "dist/index.es.js", + "types": "dist/types/index.d.ts", + "system": "dist/index.legacy.js", + "styles": [ + "dist/style.css" + ], + "files": [ + "dist", + "public", + "CHANGELOG.md", + "README.md" + ], + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "dev": "vite build --watch", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@floating-ui/dom": "^1.5.3", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", + "@types/lodash-es": "^4.17.12", + "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-libcss": "^1.1.1", + "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", + "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", + "vuedraggable": "^4.1.0" + }, + "peerDependencies": { + "@floating-ui/dom": "^1.5.1", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "vue": "^3.3.8", + "vue-router": "^4.2.5", + "vuedraggable": "^4.1.0" + } +} diff --git a/packages/core/src/create-plugin/template/platform/appcounter/scripts/link.sh b/packages/core/src/create-plugin/template/platform/appcounter/scripts/link.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4edc1556f72a02300c491cda3c13a7ff34795a7 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/scripts/link.sh @@ -0,0 +1,6 @@ +pnpm link --global "@ibiz-template/vue3-util" +pnpm link --global "@ibiz-template/model-helper" +pnpm link --global "@ibiz-template/runtime" +pnpm link --global "@ibiz-template/core" +pnpm link --global "@ibiz-template/theme" +pnpm link --global "@ibiz-template/vue3-components" diff --git a/packages/core/src/create-plugin/template/platform/appcounter/src/index.ts b/packages/core/src/create-plugin/template/platform/appcounter/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..02efdd2070db262af37fe4327105df47f71b375b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/src/index.ts @@ -0,0 +1,13 @@ +import { App } from 'vue'; +import { registerAppCounterProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Provider } from './{{pluginName}}.provider'; + +export default { + install(_app: App) { + // 全局注册计数器插件适配器, APPCOUNTER是插件类型,{{pluginId}}是插件标识 + registerAppCounterProvider( + 'APPCOUNTER_{{pluginId}}', + () => new {{ pascalCasePluginName }}Provider(), + ); + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/appcounter/src/{{pluginName}}.provider.ts b/packages/core/src/create-plugin/template/platform/appcounter/src/{{pluginName}}.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..511a98d57ef48c323cfc18812ca46422285c208c --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/src/{{pluginName}}.provider.ts @@ -0,0 +1,9 @@ +import { IAppCounter } from '@ibiz/model-core'; +import { AppCounter, IAppCounterProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }} } from './{{pluginName}}'; + +export class {{ pascalCasePluginName }}Provider implements IAppCounterProvider { + createCounter(model: IAppCounter): AppCounter { + return new {{ pascalCasePluginName }}(model); + } +} diff --git a/packages/core/src/create-plugin/template/platform/appcounter/src/{{pluginName}}.ts b/packages/core/src/create-plugin/template/platform/appcounter/src/{{pluginName}}.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fe4d4fd6c2010ff4db728a559ffa9cacb4fc766 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/src/{{pluginName}}.ts @@ -0,0 +1,8 @@ +import { AppCounter } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }} extends AppCounter { + protected async load(): Promise { + // 加载逻辑 + return this.data; + } +} diff --git a/packages/core/src/create-plugin/template/platform/appcounter/tsconfig.json b/packages/core/src/create-plugin/template/platform/appcounter/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..ba8f48be2a612227b3b2cd44668c26316fa3dd4b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/core/src/create-plugin/template/platform/appcounter/tsconfig.node.json b/packages/core/src/create-plugin/template/platform/appcounter/tsconfig.node.json new file mode 100644 index 0000000000000000000000000000000000000000..9d31e2aed93c876bc048cf2f863cb2a847c901e8 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/core/src/create-plugin/template/platform/appcounter/vite.config.ts b/packages/core/src/create-plugin/template/platform/appcounter/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc3449a5a42babd06efbe73c42acd8989ffb91fc --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/appcounter/vite.config.ts @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import libLegacy from '@qx-chitanda/vite-plugin-lib-legacy'; +import dts from 'vite-plugin-dts'; +import libCss from 'vite-plugin-libcss'; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: './src/index.ts', + fileName: format => `index.${format}.js`, + }, + rollupOptions: { + external: [ + '@ibiz-template/core', + '@ibiz-template/model-helper', + '@ibiz-template/runtime', + '@ibiz-template/theme', + '@ibiz-template/vue3-util', + '@ibiz/dynamic-model-api', + '@floating-ui/dom', + 'async-validator', + 'axios', + 'dayjs', + 'element-plus', + 'lodash-es', + 'pluralize', + 'qs', + 'qx-util', + 'ramda', + 'vue', + 'vue-router', + 'vuedraggable', + ], + }, + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@import "@ibiz-template/theme/style/global.scss";', + }, + }, + }, + plugins: [ + // eslint({ + // include: 'src/**/*.{ts,tsx,js,jsx}', + // }), + vue(), + vueJsx(), + libLegacy(), + libCss(), + dts({ + outDir: 'dist/types', + }), + ], +}); diff --git a/packages/core/src/create-plugin/template/platform/chart_render/package.json b/packages/core/src/create-plugin/template/platform/chart_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/chart_render/package.json +++ b/packages/core/src/create-plugin/template/platform/chart_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/custom/README.md b/packages/core/src/create-plugin/template/platform/custom/README.md index 9439fe6aba615cd11167e4d9736dfd89154e91c1..1795d766529b2ec946c8ac35c37c4482e735c068 100644 --- a/packages/core/src/create-plugin/template/platform/custom/README.md +++ b/packages/core/src/create-plugin/template/platform/custom/README.md @@ -28,7 +28,7 @@ - 部件插件控制器 -部件插件控制器可继承基础控制器,然后根据需求进行调整。其中,基础控制器可参考附录中控制器部分。 +部件插件控制器承载部件的逻辑控制,可继承基础控制器,然后根据需求进行调整。其中,基础控制器可参考附录中控制器部分。 ## 本地开发 diff --git a/packages/core/src/create-plugin/template/platform/custom/package.json b/packages/core/src/create-plugin/template/platform/custom/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/custom/package.json +++ b/packages/core/src/create-plugin/template/platform/custom/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/dataview_render/package.json b/packages/core/src/create-plugin/template/platform/dataview_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/dataview_render/package.json +++ b/packages/core/src/create-plugin/template/platform/dataview_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/demethod/.eslintrc.cjs b/packages/core/src/create-plugin/template/platform/demethod/.eslintrc.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c6e5a1dd5b2fa946548b00254225469f2f15bee9 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/.eslintrc.cjs @@ -0,0 +1,52 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + }, + extends: ['airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['prettier', '@typescript-eslint', 'unused-imports'], + rules: { + 'prettier/prettier': 'error', + 'arrow-body-style': 'off', + 'prefer-arrow-callback': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-new': [0], + 'no-continue': [0], + '@typescript-eslint/no-empty-interface': 'off', + 'no-use-before-define': [0], + 'no-restricted-syntax': [0], + 'no-empty-function': [0], + 'no-useless-constructor': [0], // 禁止空的构造函数 + 'no-param-reassign': [0], // 禁止修改传入函数的参数 + 'no-underscore-dangle': [0], // 禁止使用下划线开头的变量名 + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // 禁止使用 ++,-- + 'consistent-return': [0], // 函数可以有不同类型返回值 + 'class-methods-use-this': [0], // 方法内未使用此方法时,强制定义为静态方法 + 'import/prefer-default-export': [0], // 一个模块只能有默认导出,不可以有多个导出 + 'import/no-unresolved': [0], // 不允许未解决的模块 + 'import/extensions': [0], // 不允许导入文件时不带后缀 + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-inferrable-types': [0], + '@typescript-eslint/no-non-null-assertion': [0], + '@typescript-eslint/no-explicit-any': ['error'], + '@typescript-eslint/explicit-function-return-type': 'error', // 要求函数和类方法的显式返回类型 + '@typescript-eslint/explicit-module-boundary-types': 'error', // 要求导出函数和类的公共类方法的显式返回和参数类型 + 'import/no-extraneous-dependencies': [ + 0, + { + devDependencies: true, + peerDependencies: true, + // optionalDependencies: true, + // bundledDependencies: true + }, + ], + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/demethod/CHANGELOG.md b/packages/core/src/create-plugin/template/platform/demethod/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8ac8e7f05d173977a1ad060d18e7f0b6a5f23cf5 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/CHANGELOG.md @@ -0,0 +1,3 @@ +# 版本变更日志 + +添加变更日志 \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/demethod/README.md b/packages/core/src/create-plugin/template/platform/demethod/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1c5bec64f7f662cce87c571b5f88f8e9b4e16423 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/README.md @@ -0,0 +1,65 @@ +# 实体行为插件 + +实体行为插件可自定义实体行为处理逻辑,当标准逻辑无法满足要求时,可以通过实体行为插件来实现。modeling建模平台创建实体行为插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) + +## 插件结构 + +``` +|─ ─ {{pluginName}} 实体行为插件顶层目录 + |─ ─ src 实体行为插件源代码目录 +​ |─ ─ {{pluginName}}.provider.ts 实体行为插件适配器 +​ |─ ─ {{pluginName}}.ts 实体行为插件实现类 +​ |─ ─ index.ts 实体行为插件入口文件 +``` + +- 实体行为插件入口文件 + +实体行为插件入口文件会全局注册实体行为插件适配器,供外部使用。 + +- 实体行为插件实现类 + +实体行为插件实现类可继承基础应用方法Method,重写对应的处理逻辑。 + +- 实体行为插件适配器 + +实体行为插件适配器的create方法返回对应实体行为插件实现类的实例。 + +## 本地开发 + +1. 安装依赖并link至全局 + +```sh +// 安装依赖 +pnpm i + +// link底包 +./scripts/link.sh + +// 启动 +pnpm dev + +// link到全局 +pnpm link --global +``` + +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` + +3. 主项目包中注册插件 + +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' + +export default { + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); + }, +}; +``` diff --git a/packages/core/src/create-plugin/template/platform/demethod/package.json b/packages/core/src/create-plugin/template/platform/demethod/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7bcf063680ec82aa96d7b56a1d83dbed72f592da --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/package.json @@ -0,0 +1,106 @@ +{ + "name": "{{pluginGroup}}/{{pluginName}}", + "version": "0.0.1", + "description": "{{pluginDescription}}", + "author": "iBiz", + "license": "MIT", + "type": "module", + "main": "dist/index.es.js", + "module": "dist/index.es.js", + "types": "dist/types/index.d.ts", + "system": "dist/index.legacy.js", + "styles": [ + "dist/style.css" + ], + "files": [ + "dist", + "public", + "CHANGELOG.md", + "README.md" + ], + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "dev": "vite build --watch", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@floating-ui/dom": "^1.5.3", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", + "@types/lodash-es": "^4.17.12", + "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-libcss": "^1.1.1", + "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", + "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", + "vuedraggable": "^4.1.0" + }, + "peerDependencies": { + "@floating-ui/dom": "^1.5.1", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "vue": "^3.3.8", + "vue-router": "^4.2.5", + "vuedraggable": "^4.1.0" + } +} diff --git a/packages/core/src/create-plugin/template/platform/demethod/scripts/link.sh b/packages/core/src/create-plugin/template/platform/demethod/scripts/link.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4edc1556f72a02300c491cda3c13a7ff34795a7 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/scripts/link.sh @@ -0,0 +1,6 @@ +pnpm link --global "@ibiz-template/vue3-util" +pnpm link --global "@ibiz-template/model-helper" +pnpm link --global "@ibiz-template/runtime" +pnpm link --global "@ibiz-template/core" +pnpm link --global "@ibiz-template/theme" +pnpm link --global "@ibiz-template/vue3-components" diff --git a/packages/core/src/create-plugin/template/platform/demethod/src/index.ts b/packages/core/src/create-plugin/template/platform/demethod/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..55cecbaaabeadf5b5ba063441579501d7467164c --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/src/index.ts @@ -0,0 +1,13 @@ +import { App } from 'vue'; +import { registerDEMethodProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Provider } from './{{pluginName}}.provider'; + +export default { + install(_app: App) { + // 全局注册实体行为插件适配器, DEMETHOD是插件类型,{{pluginId}}是插件标识 + registerDEMethodProvider( + 'DEMETHOD_{{pluginId}}', + () => new {{ pascalCasePluginName }}Provider(), + ); + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/demethod/src/{{pluginName}}.provider.ts b/packages/core/src/create-plugin/template/platform/demethod/src/{{pluginName}}.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..aed9a8fb4950947482222d267991c339fa974c91 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/src/{{pluginName}}.provider.ts @@ -0,0 +1,19 @@ +import { + IAppDEService, + IDEMethodCreateOptions, + IDEMethodProvider, + Method, +} from '@ibiz-template/runtime'; +import { IAppDataEntity, IAppDEMethod } from '@ibiz/model-core'; +import { {{ pascalCasePluginName }} } from './{{pluginName}}'; + +export class {{ pascalCasePluginName }}Provider implements IDEMethodProvider { + create( + service: IAppDEService, + entity: IAppDataEntity, + method: IAppDEMethod, + opts: IDEMethodCreateOptions, + ): Method { + return new {{ pascalCasePluginName }}(service, entity, method, opts.localMode); + } +} diff --git a/packages/core/src/create-plugin/template/platform/demethod/src/{{pluginName}}.ts b/packages/core/src/create-plugin/template/platform/demethod/src/{{pluginName}}.ts new file mode 100644 index 0000000000000000000000000000000000000000..478d85c3fcb21679a7eb1f311b9706201250104c --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/src/{{pluginName}}.ts @@ -0,0 +1,14 @@ +import { HttpResponse } from '@ibiz-template/core'; +import { Method } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }} extends Method { + async exec( + context: IContext, + data?: IData | IData[], + params?: IParams, + header?: IData, + ): Promise> { + // 处理逻辑 + return new HttpResponse({}); + } +} diff --git a/packages/core/src/create-plugin/template/platform/demethod/tsconfig.json b/packages/core/src/create-plugin/template/platform/demethod/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..ba8f48be2a612227b3b2cd44668c26316fa3dd4b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/core/src/create-plugin/template/platform/demethod/tsconfig.node.json b/packages/core/src/create-plugin/template/platform/demethod/tsconfig.node.json new file mode 100644 index 0000000000000000000000000000000000000000..9d31e2aed93c876bc048cf2f863cb2a847c901e8 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/core/src/create-plugin/template/platform/demethod/vite.config.ts b/packages/core/src/create-plugin/template/platform/demethod/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc3449a5a42babd06efbe73c42acd8989ffb91fc --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/demethod/vite.config.ts @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import libLegacy from '@qx-chitanda/vite-plugin-lib-legacy'; +import dts from 'vite-plugin-dts'; +import libCss from 'vite-plugin-libcss'; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: './src/index.ts', + fileName: format => `index.${format}.js`, + }, + rollupOptions: { + external: [ + '@ibiz-template/core', + '@ibiz-template/model-helper', + '@ibiz-template/runtime', + '@ibiz-template/theme', + '@ibiz-template/vue3-util', + '@ibiz/dynamic-model-api', + '@floating-ui/dom', + 'async-validator', + 'axios', + 'dayjs', + 'element-plus', + 'lodash-es', + 'pluralize', + 'qs', + 'qx-util', + 'ramda', + 'vue', + 'vue-router', + 'vuedraggable', + ], + }, + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@import "@ibiz-template/theme/style/global.scss";', + }, + }, + }, + plugins: [ + // eslint({ + // include: 'src/**/*.{ts,tsx,js,jsx}', + // }), + vue(), + vueJsx(), + libLegacy(), + libCss(), + dts({ + outDir: 'dist/types', + }), + ], +}); diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/.eslintrc.cjs b/packages/core/src/create-plugin/template/platform/deuiaction/.eslintrc.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c6e5a1dd5b2fa946548b00254225469f2f15bee9 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/.eslintrc.cjs @@ -0,0 +1,52 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + }, + extends: ['airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['prettier', '@typescript-eslint', 'unused-imports'], + rules: { + 'prettier/prettier': 'error', + 'arrow-body-style': 'off', + 'prefer-arrow-callback': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-new': [0], + 'no-continue': [0], + '@typescript-eslint/no-empty-interface': 'off', + 'no-use-before-define': [0], + 'no-restricted-syntax': [0], + 'no-empty-function': [0], + 'no-useless-constructor': [0], // 禁止空的构造函数 + 'no-param-reassign': [0], // 禁止修改传入函数的参数 + 'no-underscore-dangle': [0], // 禁止使用下划线开头的变量名 + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // 禁止使用 ++,-- + 'consistent-return': [0], // 函数可以有不同类型返回值 + 'class-methods-use-this': [0], // 方法内未使用此方法时,强制定义为静态方法 + 'import/prefer-default-export': [0], // 一个模块只能有默认导出,不可以有多个导出 + 'import/no-unresolved': [0], // 不允许未解决的模块 + 'import/extensions': [0], // 不允许导入文件时不带后缀 + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-inferrable-types': [0], + '@typescript-eslint/no-non-null-assertion': [0], + '@typescript-eslint/no-explicit-any': ['error'], + '@typescript-eslint/explicit-function-return-type': 'error', // 要求函数和类方法的显式返回类型 + '@typescript-eslint/explicit-module-boundary-types': 'error', // 要求导出函数和类的公共类方法的显式返回和参数类型 + 'import/no-extraneous-dependencies': [ + 0, + { + devDependencies: true, + peerDependencies: true, + // optionalDependencies: true, + // bundledDependencies: true + }, + ], + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/CHANGELOG.md b/packages/core/src/create-plugin/template/platform/deuiaction/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8ac8e7f05d173977a1ad060d18e7f0b6a5f23cf5 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/CHANGELOG.md @@ -0,0 +1,3 @@ +# 版本变更日志 + +添加变更日志 \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/README.md b/packages/core/src/create-plugin/template/platform/deuiaction/README.md new file mode 100644 index 0000000000000000000000000000000000000000..513a28072d617e211e3c7c765298e474b361e5fa --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/README.md @@ -0,0 +1,60 @@ +# 界面行为插件 + +界面行为插件可自定义界面行为处理逻辑,当标准逻辑无法满足要求时,可以通过界面行为插件来实现。modeling建模平台创建界面行为插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) + +## 插件结构 + +``` +|─ ─ {{pluginName}} 界面行为插件顶层目录 + |─ ─ src 界面行为插件源代码目录 +​ |─ ─ {{pluginName}}.provider.ts 界面行为插件适配器 +​ |─ ─ index.ts 界面行为插件入口文件 +``` + +- 界面行为插件入口文件 + +界面行为插件入口文件会全局注册界面行为插件适配器,供外部使用。 + +- 界面行为插件适配器 + +界面行为插件适配器主要通过重写execAction方法去自定义界面行为的处理逻辑。 + +## 本地开发 + +1. 安装依赖并link至全局 + +```sh +// 安装依赖 +pnpm i + +// link底包 +./scripts/link.sh + +// 启动 +pnpm dev + +// link到全局 +pnpm link --global +``` + +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` + +3. 主项目包中注册插件 + +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' + +export default { + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); + }, +}; +``` diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/package.json b/packages/core/src/create-plugin/template/platform/deuiaction/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7bcf063680ec82aa96d7b56a1d83dbed72f592da --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/package.json @@ -0,0 +1,106 @@ +{ + "name": "{{pluginGroup}}/{{pluginName}}", + "version": "0.0.1", + "description": "{{pluginDescription}}", + "author": "iBiz", + "license": "MIT", + "type": "module", + "main": "dist/index.es.js", + "module": "dist/index.es.js", + "types": "dist/types/index.d.ts", + "system": "dist/index.legacy.js", + "styles": [ + "dist/style.css" + ], + "files": [ + "dist", + "public", + "CHANGELOG.md", + "README.md" + ], + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "dev": "vite build --watch", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@floating-ui/dom": "^1.5.3", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", + "@types/lodash-es": "^4.17.12", + "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-libcss": "^1.1.1", + "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", + "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", + "vuedraggable": "^4.1.0" + }, + "peerDependencies": { + "@floating-ui/dom": "^1.5.1", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "vue": "^3.3.8", + "vue-router": "^4.2.5", + "vuedraggable": "^4.1.0" + } +} diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/scripts/link.sh b/packages/core/src/create-plugin/template/platform/deuiaction/scripts/link.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4edc1556f72a02300c491cda3c13a7ff34795a7 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/scripts/link.sh @@ -0,0 +1,6 @@ +pnpm link --global "@ibiz-template/vue3-util" +pnpm link --global "@ibiz-template/model-helper" +pnpm link --global "@ibiz-template/runtime" +pnpm link --global "@ibiz-template/core" +pnpm link --global "@ibiz-template/theme" +pnpm link --global "@ibiz-template/vue3-components" diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/src/index.ts b/packages/core/src/create-plugin/template/platform/deuiaction/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..91b5e8599eb3d148d7473fd582ce78b43cb14291 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/src/index.ts @@ -0,0 +1,13 @@ +import { App } from 'vue'; +import { registerUIActionProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Provider } from './{{pluginName}}.provider'; + +export default { + install(_app: App) { + // 全局注册界面行为插件适配器,DEUIACTION是插件类型,{{pluginId}}是插件标识 + registerUIActionProvider( + 'DEUIACTION_{{pluginId}}', + () => new {{ pascalCasePluginName }}Provider(), + ); + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/src/{{pluginName}}.provider.ts b/packages/core/src/create-plugin/template/platform/deuiaction/src/{{pluginName}}.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..d7f09cf18eb1110577b4cc6c4a855cae762bba63 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/src/{{pluginName}}.provider.ts @@ -0,0 +1,17 @@ +import { IAppDEUIAction } from '@ibiz/model-core'; +import { + IUIActionResult, + IUILogicParams, + UIActionProviderBase, +} from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}Provider extends UIActionProviderBase { + async execAction( + action: IAppDEUIAction, + args: IUILogicParams, + ): Promise { + const actionResult: IUIActionResult = {}; + // 处理逻辑 + return actionResult; + } +} diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/tsconfig.json b/packages/core/src/create-plugin/template/platform/deuiaction/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..ba8f48be2a612227b3b2cd44668c26316fa3dd4b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/tsconfig.node.json b/packages/core/src/create-plugin/template/platform/deuiaction/tsconfig.node.json new file mode 100644 index 0000000000000000000000000000000000000000..9d31e2aed93c876bc048cf2f863cb2a847c901e8 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/core/src/create-plugin/template/platform/deuiaction/vite.config.ts b/packages/core/src/create-plugin/template/platform/deuiaction/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc3449a5a42babd06efbe73c42acd8989ffb91fc --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/deuiaction/vite.config.ts @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import libLegacy from '@qx-chitanda/vite-plugin-lib-legacy'; +import dts from 'vite-plugin-dts'; +import libCss from 'vite-plugin-libcss'; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: './src/index.ts', + fileName: format => `index.${format}.js`, + }, + rollupOptions: { + external: [ + '@ibiz-template/core', + '@ibiz-template/model-helper', + '@ibiz-template/runtime', + '@ibiz-template/theme', + '@ibiz-template/vue3-util', + '@ibiz/dynamic-model-api', + '@floating-ui/dom', + 'async-validator', + 'axios', + 'dayjs', + 'element-plus', + 'lodash-es', + 'pluralize', + 'qs', + 'qx-util', + 'ramda', + 'vue', + 'vue-router', + 'vuedraggable', + ], + }, + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@import "@ibiz-template/theme/style/global.scss";', + }, + }, + }, + plugins: [ + // eslint({ + // include: 'src/**/*.{ts,tsx,js,jsx}', + // }), + vue(), + vueJsx(), + libLegacy(), + libCss(), + dts({ + outDir: 'dist/types', + }), + ], +}); diff --git a/packages/core/src/create-plugin/template/platform/editform_render/package.json b/packages/core/src/create-plugin/template/platform/editform_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/editform_render/package.json +++ b/packages/core/src/create-plugin/template/platform/editform_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/editor_customstyle/package.json b/packages/core/src/create-plugin/template/platform/editor_customstyle/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/editor_customstyle/package.json +++ b/packages/core/src/create-plugin/template/platform/editor_customstyle/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/form_usercontrol/package.json b/packages/core/src/create-plugin/template/platform/form_usercontrol/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/form_usercontrol/package.json +++ b/packages/core/src/create-plugin/template/platform/form_usercontrol/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/grid_colrender/package.json b/packages/core/src/create-plugin/template/platform/grid_colrender/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/grid_colrender/package.json +++ b/packages/core/src/create-plugin/template/platform/grid_colrender/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/grid_render/package.json b/packages/core/src/create-plugin/template/platform/grid_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/grid_render/package.json +++ b/packages/core/src/create-plugin/template/platform/grid_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/list_render/package.json b/packages/core/src/create-plugin/template/platform/list_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/list_render/package.json +++ b/packages/core/src/create-plugin/template/platform/list_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/portlet_custom/package.json b/packages/core/src/create-plugin/template/platform/portlet_custom/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/portlet_custom/package.json +++ b/packages/core/src/create-plugin/template/platform/portlet_custom/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/.eslintrc.cjs b/packages/core/src/create-plugin/template/platform/searchbar_render/.eslintrc.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c6e5a1dd5b2fa946548b00254225469f2f15bee9 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/.eslintrc.cjs @@ -0,0 +1,52 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + }, + extends: ['airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['prettier', '@typescript-eslint', 'unused-imports'], + rules: { + 'prettier/prettier': 'error', + 'arrow-body-style': 'off', + 'prefer-arrow-callback': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-new': [0], + 'no-continue': [0], + '@typescript-eslint/no-empty-interface': 'off', + 'no-use-before-define': [0], + 'no-restricted-syntax': [0], + 'no-empty-function': [0], + 'no-useless-constructor': [0], // 禁止空的构造函数 + 'no-param-reassign': [0], // 禁止修改传入函数的参数 + 'no-underscore-dangle': [0], // 禁止使用下划线开头的变量名 + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // 禁止使用 ++,-- + 'consistent-return': [0], // 函数可以有不同类型返回值 + 'class-methods-use-this': [0], // 方法内未使用此方法时,强制定义为静态方法 + 'import/prefer-default-export': [0], // 一个模块只能有默认导出,不可以有多个导出 + 'import/no-unresolved': [0], // 不允许未解决的模块 + 'import/extensions': [0], // 不允许导入文件时不带后缀 + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-inferrable-types': [0], + '@typescript-eslint/no-non-null-assertion': [0], + '@typescript-eslint/no-explicit-any': ['error'], + '@typescript-eslint/explicit-function-return-type': 'error', // 要求函数和类方法的显式返回类型 + '@typescript-eslint/explicit-module-boundary-types': 'error', // 要求导出函数和类的公共类方法的显式返回和参数类型 + 'import/no-extraneous-dependencies': [ + 0, + { + devDependencies: true, + peerDependencies: true, + // optionalDependencies: true, + // bundledDependencies: true + }, + ], + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/CHANGELOG.md b/packages/core/src/create-plugin/template/platform/searchbar_render/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8ac8e7f05d173977a1ad060d18e7f0b6a5f23cf5 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/CHANGELOG.md @@ -0,0 +1,3 @@ +# 版本变更日志 + +添加变更日志 \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/README.md b/packages/core/src/create-plugin/template/platform/searchbar_render/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9fc21450747bce0f8d43539ddad3e066d8f71260 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/README.md @@ -0,0 +1,71 @@ +# 搜索栏插件 + +搜索栏插件可自定义搜索栏内容的绘制,当标准逻辑无法满足搜索栏绘制要求时,可以通过搜索栏插件来实现。modeling建模平台创建搜索栏插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) + +## 插件结构 + +``` +|─ ─ {{pluginName}} 搜索栏插件顶层目录 + |─ ─ src 搜索栏插件源代码目录 +​ |─ ─ {{pluginName}}.controller.ts 搜索栏插件控制器 +​ |─ ─ {{pluginName}}.provider.ts 搜索栏插件适配器 +​ |─ ─ {{pluginName}}.scss 搜索栏插件样式 +​ |─ ─ {{pluginName}}.tsx 搜索栏插件组件 +​ |─ ─ index.ts 搜索栏插件入口文件 +``` + +- 搜索栏插件入口文件 + +搜索栏插件入口文件会全局注册搜索栏插件适配器和搜索栏插件组件,供外部使用。 + +- 搜索栏插件组件 + +搜索栏插件组件使用tsx的书写方式,承载搜索栏绘制的内容。 + +- 搜索栏插件适配器 + +搜索栏插件适配器主要通过component属性指定搜索栏实际要绘制的组件,并且通过createController方法返回传递给搜索栏的控制器。 + +- 搜索栏插件控制器 + +搜索栏插件控制器承载搜索栏的逻辑控制。 + +## 本地开发 + +1. 安装依赖并link至全局 + +```sh +// 安装依赖 +pnpm i + +// link底包 +./scripts/link.sh + +// 启动 +pnpm dev + +// link到全局 +pnpm link --global +``` + +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` + +3. 主项目包中注册插件 + +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' + +export default { + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); + }, +}; +``` diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/package.json b/packages/core/src/create-plugin/template/platform/searchbar_render/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7bcf063680ec82aa96d7b56a1d83dbed72f592da --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/package.json @@ -0,0 +1,106 @@ +{ + "name": "{{pluginGroup}}/{{pluginName}}", + "version": "0.0.1", + "description": "{{pluginDescription}}", + "author": "iBiz", + "license": "MIT", + "type": "module", + "main": "dist/index.es.js", + "module": "dist/index.es.js", + "types": "dist/types/index.d.ts", + "system": "dist/index.legacy.js", + "styles": [ + "dist/style.css" + ], + "files": [ + "dist", + "public", + "CHANGELOG.md", + "README.md" + ], + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "dev": "vite build --watch", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@floating-ui/dom": "^1.5.3", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", + "@types/lodash-es": "^4.17.12", + "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-libcss": "^1.1.1", + "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", + "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", + "vuedraggable": "^4.1.0" + }, + "peerDependencies": { + "@floating-ui/dom": "^1.5.1", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "vue": "^3.3.8", + "vue-router": "^4.2.5", + "vuedraggable": "^4.1.0" + } +} diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/scripts/link.sh b/packages/core/src/create-plugin/template/platform/searchbar_render/scripts/link.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4edc1556f72a02300c491cda3c13a7ff34795a7 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/scripts/link.sh @@ -0,0 +1,6 @@ +pnpm link --global "@ibiz-template/vue3-util" +pnpm link --global "@ibiz-template/model-helper" +pnpm link --global "@ibiz-template/runtime" +pnpm link --global "@ibiz-template/core" +pnpm link --global "@ibiz-template/theme" +pnpm link --global "@ibiz-template/vue3-components" diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/src/index.ts b/packages/core/src/create-plugin/template/platform/searchbar_render/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..68e967a203a6f1ae3aefaa8b29e85936b5e52256 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/src/index.ts @@ -0,0 +1,16 @@ +import { App } from 'vue'; +import { registerControlProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }} } from './{{pluginName}}'; +import { {{ pascalCasePluginName }}Provider } from './{{pluginName}}.provider'; + +export default { + install(app: App) { + // 全局注册搜索栏插件组件 + app.component({{ pascalCasePluginName }}.name!, {{ pascalCasePluginName }}); + // 全局注册搜索栏插件适配器,SEARCHBAR_RENDER是插件类型,{{pluginId}}是插件标识 + registerControlProvider( + 'SEARCHBAR_RENDER_{{pluginId}}', + () => new {{ pascalCasePluginName }}Provider(), + ); + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.controller.ts b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f24bcf1f07821ba6c315c3cc877ea3130cfa486 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.controller.ts @@ -0,0 +1,3 @@ +import { SearchBarController } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}Controller extends SearchBarController {} diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.provider.ts b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a32e3ffd8cf352373e44506e938059b9c46041a --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.provider.ts @@ -0,0 +1,20 @@ +import { + CTX, + IControlController, + IControlProvider, +} from '@ibiz-template/runtime'; +import { IControl } from '@ibiz/model-core'; +import { {{ pascalCasePluginName }}Controller } from './{{pluginName}}.controller'; + +export class {{ pascalCasePluginName }}Provider implements IControlProvider { + component: string = 'IBiz{{ pascalCasePluginName }}'; + + createController( + model: IControl, + context: IContext, + params: IParams, + ctx: CTX, + ): IControlController { + return new {{ pascalCasePluginName }}Controller(model, context, params, ctx); + } +} diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.scss b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.scss new file mode 100644 index 0000000000000000000000000000000000000000..f494ab6cf7c220eae2d3b11bd32b7e3d96d2dc16 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}){ + // 样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.tsx b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.tsx new file mode 100644 index 0000000000000000000000000000000000000000..48ca729e0cb2b9ad834346cacd4960eb63cbbf99 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/src/{{pluginName}}.tsx @@ -0,0 +1,46 @@ +import { defineComponent, PropType } from 'vue'; +import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { ISearchBar } from '@ibiz/model-core'; +import { IControlProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Controller } from './{{pluginName}}.controller'; +import './{{pluginName}}.scss'; + +export const {{ pascalCasePluginName }} = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}', + props: { + /** + * @description 搜索栏模型数据 + */ + modelData: { + type: Object as PropType, + required: true, + }, + /** + * @description 应用上下文对象 + */ + context: { type: Object as PropType, required: true }, + /** + * @description 视图参数对象 + * @default {} + */ + params: { type: Object as PropType, default: () => ({}) }, + /** + * @description 部件适配器 + */ + provider: { type: Object as PropType }, + }, + setup() { + const c = useControlController( + (...args) => new {{ pascalCasePluginName }}Controller(...args), + ); + const ns = useNamespace('{{pluginName}}'); + + return { + c, + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/tsconfig.json b/packages/core/src/create-plugin/template/platform/searchbar_render/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..ba8f48be2a612227b3b2cd44668c26316fa3dd4b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/tsconfig.node.json b/packages/core/src/create-plugin/template/platform/searchbar_render/tsconfig.node.json new file mode 100644 index 0000000000000000000000000000000000000000..9d31e2aed93c876bc048cf2f863cb2a847c901e8 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/core/src/create-plugin/template/platform/searchbar_render/vite.config.ts b/packages/core/src/create-plugin/template/platform/searchbar_render/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc3449a5a42babd06efbe73c42acd8989ffb91fc --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/searchbar_render/vite.config.ts @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import libLegacy from '@qx-chitanda/vite-plugin-lib-legacy'; +import dts from 'vite-plugin-dts'; +import libCss from 'vite-plugin-libcss'; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: './src/index.ts', + fileName: format => `index.${format}.js`, + }, + rollupOptions: { + external: [ + '@ibiz-template/core', + '@ibiz-template/model-helper', + '@ibiz-template/runtime', + '@ibiz-template/theme', + '@ibiz-template/vue3-util', + '@ibiz/dynamic-model-api', + '@floating-ui/dom', + 'async-validator', + 'axios', + 'dayjs', + 'element-plus', + 'lodash-es', + 'pluralize', + 'qs', + 'qx-util', + 'ramda', + 'vue', + 'vue-router', + 'vuedraggable', + ], + }, + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@import "@ibiz-template/theme/style/global.scss";', + }, + }, + }, + plugins: [ + // eslint({ + // include: 'src/**/*.{ts,tsx,js,jsx}', + // }), + vue(), + vueJsx(), + libLegacy(), + libCss(), + dts({ + outDir: 'dist/types', + }), + ], +}); diff --git a/packages/core/src/create-plugin/template/platform/searchform_render/package.json b/packages/core/src/create-plugin/template/platform/searchform_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/searchform_render/package.json +++ b/packages/core/src/create-plugin/template/platform/searchform_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/toolbar_item/package.json b/packages/core/src/create-plugin/template/platform/toolbar_item/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/toolbar_item/package.json +++ b/packages/core/src/create-plugin/template/platform/toolbar_item/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/toolbar_render/package.json b/packages/core/src/create-plugin/template/platform/toolbar_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/toolbar_render/package.json +++ b/packages/core/src/create-plugin/template/platform/toolbar_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/tree_render/package.json b/packages/core/src/create-plugin/template/platform/tree_render/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/tree_render/package.json +++ b/packages/core/src/create-plugin/template/platform/tree_render/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/uilogicnode/package.json b/packages/core/src/create-plugin/template/platform/uilogicnode/package.json index 526db31b8430b973184cd5e8a7416fd394369d62..7bcf063680ec82aa96d7b56a1d83dbed72f592da 100644 --- a/packages/core/src/create-plugin/template/platform/uilogicnode/package.json +++ b/packages/core/src/create-plugin/template/platform/uilogicnode/package.json @@ -2,7 +2,7 @@ "name": "{{pluginGroup}}/{{pluginName}}", "version": "0.0.1", "description": "{{pluginDescription}}", - "author": "tony001", + "author": "iBiz", "license": "MIT", "type": "module", "main": "dist/index.es.js", diff --git a/packages/core/src/create-plugin/template/platform/view_custom/.eslintrc.cjs b/packages/core/src/create-plugin/template/platform/view_custom/.eslintrc.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c6e5a1dd5b2fa946548b00254225469f2f15bee9 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/.eslintrc.cjs @@ -0,0 +1,52 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + }, + extends: ['airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['prettier', '@typescript-eslint', 'unused-imports'], + rules: { + 'prettier/prettier': 'error', + 'arrow-body-style': 'off', + 'prefer-arrow-callback': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-new': [0], + 'no-continue': [0], + '@typescript-eslint/no-empty-interface': 'off', + 'no-use-before-define': [0], + 'no-restricted-syntax': [0], + 'no-empty-function': [0], + 'no-useless-constructor': [0], // 禁止空的构造函数 + 'no-param-reassign': [0], // 禁止修改传入函数的参数 + 'no-underscore-dangle': [0], // 禁止使用下划线开头的变量名 + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // 禁止使用 ++,-- + 'consistent-return': [0], // 函数可以有不同类型返回值 + 'class-methods-use-this': [0], // 方法内未使用此方法时,强制定义为静态方法 + 'import/prefer-default-export': [0], // 一个模块只能有默认导出,不可以有多个导出 + 'import/no-unresolved': [0], // 不允许未解决的模块 + 'import/extensions': [0], // 不允许导入文件时不带后缀 + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-inferrable-types': [0], + '@typescript-eslint/no-non-null-assertion': [0], + '@typescript-eslint/no-explicit-any': ['error'], + '@typescript-eslint/explicit-function-return-type': 'error', // 要求函数和类方法的显式返回类型 + '@typescript-eslint/explicit-module-boundary-types': 'error', // 要求导出函数和类的公共类方法的显式返回和参数类型 + 'import/no-extraneous-dependencies': [ + 0, + { + devDependencies: true, + peerDependencies: true, + // optionalDependencies: true, + // bundledDependencies: true + }, + ], + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/view_custom/CHANGELOG.md b/packages/core/src/create-plugin/template/platform/view_custom/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8ac8e7f05d173977a1ad060d18e7f0b6a5f23cf5 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/CHANGELOG.md @@ -0,0 +1,3 @@ +# 版本变更日志 + +添加变更日志 \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/view_custom/README.md b/packages/core/src/create-plugin/template/platform/view_custom/README.md new file mode 100644 index 0000000000000000000000000000000000000000..dce9c6ef88cadd024efcf22982148ec966e1b153 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/README.md @@ -0,0 +1,130 @@ +# 视图插件 + +视图插件可自定义视图内容的绘制,当标准逻辑无法满足视图绘制要求时,可以通过视图插件来实现。modeling建模平台创建视图插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) + +## 插件结构 + +``` +|─ ─ {{pluginName}} 视图插件顶层目录 + |─ ─ src 视图插件源代码目录 +​ |─ ─ {{pluginName}}.controller.ts 视图插件控制器 +​ |─ ─ {{pluginName}}.engine.ts 视图插件引擎 +​ |─ ─ {{pluginName}}.provider.ts 视图插件适配器 +​ |─ ─ {{pluginName}}.scss 视图插件样式 +​ |─ ─ {{pluginName}}.tsx 视图插件组件 +​ |─ ─ index.ts 视图插件入口文件 +``` + +- 视图插件入口文件 + +视图插件入口文件会全局注册视图插件适配器和视图插件组件,供外部使用。 + +- 视图插件组件 + +视图插件组件使用tsx的书写方式,承载视图绘制的内容,可拷贝基础UI绘制,然后根据需求进行调整。其中,基础UI绘制可参考附录中UI呈现部分。 + +- 视图插件适配器 + +视图插件适配器主要通过component属性指定视图实际要绘制的组件,并且通过createController方法返回传递给视图的控制器。 + +- 视图插件控制器 + +视图插件控制器承载视图的逻辑控制,可继承基础控制器,然后根据需求进行调整。其中,基础控制器可参考附录中控制器部分。 + +- 视图插件引擎 + +视图插件引擎承载视图的界面驱动逻辑控制,可继承基础引擎,然后根据需求进行调整。其中,基础引擎可参考附录中引擎部分。 + +## 本地开发 + +1. 安装依赖并link至全局 + +```sh +// 安装依赖 +pnpm i + +// link底包 +./scripts/link.sh + +// 启动 +pnpm dev + +// link到全局 +pnpm link --global +``` + +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` + +3. 主项目包中注册插件 + +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' + +export default { + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); + }, +}; +``` + +## 附录 + +| 视图类型 | UI呈现 | 控制器 | 引擎 | +| :----------------------------: | :-----------: | :-------------------------: | :----------------------: | +| 应用数据导入视图 | View | AppDataUploadViewController | AppDataUploadViewEngine | +| 日历导航视图 | View | ViewController | CalendarExpViewEngine | +| 日历视图 | View | ViewController | CalendarViewEngine | +| 图表导航视图 | View | ViewController | ChartExpViewEngine | +| 图表视图 | View | ViewController | ChartViewEngine | +| 自定义视图 | View | ViewController | CustomViewEngine | +| 卡片导航视图 | View | ViewController | DataViewExpViewEngine | +| 卡片视图 | View | ViewController | DataViewEngine | +| 实体首页视图 | View | ViewController | DEIndexViewEngine | +| 编辑视图 | View | ViewController | EditViewEngine | +| 编辑视图2(左右关系) | View | ViewController | EditView2Engine | +| 编辑视图3(分页关系) | View | ViewController | EditView3Engine | +| 编辑视图4(上下关系) | View | ViewController | EditView4Engine | +| 表单选择数据视图 | View | ViewController | FormPickupDataViewEngine | +| 甘特图视图 | View | ViewController | GanttViewEngine | +| 表格导航视图 | View | ViewController | GridExpViewEngine | +| 表格视图 | View | ViewController | GridViewEngine | +| 首页视图 | View | ViewController | IndexViewEngine | +| 看板视图 | View | ViewController | KanbanViewEngine | +| 列表导航视图 | View | ViewController | ListExpViewEngine | +| 列表视图 | View | ViewController | ListViewEngine | +| 登录视图 | View | ViewController | LoginViewEngine | +| 地图视图 | View | ViewController | MapViewEngine | +| 多数据自定义视图 | View | ViewController | MDCustomViewEngine | +| 多表单编辑视图 | View | ViewController | MEditView9Engine | +| 多数据选择视图 | View | ViewController | MPickupViewEngine | +| 多数据选择视图(左右关系) | View | ViewController | MPickupView2Engine | +| 选项操作视图 | View | ViewController | OptViewEngine | +| 面板视图 | View | ViewController | PanelViewEngine | +| 选择数据视图 | View | ViewController | PickupDataViewEngine | +| 选择表格视图 | View | ViewController | PickupGridViewEngine | +| 选择树视图 | View | ViewController | PickupTreeViewEngine | +| 数据选择视图 | View | ViewController | PickupViewEngine | +| 数据选择视图(左右关系) | View | ViewController | PickupView2Engine | +| 数据看板视图 | PortalView | ViewController | PortalViewEngine | +| 报表视图 | View | ViewController | ReportViewEngine | +| 子系统引用视图 | SubAppRefView | ViewController | SubAppRefViewEngine | +| 分页导航视图 | View | ViewController | TabExpViewEngine | +| 分页搜索视图 | View | ViewController | TabSearchViewEngine | +| 树导航视图 | View | ViewController | TreeExpViewEngine | +| 树表格视图(增强) | View | ViewController | TreeGridExViewEngine | +| 树表格视图 | View | ViewController | TreeGridViewEngine | +| 树视图 | View | ViewController | TreeViewEngine | +| 工作流动态操作视图 | View | ViewController | WFDynaActionViewEngine | +| 工作流动态编辑视图 | View | ViewController | WFDynaEditViewEngine | +| 工作流动态编辑视图(分页关系) | View | ViewController | WFDynaEditView3Engine | +| 工作流动态启动视图 | View | ViewController | WFDynaStartViewEngine | +| 应用流程处理记录视图 | View | ViewController | WFStepDataViewEngine | +| 向导视图 | View | ViewController | WizardViewEngine | diff --git a/packages/core/src/create-plugin/template/platform/view_custom/package.json b/packages/core/src/create-plugin/template/platform/view_custom/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7bcf063680ec82aa96d7b56a1d83dbed72f592da --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/package.json @@ -0,0 +1,106 @@ +{ + "name": "{{pluginGroup}}/{{pluginName}}", + "version": "0.0.1", + "description": "{{pluginDescription}}", + "author": "iBiz", + "license": "MIT", + "type": "module", + "main": "dist/index.es.js", + "module": "dist/index.es.js", + "types": "dist/types/index.d.ts", + "system": "dist/index.legacy.js", + "styles": [ + "dist/style.css" + ], + "files": [ + "dist", + "public", + "CHANGELOG.md", + "README.md" + ], + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "dev": "vite build --watch", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@floating-ui/dom": "^1.5.3", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", + "@types/lodash-es": "^4.17.12", + "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-libcss": "^1.1.1", + "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", + "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", + "vuedraggable": "^4.1.0" + }, + "peerDependencies": { + "@floating-ui/dom": "^1.5.1", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "vue": "^3.3.8", + "vue-router": "^4.2.5", + "vuedraggable": "^4.1.0" + } +} diff --git a/packages/core/src/create-plugin/template/platform/view_custom/scripts/link.sh b/packages/core/src/create-plugin/template/platform/view_custom/scripts/link.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4edc1556f72a02300c491cda3c13a7ff34795a7 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/scripts/link.sh @@ -0,0 +1,6 @@ +pnpm link --global "@ibiz-template/vue3-util" +pnpm link --global "@ibiz-template/model-helper" +pnpm link --global "@ibiz-template/runtime" +pnpm link --global "@ibiz-template/core" +pnpm link --global "@ibiz-template/theme" +pnpm link --global "@ibiz-template/vue3-components" diff --git a/packages/core/src/create-plugin/template/platform/view_custom/src/index.ts b/packages/core/src/create-plugin/template/platform/view_custom/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..84829da40450a2783adf8d4bea8e2fd96aa40d24 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/src/index.ts @@ -0,0 +1,16 @@ +import { App } from 'vue'; +import { registerViewProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }} } from './{{pluginName}}'; +import { {{ pascalCasePluginName }}Provider } from './{{pluginName}}.provider'; + +export default { + install(app: App) { + // 全局注册视图插件组件 + app.component({{ pascalCasePluginName }}.name!, {{ pascalCasePluginName }}); + // 全局注册视图插件适配器,VIEW_CUSTOM是插件类型,{{pluginId}}是插件标识 + registerViewProvider( + 'VIEW_CUSTOM_{{pluginId}}', + () => new {{ pascalCasePluginName }}Provider(), + ); + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.controller.ts b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..685fb1325688e813cb546d9e33c530940d085d53 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.controller.ts @@ -0,0 +1,8 @@ +import { ViewController } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Engine } from './{{pluginName}}.engine'; + +export class {{ pascalCasePluginName }}Controller extends ViewController { + protected initEngines(): void { + this.engines.push(new {{ pascalCasePluginName }}Engine(this)); + } +} diff --git a/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.engine.ts b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.engine.ts new file mode 100644 index 0000000000000000000000000000000000000000..072185f46cbba3ce5642805cc95ca22532f35acd --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.engine.ts @@ -0,0 +1,3 @@ +import { ViewEngineBase } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}Engine extends ViewEngineBase {} diff --git a/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.provider.ts b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..7613863ea347a99b10d5544a360686aa9b1ad84d --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.provider.ts @@ -0,0 +1,16 @@ +import { CTX, IViewController, IViewProvider } from '@ibiz-template/runtime'; +import { IAppView } from '@ibiz/model-core'; +import { {{ pascalCasePluginName }}Controller } from './{{pluginName}}.controller'; + +export class {{ pascalCasePluginName }}Provider implements IViewProvider { + component: string = 'IBiz{{ pascalCasePluginName }}'; + + createController( + model: IAppView, + context: IContext, + params?: IParams, + ctx?: CTX, + ): IViewController { + return new {{ pascalCasePluginName }}Controller(model, context, params, ctx); + } +} diff --git a/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.scss b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.scss new file mode 100644 index 0000000000000000000000000000000000000000..f494ab6cf7c220eae2d3b11bd32b7e3d96d2dc16 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}){ + // 样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.tsx b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.tsx new file mode 100644 index 0000000000000000000000000000000000000000..960749fba057aac01cf40be9e38e9c1008baad32 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/src/{{pluginName}}.tsx @@ -0,0 +1,49 @@ +import { PropType, defineComponent } from 'vue'; +import { IModal, IViewProvider } from '@ibiz-template/runtime'; +import { useNamespace, useViewController } from '@ibiz-template/vue3-util'; +import { IAppView } from '@ibiz/model-core'; +import { {{ pascalCasePluginName }}Controller } from './{{pluginName}}.controller'; +import './{{pluginName}}.scss'; + +export const {{ pascalCasePluginName }} = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}', + props: { + /** + * @description 应用上下文 + */ + context: { type: Object as PropType }, + /** + * @description 视图参数 + * @default {} + */ + params: { type: Object as PropType, default: () => ({}) }, + /** + * @description 视图模型 + */ + modelData: { type: Object as PropType, required: true }, + /** + * @description 视图模态操作对象,在模态等形式打开视图时,需给视图注入此对象 + */ + modal: { type: Object as PropType }, + /** + * @description 视图状态 + */ + state: { type: Object as PropType }, + /** + * @description 视图适配器 + */ + provider: { type: Object as PropType }, + }, + setup() { + const c = useViewController((...args) => new {{ pascalCasePluginName }}Controller(...args)); + const ns = useNamespace('{{pluginName}}'); + + return { + c, + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/platform/view_custom/tsconfig.json b/packages/core/src/create-plugin/template/platform/view_custom/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..ba8f48be2a612227b3b2cd44668c26316fa3dd4b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/core/src/create-plugin/template/platform/view_custom/tsconfig.node.json b/packages/core/src/create-plugin/template/platform/view_custom/tsconfig.node.json new file mode 100644 index 0000000000000000000000000000000000000000..9d31e2aed93c876bc048cf2f863cb2a847c901e8 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/core/src/create-plugin/template/platform/view_custom/vite.config.ts b/packages/core/src/create-plugin/template/platform/view_custom/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc3449a5a42babd06efbe73c42acd8989ffb91fc --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/view_custom/vite.config.ts @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import libLegacy from '@qx-chitanda/vite-plugin-lib-legacy'; +import dts from 'vite-plugin-dts'; +import libCss from 'vite-plugin-libcss'; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: './src/index.ts', + fileName: format => `index.${format}.js`, + }, + rollupOptions: { + external: [ + '@ibiz-template/core', + '@ibiz-template/model-helper', + '@ibiz-template/runtime', + '@ibiz-template/theme', + '@ibiz-template/vue3-util', + '@ibiz/dynamic-model-api', + '@floating-ui/dom', + 'async-validator', + 'axios', + 'dayjs', + 'element-plus', + 'lodash-es', + 'pluralize', + 'qs', + 'qx-util', + 'ramda', + 'vue', + 'vue-router', + 'vuedraggable', + ], + }, + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@import "@ibiz-template/theme/style/global.scss";', + }, + }, + }, + plugins: [ + // eslint({ + // include: 'src/**/*.{ts,tsx,js,jsx}', + // }), + vue(), + vueJsx(), + libLegacy(), + libCss(), + dts({ + outDir: 'dist/types', + }), + ], +}); diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/.eslintrc.cjs b/packages/core/src/create-plugin/template/platform/wizardpanel_render/.eslintrc.cjs new file mode 100644 index 0000000000000000000000000000000000000000..c6e5a1dd5b2fa946548b00254225469f2f15bee9 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/.eslintrc.cjs @@ -0,0 +1,52 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + }, + extends: ['airbnb-base', 'prettier', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['prettier', '@typescript-eslint', 'unused-imports'], + rules: { + 'prettier/prettier': 'error', + 'arrow-body-style': 'off', + 'prefer-arrow-callback': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-new': [0], + 'no-continue': [0], + '@typescript-eslint/no-empty-interface': 'off', + 'no-use-before-define': [0], + 'no-restricted-syntax': [0], + 'no-empty-function': [0], + 'no-useless-constructor': [0], // 禁止空的构造函数 + 'no-param-reassign': [0], // 禁止修改传入函数的参数 + 'no-underscore-dangle': [0], // 禁止使用下划线开头的变量名 + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // 禁止使用 ++,-- + 'consistent-return': [0], // 函数可以有不同类型返回值 + 'class-methods-use-this': [0], // 方法内未使用此方法时,强制定义为静态方法 + 'import/prefer-default-export': [0], // 一个模块只能有默认导出,不可以有多个导出 + 'import/no-unresolved': [0], // 不允许未解决的模块 + 'import/extensions': [0], // 不允许导入文件时不带后缀 + 'unused-imports/no-unused-imports': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-inferrable-types': [0], + '@typescript-eslint/no-non-null-assertion': [0], + '@typescript-eslint/no-explicit-any': ['error'], + '@typescript-eslint/explicit-function-return-type': 'error', // 要求函数和类方法的显式返回类型 + '@typescript-eslint/explicit-module-boundary-types': 'error', // 要求导出函数和类的公共类方法的显式返回和参数类型 + 'import/no-extraneous-dependencies': [ + 0, + { + devDependencies: true, + peerDependencies: true, + // optionalDependencies: true, + // bundledDependencies: true + }, + ], + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/CHANGELOG.md b/packages/core/src/create-plugin/template/platform/wizardpanel_render/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8ac8e7f05d173977a1ad060d18e7f0b6a5f23cf5 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/CHANGELOG.md @@ -0,0 +1,3 @@ +# 版本变更日志 + +添加变更日志 \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/README.md b/packages/core/src/create-plugin/template/platform/wizardpanel_render/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c8d5791d1f87c1f85e64ffe4a3b3505f544e2d15 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/README.md @@ -0,0 +1,71 @@ +# 向导面板插件 + +向导面板插件可自定义向导面板内容的绘制,当标准逻辑无法满足向导面板绘制要求时,可以通过向导面板插件来实现。modeling建模平台创建向导面板插件可参见 [插件开发](https://open.ibizlab.cn/apphub/zh/guide/plugin-dev.html) + +## 插件结构 + +``` +|─ ─ {{pluginName}} 向导面板插件顶层目录 + |─ ─ src 向导面板插件源代码目录 +​ |─ ─ {{pluginName}}.controller.ts 向导面板插件控制器 +​ |─ ─ {{pluginName}}.provider.ts 向导面板插件适配器 +​ |─ ─ {{pluginName}}.scss 向导面板插件样式 +​ |─ ─ {{pluginName}}.tsx 向导面板插件组件 +​ |─ ─ index.ts 向导面板插件入口文件 +``` + +- 向导面板插件入口文件 + +向导面板插件入口文件会全局注册向导面板插件适配器和向导面板插件组件,供外部使用。 + +- 向导面板插件组件 + +向导面板插件组件使用tsx的书写方式,承载向导面板绘制的内容。 + +- 向导面板插件适配器 + +向导面板插件适配器主要通过component属性指定向导面板实际要绘制的组件,并且通过createController方法返回传递给向导面板的控制器。 + +- 向导面板插件控制器 + +向导面板插件控制器承载向导面板的逻辑控制。 + +## 本地开发 + +1. 安装依赖并link至全局 + +```sh +// 安装依赖 +pnpm i + +// link底包 +./scripts/link.sh + +// 启动 +pnpm dev + +// link到全局 +pnpm link --global +``` + +2. 主项目包中引用插件 + +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' +``` + +3. 主项目包中注册插件 + +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' + +export default { + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); + }, +}; +``` diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/package.json b/packages/core/src/create-plugin/template/platform/wizardpanel_render/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7bcf063680ec82aa96d7b56a1d83dbed72f592da --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/package.json @@ -0,0 +1,106 @@ +{ + "name": "{{pluginGroup}}/{{pluginName}}", + "version": "0.0.1", + "description": "{{pluginDescription}}", + "author": "iBiz", + "license": "MIT", + "type": "module", + "main": "dist/index.es.js", + "module": "dist/index.es.js", + "types": "dist/types/index.d.ts", + "system": "dist/index.legacy.js", + "styles": [ + "dist/style.css" + ], + "files": [ + "dist", + "public", + "CHANGELOG.md", + "README.md" + ], + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "scripts": { + "dev": "vite build --watch", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@floating-ui/dom": "^1.5.3", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", + "@types/lodash-es": "^4.17.12", + "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-libcss": "^1.1.1", + "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", + "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", + "vuedraggable": "^4.1.0" + }, + "peerDependencies": { + "@floating-ui/dom": "^1.5.1", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", + "@ibiz-template/theme": "^0.7.39", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz/model-core": "^0.1.72", + "async-validator": "^4.2.5", + "axios": "^1.6.2", + "dayjs": "^1.11.10", + "element-plus": "^2.4.2", + "lodash-es": "^4.17.21", + "pluralize": "^8.0.0", + "qs": "^6.11.2", + "qx-util": "^0.4.8", + "ramda": "^0.29.1", + "vue": "^3.3.8", + "vue-router": "^4.2.5", + "vuedraggable": "^4.1.0" + } +} diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/scripts/link.sh b/packages/core/src/create-plugin/template/platform/wizardpanel_render/scripts/link.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4edc1556f72a02300c491cda3c13a7ff34795a7 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/scripts/link.sh @@ -0,0 +1,6 @@ +pnpm link --global "@ibiz-template/vue3-util" +pnpm link --global "@ibiz-template/model-helper" +pnpm link --global "@ibiz-template/runtime" +pnpm link --global "@ibiz-template/core" +pnpm link --global "@ibiz-template/theme" +pnpm link --global "@ibiz-template/vue3-components" diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/index.ts b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b849f2c1201712a2538a330270003627f06554c --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/index.ts @@ -0,0 +1,16 @@ +import { App } from 'vue'; +import { registerControlProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }} } from './{{pluginName}}'; +import { {{ pascalCasePluginName }}Provider } from './{{pluginName}}.provider'; + +export default { + install(app: App) { + // 全局注册向导面板插件组件 + app.component({{ pascalCasePluginName }}.name!, {{ pascalCasePluginName }}); + // 全局注册向导面板插件适配器,WIZARDPANEL_RENDER是插件类型,{{pluginId}}是插件标识 + registerControlProvider( + 'WIZARDPANEL_RENDER_{{pluginId}}', + () => new {{ pascalCasePluginName }}Provider(), + ); + }, +}; diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.controller.ts b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..55779eb590cc872ff02bfa06e1e5ed1b7d0a5709 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.controller.ts @@ -0,0 +1,3 @@ +import { WizardPanelController } from '@ibiz-template/runtime'; + +export class {{ pascalCasePluginName }}Controller extends WizardPanelController {} diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.provider.ts b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a32e3ffd8cf352373e44506e938059b9c46041a --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.provider.ts @@ -0,0 +1,20 @@ +import { + CTX, + IControlController, + IControlProvider, +} from '@ibiz-template/runtime'; +import { IControl } from '@ibiz/model-core'; +import { {{ pascalCasePluginName }}Controller } from './{{pluginName}}.controller'; + +export class {{ pascalCasePluginName }}Provider implements IControlProvider { + component: string = 'IBiz{{ pascalCasePluginName }}'; + + createController( + model: IControl, + context: IContext, + params: IParams, + ctx: CTX, + ): IControlController { + return new {{ pascalCasePluginName }}Controller(model, context, params, ctx); + } +} diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.scss b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.scss new file mode 100644 index 0000000000000000000000000000000000000000..f494ab6cf7c220eae2d3b11bd32b7e3d96d2dc16 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.scss @@ -0,0 +1,3 @@ +@include b({{pluginName}}){ + // 样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.tsx b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.tsx new file mode 100644 index 0000000000000000000000000000000000000000..50925c53bd7a5c249825f6b0e1d977ae9a1a24f3 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/src/{{pluginName}}.tsx @@ -0,0 +1,46 @@ +import { defineComponent, PropType } from 'vue'; +import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { IDEWizardPanel } from '@ibiz/model-core'; +import { IControlProvider } from '@ibiz-template/runtime'; +import { {{ pascalCasePluginName }}Controller } from './{{pluginName}}.controller'; +import './{{pluginName}}.scss'; + +export const {{ pascalCasePluginName }} = defineComponent({ + name: 'IBiz{{ pascalCasePluginName }}', + props: { + /** + * @description 向导面板模型数据 + */ + modelData: { + type: Object as PropType, + required: true, + }, + /** + * @description 应用上下文对象 + */ + context: { type: Object as PropType, required: true }, + /** + * @description 视图参数对象 + * @default {} + */ + params: { type: Object as PropType, default: () => ({}) }, + /** + * @description 部件适配器 + */ + provider: { type: Object as PropType }, + }, + setup() { + const c = useControlController( + (...args) => new {{ pascalCasePluginName }}Controller(...args), + ); + const ns = useNamespace('{{pluginName}}'); + + return { + c, + ns, + }; + }, + render() { + return
插件示例
; + }, +}); diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/tsconfig.json b/packages/core/src/create-plugin/template/platform/wizardpanel_render/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..ba8f48be2a612227b3b2cd44668c26316fa3dd4b --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "jsxImportSource": "vue", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/tsconfig.node.json b/packages/core/src/create-plugin/template/platform/wizardpanel_render/tsconfig.node.json new file mode 100644 index 0000000000000000000000000000000000000000..9d31e2aed93c876bc048cf2f863cb2a847c901e8 --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/core/src/create-plugin/template/platform/wizardpanel_render/vite.config.ts b/packages/core/src/create-plugin/template/platform/wizardpanel_render/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc3449a5a42babd06efbe73c42acd8989ffb91fc --- /dev/null +++ b/packages/core/src/create-plugin/template/platform/wizardpanel_render/vite.config.ts @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import libLegacy from '@qx-chitanda/vite-plugin-lib-legacy'; +import dts from 'vite-plugin-dts'; +import libCss from 'vite-plugin-libcss'; +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + lib: { + entry: './src/index.ts', + fileName: format => `index.${format}.js`, + }, + rollupOptions: { + external: [ + '@ibiz-template/core', + '@ibiz-template/model-helper', + '@ibiz-template/runtime', + '@ibiz-template/theme', + '@ibiz-template/vue3-util', + '@ibiz/dynamic-model-api', + '@floating-ui/dom', + 'async-validator', + 'axios', + 'dayjs', + 'element-plus', + 'lodash-es', + 'pluralize', + 'qs', + 'qx-util', + 'ramda', + 'vue', + 'vue-router', + 'vuedraggable', + ], + }, + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@import "@ibiz-template/theme/style/global.scss";', + }, + }, + }, + plugins: [ + // eslint({ + // include: 'src/**/*.{ts,tsx,js,jsx}', + // }), + vue(), + vueJsx(), + libLegacy(), + libCss(), + dts({ + outDir: 'dist/types', + }), + ], +}); diff --git a/packages/core/src/create-plugin/template/theme/README.md b/packages/core/src/create-plugin/template/theme/README.md index 8e5b3074abe64290bce48b7354cb5df16ae7578e..8a91568621d387a2ea156a425bb8df4e20f7cb77 100644 --- a/packages/core/src/create-plugin/template/theme/README.md +++ b/packages/core/src/create-plugin/template/theme/README.md @@ -1,126 +1,64 @@ # 主题插件 -## 新建主题 +主题插件可自定义主题样式和视图布局,当标准主题无法满足要求时,可以通过主题插件来实现。modeling建模平台创建主题插件可参见 [主题定制](https://open.ibizlab.cn/apphub/zh/guide/theme-custom.html) -新建界面主题,需要注意的是主题标识需要和主题插件包中的主题class类名一致,并且配置主题参数theme-package-path,主题参数的值是主题插件包信息。 +## 插件结构 - - -## 插件机制 - -应用初始化的时候,如果应用配置了主题,则会加载其对应的主题包插件,从而应用自定义主题样式和覆盖指定的默认视图布局,详情如下: - -```typescript -async initModel(context: IParams, permission: boolean = true): Promise { - // 没初始化或者初始化了但是切换模型 - if ( - !this.hasModelInit || - (this.hasModelInit && this.noPermissionModel !== permission) - ) { - // 清空重置基座 - ibiz.hub.reset(); - const helper = new ModelHelper( - async (url: string, params?: IParams) => { - const res = await ibiz.net.get( - `${ibiz.env.remoteModelUrl}${url}`, - params, - permission ? {} : { srfdcsystem: ibiz.env.dcSystem }, - ); - return res.data; - }, - ibiz.env.appId, - context, - permission, - ); - const tempApp = await helper.getAppModel(); - await this.initEnvironment(tempApp); - const app = await ibiz.hub.getAppAsync(ibiz.env.appId); - await AppHooks.initedApp.call({ context, app }); - const appModel = app.model; - ibiz.env.isMob = appModel.mobileApp === true; - if (ibiz.env.isEnableMultiLan) { - const lang = ibiz.i18n.getLang(); - const m = await helper.getPSAppLang( - lang.replace('-', '_').toUpperCase(), - ); - const items = m.languageItems || []; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const data: any = {}; - items.forEach(item => { - data[item.lanResTag!] = item.content; - }); - i18n.global.mergeLocaleMessage(lang, data); - } - const module = await import('@ibiz-template/web-theme'); - const theme = module.default || module; - AppHooks.useComponent.callSync(null, theme); - if (ibiz.config.theme) ibiz.util.theme.setTheme(ibiz.config.theme); - if (appModel.appUIThemes) { - await this.loadTheme(); - } - - // 设置浏览器标题 - if (app.model.title) { - ibiz.util.setBrowserTitle(''); - } - } - - this.noPermissionModel = permission; - this.hasModelInit = true; - } +``` +|─ ─ {{pluginName}} 主题插件顶层目录 + |─ ─ src 主题插件源代码目录 +​ |─ ─ layout 布局目录 + |─ ─ de-grid-view-layout.ts 默认实体表格视图布局模型 + |─ ─ index.ts 布局入口文件,覆盖默认视图布局 + |─ ─ theme 主题目录 + |─ ─ default 自定义主题目录 + |─ ─ app.scss 应用级主题样式 + |─ ─ ctrl.scss 部件级主题样式 + |─ ─ editor.scss 编辑器主题样式 + |─ ─ element-plus.scss element-plus主题样式 + |─ ─ theme.scss 样式变量 + |─ ─ view.scss 视图级主题样式 + |─ ─ index.scss 自定义主题入口文件,加载自定义主题样式 + |─ ─ index.ts 主题入口文件,加载主题样式 +​ |─ ─ index.ts 主题插件入口文件,加载主题样式和覆盖默认视图布局 ``` -## 插件示例 +## 本地开发 -### 插件效果 +1. 安装依赖并link至全局 -#### 使用插件前 +```sh +// 安装依赖 +pnpm i - +// link底包 +./scripts/link.sh -#### 使用插件后 +// 启动 +pnpm dev - +// link到全局 +pnpm link --global +``` -### 插件结构 +2. 主项目包中引用插件 +```sh +// link插件 +pnpm link --global '{{pluginGroup}}/{{pluginName}}' ``` -|─ ─ theme 主题插件顶层目录,可根据实际业务命名 - |─ ─ src 主题插件源代码目录 -​ |─ ─ layout 布局目录 - |─ ─ de-grid-view-layout.ts 默认表格视图布局json - |─ ─ index.ts 布局入口文件 - |─ ─ theme 主题目录 - |─ ─ custom-theme.scss 自定义主题 - |─ ─ index.ts 主题入口文件 -​ |─ ─ index.ts 主题插件入口文件 -``` - -### 主题插件入口文件 -主题插件入口文件会加载自定义主题样式,并且覆盖指定的默认视图布局,供外部使用。 +3. 主项目包中注册插件 -```typescript -import WebTheme from '@ibiz-template/web-theme'; -import { install } from './layout'; -import './theme/index.scss'; +```ts +import { App } from 'vue'; +import {{ pascalCasePluginName }} from '{{pluginGroup}}/{{pluginName}}' export default { - install(): void { - // 安装默认主题 - WebTheme.install(); - // 覆盖默认视图布局 - install((key: string, model: any) => { - ibiz.util.layoutPanel.register(key, model); - }); + install(app: App) { + app.use({{ pascalCasePluginName }}); + // 设置本地开发需要忽略加载的插件,可填写正则或全匹配字符串。匹配插件在modeling建模平台配置的[运行时插件仓库配置]内容 + ibiz.plugin.setDevIgnore(/^{{pluginGroup}}\/{{pluginName}}/); }, }; ``` - -### 布局入口文件 - -布局入口文件会覆盖指定的默认视图布局,可以重新定义默认视图布局的json结构。 - -### 主题入口文件 - -主题入口文件会加载自定义主题样式。 diff --git a/packages/core/src/create-plugin/template/theme/package.json b/packages/core/src/create-plugin/template/theme/package.json index 65ace5fdca3bb29e400a42821d55f743395bc303..545839a9112491c6d74675b06a51c00fbcc80337 100644 --- a/packages/core/src/create-plugin/template/theme/package.json +++ b/packages/core/src/create-plugin/template/theme/package.json @@ -28,38 +28,70 @@ }, "devDependencies": { "@floating-ui/dom": "^1.5.3", - "@ibiz-template/core": "0.7.40-alpha.13", - "@ibiz-template/model-helper": "0.7.40-alpha.13", - "@ibiz-template/runtime": "0.7.40-alpha.13", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", "@ibiz-template/theme": "^0.7.39", - "@ibiz-template/vue3-util": "0.7.40-alpha.13", - "@ibiz-template/web-theme": "3.1.0", - "@ibiz/model-core": "^0.1.71", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz-template/web-theme": "^3.4.0", + "@ibiz/model-core": "^0.1.72", + "@qx-chitanda/vite-plugin-lib-legacy": "^4.1.1", "@types/lodash-es": "^4.17.12", "@types/ramda": "^0.29.6", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "@vitejs/plugin-vue": "^4.4.1", + "@vitejs/plugin-vue-jsx": "^3.0.2", "async-validator": "^4.2.5", "axios": "^1.6.2", "dayjs": "^1.11.10", "element-plus": "^2.4.2", + "eslint": "^8.53.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "eslint-plugin-vue": "^9.18.1", + "husky": "^8.0.3", + "lerna": "^8.0.0", + "lint-staged": "^15.1.0", "lodash-es": "^4.17.21", "pluralize": "^8.0.0", + "postcss": "^8.4.31", + "prettier": "^3.1.0", "qs": "^6.11.2", "qx-util": "^0.4.8", "ramda": "^0.29.1", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "1.69.5", + "stylelint": "15.11.0", + "stylelint-config-prettier": "^9.0.5", + "stylelint-config-recess-order": "^4.3.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-config-standard-scss": "^11.1.0", + "stylelint-scss": "5.3.1", + "terser": "^5.24.0", + "typescript": "5.2.2", + "vite": "^4.5.0", + "vite-plugin-dts": "^3.6.3", + "vite-plugin-eslint": "^1.8.1", "vite-plugin-libcss": "^1.1.1", "vue": "^3.3.8", + "vue-eslint-parser": "^9.3.2", "vue-router": "^4.2.5", + "vue-tsc": "1.8.22", "vuedraggable": "^4.1.0" }, "peerDependencies": { "@floating-ui/dom": "^1.5.1", - "@ibiz-template/core": "0.7.40-alpha.13", - "@ibiz-template/model-helper": "0.7.40-alpha.13", - "@ibiz-template/runtime": "0.7.40-alpha.13", + "@ibiz-template/core": "^0.7.40-alpha.7", + "@ibiz-template/model-helper": "^0.7.40-alpha.8", + "@ibiz-template/runtime": "^0.7.40-alpha.8", "@ibiz-template/theme": "^0.7.39", - "@ibiz-template/vue3-util": "0.7.40-alpha.13", - "@ibiz-template/web-theme": "3.1.0", - "@ibiz/model-core": "^0.1.71", + "@ibiz-template/vue3-util": "^0.7.40-alpha.8", + "@ibiz-template/web-theme": "^3.4.0", + "@ibiz/model-core": "^0.1.72", "async-validator": "^4.2.5", "axios": "^1.6.2", "dayjs": "^1.11.10", diff --git a/packages/core/src/create-plugin/template/theme/public/docs/image.png b/packages/core/src/create-plugin/template/theme/public/docs/image.png deleted file mode 100644 index 3e0baf5adf280c04430d161b63ad2f491dfadb82..0000000000000000000000000000000000000000 Binary files a/packages/core/src/create-plugin/template/theme/public/docs/image.png and /dev/null differ diff --git a/packages/core/src/create-plugin/template/theme/public/docs/image2.png b/packages/core/src/create-plugin/template/theme/public/docs/image2.png deleted file mode 100644 index 3375d33d0d6060ebe8797af9413e16385e656718..0000000000000000000000000000000000000000 Binary files a/packages/core/src/create-plugin/template/theme/public/docs/image2.png and /dev/null differ diff --git a/packages/core/src/create-plugin/template/theme/public/docs/image3.png b/packages/core/src/create-plugin/template/theme/public/docs/image3.png deleted file mode 100644 index 39dc57287e66f32a9a964e328d93d9f5a289bd0d..0000000000000000000000000000000000000000 Binary files a/packages/core/src/create-plugin/template/theme/public/docs/image3.png and /dev/null differ diff --git a/packages/core/src/create-plugin/template/theme/src/index.ts b/packages/core/src/create-plugin/template/theme/src/index.ts index 21767cc1891732d82740f2154a2912769915190b..0aa030db7c122f736d83ba643fcac79969b962be 100644 --- a/packages/core/src/create-plugin/template/theme/src/index.ts +++ b/packages/core/src/create-plugin/template/theme/src/index.ts @@ -1,14 +1,15 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import WebTheme from '@ibiz-template/web-theme'; -// import { install } from './layout'; -// import './theme/index.scss'; +import { install } from './layout'; +import './theme/index.scss'; export default { install(): void { // 安装默认主题 WebTheme.install(); // 覆盖默认视图布局 - // install((key: string, model: any) => { - // ibiz.util.layoutPanel.register(key, model); - // }); + install((key: string, model: any) => { + ibiz.util.layoutPanel.register(key, model); + }); }, }; diff --git a/packages/core/src/create-plugin/template/theme/src/layout/index.ts b/packages/core/src/create-plugin/template/theme/src/layout/index.ts index 5bf34417b48bcf43463f9b65576b89bf4a50984f..f02b952b3f992c51c700ef7e23aaa01b084bb4f9 100644 --- a/packages/core/src/create-plugin/template/theme/src/layout/index.ts +++ b/packages/core/src/create-plugin/template/theme/src/layout/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import DEGridView from './de-grid-view-layout'; export function install(callBack: (key: string, model: any) => void): void { diff --git a/packages/core/src/create-plugin/template/theme/src/theme/custom-theme.scss b/packages/core/src/create-plugin/template/theme/src/theme/custom-theme.scss deleted file mode 100644 index 347a3a41fec915f33f54cfc163da868682e23231..0000000000000000000000000000000000000000 --- a/packages/core/src/create-plugin/template/theme/src/theme/custom-theme.scss +++ /dev/null @@ -1,421 +0,0 @@ -/* stylelint-disable selector-class-pattern */ -:root.custom_theme { -// 红色 -#{getCssVarName(red, 0)}: 254, 242, 237; -#{getCssVarName(red, 1)}: 254, 221, 210; -#{getCssVarName(red, 2)}: 253, 183, 164; -#{getCssVarName(red, 3)}: 251, 144, 120; -#{getCssVarName(red, 4)}: 250, 102, 75; -#{getCssVarName(red, 5)}: 249, 57, 31; -#{getCssVarName(red, 6)}: 213, 37, 20; -#{getCssVarName(red, 7)}: 177, 20, 13; -#{getCssVarName(red, 8)}: 142, 7, 5; -#{getCssVarName(red, 9)}: 106, 2, 3; - -// 粉色 -#{getCssVarName(pink, 0)}: 253, 236, 239; -#{getCssVarName(pink, 1)}: 251, 207, 216; -#{getCssVarName(pink, 2)}: 246, 160, 181; -#{getCssVarName(pink, 3)}: 242, 115, 150; -#{getCssVarName(pink, 4)}: 238, 72, 122; -#{getCssVarName(pink, 5)}: 233, 31, 99; -#{getCssVarName(pink, 6)}: 197, 18, 86; -#{getCssVarName(pink, 7)}: 162, 11, 72; -#{getCssVarName(pink, 8)}: 126, 4, 58; -#{getCssVarName(pink, 9)}: 90, 1, 44; - -// 紫色 -#{getCssVarName(purple, 0)}: 247, 233, 247; -#{getCssVarName(purple, 1)}: 239, 202, 239; -#{getCssVarName(purple, 2)}: 221, 155, 224; -#{getCssVarName(purple, 3)}: 201, 112, 209; -#{getCssVarName(purple, 4)}: 180, 73, 194; -#{getCssVarName(purple, 5)}: 158, 40, 179; -#{getCssVarName(purple, 6)}: 135, 30, 159; -#{getCssVarName(purple, 7)}: 112, 23, 138; -#{getCssVarName(purple, 8)}: 92, 14, 117; -#{getCssVarName(purple, 9)}: 72, 11, 97; - -// 紫罗兰色 -#{getCssVarName(violet, 0)}: 243, 237, 249; -#{getCssVarName(violet, 1)}: 226, 209, 244; -#{getCssVarName(violet, 2)}: 196, 167, 233; -#{getCssVarName(violet, 3)}: 166, 126, 221; -#{getCssVarName(violet, 4)}: 136, 91, 210; -#{getCssVarName(violet, 5)}: 106, 58, 199; -#{getCssVarName(violet, 6)}: 87, 47, 179; -#{getCssVarName(violet, 7)}: 70, 36, 158; -#{getCssVarName(violet, 8)}: 54, 28, 138; -#{getCssVarName(violet, 9)}: 40, 20, 117; - -// 靛蓝 -#{getCssVarName(indigo, 0)}: 237, 239, 248; -#{getCssVarName(indigo, 1)}: 209, 216, 240; -#{getCssVarName(indigo, 2)}: 167, 179, 225; -#{getCssVarName(indigo, 3)}: 128, 144, 211; -#{getCssVarName(indigo, 4)}: 94, 111, 196; -#{getCssVarName(indigo, 5)}: 63, 81, 181; -#{getCssVarName(indigo, 6)}: 51, 66, 161; -#{getCssVarName(indigo, 7)}: 41, 52, 140; -#{getCssVarName(indigo, 8)}: 31, 40, 120; -#{getCssVarName(indigo, 9)}: 23, 29, 99; - -// 蓝色 -#{getCssVarName(blue, 0)}: 234, 245, 255; -#{getCssVarName(blue, 1)}: 203, 231, 254; -#{getCssVarName(blue, 2)}: 152, 205, 253; -#{getCssVarName(blue, 3)}: 101, 179, 252; -#{getCssVarName(blue, 4)}: 51, 149, 252; -#{getCssVarName(blue, 5)}: 3, 118, 250; -#{getCssVarName(blue, 6)}: 2, 97, 214; -#{getCssVarName(blue, 7)}: 2, 79, 179; -#{getCssVarName(blue, 8)}: 0, 61, 143; -#{getCssVarName(blue, 9)}: 0, 44, 107; - -// 浅蓝色 -#{getCssVarName(light, blue, 0)}: 234, 247, 253; -#{getCssVarName(light, blue, 1)}: 202, 236, 252; -#{getCssVarName(light, blue, 2)}: 149, 216, 248; -#{getCssVarName(light, blue, 3)}: 97, 195, 245; -#{getCssVarName(light, blue, 4)}: 48, 172, 241; -#{getCssVarName(light, blue, 5)}: 0, 149, 238; -#{getCssVarName(light, blue, 6)}: 0, 123, 202; -#{getCssVarName(light, blue, 7)}: 0, 99, 167; -#{getCssVarName(light, blue, 8)}: 0, 75, 131; -#{getCssVarName(light, blue, 9)}: 0, 53, 95; - -// 青色 -#{getCssVarName(cyan, 0)}: 229, 247, 248; -#{getCssVarName(cyan, 1)}: 194, 239, 240; -#{getCssVarName(cyan, 2)}: 138, 221, 225; -#{getCssVarName(cyan, 3)}: 87, 203, 211; -#{getCssVarName(cyan, 4)}: 44, 184, 197; -#{getCssVarName(cyan, 5)}: 6, 164, 182; -#{getCssVarName(cyan, 6)}: 3, 134, 152; -#{getCssVarName(cyan, 7)}: 2, 105, 121; -#{getCssVarName(cyan, 8)}: 0, 77, 91; -#{getCssVarName(cyan, 9)}: 1, 50, 61; - -// 蓝绿色 -#{getCssVarName(teal, 0)}: 227, 247, 244; -#{getCssVarName(teal, 1)}: 192, 240, 232; -#{getCssVarName(teal, 2)}: 135, 224, 211; -#{getCssVarName(teal, 3)}: 84, 209, 193; -#{getCssVarName(teal, 4)}: 39, 194, 176; -#{getCssVarName(teal, 5)}: 5, 179, 161; -#{getCssVarName(teal, 6)}: 0, 149, 137; -#{getCssVarName(teal, 7)}: 0, 119, 111; -#{getCssVarName(teal, 8)}: 0, 90, 85; -#{getCssVarName(teal, 9)}: 1, 60, 58; - -// 绿色 -#{getCssVarName(green, 0)}: 236, 246, 236; -#{getCssVarName(green, 1)}: 208, 240, 208; -#{getCssVarName(green, 2)}: 164, 224, 167; -#{getCssVarName(green, 3)}: 126, 209, 130; -#{getCssVarName(green, 4)}: 90, 194, 98; -#{getCssVarName(green, 5)}: 59, 179, 70; -#{getCssVarName(green, 6)}: 49, 149, 58; -#{getCssVarName(green, 7)}: 37, 119, 47; -#{getCssVarName(green, 8)}: 26, 89, 36; -#{getCssVarName(green, 9)}: 18, 60, 24; - -// 浅绿色 -#{getCssVarName(light, green, 0)}: 243, 248, 236; -#{getCssVarName(light, green, 1)}: 226, 240, 208; -#{getCssVarName(light, green, 2)}: 200, 225, 165; -#{getCssVarName(light, green, 3)}: 173, 211, 127; -#{getCssVarName(light, green, 4)}: 147, 197, 91; -#{getCssVarName(light, green, 5)}: 123, 182, 60; -#{getCssVarName(light, green, 6)}: 100, 152, 47; -#{getCssVarName(light, green, 7)}: 79, 121, 38; -#{getCssVarName(light, green, 8)}: 57, 91, 27; -#{getCssVarName(light, green, 9)}: 36, 61, 18; - -// 清柠色 -#{getCssVarName(lime, 0)}: 241, 250, 230; -#{getCssVarName(lime, 1)}: 227, 246, 197; -#{getCssVarName(lime, 2)}: 203, 237, 142; -#{getCssVarName(lime, 3)}: 183, 226, 91; -#{getCssVarName(lime, 4)}: 168, 218, 44; -#{getCssVarName(lime, 5)}: 154, 209, 0; -#{getCssVarName(lime, 6)}: 125, 174, 0; -#{getCssVarName(lime, 7)}: 99, 139, 2; -#{getCssVarName(lime, 8)}: 72, 104, 0; -#{getCssVarName(lime, 9)}: 47, 70, 0; - -// 黄色 -#{getCssVarName(yellow, 0)}: 255, 253, 234; -#{getCssVarName(yellow, 1)}: 255, 250, 203; -#{getCssVarName(yellow, 2)}: 253, 243, 152; -#{getCssVarName(yellow, 3)}: 252, 231, 101; -#{getCssVarName(yellow, 4)}: 251, 218, 49; -#{getCssVarName(yellow, 5)}: 249, 200, 0; -#{getCssVarName(yellow, 6)}: 208, 170, 0; -#{getCssVarName(yellow, 7)}: 167, 139, 0; -#{getCssVarName(yellow, 8)}: 125, 106, 0; -#{getCssVarName(yellow, 9)}: 83, 72, 0; - -// 琥珀色 -#{getCssVarName(amber, 0)}: 255, 251, 236; -#{getCssVarName(amber, 1)}: 252, 245, 206; -#{getCssVarName(amber, 2)}: 249, 232, 158; -#{getCssVarName(amber, 3)}: 246, 216, 110; -#{getCssVarName(amber, 4)}: 243, 198, 65; -#{getCssVarName(amber, 5)}: 240, 177, 20; -#{getCssVarName(amber, 6)}: 200, 138, 16; -#{getCssVarName(amber, 7)}: 160, 102, 10; -#{getCssVarName(amber, 8)}: 120, 70, 5; -#{getCssVarName(amber, 9)}: 80, 43, 3; - -// 橙色 -#{getCssVarName(orange, 0)}: 255, 243, 224; -#{getCssVarName(orange, 1)}: 255, 223, 177; -#{getCssVarName(orange, 2)}: 255, 204, 128; -#{getCssVarName(orange, 3)}: 254, 183, 77; -#{getCssVarName(orange, 4)}: 255, 167, 38; -#{getCssVarName(orange, 5)}: 255, 152, 0; -#{getCssVarName(orange, 6)}: 250, 141, 0; -#{getCssVarName(orange, 7)}: 245, 124, 2; -#{getCssVarName(orange, 8)}: 239, 108, 0; -#{getCssVarName(orange, 9)}: 230, 81, 0; - -// 灰色 -#{getCssVarName(grey, 0)}: 249, 249, 249; -#{getCssVarName(grey, 1)}: 230, 232, 234; -#{getCssVarName(grey, 2)}: 198, 202, 205; -#{getCssVarName(grey, 3)}: 167, 171, 175; -#{getCssVarName(grey, 4)}: 136, 141, 145; -#{getCssVarName(grey, 5)}: 107, 102, 116; -#{getCssVarName(grey, 6)}: 85, 91, 97; -#{getCssVarName(grey, 7)}: 65, 70, 76; -#{getCssVarName(grey, 8)}: 46, 50, 55; -#{getCssVarName(grey, 9)}: 29, 31, 35; - - -// 蓝青色 -#{getCssVarName(blue, cyan, 0)}: 217, 236, 255; -#{getCssVarName(blue, cyan, 1)}: 164, 201, 238; -#{getCssVarName(blue, cyan, 2)}: 131, 171, 212; -#{getCssVarName(blue, cyan, 3)}: 105, 148, 190; -#{getCssVarName(blue, cyan, 4)}: 85, 125, 165; -#{getCssVarName(blue, cyan, 5)}: 70, 107, 144; -#{getCssVarName(blue, cyan, 6)}: 48, 81, 115; -#{getCssVarName(blue, cyan, 7)}: 36, 65, 96; -#{getCssVarName(blue, cyan, 8)}: 26, 52, 79; -#{getCssVarName(blue, cyan, 9)}: 16, 41, 68; - -// 天蓝色 -#{getCssVarName(sky, blue, 0)}: 232, 249, 255; -#{getCssVarName(sky, blue, 1)}: 183, 232, 251; -#{getCssVarName(sky, blue, 2)}: 135, 212, 248; -#{getCssVarName(sky, blue, 3)}: 89, 190, 244; -#{getCssVarName(sky, blue, 4)}: 44, 165, 241; -#{getCssVarName(sky, blue, 5)}: 0, 137, 237; -#{getCssVarName(sky, blue, 6)}: 0, 108, 197; -#{getCssVarName(sky, blue, 7)}: 0, 81, 157; -#{getCssVarName(sky, blue, 8)}: 0, 56, 117; -#{getCssVarName(sky, blue, 9)}: 0, 34, 77; - -// 黑、白色 -#{getCssVarName(white)}: 255, 255, 255; -#{getCssVarName(black)}: 0, 0, 0; - -// 功能色 -#{getCssVarName(color, white)}: rgba(var(#{getCssVarName(white)}),1); // 浅色模式下深色背景内容Inverse -#{getCssVarName(color, black)}: rgba(var(#{getCssVarName(black)}),1); // 深色模式下浅色背景内容Inverse - -// 主要颜色 -#{getCssVarName(color, primary)}: rgba(var(#{getCssVarName(sky, blue, 5)}),1); // 主要颜色。仅在需要非常强调的情况下使用。 -#{getCssVarName(color, primary, text)}: rgba(var(#{getCssVarName(white)}), 1); // 主要颜色文字色,和背景色形成对比 -#{getCssVarName(color, primary, hover)}: rgba(var(#{getCssVarName(sky, blue, 4)}),1); // 主要颜色悬浮态 -#{getCssVarName(color, primary, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 主要颜色文字色,和背景色形成对比 -#{getCssVarName(color, primary, active)}: rgba(var(#{getCssVarName(sky, blue, 6)}),1); // 主要颜色激活态 -#{getCssVarName(color, primary, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 主要颜色文字色,和背景色形成对比 -#{getCssVarName(color, primary, disabled)}: rgba(var(#{getCssVarName(sky, blue, 2)}),1); // 主要颜色禁用态 -#{getCssVarName(color, primary, disabled, text)}: rgba(var(#{getCssVarName(white)}), 1); // 主要颜色文字色,和背景色形成对比 -#{getCssVarName(color, primary, light, default)}: rgba(var(#{getCssVarName(sky, blue, 0)}),1); // 浅版主要颜色(多用于背景)。仅在需要非常强调的情况下使用。 -#{getCssVarName(color, primary, light, hover)}: rgba(var(#{getCssVarName(sky, blue, 1)}),1); // 浅版主要颜色悬浮态 -#{getCssVarName(color, primary, light, active)}: rgba(var(#{getCssVarName(sky, blue, 2)}),1); // 浅版主要颜色激活态 - -// 次要颜色 -#{getCssVarName(color, secondary)}: rgba(var(#{getCssVarName(light, blue, 5)}),1); // 次要颜色。强调作用次于主要颜色,但仍然具有强调作用。 -#{getCssVarName(color, secondary, text)}: rgba(var(#{getCssVarName(white)}), 1); // 次要颜色文字色,和背景色形成对比 -#{getCssVarName(color, secondary, hover)}: rgba(var(#{getCssVarName(light, blue, 6)}),1); // 次要颜色悬浮态 -#{getCssVarName(color, secondary, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 次要颜色文字色,和背景色形成对比 -#{getCssVarName(color, secondary, active)}: rgba(var(#{getCssVarName(light, blue, 7)}),1); // 次要颜色激活态 -#{getCssVarName(color, secondary, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 次要颜色文字色,和背景色形成对比 -#{getCssVarName(color, secondary, disabled)}: rgba(var(#{getCssVarName(light, blue, 2)}),1); // 次要颜色禁用态 -#{getCssVarName(color, secondary, disabled, text)}: rgba(var(#{getCssVarName(white)}), 1); // 次要颜色文字色,和背景色形成对比 -#{getCssVarName(color, secondary, light, default)}: rgba(var(#{getCssVarName(light, blue, 0)}),1); // 浅版次要颜色(多用于背景)。强调作用次于主要颜色,但仍然具有强调作用。 -#{getCssVarName(color, secondary, light, hover)}: rgba(var(#{getCssVarName(light, blue, 1)}),1); // 浅版次要颜色悬浮态 -#{getCssVarName(color, secondary, light, active)}: rgba(var(#{getCssVarName(light, blue, 2)}),1); // 浅版次要颜色激活态 - -// 第三颜色 -#{getCssVarName(color, tertiary)}: rgba(var(#{getCssVarName(grey, 5)}),1); // 第三颜色,可以在页面上多次使用 -#{getCssVarName(color, tertiary, text)}: rgba(var(#{getCssVarName(white)}), 1); // 第三颜色文字色,和背景色形成对比 -#{getCssVarName(color, tertiary, hover)}: rgba(var(#{getCssVarName(grey, 4)}),1); // 第三颜色悬浮态 -#{getCssVarName(color, tertiary, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 第三颜色文字色,和背景色形成对比 -#{getCssVarName(color, tertiary, active)}: rgba(var(#{getCssVarName(grey, 6)}),1); // 第三颜色激活态 -#{getCssVarName(color, tertiary, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 第三颜色文字色,和背景色形成对比 -#{getCssVarName(color, tertiary, light, default)}: rgba(var(#{getCssVarName(grey, 0)}),1); // 浅版第三颜色(多用于背景),可以在页面上多次使用 -#{getCssVarName(color, tertiary, light, hover)}: rgba(var(#{getCssVarName(grey, 1)}),1); // 浅版第三颜色悬浮态 -#{getCssVarName(color, tertiary, light, active)}: rgba(var(#{getCssVarName(grey, 2)}),1); // 浅版第三颜色激活态 - -// 信息色 -#{getCssVarName(color, info)}: rgba(var(#{getCssVarName(sky, blue, 5)}),1); // 信息色, 通常用于表达客观、中立信息 -#{getCssVarName(color, info, text)}: rgba(var(#{getCssVarName(white)}), 1); // 信息颜色文字色,和背景色形成对比 -#{getCssVarName(color, info, hover)}: rgba(var(#{getCssVarName(sky, blue, 4)}),1); // 信息色悬浮态 -#{getCssVarName(color, info, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 信息颜色文字色,和背景色形成对比 -#{getCssVarName(color, info, active)}: rgba(var(#{getCssVarName(sky, blue, 6)}),1); // 信息色激活态 -#{getCssVarName(color, info, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 信息颜色文字色,和背景色形成对比 -#{getCssVarName(color, info, disabled)}: rgba(var(#{getCssVarName(sky, blue, 2)}),1); // 信息色禁用态 -#{getCssVarName(color, info, disabled, text)}: rgba(var(#{getCssVarName(white)}), 1); // 信息颜色文字色,和背景色形成对比 -#{getCssVarName(color, info, light, default)}: rgba(var(#{getCssVarName(sky, blue, 0)}),1); // 浅版信息色(多用于背景),通常用于表达客观、中立信息 -#{getCssVarName(color, info, light, hover)}: rgba(var(#{getCssVarName(sky, blue, 1)}),1); // 浅版信息色悬浮态 -#{getCssVarName(color, info, light, active)}: rgba(var(#{getCssVarName(sky, blue, 2)}),1); // 浅版信息色激活态 - -// 成功色 -#{getCssVarName(color, success)}: rgba(var(#{getCssVarName(green, 5)}),1); // 成功色,表示安全、成功、开启的状态 -#{getCssVarName(color, success, text)}: rgba(var(#{getCssVarName(white)}), 1); // 成功颜色文字色,和背景色形成对比 -#{getCssVarName(color, success, hover)}: rgba(var(#{getCssVarName(green, 4)}),1); // 成功色悬浮态 -#{getCssVarName(color, success, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 成功颜色文字色,和背景色形成对比 -#{getCssVarName(color, success, active)}: rgba(var(#{getCssVarName(green, 6)}),1); // 成功色激活态 -#{getCssVarName(color, success, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 成功颜色文字色,和背景色形成对比 -#{getCssVarName(color, success, disabled)}: rgba(var(#{getCssVarName(green, 2)}),1); // 成功色禁用态 -#{getCssVarName(color, success, disabled, text)}: rgba(var(#{getCssVarName(white)}), 1); // 成功颜色文字色,和背景色形成对比 -#{getCssVarName(color, success, light, default)}: rgba(var(#{getCssVarName(green, 0)}),1); // 浅版成功色(多用于背景),表示安全、成功、开启的状态 -#{getCssVarName(color, success, light, hover)}: rgba(var(#{getCssVarName(green, 1)}),1); // 浅版成功色悬浮态 -#{getCssVarName(color, success, light, active)}: rgba(var(#{getCssVarName(green, 2)}),1); // 浅版成功色激活态 - -// 警示色 -#{getCssVarName(color, warning)}: rgba(var(#{getCssVarName(orange, 5)}),1); // 警示色,表示警告、不安全的状态 -#{getCssVarName(color, warning, text)}: rgba(var(#{getCssVarName(white)}), 1); // 警告颜色文字色,和背景色形成对比 -#{getCssVarName(color, warning, hover)}: rgba(var(#{getCssVarName(orange, 4)}),1); // 警示色悬浮态 -#{getCssVarName(color, warning, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 警告颜色文字色,和背景色形成对比 -#{getCssVarName(color, warning, active)}: rgba(var(#{getCssVarName(orange, 6)}),1); // 警示色激活态 -#{getCssVarName(color, warning, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 警告颜色文字色,和背景色形成对比 -#{getCssVarName(color, warning, light, default)}: rgba(var(#{getCssVarName(orange, 0)}),1); // 浅版警示色(多用于背景),表示警告、不安全的状态 -#{getCssVarName(color, warning, light, hover)}: rgba(var(#{getCssVarName(orange, 1)}),1); // 浅版警示色悬浮态 -#{getCssVarName(color, warning, light, active)}: rgba(var(#{getCssVarName(orange, 2)}),1); // 浅版警示色激活态 - -// 危险色 -#{getCssVarName(color, danger)}: rgba(var(#{getCssVarName(red, 5)}),1); // 危险色,表示危险的操作、或需要特别注意的危险信息 -#{getCssVarName(color, danger, text)}: rgba(var(#{getCssVarName(white)}), 1); // 危险颜色文字色,和背景色形成对比 -#{getCssVarName(color, danger, hover)}: rgba(var(#{getCssVarName(red, 4)}),1); // 危险色悬浮态 -#{getCssVarName(color, danger, hover, text)}: rgba(var(#{getCssVarName(white)}), 1); // 危险颜色文字色,和背景色形成对比 -#{getCssVarName(color, danger, active)}: rgba(var(#{getCssVarName(red, 6)}),1); // 危险色激活态 -#{getCssVarName(color, danger, active, text)}: rgba(var(#{getCssVarName(white)}), 1); // 危险颜色文字色,和背景色形成对比 -#{getCssVarName(color, danger, light, default)}: rgba(var(#{getCssVarName(red, 0)}),1); // 浅版危险色(多用于背景),表示危险的操作、或需要特别注意的危险信息 -#{getCssVarName(color, danger, light, hover)}: rgba(var(#{getCssVarName(red, 1)}),1); // 浅版危险色悬浮态 -#{getCssVarName(color, danger, light, active)}: rgba(var(#{getCssVarName(red, 2)}),1); // 浅版危险色激活态 - -// 文本/图标颜色 -#{getCssVarName(color, text, 0)}: rgba(var(#{getCssVarName(grey, 9)}),1); // 文本/图标颜色 - 最主要 -#{getCssVarName(color, text, 1)}: rgba(var(#{getCssVarName(grey, 7)}),1); // 文本/图标颜色 - 稍次要 -#{getCssVarName(color, text, 2)}: rgba(var(#{getCssVarName(grey, 6)}),1); // 文本/图标颜色 - 次要 -#{getCssVarName(color, text, 3)}: rgba(var(#{getCssVarName(grey, 4)}),1); // 文本/图标颜色 - 最次要 -#{getCssVarName(color, text, menu)}: rgba(var(#{getCssVarName(grey, 9)}),1); // 文本 - 特殊-菜单颜色 - -// 链接颜色 -#{getCssVarName(color, link)}: rgba(var(#{getCssVarName(sky, blue, 5)}),1); // 链接颜色 -#{getCssVarName(color, link, hover)}: rgba(var(#{getCssVarName(sky, blue, 4)}),1); // 链接颜色 - 悬浮态 -#{getCssVarName(color, link, active)}: rgba(var(#{getCssVarName(sky, blue, 6)}),1); // 链接颜色 - 激活态 -#{getCssVarName(color, link, visited)}: rgba(var(#{getCssVarName(sky, blue, 5)}),1); // 链接颜色 - 已访问 - -// 背景色 -#{getCssVarName(color, bg, 0)}: rgba(var(#{getCssVarName(grey, 0)}),1); // 背景色 - 最下层(底部页面) -#{getCssVarName(color, bg, 1)}: rgba(var(#{getCssVarName(white)}),1); // 背景色 - 次下层(页面中需要提升的内容) -#{getCssVarName(color, bg, 2)}: rgba(var(#{getCssVarName(white)}),1); // 背景色 - 中间层(模态等容器) -#{getCssVarName(color, bg, 3)}: rgba(var(#{getCssVarName(white)}),1); // 背景色 - 次上层(通知,Toast等) -#{getCssVarName(color, bg, 4)}: rgba(var(#{getCssVarName(white)}),1); // 背景色 - 最上层(特殊) -#{getCssVarName(color, bg, 5)}: rgba(var(#{getCssVarName(sky, blue, 4)}),1); // 背景色(特殊) - 应用搜索框使用 -#{getCssVarName(color, bg, overlay)}: rgba(22 22 26 / 60%); // 蒙层背景色 - -// 填充色 -#{getCssVarName(color, fill, 0)}: rgba(var(#{getCssVarName(grey, 8)}),0.05); // 填充色 - 默认态 -#{getCssVarName(color, fill, 1)}: rgba(var(#{getCssVarName(grey, 8)}),0.1); // 填充色 - 悬浮态 -#{getCssVarName(color, fill, 2)}: rgba(var(#{getCssVarName(grey, 8), }),0.13); // 填充色 - 激活态 -#{getCssVarName(color, scroll, menu)}: rgba(var(#{getCssVarName(grey, 8), }),0.13); // 填充色 - 特殊-菜单滚动条颜色 - - -// 边框 -#{getCssVarName(color, border)}: rgba(var(#{getCssVarName(grey, 9)}),0.1); // 默认描边颜色 - -// 禁用态 -#{getCssVarName(color, disabled, text)}: rgba(var(#{getCssVarName(grey, 9)}), 0.35); // 禁用态 - 文字 -#{getCssVarName(color, disabled, border)}: rgba(var(#{getCssVarName(grey, 1)}),1); // 禁用态 - 描边 -#{getCssVarName(color, disabled, bg)}: rgba(var(#{getCssVarName(grey, 1)}),1); // 禁用态 - 背景 -#{getCssVarName(color, disabled, fill)}: rgba(var(#{getCssVarName(grey, 8)}),0.04); // 禁用态 - 填充 - -// 阴影 -#{getCssVarName(color, shadow)}: rgba(var(#{getCssVarName(black)}),0.04); // 用于模拟描边的阴影颜色 -#{getCssVarName(shadow, elevated)}: - 0 0 1px rgba(0 0 0 / 30%), - 0 4px 14px rgba(0 0 0 / 10%); // 用于toast, modal, popover等需要提升层级的界面元素 - -// 字号 -#{getCssVarName('font-size', 'small')}: 12px; -#{getCssVarName('font-size', 'regular')}: 14px; -#{getCssVarName('font-size', 'header-6')}: 16px; -#{getCssVarName('font-size', 'header-5')}: 18px; -#{getCssVarName('font-size', 'header-4')}: 20px; -#{getCssVarName('font-size', 'header-3')}: 24px; -#{getCssVarName('font-size', 'header-2')}: 28px; -#{getCssVarName('font-size', 'header-1')}: 32px; - -// 字重 -#{getCssVarName('font-weight', 'light')}: 200; -#{getCssVarName('font-weight', 'regular')}: 400; -#{getCssVarName('font-weight', 'bold')}: 800; - -// 圆角 -#{getCssVarName(border, radius, extra, small)}: 2px; // 超小圆角,用于 checkbox 内圆角 -#{getCssVarName(border, radius, small)}: 4px; // 小圆角, 用于 button、tag、tabs 等大多数组件, 比较常用 -#{getCssVarName(border, radius, medium)}: 8px; // 中圆角, 用于 dropdown、scrollist、transfer 等菜单类组件 -#{getCssVarName(border, radius, large)}: 12px; // 大圆角, 用于 modal -#{getCssVarName(border, radius, circle)}: 50%; // 全圆角, 用于 avatar, badge 等组件 -#{getCssVarName(border, radius, full)}: 9999px; // 用于创建全尺寸圆角,如胶囊标签等 - -// 高度 -#{getCssVarName('height-control', 'small')}: 24px; -#{getCssVarName('height-control', 'default')}: 32px; -#{getCssVarName('height-control', 'large')}: 40px; - -// 描边尺寸 -#{getCssVarName('border-thickness')}: 0; -#{getCssVarName('border-thickness', 'control')}: 1px; -#{getCssVarName('border-thickness', 'control-focus')}: 1px; - -// 图标尺寸 -#{getCssVarName('width-icon', 'extra-small')}: 8px; -#{getCssVarName('width-icon', 'small')}: 12px; -#{getCssVarName('width-icon', 'medium')}: 16px; -#{getCssVarName('width-icon', 'large')}: 20px; -#{getCssVarName('width-icon', 'extra-large')}: 24px; - -// 间距 -#{getCssVarName('spacing', 'none')}: 0; -#{getCssVarName('spacing', 'super-tight')}: 2px; -#{getCssVarName('spacing', 'extra-tight')}: 4px; -#{getCssVarName('spacing', 'tight')}: 8px; -#{getCssVarName('spacing', 'base-tight')}: 12px; -#{getCssVarName('spacing', 'base')}: 16px; -#{getCssVarName('spacing', 'base-loose')}: 20px; -#{getCssVarName('spacing', 'loose')}: 24px; -#{getCssVarName('spacing', 'extra-loose')}: 32px; -#{getCssVarName('spacing', 'super-loose')}: 40px; -} - -// 主题下的区域性样式覆盖 - -:root.custom_theme { - @include b(panel-app-header) { - #{getCssVarName(grey, 9)}: 255, 255, 255; - #{getCssVarName(color, text, 0)}: rgba(var(#{getCssVarName(grey, 9)}), 1); // 文本/图标颜色 - 最主要 - #{getCssVarName(color, text, 1)}: rgba(var(#{getCssVarName(grey, 9)}), .8); // 文本/图标颜色 - 稍次要 - #{getCssVarName(color, text, 2)}: rgba(var(#{getCssVarName(grey, 9)}), .6); // 文本/图标颜色 - 次要 - #{getCssVarName(color, text, 3)}: rgba(var(#{getCssVarName(grey, 9)}), .35); // 文本/图标颜色 - 最次要 - #{getCssVarName(color, text, menu)}: rgba(var(#{getCssVarName(grey, 9)}), 1); - } -} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/app.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/app.scss new file mode 100644 index 0000000000000000000000000000000000000000..7c3329aa5dfeade5d3af7ac4178b3fe6e56ceeca --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/app.scss @@ -0,0 +1,3 @@ +:root.{{pluginName}} { + // 应用级主题样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/ctrl.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/ctrl.scss new file mode 100644 index 0000000000000000000000000000000000000000..92ac5e2c57dec58c916c6ecb77d85257ec62be04 --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/ctrl.scss @@ -0,0 +1,3 @@ +:root.{{pluginName}} { + // 部件级主题样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/editor.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/editor.scss new file mode 100644 index 0000000000000000000000000000000000000000..f0e540f14ed4cc04e4c68e23b051ca657078efd0 --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/editor.scss @@ -0,0 +1,3 @@ +:root.{{pluginName}} { + // 编辑器主题样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/element-plus.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/element-plus.scss new file mode 100644 index 0000000000000000000000000000000000000000..d821fb4a06f9adef6e65654ceaf92be3a933fda3 --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/element-plus.scss @@ -0,0 +1,3 @@ +:root.{{pluginName}} { + // element-plus主题样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/index.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/index.scss new file mode 100644 index 0000000000000000000000000000000000000000..4dc118e9edc4ccb35488b533fa7ef91dfcd412c2 --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/index.scss @@ -0,0 +1,6 @@ +@import './app'; +@import './ctrl'; +@import './editor'; +@import './element-plus'; +@import './theme'; +@import './view'; \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/theme.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/theme.scss new file mode 100644 index 0000000000000000000000000000000000000000..40a4e8533a8129ef29cd3601da598b1734289b5b --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/theme.scss @@ -0,0 +1,3 @@ +:root.{{pluginName}} { + // 样式变量 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/default/view.scss b/packages/core/src/create-plugin/template/theme/src/theme/default/view.scss new file mode 100644 index 0000000000000000000000000000000000000000..2fc2c42fd5c1dbf8c4a4a2d51269a2abe0eef13c --- /dev/null +++ b/packages/core/src/create-plugin/template/theme/src/theme/default/view.scss @@ -0,0 +1,3 @@ +:root.{{pluginName}} { + // 视图级主题样式 +} \ No newline at end of file diff --git a/packages/core/src/create-plugin/template/theme/src/theme/index.scss b/packages/core/src/create-plugin/template/theme/src/theme/index.scss index 001af8433552fc3e8651dc36ee8596558ae0328d..7eaf0d63f3067dc0d0826e67599a5aab43942343 100644 --- a/packages/core/src/create-plugin/template/theme/src/theme/index.scss +++ b/packages/core/src/create-plugin/template/theme/src/theme/index.scss @@ -1,2 +1,5 @@ -/* 自定义主题 */ -@import './custom-theme'; +/* 引用基础包 */ +@import '../../node_modules/@ibiz-template/web-theme/src/theme/index'; + +/* 引用自定义主题 */ +@import './default/index';