3.5.2.3 构建View的Layout

在日常需求中也经常需要调整Layout的情况,如出现树表结构(左树右表、级联),我们则需要通过修改View的Layout来完成。今天就带您学习下Layout的自定义

第一个表格Layout

如果我们想去除表格视图区域的搜索区、ActionBar(操作区),就可以为视图自定义一个简单的Layout就行啦

Step1 新建一个表格的Layout

在views/demo_core/layout路径下增加一个名为sample_table_layout.xml文件,name设置为sampleTableLayout

<view type="TABLE" name="sampleTableLayout">
<!--    <view type="SEARCH">-->
<!--        <pack widget="fieldset">-->
<!--            <element widget="search" slot="search" slotSupport="field"/>-->
<!--        </pack>-->
<!--    </view>-->
    <pack widget="fieldset" style="height: 100%" wrapperStyle="height: 100%">
        <pack widget="row" style="height: 100%; flex-direction: column">
<!--            <pack widget="col" mode="full" style="flex: 0 0 auto">-->
<!--                <element widget="actionBar" slot="actionBar" slotSupport="action">-->
<!--                    <xslot name="actions" slotSupport="action" />-->
<!--                </element>-->
<!--            </pack>-->
            <pack widget="col" mode="full" style="min-height: 234px">
                <element widget="table" slot="table" slotSupport="field">
                    <xslot name="fields" slotSupport="field" />
                    <element widget="rowAction" slot="rowActions" slotSupport="action"/>
                </element>
            </pack>
        </pack>
    </pack>
</view>

图3-5-2-27 新建一个表格的Layout

Step2 修改宠物达人自定义表格Template

在view标签上增加layout属性值为"sampleTableLayout"

<view name="tableView" model="demo.PetTalent" cols="1" type="TABLE" enableSequence="true" layout="sampleTableLayout">
……省略其他
</view>

图3-5-2-28 修改宠物达人自定义表格Template

Step3 重启看效果

image.png

图3-5-2-29 示例效果

Step4 修改宠物达人自定义表格Template

去除在view标签上的layout属性配置,让其回复正常

第一个树表Layout

本节以“给商品管理页面以树表的方式增加商品类目过滤”为例

Step1 增加商品类目模型

增加PetItemCategory模型继承CodeModel,新增两个字段定义name和parent,其中parent字段M2O关联自身模型,非必填字段(如字段值为空即为一级类目):

package pro.shushi.pamirs.demo.api.model;

import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.common.CodeModel;

@Model.model(PetItemCategory.MODEL_MODEL)
@Model(displayName = "宠物商品类目",summary="宠物商品类目",labelFields={"name"})
public class PetItemCategory extends CodeModel {

    public static final String MODEL_MODEL="demo.PetItemCategory";
    @Field(displayName = "类目名称",required = true)
    private String name;

    @Field(displayName = "父类目")
    @Field.many2one
    private PetItemCategory parent;
}

图3-5-2-30 增加商品类目模型

Step2 修改自定义商品模型

为商品模型PetItem增加一个category字段m2o关联PetItemCategory

@Field(displayName = "类目")
@Field.many2one
private PetItemCategory category;

图3-5-2-31 修改宠物商品模型

Step3 新增名为treeTableLayout的Layout

在views/demo_core/layout路径下增加一个名为tree_table_layout.xml文件,name设置为treeTableLayout

image.png

图3-5-2-32 新增名为treeTableLayout的Layout

<view type="TABLE" name="treeTableLayout">
  <view type="SEARCH">
    <pack widget="fieldset">
      <element widget="search" slot="search" slotSupport="field"/>
    </pack>
  </view>
  <pack widget="fieldset" style="height: 100%" wrapperStyle="height: 100%">
    <pack widget="row" wrap="false" style="height: 100%">
      <pack widget="col" mode="full" style="min-width: 257px; max-width: 257px">
        <pack widget="fieldset" style="height: 100%" wrapperStyle="height: 100%; padding: 24px 16px">
          <pack widget="col" style="height: 100%">
            <element widget="tree" slot="tree" style="height: 100%" />
          </pack>
        </pack>
      </pack>
      <pack widget="col" mode="full" style="min-width: 400px">
        <pack widget="row" style="height: 100%; flex-direction: column">
          <pack widget="col" mode="full" style="width: 100%; flex: 0 0 auto">
            <element widget="actionBar" slot="actionBar" slotSupport="action">
              <xslot name="actions" slotSupport="action" />
            </element>
          </pack>
          <pack widget="col" mode="full" style="width: 100%; min-height: 345px">
            <element widget="table" slot="table" slotSupport="field">
              <xslot name="fields" slotSupport="field" />
              <element widget="rowAction" slot="rowActions" slotSupport="action" />
            </element>
          </pack>
        </pack>
      </pack>
    </pack>
  </pack>
</view>

图3-5-2-33 treeTableLayout的示例代码

Step4 自定义商品管理的Template

  1. 在views/demo_core/template路径下增加一个名为pet_item_table.xml文件

  2. 跟普通自定义template的区别在于

a. 配置layout属性为【treeTableLayout】跟前面layout定义一致

b. 配置了widget为tree的template节点,node可以配置多个,node配置说明如下

ⅰ. model,模型编码,必填。

ⅱ. label,数据标题,支持表达式,必填。

ⅲ. labelFields,数据标题中使用的字段列表,必填。

ⅳ. references,层级关联字段,第一层无效,其他层必填。模型编码#字段。

ⅴ. selfReferences,自关联字段,模型编码#字段。

ⅵ. search,点击搜索字段,必须使用主表格字段。模型编码#字段。

ⅶ. filter,层级过滤条件。模型编码#字段。

以上所有使用#拼接的属性配置,与model一致的情况下,均可以省略模型编码。

image.png

图3-5-2-34 pet_item_table.xml示例代码图

<view name="tableView" model="demo.PetItem"  type="TABLE" cols="1" enableSequence="false" layout="treeTableLayout">
  <template slot="actions" autoFill="true"/>
  <template slot="rowActions" autoFill="true"/>
  <template slot="fields">
    <field invisible="true" priority="5" data="id" label="ID" readonly="true"/>
    <field priority="90" data="code" label="编码"/>
    <field priority="101" data="itemName" label="商品名称"/>
    <field priority="101" data="dataStatus" label="数据状态">
      <options>
        <option name="DRAFT" displayName="草稿" value="DRAFT" state="ACTIVE"/>
        <option name="NOT_ENABLED" displayName="未启用" value="NOT_ENABLED" state="ACTIVE"/>
        <option name="ENABLED" displayName="已启用" value="ENABLED" state="ACTIVE"/>
        <option name="DISABLED" displayName="已禁用" value="DISABLED" state="ACTIVE"/>
      </options>
    </field>
    <field priority="102" data="price" label="商品价格"/>
    <field priority="103" data="shop" label="店铺">
      <options>
        <option references="demo.PetShop" referencesType="STORE" referencesLabelFields="shopName">
          <field name="shopName" data="shopName" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="104" data="shopId" label="店铺id"/>
    <field priority="105" data="type" label="品种">
      <options>
        <option references="demo.PetType" referencesType="STORE" referencesLabelFields="name">
          <field name="name" data="name" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="106" data="typeId" label="品种类型"/>
    <field priority="107" data="petItemDetails" label="详情">
      <options>
        <option references="demo.PetItemDetail" referencesType="TRANSIENT" referencesLabelFields="remark">
          <field name="remark" data="remark" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="108" data="tags" label="商品标签"/>
    <field priority="109" data="petTalents" label="推荐达人">
      <options>
        <option references="demo.PetTalent" referencesType="STORE" referencesLabelFields="name">
          <field name="name" data="name" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="200" data="createDate" label="创建时间" readonly="true"/>
    <field priority="210" data="writeDate" label="更新时间" readonly="true"/>
    <field priority="220" data="createUid" label="创建人id"/>
    <field priority="230" data="writeUid" label="更新人id"/>
  </template>
  <template slot="search" autoFill="true" cols="4"/>
  <template enableSearch="true" slot="tree" style="height: 100%" widget="tree">
    <nodes>
<!--       <node label="activeRecord.name" labelFields="name" model="demo.PetItemCategory" search="demo.PetItem#category" selfReferences="parent"/> -->
           <node label="activeRecord.name" labelFields="name" model="demo.PetItemCategory" search="demo.PetItem#category" selfReferences="demo.PetItemCategory#parent"/>
     </nodes>
   </template>
 </view>

图3-5-2-35 pet_item_table.xml示例代码

Step5 为商品类目增加管理入口

修改DemoMenus类,增加类目管理菜单

image.png

图3-5-2-36 增加类目管理菜单

@UxMenu("类目管理")@UxRoute(PetItemCategory.MODEL_MODEL) class PetItemCategoryMenu{
}

图3-5-2-37 增加类目管理菜单代码

Step6 重启看效果

  1. 进入类目管理页面,新增商品类目数据

image.png

图3-5-2-38 示例效果

  1. 进入商品管理页面,找一行数据修改其类目字段,然后再点击左边树看过滤效果

image.png

图3-5-2-39 示例效果

第一个级联Layout

本节以“给商品管理页面以级联的方式增加商品类目过滤”为例,该例子中左边级联项由多个模型组成

Step1 增加商品类目类型模型

增加PetItemCategoryType模型集成CodeModel,新增两个字段定义name

package pro.shushi.pamirs.demo.api.model;

import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.common.CodeModel;

@Model.model(PetItemCategoryType.MODEL_MODEL)
@Model(displayName = "宠物商品类目类型",summary="宠物商品类目类型",labelFields={"name"})
public class PetItemCategoryType extends CodeModel {

    public static final String MODEL_MODEL="demo.PetItemCategoryType";
    @Field(displayName = "类目类型名称",required = true)
    private String name;

}

图3-5-2-40 增加PetItemCategoryType模型集成CodeModel

Step2 修改商品类目

为商品类目模型PetItemCategory增加一个type字段m2o关联PetItemCategoryType

@Field(displayName = "类目类型")
@Field.many2one
private PetItemCategoryType type;

图3-5-2-41 为商品类目模型PetItemCategory增加一个type字段

Step3 新增名为cascaderTableLayout的Layout

在views/demo_core/layout路径下增加一个名为cascader_table_layout.xml文件

image.png

图3-5-2-42 新增名为cascaderTableLayout的Layout

<view type="TABLE" name="cascaderTableLayout">
<view type="SEARCH">
    <pack widget="fieldset">
        <element widget="search" slot="search" slotSupport="field"/>
    </pack>
</view>
<pack widget="fieldset" style="height: 100%" wrapperStyle="height: 100%; overflow: auto">
    <pack widget="row" wrap="false" style="height: 100%">
        <pack widget="col" mode="full" style="flex: unset">
            <element widget="card-cascader" slot="cardCascader" style="height: 100%" />
        </pack>
        <pack widget="col" mode="full" style="min-width: 564px">
            <pack widget="row" style="height: 100%; flex-direction: column">
                <pack widget="col" mode="full" style="width: 100%; flex: 0 0 auto">
                    <element widget="actionBar" slot="actionBar" slotSupport="action">
                        <xslot name="actions" slotSupport="action" />
                    </element>
                </pack>
                <pack widget="col" mode="full" style="width: 100%; min-height: 345px">
                    <element widget="table" slot="table" slotSupport="field">
                        <xslot name="fields" slotSupport="field" />
                        <element widget="rowAction" slot="rowActions" slotSupport="action"/>
                    </element>
                </pack>
            </pack>
        </pack>
    </pack>
</pack>
</view>

图3-5-2-43 代码说明

Step4 修改商品管理的Template

  1. 修改在views/demo_core/template路径下名为pet_item_table.xml的文件

a. 配置layout属性为【cascaderTableLayout】跟前面layout定义一致

b. 配置了widget为card-cascader的template节点,node可以配置多个,node配置跟树表的配置一致

<view name="tableView" model="demo.PetItem"  type="TABLE" cols="1" enableSequence="false" layout="cascaderTableLayout">
  <template slot="actions" autoFill="true"/>
  <template slot="rowActions" autoFill="true"/>
  <template slot="fields">
    <field invisible="true" priority="5" data="id" label="ID" readonly="true"/>
    <field priority="90" data="code" label="编码"/>
    <field priority="101" data="itemName" label="商品名称"/>
    <field priority="101" data="dataStatus" label="数据状态">
      <options>
        <option name="DRAFT" displayName="草稿" value="DRAFT" state="ACTIVE"/>
        <option name="NOT_ENABLED" displayName="未启用" value="NOT_ENABLED" state="ACTIVE"/>
        <option name="ENABLED" displayName="已启用" value="ENABLED" state="ACTIVE"/>
        <option name="DISABLED" displayName="已禁用" value="DISABLED" state="ACTIVE"/>
      </options>
    </field>
    <field priority="102" data="price" label="商品价格"/>
    <field priority="103" data="shop" label="店铺">
      <options>
        <option references="demo.PetShop" referencesType="STORE" referencesLabelFields="shopName">
          <field name="shopName" data="shopName" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="104" data="shopId" label="店铺id"/>
    <field priority="105" data="type" label="品种">
      <options>
        <option references="demo.PetType" referencesType="STORE" referencesLabelFields="name">
          <field name="name" data="name" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="106" data="typeId" label="品种类型"/>
    <field priority="107" data="petItemDetails" label="详情">
      <options>
        <option references="demo.PetItemDetail" referencesType="TRANSIENT" referencesLabelFields="remark">
          <field name="remark" data="remark" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="108" data="tags" label="商品标签"/>
    <field priority="109" data="petTalents" label="推荐达人">
      <options>
        <option references="demo.PetTalent" referencesType="STORE" referencesLabelFields="name">
          <field name="name" data="name" ttype="STRING"/>
        </option>
      </options>
    </field>
    <field priority="200" data="createDate" label="创建时间" readonly="true"/>
    <field priority="210" data="writeDate" label="更新时间" readonly="true"/>
    <field priority="220" data="createUid" label="创建人id"/>
    <field priority="230" data="writeUid" label="更新人id"/>
  </template>
  <template slot="search" autoFill="true" cols="4"/>
  <template enableSearch="true" slot="cardCascader" style="height: 100%" widget="card-cascader">
      <nodes>
          <node label="activeRecord.name" title="类目类型" labelFields="name" model="demo.PetItemCategoryType" />
          <node label="activeRecord.name" title="类目" labelFields="name" model="demo.PetItemCategory" search="demo.PetItem#category" references="demo.PetItemCategory#type" selfReferences="demo.PetItemCategory#parent"/>
      </nodes>
  </template>
</view>

图3-5-2-44 修改商品管理的Template

Step5 为商品类目类型增加管理入口

image.png

图3-5-2-45 为商品类目类型增加管理入口

@UxMenu("类目类型")@UxRoute(PetItemCategoryType.MODEL_MODEL) class PetItemCategoryTypeMenu{
}

图3-5-2-46 代码示例

Step6 重启看效果

  1. 进入类目类型管理页面,新增商品类目类型数据

image.png

图3-5-2-47 进入类目类型管理页面

  1. 进入类目管理页面,修改一级类目的类型

image.png

图3-5-2-48 修改一级类目的类型

  1. 进入商品管理页面,找一行数据修改其类目字段,然后再点击左边级联项看过滤效果

image.png

图3-5-2-49 进入商品管理页面

树表与级联的更多配置

Oinone社区 作者:史, 昂原创文章,如若转载,请注明出处:https://doc.oinone.top/oio4/9254.html

访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验

(0)
史, 昂的头像史, 昂数式管理员
上一篇 2024年5月23日 am9:24
下一篇 2024年5月23日 am9:26

相关推荐

  • 3.5.7.4 自定义页面

    页面是什么 在Oinone前端体系中,页面是一个核心概念,它代表着终端用户所看到的当前视图。这个视图可以有多种形式,主要取决于页面是如何定义和构建的。在深入理解页面之前,我们需要了解两个关键的功能:自定义布局 和 自定义母版。 作用场景 自定义布局 提供了布局调整的强大功能,但在某些情况下,它可能无法完全满足特定的需求。这时,自定义页面就显得尤为重要。自定义页面是对 自定义布局 的补充,允许开发者从更深层次自由地控制和设计用户界面。 当标准布局无法实现所需的视觉效果或功能时,自定义页面提供了更高的灵活性。开发者可以通过自定义页面来实现独特的布局设计,添加特定的交互元素,或者整合复杂的业务逻辑,以创造独特且丰富的用户体验。 自定义页面 自定义视图组件允许开发者定义和使用特定于业务需求的视图布局。下面是一个具体的示例,展示了如何定义、注册和使用通过 setComponent 结合 TypeScript 和 Vue 的自定义视图组件。 示例工程目录 以下是需关注的工程目录示例,main.ts更新导入./view: 图3-5-7-48 自定义页面工程目录示例 1. 定义 TypeScript 组件 首先,我们定义了一个名为 CustomViewWidget 的 TypeScript 组件,并在该组件中通过 setComponent 结合 Vue 单文件组件。 import { BaseElementWidget, BaseElementViewWidget, SPI, ViewWidget } from '@kunlun/dependencies'; import CustomViewVue from './CustomView.vue'; @SPI.ClassFactory(BaseElementWidget.Token({ widget: 'CustomViewWidget' })) export class CustomViewWidget extends BaseElementViewWidget { public initialize(props) { super.initialize(props); this.setComponent(CustomViewVue); return this; } } 图3-5-7-49 定义TypeScript组件代码示例 2. Vue 单文件组件 其次,我们创建了对应的 Vue 单文件组件 CustomView.vue,用于展示自定义视图的具体内容。 <template> <div class="custom-view-wrapper"> <h1>自定义视图</h1> </div> </template> <script lang="ts"> import { defineComponent } from 'vue'; export default defineComponent({ inheritAttrs: false, name: 'ViewComponentVue' }); </script> <style lang="scss"> .custom-view-wrapper {} </style> 图3-5-7-50 定义Vue组件代码示例 3. 注册自定义视图布局 接下来,我们使用 registerLayout 函数注册了一个表格视图布局,并在其中引入了通过 setComponent 结合的自定义视图组件。 import { registerLayout, ViewType } from "@kunlun/dependencies"; export const registerCustomView = () => { registerLayout( ` <view type="TABLE"> <element widget="CustomViewWidget" /> </view> `, { viewType: ViewType.Table, moduleName: 'resource', model: 'resource.ResourceCountryGroup' } ); }; registerCustomView(); 图3-5-7-51 注册自定义视图布局代码示例 效果 图3-5-7-52 自定义页面效果示例 4. 自定义视图在表格中的应用 当我们注册了自定义视图后,它就可以在表格视图中被使用。在表格视图的布局中,我们通过 标签将自定义视图嵌套在表格中,从而覆盖了表格的默认布局 5. 入参一致性 值得强调的是,registerLayout 函数和自定义布局的规则是一致的,这意味着开发者可以在自定义布局中使用与 registerLayout 相同的入参规则,从而实现更加灵活和统一的视图布局设计 与内置组件结合 1. 注册视图元素布局 首先,我们使用 registerLayout 函数注册了一个表格视图的布局。这个布局包含了搜索框、操作栏、以及一个自定义视图组件。 import { registerLayout, ViewType } from "@kunlun/dependencies"; import { CustomViewWidget } from…

    2024年5月23日
    1.3K00
  • 2.4 Oinone的三大独特性

    Oinone在技术方面通过整合互联网架构和低代码技术,实现了三个独特的关键创新点(如图2-5所示): 独立模块化的个性化定制:每个需求都可以被视为一个独立的模块,从而实现个性化定制,提高软件生产效率。此外,这些独立模块也不会影响产品的迭代和升级,为客户带来无忧的体验。 灵活的部署方式:单体部署和分布式部署的灵活切换,为企业业务的发展提供了便利,同时适用于不同规模的公司,有助于有效地节约企业成本,提升创新效率,并让互联网技术更加亲民。 低代码和无代码的结合:低无一体为不同的IT组织和业务用户提供了有效的协同工作方式,能够快速部署安全、可扩展的应用程序和解决方案,帮助企业/组织更好地管理业务流程并不断优化。 图2-5 Oinone的三大独特性

    2024年5月23日
    1.1K00
  • 3.1.2 环境准备(windows版)

    一、后端基础环境准备 安装JDK1.8 ,高于1.8_221以上(下载地址见书籍【附件一】) 打开Windows环境变量配置页 此电脑 => 右键属性 => 系统高级设置 => 环境变量 配置环境变量 在用户环境变量中新建变量为JAVA_HOME的项,值为JDK安装之后的路径 图3-1-27 新建环境变量JAVA_HOM 编辑变量为Path的项添加一个值%JAVA_HOME%\bin 图3-1-28 添加一个环境变量值%JAVA_HOME%\\bin PowerShell或者CMD中验证,输出类似信息为安装配置成功 图3-1-29 验证JAVA是否安装成功 安装 Apache Maven 3.8+ (下载地址见书籍【附件一】) 删除Maven安装目录下的conf/settings.xml 配置mvn的settings,下载附件settings-open.xml,并重命名为settings.xml,建议直接放在【C:\Users\你的用户名.m2】下面。下载地址见oinone开源社区群公告,也可以联系oinone合作伙伴或服务人员 配置环境变量 在用户环境变量中新建变量为M2_HOME的项,值为Maven安装路径 图3-1-30 新建变量M2_HOME 编辑变量为Path的项添加一个值%M2_HOME%\bin 图3-1-31 添加一个值%M2_HOME%\\bin 验证 图3-1-32 验证Maven是否安装成功 安装 Jetbrains IDEA (下载地址见书籍【附件一】) 插件安装 下载地址 密码: mdji 如果IDEA安装了Lombok插件,请禁用Lombok插件 点击菜单项File => Settings => Plugins 图3-1-33 插件管理页面操作示意 下载插件包 (联系Oinone官方客服) 图3-1-35 操作指引 图3-1-36 操作指引 安装MySQL 8 (下载地址见书籍【附件一】) 解压下载的ZIP安装包, 复制到自定义安装目录 设置环境变量 MYSQL_BASE_DIR 提换成MySQL安装目录路径 把 %MYSQL_BASE_DIR%\bin 加入到系统环境变量中 在PowerShell中可以使用 Get-Command mysqld 命令验证环境变量是否配置成功,执行成功输出mysqld的所在路径 初始化 在命令行中执行 mysqld –initialize-insecure –user=mysql 安装 mysqld -install 启动MySQL服务 mysqld -install 设置root用户密码 alter user \’root\’@\’localhost\’ identified with mysql_native_password by \’oinone\’; flush privileges; 安装DB GUI工具 Datagrip、MySQLWorkbench、DBEaver 选其一 ### 安装Git (下载地址见书籍【附件一】) 安装GraphQL测试工具Insomnia(下载地址见书籍【附件一】) 安装RocketMQ(下载地址见书籍【附件一】) 修改安装目录下bin中对应文件的默认配置 a. runserver.cmd文件内容 -Xms2g -Xmx2g为 -Xms1g -Xmx1g b. runbroker.cmd文件内容 -Xms2g -Xmx2g为 -Xms1g -Xmx1g,以及-XX:G1HeapRegionSize=1m 启动RocketMQ NameServer命令 RocketMQ安装目录\bin\mqnamesrv.cmd start 启动RocketMQ Broker命令 RocketMQ安装目录\bin\mqbroker.cmd -n localhost:9876 停止 RocketMQ命令 mqshutdown.cmd broker mqshutdown.cmd namesrv 安装ElasticSearch 版本 8.4.1(下载地址见书籍【附件一】) (非必须) ES运行时需要JDK18及以上版本JDK运行环境, ES安装包中包含了一个JDK18版本 set JAVA_HOME=ES安装路径\jdk 启动 ES安装路径\bin\elasticsearch.bat 停止 ctrl+c 或者关闭cmd、PowerShell的窗口 安装Redis (下载地址见书籍【附件一】) 解压安装包到安装目录 在PowerShell进入到Redis安装目录 在PowerShell中执行.\redis-server.exe,输出图中类似信息(如下图3-35所示): 图3-1-37 验证redis是否安装成功 新开PowerShell窗口, 进入到Redis安装目录, 执行 .\redis-cli.exe回车,输入 ping 回车输出 PONG即表示Redis安装成功 图3-1-38 验证redis是否安装成功 Zookeeper安装(下载地址见书籍【附件一】) 解压安装, 在 PowerShell中执行 tar zxvf 安装包路径(tar.gz包) -C Zk安装目录 进入 Zk安装目录\conf\ 复制 zoo_sample.cfg文件为 zoo.cfg 修改zoo.cfg文件的内容 (其中dataDir需要自己设定) tickTime=2000…

    2024年5月23日
    2.4K00
  • 3.5.6.3 布局的配置

    布局是将页面拆分成一个一个的小单元,按照上下中左右进行排列。 前沿 在前端领域中,布局可以分为三大块「Float、Flex、Grid 」,Float可以说的上是上古时期的布局了,如今市面还是很少见的,除了一些古老的网站。 目前,平台主要支持通过配置XML上面的cols和span来进行布局。平台也同样支持自由布局,合理的使用row、col、containers和container四个布局容器相关组件,将可以实现各种类型的布局样式,换句话说,平台实现的自由布局功能是Flex和Grid的结合体。 这里主要是讲解Flex和Grid布局,以及目前新的模板布局实现的思路。 Flex布局 Flex布局采用的是一维布局,那么什么是一维布局呢,所谓的一维布局就是只有一个方向、没有体积、面积,比如一条直线。它适合做局部布局,就像我们原来的顶部菜单、面包屑导航,以及现在的主视图字段配置。 图3-5-6-19 Flex布局示意 图3-5-6-20 Flex布局示意 图3-5-6-21 Flex布局示意 从上图可以看看出,Flex布局只能在X、Y轴进行转换,它无法对上下左右四个方向同时处理,因为它没“面积”的概念。所以它最适合做局部布局。 优点 图3-5-6-22 Flex兼容性 Flex的兼容性,可以看得出来,目前主流的浏览器都支持该属性。所以Flex兼容性强,如果你想对局部做布局处理,Flex是最好选择。 缺陷 刚刚也提到了,用户想要的布局是千奇百怪的,如果他想要的布局在现有的功能中无法实现怎么办?让用户放弃?还是说服他使用现在的布局。 Grid布局 Grid布局系统采用的是二维布局,二维布局有四个方向:上、下、左、右,它只有面积没有体积,比如一张纸、网格。 Grid布局 <div id="grid-container-one"> <div class="one-1">Grid Item 1</div> <div>Grid Item 2</div> <div>Grid Item 3</div> <div>Grid Item 4</div> <div>Grid Item 5</div> <div class="one-6">Grid Item 6</div> </div> <div id="grid-container-two"> <div class="tow-1">Grid Item 1</div> <div class="tow-2">Grid Item 2</div> <div>Grid Item 3</div> <div>Grid Item 4</div> <div>Grid Item 5</div> <div>Grid Item 6</div> </div> <div id="grid-container-three"> <div>Grid Item 1</div> <div>Grid Item 2</div> <div class="grid">Grid Item 3</div> <div class="grid-column">Grid Item 4</div> <div>Grid Item 5</div> <div>Grid Item 6</div> <div>Grid Item 7</div> <div class="grid-column">Grid Item 8</div> </div> HTML CSSResult Skip Results Iframe EDIT ON * { box-sizing: border-box; padding: 0; margin: 0; line-height: 1.5; font-weight: bold; text-align: center; } #grid-container-one{ background-color: black; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 50px); gap: 10px; border: solid black 2px; margin-bottom: 20px; color: salmon; } #grid-container-one div { border: solid white 2px; padding: 10px; } #grid-container-one .one-1 { grid-area: span 1/span 3; text-aligin: center } #grid-container-one .one-6 { grid-column: 3 /4; } #grid-container-two{ background-color: CADETBLUE; display: grid; grid-template-columns: 15% repeat(2, 1fr);…

    2024年5月23日
    1.1K00
  • 4.3 Oinone的分布式体验

    在oinone的体系中分布式比较独特,boot工程中启动模块中包含就走本地,不包含就走远程,本文带您体验下分布式部署以及分布式部署需要注意点。 看下面例子之前先把话术统一下:启动或请求SecondModule代表启动或请求pamirs-second-boot工程,启动或请求DemoModule代表启动或请求pamirs-demo-boot工程,并没有严格意义上启动哪个模块之说,只有启动工程包含哪个模块。 一、构建SecondModule模块 Step1 构建模块工程 参考3.2.1【构建第一个Module】一文,利用脚手架工具构建一个SecondModule,记住需要修改脚本。 脚本修改如下: #!/bin/bash # 项目生成脚手架 # 用于新项目的构建 # 脚手架使用目录 # 本地 local # 本地脚手架信息存储路径 ~/.m2/repository/archetype-catalog.xml archetypeCatalog=local # 以下参数以pamirs-second为例 # 新项目的groupId groupId=pro.shushi.pamirs.second # 新项目的artifactId artifactId=pamirs-second # 新项目的version version=1.0.0-SNAPSHOT # Java包名前缀 packagePrefix=pro.shushi # Java包名后缀 packageSuffix=pamirs.second # 新项目的pamirs platform version pamirsVersion=4.6.0 # Java类名称前缀 javaClassNamePrefix=Second # 项目名称 module.displayName projectName=OinoneSecond # 模块 MODULE_MODULE 常量 moduleModule=second_core # 模块 MODULE_NAME 常量 moduleName=SecondCore # spring.application.name applicationName=pamirs-second # tomcat server address serverAddress=0.0.0.0 # tomcat server port serverPort=8090 # redis host redisHost=127.0.0.1 # redis port redisPort=6379 # 数据库名 db=demo # zookeeper connect string zkConnectString=127.0.0.1:2181 # zookeeper rootPath zkRootPath=/second mvn archetype:generate \ -DinteractiveMode=false \ -DarchetypeCatalog=${archetypeCatalog} \ -DarchetypeGroupId=pro.shushi.pamirs.archetype \ -DarchetypeArtifactId=pamirs-project-archetype \ -DarchetypeVersion=4.6.0 \ -DgroupId=${groupId} \ -DartifactId=${artifactId} \ -Dversion=${version} \ -DpamirsVersion=${pamirsVersion} \ -Dpackage=${packagePrefix}.${packageSuffix} \ -DpackagePrefix=${packagePrefix} \ -DpackageSuffix=${packageSuffix} \ -DjavaClassNamePrefix=${javaClassNamePrefix} \ -DprojectName="${projectName}" \ -DmoduleModule=${moduleModule} \ -DmoduleName=${moduleName} \ -DapplicationName=${applicationName} \ -DserverAddress=${serverAddress} \ -DserverPort=${serverPort} \ -DredisHost=${redisHost} \ -DredisPort=${redisPort} \ -Ddb=${db} \ -DzkConnectString=${zkConnectString} \ -DzkRootPath=${zkRootPath} 图4-3-1 构建一个名为SecondModule的模块 脚步执行生成工程如下: 图4-3-2 SecondModule的工程结构 Step2 调整配置 修改application-dev.yml文件 修改SecondModule的application-dev.yml的内容 base库换成与DemoModule一样的配置,配置项为:pamirs.datasource.base pamirs: datasource: base: driverClassName: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource url: jdbc:mysql://127.0.0.1:3306/demo_base?useSSL=false&allowPublicKeyRetrieval=true&useServerPrepStmts=true&cachePrepStmts=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true username: root # 数据库用户 password: oinone # 数据库用户对应的密码 initialSize: 5 maxActive: 200 minIdle: 5 maxWait: 60000 timeBetweenEvictionRunsMillis: 60000…

    2024年5月23日
    1.2K00

Leave a Reply

登录后才能评论