HarmonyOS Next“说书人”项目 单机版 实践案例

news2025/1/2 11:26:19

前段时间开发了一个软件,取名为“说书人”,后由于备案暂时没有通过,于是删除了联网功能,重新做了一个单机版,这里对于单机版的开发实践案例进行一个发出,希望能帮助到大家

文章最后给出了AtomGit仓库地址

pages/Data 目录

此目录下存储了项目中会使用到的数据

AppData.ets

此处存储了应用的版本号信息

export interface appAloneDataTem {
  appName: string,
  appVersion: string,
  appLogin: boolean
}

export let appAloneData: appAloneDataTem = {
  appName: '说书人',
  appVersion: 'V 1.0.0',
  appLogin: false
}

PersistentStorage.persistProp('appData', appAloneData)复制

bookData.ets

此处存储了书本信息

export interface bookDataTemplate{
  bookID: number,
  bookName: string,
  bookBrief: string,
  // bookHead: string,
  bookLabel: string[],

  // 发布状态:真为公有,假为私有
  releaseState: boolean,

  createUserID: number,
  createUserName: string,

  createUserOpen: boolean,

  haveRoleID: string[],
  chapterIndex: string
}

export let bookData: bookDataTemplate = {
  bookID: 0,
  bookName: '',
  bookBrief: '简介',
  // bookHead: "",
  bookLabel: [],

  releaseState: false,

  createUserID: 0,
  createUserName: '未知用户',

  createUserOpen: true,
  haveRoleID: [],
  chapterIndex: "0",
}

export let bookDataList: bookDataTemplate[] = [
  {
    bookID: 0,
    bookName: '开幕',
    bookBrief: '《说书人》的第一幕',
    // bookHead: "",
    bookLabel: [],

    releaseState: false,

    createUserID: 0,
    createUserName: '未知用户',

    createUserOpen: true,
    haveRoleID: [],
    chapterIndex: "0",
  }
]

PersistentStorage.persistProp('bookData', bookData)
PersistentStorage.persistProp('bookDataList', bookDataList)复制

frameData.ets

此处存储了项目所需要使用到的一些设置信息,以及公有的组件

import router from '@ohos.router';

// 画面设置
export interface frame{
  typefaceSize: number,
  backGround: ResourceColor,
}

export let frameDataSet: frame = {
  typefaceSize: 16,
  backGround: "#ffffff",
}

// 颜色加法
export let ThisPagefontColor: ResourceColor =
  '#' +
  setTenSix(frameDataSet.backGround.toString().slice(1,3)) +
  setTenSix(frameDataSet.backGround.toString().slice(3,5)) +
  setTenSix(frameDataSet.backGround.toString().slice(5,7))

// 十进制转十六进制
function setTenSix(Color: string){
  let colorData = (255 - parseInt('0x' + Color.toString()))
  return colorData <= 15 ? '0' + colorData.toString(16) : colorData.toString(16)
}

PersistentStorage.persistProp('frame', frameDataSet)

PersistentStorage.persistProp('fontColor', ThisPagefontColor)

@Component
export struct frameData {
  @StorageProp('frame')  frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor

  build() {
    Text('Back')
      .fontColor(this.ThisColor)
      .fontSize(this.frameData.typefaceSize + 6)
      .onClick(() => {
        router.back()
      })
  }
}复制
readBookCharpter.ets

此处存储了章节信息

// 章节信息
export interface readBookCharpterTemplate{
  // 章节ID
  articleID: number,
  // 章节索引
  chapterIndex: string,
  // 章节内容
  dialogueList: string,
  // 造物者之ID
  createUserID: string,
  // 归属之书
  ascriptionBookID: number,
}

export let readBookCharpterData: readBookCharpterTemplate = {
  articleID: 0,
  chapterIndex: "1-1",
  dialogueList: "",
  createUserID: "",
  ascriptionBookID: 0
}

export let readBookCharpterDataList: readBookCharpterTemplate[] = [
  {
    articleID: 0,
    chapterIndex: "1-1",
    dialogueList: "left|官方001|大家好!,left|官方001|欢迎使用《说书人》APP,它是一款面向角色编写剧本的软件 ,left|官方001|你可以在这款软件中定义角色,为多个角色之间编写剧本,还可以编写角色的关系网,查看角色的时间线等等... ,left|官方001|虽然在“还可以”之后的功能都还没实现就是了 ,left|官方001|截止编写本幕为止,软件只完成了基本功能,还有相当多不完善的地方,都会在为了慢慢解决的 ,left|官方001|十分感谢您对《说书人》的使用,如果使用过程中存在什么意见或建议,可以添加客服QQ提出 ,left|官方001|客服QQ: 1827650871",
    createUserID: "",
    ascriptionBookID: 0
  }
]

PersistentStorage.persistProp('readBookCharpterData', readBookCharpterData)
PersistentStorage.persistProp('readBookCharpterDataList', readBookCharpterDataList)复制

roleData.ets

此处存储了角色会使用的数据


export interface roleCustom{
  name: string,
  value: string
}

export interface roleDataTemplate{
  roleID: number,
  roleName: string,
  roleAge: string,
  roleGender: string,
  roleBrief: string,
  roleHead: string,
  roleLabel: string[],
  roleCustom: roleCustom[],

  // 发布状态:真为公有,假为私有
  releaseState: boolean,

  // 创造他的用户
  createUserID: number,
  createUserName: string,

  // 用户是否公开
  createUserOpen: boolean,

  // 有关系的角色和出现过的书籍
  relevantRoleID: string[],
  relevantBookID: string[]
}

export let roleData: roleDataTemplate = {
  roleID: 0,
  roleName: '',
  roleAge: '0',
  roleGender: '',
  roleBrief: '简介',
  roleHead: "",
  roleLabel: [],
  roleCustom: [],

  releaseState: false,

  createUserID: 0,
  createUserName: "未知用户",

  createUserOpen: true,
  relevantRoleID: [],
  relevantBookID: []
}

export let roleDataList: roleDataTemplate[] = [
  {
    roleID: 0,
    roleName: '官方001',
    roleAge: '18',
    roleGender: '男',
    roleBrief: '一个勤劳的打工人',
    roleHead: "",
    roleLabel: [],
    roleCustom: [],

    releaseState: false,

    createUserID: 0,
    createUserName: "未知用户",

    createUserOpen: true,
    relevantRoleID: [],
    relevantBookID: []
  },
]

PersistentStorage.persistProp('roleData', roleData)
PersistentStorage.persistProp('roleDataList', roleDataList)复制
inspirationTem.ets
export interface inspirationTem {
  inspirationID: number,
  inspirationTitle: string,
  inspirationMain: string
}

export let inspirationData: inspirationTem = {
  inspirationID: 0,
  inspirationTitle: '标题',
  inspirationMain: '正文'
}

export let inspirationDataList: inspirationTem[] = [
  {
    inspirationID: 0,
    inspirationTitle: '标题',
    inspirationMain: '正文'
  }
]

PersistentStorage.persistProp('inspirationData', inspirationData)
PersistentStorage.persistProp('inspirationDataList', inspirationDataList)复制

以上,便是整个应用所使用的数据信息,使用持久化存储将数据存储在本地

接下来,便是主要页面

pages/index.ets

import router from '@ohos.router'
import { frame, frameDataSet,ThisPagefontColor } from './Data/frameData'
import { userOwnData, userOwn } from './Data/userData'

import promptAction from '@ohos.promptAction';

@Entry
@Component
struct Index {

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor

  @StorageLink('userOwnData') userOwn: userOwnData = userOwn

  @State indexTime: number = 0

  onPageShow(): void {
    promptAction.showToast({
      message: "欢迎使用说书人"
    })
    this.indexTime = setTimeout(() => {
    router.clear()
      router.replaceUrl({
        "url":"pages/Main/userSpace",
        "params": {
          "goPageIndex" : 0
        }
      })
      promptAction.showToast({
        message: '登陆成功!'
      })
    }, 3000)
  }

  build() {
    Flex({
      justifyContent: FlexAlign.Center
    }){
    }
    .width('100%')
    .height('100%')
    .backgroundImage($r('app.media.fengmian'))
    .backgroundImageSize(ImageSize.Cover)
    .backgroundColor(this.frameData.backGround)
    .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
    .onClick(() => {
      clearTimeout(this.indexTime)
      router.clear()
      router.replaceUrl({
        "url":"pages/Main/userSpace",
        "params": {
          "goPageIndex" : 0
        }
      })
      promptAction.showToast({
        message: '登陆成功!'
      })
    })
  }
}复制

pages/loginPOP.ets

import { frame, frameDataSet,ThisPagefontColor, frameData } from './Data/frameData'
import router from '@ohos.router';

@CustomDialog
export default struct agreePage {

  agreePage: CustomDialogController

  onCancel: () => void = () => {}
  onJUJUE: () => void = () => {}


  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor


  build() {
    /* 用户名和需要修改的参数都由外部传递
      此处只涉及数据修改任务*/
    Flex(){
      Column({space: 16}){
        Row(){
          Text('《用户协议》与《隐私政策》提示')
            .fontSize(this.frameData.typefaceSize + 4)
            .fontColor(this.ThisColor)
        }.width('100%')
        .justifyContent(FlexAlign.Center)
        .padding({
          top: 24,
          left: 24
        })

        Scroll(){
          Column({ space: 12 }){
              Text(`
您需要阅读并同意隐私政策和用户协议后,才能使用《说书人》软件。

如果您不同意,很遗憾我们无法为您提供相关服务。
              `)
                .fontColor(this.ThisColor)
                .fontSize(this.frameData.typefaceSize + 2)
            Flex({
              wrap: FlexWrap.Wrap
            }){
              Text('您可以点击阅读')
                  .fontColor(this.ThisColor)
                  .fontSize(this.frameData.typefaceSize + 2)
              Text(`《用户协议》`)
                .fontColor(`#4a90e2`)
                .fontSize(this.frameData.typefaceSize + 2)
                .onClick(() => {
                  router.pushUrl({
                    url: "pages/agreement/userAgreememt"
                  })
                  this.agreePage.close()
                })
              Text(`与`)
                .fontColor(this.ThisColor)
                .fontSize(this.frameData.typefaceSize + 2)
              Text(`《隐私政策》`)
                .fontColor(`#4a90e2`)
                .fontSize(this.frameData.typefaceSize + 2)
                .onClick(() => {
                  router.pushUrl({
                    url: "pages/agreement/privacyAgreement"
                  })
                  this.agreePage.close()
                })
              Text(`了解相关信息。
              `)
                .fontColor(this.ThisColor)
                .fontSize(this.frameData.typefaceSize + 2)
              Text(`如您同意,请点击“同意”开始接受我们的服务。`)
                .fontColor(this.ThisColor)
                .fontSize(this.frameData.typefaceSize + 2)
            }.width('100%')
          }
          .padding({
            left: 24,
            right: 24
          })
        }.edgeEffect(EdgeEffect.Spring)


        Row(){
          Button('同意 ')
            .type(ButtonType.Normal)
            .backgroundColor(this.frameData.backGround)
            .fontSize(this.frameData.typefaceSize + 2)
            .fontColor(this.ThisColor)
            .border({width: {
              left: 1,
              right: 1,
              bottom: 1
            },color: '#f4f6f5'})
            .width('50%')
            .onClick(() => {
              this.onCancel()
              this.agreePage.close()
            })

          Button('拒绝')
            .type(ButtonType.Normal)
            .backgroundColor(this.frameData.backGround)
            .fontSize(this.frameData.typefaceSize + 2)
            .fontColor(this.ThisColor)
            .border({width: {
              left: 1,
              right: 1,
              bottom: 1
            },color: '#f4f6f5'})
            .width('50%')
            .onClick(() => {
              this.onJUJUE()
              this.agreePage.close()
            })

        }
      }
    }.backgroundColor(this.frameData.backGround)

  }
}复制

pages/Main

以下是Main目录中的文件,此处存储了主要界面

userSpace.ets

import { frame, frameDataSet, ThisPagefontColor } from '../Data/frameData'

import scriptInterface from './mainPage/scriptPage'
import RelationshipPage from './mainPage/relationshipPage'

@Entry
@Component
struct UserSpace {

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor

  build() {
    Flex(){
      Tabs(){
        TabContent(){
          scriptInterface()
        }.tabBar('首页')
        TabContent(){
          RelationshipPage()
        }.tabBar('灵感')
      }.barPosition(BarPosition.End)
    }
    .backgroundColor(this.frameData.backGround)
  }
}复制

pages/Main/mainPage/scriptPage.ets

import { frame, frameDataSet,ThisPagefontColor } from '../../Data/frameData'
import { router } from '@kit.ArkUI'
import { roleDataList, roleDataTemplate, } from '../../Data/roleData'

import { standardCudeImage } from '../../template/textImgTemplate'
import { bookDataList, bookDataTemplate } from '../../Data/bookData'
import { it } from '@ohos/hypium'

@Entry
@Component
export default struct scriptInterface {

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor

  @StorageProp('roleDataList') roleDataList: roleDataTemplate[]  = roleDataList
  @StorageProp('bookDataList') bookDataList: bookDataTemplate[] = bookDataList

  @State openSet: boolean = false
  @State ThisText: string = ''

  @State sw:number = 0
  @State sh:number = 0

  build() {
    Flex(){
      Stack({
        alignContent: Alignment.Top
      }){
        Column(){
          Row(){
            TextInput({placeholder: "搜索"})
              .width('90%')
              .textAlign(TextAlign.Center)
              .onChange(value => {
                this.ThisText = value
              })
            Text('+')
              .fontSize(32)
              .width(50)
              .textAlign(TextAlign.Center)
          }
          .width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
          .onClick(() => {
            this.openSet = !this.openSet
          })
          Tabs(){
            // 角色
            TabContent(){
              Scroll(){
                Column({ space: 16 }){
                  ForEach(this.roleDataList, (item: roleDataTemplate, index) => {
                    if (item.roleName.includes(this.ThisText) || item.roleID.toString().includes(this.ThisText)) {
                      // 角色模板
                      Row({space: 16}){
                        Text(`${item.roleName}`)
                          .fontSize(16)
                          .width(90)
                          .height(120)
                          .borderRadius(16)
                          .backgroundColor(this.frameData.backGround)
                          .border({
                            width: 1
                          })
                          .borderRadius(16)
                          .textOverflow({overflow: TextOverflow.Ellipsis})
                          .padding(16)
                          .textAlign(TextAlign.Center)
                        Column({ space: 6 }){
                          Row(){
                            Text(`${item.roleName}`)
                              .fontSize(this.frameData.typefaceSize + 4)
                              .fontColor(this.ThisColor)
                              .fontWeight(600)
                          }
                          Row(){
                            Text(`${item.roleBrief}`)
                              .fontSize(this.frameData.typefaceSize - 2)
                              .fontColor(this.ThisColor)
                              .maxLines(2)
                              .textOverflow({overflow: TextOverflow.Ellipsis})
                          }.width('70%')
                          Row(){
                            ForEach(item.roleLabel, (item: string) => {
                              Text(`/ ${item} /`)
                                .fontSize(this.frameData.typefaceSize - 4)
                                .fontColor(this.ThisColor)
                                .fontWeight(200)
                            })
                          }
                        }.width('100%')
                        .alignItems(HorizontalAlign.Start)
                      }
                      .onClick(() => {
                        router.pushUrl({
                          "url": "pages/userSystem/userDetailed",
                          "params": {
                            "roleID": item.roleID
                          }
                        })
                      })
                    }
                  })
                }
              }
              .height('100%')
              .align(Alignment.Top)
              .edgeEffect(EdgeEffect.Spring)
              .padding({
                top: 12,
                bottom: 64
              })
            }.tabBar('角色')
            // 剧本
            TabContent(){
              Scroll(){
                // 剧本列表
                Column({ space: 16 }){
                  ForEach(this.bookDataList, (item: bookDataTemplate, index) => {
                    if (item.bookName.includes(this.ThisText) || item.bookID.toString().includes(this.ThisText)) {
                      // 剧本模板
                      Row({space: 16}){
                        Column({ space: 6 }){
                          Row(){
                            Text(item.bookName)
                              .fontSize(this.frameData.typefaceSize + 4)
                              .fontColor(this.ThisColor)
                              .fontWeight(600)
                          }.width('70%')
                          .justifyContent(FlexAlign.End)
                          Row(){
                            Text(item.bookBrief)
                              .fontSize(this.frameData.typefaceSize - 2)
                              .fontColor(this.ThisColor)
                              .maxLines(2)
                              .textOverflow({overflow: TextOverflow.Ellipsis})
                              .textAlign(TextAlign.End)
                          }.width('70%')
                          .justifyContent(FlexAlign.End)
                          Row(){
                            /* 感觉很酷的一串代码 */
                            ForEach(item.bookLabel, (item: string) => {
                              Text(`/ ${item} /`)
                                .fontSize(this.frameData.typefaceSize - 4)
                                .fontColor(this.ThisColor)
                                .fontWeight(200)
                                .textAlign(TextAlign.End)
                            })
                          }.width('70%')
                          .justifyContent(FlexAlign.End)
                        }
                        .alignItems(HorizontalAlign.Start)
                        standardCudeImage(`${item.bookName}`, this.frameData.backGround, this.ThisColor)
                      }
                      .onClick(() => {
                        router.pushUrl({
                          url: "pages/scriptSystem/scriptDetailed",
                          params: {
                            "bookID": item.bookID,
                            "collection": false
                          }
                        })
                      })
                    }
                  })
                }
              }
              .height('100%')
              .align(Alignment.Top)
              .edgeEffect(EdgeEffect.Spring)
              .padding({
                top: 12,
                bottom: 64
              })
            }.tabBar('剧本')
          }.barPosition(BarPosition.Start)

        }
        .padding({
          left: 24,
          right: 24,
        })
        .align(Alignment.Top)
        .alignItems(HorizontalAlign.Start)

        // 阴影
        Column(){}
        .width('100%')
        .height('100%')
        .backgroundColor(Color.Black)
        .opacity(.6)
        .visibility(this.openSet ? Visibility.Visible : Visibility.None)
        .onClick(() => {
          this.openSet = false
        })

        // 角色剧本动态
        Column(){
          Row(){
            Text('角色')
              .fontSize(this.frameData.typefaceSize + 2)
              .fontColor(this.ThisColor)
          }.width(160)
          .justifyContent(FlexAlign.Center)
          .padding({
            left: 24,
            right: 24,
            top: 16,
            bottom: 16
          })
          .border({
            width: {
              bottom: 1
            }
          })
          .onClick(() => {
            router.pushUrl({
              "url": "pages/CreatePage/userCreate"
            })
            this.openSet = false
          })

          Row(){
            Text('剧本')
              .fontSize(this.frameData.typefaceSize + 2)
              .fontColor(this.ThisColor)
          }.width(160)
          .justifyContent(FlexAlign.Center)
          .padding({
            left: 24,
            right: 24,
            top: 16,
            bottom: 16
          })
          .border({
            width: {
              bottom: 1
            }
          })
          .onClick(() => {
            router.pushUrl({
              "url": "pages/CreatePage/scriptCreate"
            })
            this.openSet = false
          })
        }.border({ width: 1 })
        .borderRadius(2)
        .position({
          x: this.sw / 2 - 16,
          y: 36
        })
        .backgroundColor(Color.White)
        .visibility(this.openSet ? Visibility.Visible : Visibility.None)
      }
    }
    .backgroundColor(this.frameData.backGround)
    .onAreaChange((oldValue: Area, newValue: Area) => {
      this.sw = new Number(newValue.width).valueOf();
      this.sh = new Number(newValue.height).valueOf();
    });
  }
}复制

pages/Main/mainPage/relationshipPage

import { frame, frameDataSet,ThisPagefontColor } from '../../Data/frameData'
import { inspirationTem, inspirationData, inspirationDataList } from '../../Data/inspirationData'
import { promptAction } from '@kit.ArkUI'

@Entry
@Component
export default struct RelationshipPage {

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor

  @StorageLink('inspirationData') inspirationData: inspirationTem = inspirationData
  @StorageLink('inspirationDataList') inspirationDataList: inspirationTem[] = inspirationDataList

  @State index: number = 0

  build() {
    Flex({
      justifyContent: FlexAlign.Center,
      wrap: FlexWrap.Wrap
    }){
        Column(){

          // 标题
          Row(){
            Text('灵感图谱')
              .fontSize(this.frameData.typefaceSize + 6)
              .fontColor(this.ThisColor)
              .letterSpacing(6)
          }
          .padding({
            top: 12, bottom: 12
          })
          .width('100%')
          .justifyContent(FlexAlign.Center)
          .border({
            width: {
              bottom: 2
            }
          })

          // 正文
          Column(){
            Row(){
              TextInput({ placeholder: "标题", text: this.inspirationDataList[this.index].inspirationTitle })
                .fontWeight(600)
                .fontSize(this.frameData.typefaceSize + 14)
                .placeholderFont({
                  size: this.frameData.typefaceSize + 14
                })
                .fontColor(this.ThisColor)
                .maxLength(16)
                .showUnderline(true)
                .onChange(value => {
                  this.inspirationDataList[this.index].inspirationTitle = value
                })
            }
            .padding(24)
            Scroll(){
              Column(){
                TextArea({placeholder: '在此输入内容', text: this.inspirationDataList[this.index].inspirationMain})
                  .backgroundColor(this.frameData.backGround)
                  .borderRadius(12)
                  .height('100%')
                  .maxLength(600)
                  .border({width: 1})
                  .fontSize(this.frameData.typefaceSize + 2)
                  .onChange(value => {
                    this.inspirationDataList[this.index].inspirationMain = value
                  })
              }.padding({
                left: 24, right: 24
              })
            }.edgeEffect(EdgeEffect.Spring)
            .height('70%')
            .width('100%')
            .align(Alignment.Top)
          }.width('100%')
          .alignItems(HorizontalAlign.Start)

          // 按钮
          Row(){
            Button('上一篇')
              .fontSize(this.frameData.typefaceSize + 6)
              .fontColor(this.ThisColor)
              .backgroundColor(this.frameData.backGround)
              .layoutWeight(1)
              .onClick(() => {
                if (this.index != 0) {
                  this.index -= 1
                } else {
                  promptAction.showToast({
                    message: "已到达第一篇"
                  })
                }
              })
            Button('下一篇')
              .fontSize(this.frameData.typefaceSize + 6)
              .fontColor(this.ThisColor)
              .backgroundColor(this.frameData.backGround)
              .layoutWeight(1)
              .onClick(() => {
                if (this.index == this.inspirationDataList.length - 1) {
                  if (this.inspirationDataList[this.index].inspirationTitle != '标题' ||
                  this.inspirationDataList[this.index].inspirationMain != '正文') {
                    this.inspirationDataList.push({
                      inspirationID: this.index,
                      inspirationTitle: '标题',
                      inspirationMain: '正文'
                    })
                    this.index ++
                  } else {
                    promptAction.showToast({
                      message: "已到达最后一篇"
                    })
                  }

                } else {
                  this.index ++
                }
              })
          }.height('10%')
          .width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
      }
    }
  }
}复制

pages/userSystem/

以下是pages/userSystem/中的内容,存储了角色系统

userDetailed.ets

import { frame, frameDataSet,ThisPagefontColor, frameData } from '../Data/frameData'
import { roleDataTemplate, roleData, roleDataList } from '../Data/roleData'
import { promptAction, router } from '@kit.ArkUI'
import { standardCudeImage } from '../template/textImgTemplate'

@Extend(Text) function textCare(size: number){
  .fontColor('#3c3f41')
  .backgroundColor('#e0dcda')
  .fontSize(size)
  .fontWeight(300)
  .padding({
    left: 8,
    right: 8,
    top: 5,
    bottom: 5
  })
  .borderRadius(12)
  .opacity(.8)
}

@Entry
@Component
struct UserDetailed {

  aboutToAppear(): void {
    let params = router.getParams() as Record<string, number>
    let roleID = params['roleID']

    for (let item of this.roleDataList) {
      if (item.roleID == roleID) {
        this.roleData = item
        break
      }
    }
  }

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor
  @StorageProp('roleDataList') roleDataList: roleDataTemplate[] = roleDataList

  @State roleData: roleDataTemplate = roleData
  @State openText: boolean = false

  build() {
    Flex({
      wrap: FlexWrap.Wrap
    }){
      Column({ space: 24 }){
        // 标题
        Row(){
          Row(){
            Text('Back')
              .fontColor(this.ThisColor)
              .fontSize(this.frameData.typefaceSize + 6)
              .onClick(() => {
                router.back()
              })
              .width(100)
          }

          Text(this.roleData.roleName)
            .fontSize(this.frameData.typefaceSize + 8)
            .fontColor(this.ThisColor)

          Text('')
            .width(100)
            .textAlign(TextAlign.End)

        }.width('100%')
        .justifyContent(FlexAlign.SpaceBetween)

        Scroll(){
          Column({ space: 24 }){
            Row({space: 16}){
              Text(this.roleData.roleName)
                .fontSize(24)
                .width(120)
                .height(120)
                .borderRadius(60)
                .backgroundColor(this.frameData.backGround)
                .border({
                  width: 1
                })
                .textOverflow({overflow: TextOverflow.Ellipsis})
                .padding(2)
                .textAlign(TextAlign.Center)
                .letterSpacing(3)
              Column({ space: 9 }){

                // 书名
                Row(){
                  Text(this.roleData.roleName)
                    .fontSize(this.frameData.typefaceSize + 6)
                    .fontColor(this.ThisColor)
                    .fontWeight(600)
                }

                // ID
                Row(){
                  Text(String(this.roleData.roleID))
                    .fontSize(this.frameData.typefaceSize - 4)
                    .fontColor(Color.Gray)
                    .fontWeight(400)
                }

                // 标签
                Row({ space: 6 }){
                  ForEach(this.roleData.roleLabel, (item: string) => {
                    Text(item)
                      .textCare(this.frameData.typefaceSize - 3)
                  })
                }
              }.width('100%')
              .alignItems(HorizontalAlign.Start)
              .height(120)
            }

            // 简介
            Column({ space: 12 }){
              Text('简介')
                .fontSize(this.frameData.typefaceSize + 4)
                .fontColor(this.ThisColor)
                .fontWeight(600)
              Row(){
                Text(this.roleData.roleBrief)
                  .maxLines(this.openText ? 999 : 4)
                  .textOverflow({overflow: this.openText ? TextOverflow.None : TextOverflow.Ellipsis })
                  .fontSize(this.frameData.typefaceSize)
                  .fontColor(this.ThisColor)
              }.width('100%')
              Row(){
                Text(this.openText ? '收起' : '展开')
                  .fontSize(this.frameData.typefaceSize - 2)
                  .fontColor(this.ThisColor)
                  .fontWeight(300)
                  .onClick(() => {
                    this.openText = !this.openText
                  })
              }.width('100%')
            }.width('100%')
            .alignItems(HorizontalAlign.Start)

          }
          .alignItems(HorizontalAlign.Start)
          .height('100%')
        }.edgeEffect(EdgeEffect.Spring)
        .height('87%')


        // 目录开始阅读收藏
        Row(){
          Text('')
            .width(50)

          Text('解锁详细档案')
            .fontSize(this.frameData.typefaceSize + 2)
            .fontColor(this.ThisColor)
            .onClick(() => {
              router.pushUrl({
                "url": "pages/userSystem/userPages/userArchives",
                "params": {
                  "roleID": this.roleData.roleID
                }
              })
            })

          Text('')
            .width(50)
        }
        .width('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        .alignItems(VerticalAlign.Center)
        .border({
          width: {
            top: 2
          }
        })
        .padding({
          top: 16
        })
      }
      .padding({
        top: 16,
        left: 24,
        right: 24,
        bottom: 16
      })
    }.height('100%')
  }
}复制

pages/userSystem/userPages

import { frame, frameDataSet,ThisPagefontColor, frameData } from '../../Data/frameData'
import { roleDataTemplate, roleData, roleDataList, roleCustom } from '../../Data/roleData'
import { standardCudeImage } from '../../template/textImgTemplate'
import router from '@ohos.router';

@Entry
@Component
struct UserArchives {

  aboutToAppear(): void {
    let params = router.getParams() as Record<string, number>
    let roleID = params['roleID']

    for (let item of this.roleDataList) {
      if (item.roleID == roleID) {
        this.roleData = item
        break
      }
    }
  }

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor
  @StorageProp('roleDataList') roleDataList: roleDataTemplate[] = roleDataList

  @State roleData: roleDataTemplate = roleData

  @State sw: number = 0
  @State sh: number = 0

  build() {
    Flex(){
      Scroll(){
        Column({ space: 12 }){
          // 标题
          Row(){
            frameData()
              .width(50)
            Text(this.roleData.roleName)
              .fontSize(this.frameData.typefaceSize + 8)
              .fontColor(this.ThisColor)
            Text('详细档案')
              .width(50)
              .fontSize(this.frameData.typefaceSize + 6)
              .fontColor(this.ThisColor)
          }.width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
          .border({
            width: {
              bottom: 2
            }
          })
          .padding({
            top: 16,
            left: 24,
            right: 24,
            bottom: 16
          })

          Column({ space: 24 }){

            Stack(){
              Column({ space: 12 }){
                Row(){
                  Text('姓名:')
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                  Text(this.roleData.roleName)
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                }.width('100%')
                .justifyContent(FlexAlign.SpaceBetween)
                .margin({
                  top: 42
                })
                .padding({
                  left: 16,
                  right: 16,
                  top: 16,
                  bottom: 6
                })
                .border({
                  width: {
                    bottom: 1
                  }
                })

                Row(){
                  Text('性别:')
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                  Text(this.roleData.roleGender)
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                }.width('100%')
                .justifyContent(FlexAlign.SpaceBetween)
                .padding({
                  left: 16,
                  right: 16,
                  top: 16,
                  bottom: 6
                })
                .border({
                  width: {
                    bottom: 1
                  }
                })

                Row(){
                  Text('年龄:')
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                  Text(this.roleData.roleAge)
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                }.width('100%')
                .justifyContent(FlexAlign.SpaceBetween)
                .padding({
                  left: 16,
                  right: 16,
                  top: 16,
                  bottom: 6
                })
                .border({
                  width: {
                    bottom: 1
                  }
                })

                ForEach(this.roleData.roleCustom, (item: roleCustom, index) => {
                  Row(){
                    Text(`${item.name}: `)
                      .fontSize(this.frameData.typefaceSize + 2)
                      .fontColor(this.ThisColor)
                    Text(`${item.value}`)
                      .fontSize(this.frameData.typefaceSize + 2)
                      .fontColor(this.ThisColor)
                  }.width('100%')
                  .justifyContent(FlexAlign.SpaceBetween)
                  .padding({
                    left: 16,
                    right: 16,
                    top: 16,
                    bottom: 6
                  })
                  .border({
                    width: {
                      bottom: 1
                    }
                  })
                })

                Row(){
                  Text('简介:')
                    .fontSize(this.frameData.typefaceSize + 2)
                    .fontColor(this.ThisColor)
                  Text(`${this.roleData.roleBrief}`)
                    .fontSize(this.frameData.typefaceSize - 2)
                    .fontColor(this.ThisColor)
                    .width('70%')
                    .textAlign(TextAlign.End)
                }.width('100%')
                .justifyContent(FlexAlign.SpaceBetween)
                .padding({
                  left: 16,
                  right: 16,
                  top: 16,
                  bottom: 6
                })
                .border({
                  width: {
                    bottom: 1
                  }
                })
              }
              .border({width: 1})
              .borderRadius(16)
              .padding(16)

              Text(this.roleData.roleName)
                .fontSize(18)
                .width(90)
                .height(90)
                .borderRadius(45)
                .backgroundColor(this.frameData.backGround)
                .border({
                  width: 1
                })
                .textOverflow({overflow: TextOverflow.Ellipsis})
                .padding(2)
                .textAlign(TextAlign.Center)
                .letterSpacing(3)
                .position({
                  x: this.sw / 2 - 64,
                  y: -46
                })
            }
            .margin({
              top: 46
            })

          }.alignItems(HorizontalAlign.Center)
          .padding({
            left: 24,
            right: 24,
            top: 10,
            bottom: 10
          })

        }
      }.edgeEffect(EdgeEffect.Spring)

    }
    .onAreaChange((oldValue: Area, newValue: Area) => {
      this.sw = new Number(newValue.width).valueOf();
      this.sh = new Number(newValue.height).valueOf();
    });
  }
}复制

pages/scriptSystem/

以下是pages/scriptSystem/中的内容,存储了剧本系统

import { frame, frameDataSet,ThisPagefontColor, frameData } from '../Data/frameData'
import router from '@ohos.router'
import { bookDataTemplate, bookData, bookDataList } from '../Data/bookData'
import { standardCudeImage } from '../template/textImgTemplate'

@Extend(Text) function textCare(size: number){
  .fontColor('#3c3f41')
  .backgroundColor('#e0dcda')
  .fontSize(size)
  .fontWeight(300)
  .padding({
    left: 8,
    right: 8,
    top: 5,
    bottom: 5
  })
  .borderRadius(12)
  .opacity(.8)
}

@Entry
@Component
struct ScriptDetailed {

  aboutToAppear(): void {
    let params = router.getParams() as Record<string, number>
    let bookID = params['bookID']

    for (let i = 0; i < this.bookDataList.length; i++) {
      if (this.bookDataList[i].bookID == bookID) {
        this.bookData = this.bookDataList[i]
        break
      }
    }
  }

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor
  @StorageProp('bookDataList') bookDataList: bookDataTemplate[] = bookDataList

  @State bookData: bookDataTemplate = bookData
  @State openText: boolean = false

  build() {
    Flex({
      wrap: FlexWrap.Wrap
    }){
      Column({ space: 24 }){
        // 标题
        Row(){
          Row(){
            frameData()
          }
          .width(50)

          Text(this.bookData.bookName)
            .fontSize(this.frameData.typefaceSize + 8)
            .fontColor(this.ThisColor)
            .maxLines(1)

          Row(){
            Text('')
          }.width(50)
          .justifyContent(FlexAlign.Start)

        }.width('100%')
        .justifyContent(FlexAlign.SpaceBetween)

        Scroll(){
          Column({ space: 24 }){
            // 封面标题作者标签ID
            Row({space: 16}){
              standardCudeImage(this.bookData.bookName, this.frameData.backGround, this.ThisColor)
              Column({ space: 9 }){
                // 书名
                Row(){
                  Text(this.bookData.bookName)
                    .fontSize(this.frameData.typefaceSize + 6)
                    .fontColor(this.ThisColor)
                    .fontWeight(600)
                }

                // ID
                Row(){
                  Text(this.bookData.bookID.toString())
                    .fontSize(this.frameData.typefaceSize - 4)
                    .fontColor(Color.Gray)
                    .fontWeight(400)
                }

                // 标签
                Row({ space: 6 }){
                  ForEach(this.bookData.bookLabel, (item: string) => {
                    Text(item)
                      .textCare(this.frameData.typefaceSize - 3)
                  })
                }
              }.width('100%')
              .alignItems(HorizontalAlign.Start)
              .height(120)
            }

            // 简介
            Column({ space: 12 }){
              Text('简介')
                .fontSize(this.frameData.typefaceSize + 4)
                .fontColor(this.ThisColor)
                .fontWeight(600)
              Row(){
                Text(this.bookData.bookBrief)
                  .maxLines(this.openText ? 999 : 4)
                  .textOverflow({overflow: this.openText ? TextOverflow.None : TextOverflow.Ellipsis })
                  .fontSize(this.frameData.typefaceSize)
                  .fontColor(this.ThisColor)
              }.width('100%')
              Row(){
                Text(this.openText ? '收起' : '展开')
                  .fontSize(this.frameData.typefaceSize - 2)
                  .fontColor(this.ThisColor)
                  .fontWeight(300)
                  .onClick(() => {
                    this.openText = !this.openText
                  })
              }.width('100%')
            }.width('100%')
            .alignItems(HorizontalAlign.Start)

          }
          .alignItems(HorizontalAlign.Start)
          .height('100%')
        }.edgeEffect(EdgeEffect.Spring)
        .height('87%')
        // 目录开始阅读收藏
        Row(){
          Text('')
            .fontSize(this.frameData.typefaceSize + 2)
            .fontColor(this.ThisColor)
            .width(100)
          Text('开始阅读')
            .fontSize(this.frameData.typefaceSize + 2)
            .fontColor(this.ThisColor)
            .onClick(() => {
              router.pushUrl({
                "url": "pages/scriptSystem/scriptPages/scriptRead",
                "params": {
                  "bookID": this.bookData.bookID,
                  "chapterIndex": 1,
                }
              })
            })
          Text('')
            .fontSize(this.frameData.typefaceSize + 2)
            .fontColor(this.ThisColor)
            .width(100)
        }
        .width('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        .alignItems(VerticalAlign.Center)
        .border({
          width: {
            top: 2
          }
        })
        .padding({
          top: 16
        })
      }
      .padding({
        top: 16,
        left: 24,
        right: 24,
        bottom: 16
      })
    }.height('100%')
  }
}复制

pages/scriptSystem/scriptPages/scriptRead.ets

import { frame, frameDataSet,ThisPagefontColor, frameData } from '../../Data/frameData'
import { readBookCharpterTemplate, readBookCharpterDataList, readBookCharpterData } from '../../Data/readBookChapterData'
import { smallImage } from '../../template/textImgTemplate'
import { delPage } from './popUp/del'
import { editTextPage } from './popUp/editText'

import router from '@ohos.router';
import promptAction from '@ohos.promptAction'
import { roleDataTemplate } from '../../Data/roleData'

@Extend(Text) function textCare(size: number){
  .padding({
    left: 12,
    right: 12,
    top: 16,
    bottom: 12
  })
  .fontSize(size)
  .fontColor(Color.Black)
}

@Entry
@Component
struct ScriptRead {

  // 删除文字
  delPageOpen: CustomDialogController = new CustomDialogController({
    builder: delPage({
      onCancel: (value: boolean) => {
        if (value) {
          this.dialogueListNew.splice(this.delIndex, 1)
          this.displayList[this.displayIndex] = false
        }
      }
    })
  })

  // 添加文字
  editTextPageOpen: CustomDialogController = new CustomDialogController({
    builder: editTextPage({
      onCancel: (careValue: number ,text: string ,returnRole: roleDataTemplate, newData: boolean) => {

        let textValue: string = ''

        for (let i = 0; i < text.length; i++) {
          if (text[i] == ','){
            textValue += ','
          } else if (text[i] == '|') {
            textValue += '/'
          } else {
            textValue += text[i]
          }
        }

        let dialogue: string[] = []

        /* 如果是旁白,就不需要角色昵称 */
        if (careValue != 2){
          if (careValue == 1) {
            dialogue[0] = 'left'
          } else if(careValue == 3) {
            dialogue[0] = 'right'
          }
          dialogue[1] = returnRole.roleName
        } else {
          dialogue[0] = 'pb'
          dialogue[1] = 'pb'
        }

        dialogue[2] = textValue

        this.dialogueListNew.push(dialogue)
        this.displayList.push(true)

        this.scorllData.scrollBy(0, 10000)
      }
    }),
  })

  scorllData: Scroller = new Scroller()

  @StorageProp('frame') frameData: frame = frameDataSet
  @StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor
  @StorageLink('readBookCharpterDataList') readBookList: readBookCharpterTemplate[] = []

  @State index: number = 1
  @State bookLength: number = 0

  @State dialogueList: string[] = []
  @State dialogueListNew: string[][] = []
  @State displayList: boolean[] = []
  @State displayIndex: number = 1

  @State delIndex: number = 0

  @State readBook: readBookCharpterTemplate = readBookCharpterData

  @Builder leftUser(roleName: string, roleText: string){
    // 左侧角色
    Column({ space: 4 }){
      Row({ space: 12 }){
        smallImage(roleName, this.frameData.backGround, this.ThisColor)
        Text(`${roleName}`)
          .fontColor(this.ThisColor)
          .fontSize(this.frameData.typefaceSize)
      }
      Row(){
        Text(`${roleText}`)
          .fontColor(this.ThisColor)
          .fontSize(this.frameData.typefaceSize - 2)
      }
      .border({
        width: 1
      })
      .borderRadius({
        topRight: 12,
        bottomLeft: 12,
        bottomRight: 12
      })
      .backgroundColor(this.frameData.backGround)
      .padding({
        top: 8,
        bottom: 8,
        left: 12,
        right: 12
      })
      .margin({
        left: '12%'
      })
    }.width('70%')
    .alignItems(HorizontalAlign.Start)
  }

  @Builder rightUser(roleName: string, roleText: string){
    // 右侧角色
    Column({ space: 4 }){
      Row({ space: 12 }){
        Text(`${roleName}`)
          .fontColor(this.ThisColor)
          .fontSize(this.frameData.typefaceSize)

        smallImage(roleName, this.frameData.backGround, this.ThisColor)
      }
      .width('100%')
      .justifyContent(FlexAlign.End)

      Row(){
        Row(){
          Text(`${roleText}`)
            .fontColor(this.ThisColor)
            .fontSize(this.frameData.typefaceSize - 2)
        }
        .border({
          width: 1
        })
        .borderRadius({
          topLeft: 12,
          bottomLeft: 12,
          bottomRight: 12
        })
        .backgroundColor(this.frameData.backGround)
        .padding({
          top: 8,
          bottom: 8,
          left: 12,
          right: 12
        })
        .margin({
          right: '12%'
        })
      }.width('80%')
      .justifyContent(FlexAlign.End)

    }.width('100%')
    .alignItems(HorizontalAlign.End)
  }

  @Builder narratorUser(roleText: string){
    // 旁白
    Column({ space: 4 }){
      Row(){
        Text(`${roleText}`)
          .fontColor(this.ThisColor)
          .fontSize(this.frameData.typefaceSize - 2)
          .textAlign(TextAlign.Center)

      }
      .border({
        width: 1
      })
      .borderRadius(12)
      .padding(12)
      .margin({
        top: 8,
      })
      .justifyContent(FlexAlign.Center)
    }.padding({
      left: 24,
      right: 24
    })
    .width('100%')
  }

  aboutToAppear(): void {
    let params = router.getParams() as Record<string, number>
    let bookID = params['bookID']
    let readIndex = params['chapterIndex']

    for (let index = 0; index < this.readBookList.length; index++) {
      if (this.readBookList[index].ascriptionBookID == bookID) {
        this.readBook = this.readBookList[index]
        break
      }
    }

    this.dialogueList = this.readBook.dialogueList.split(',')

    for (let item of this.dialogueList) {
      let read = item.split('|')
      this.dialogueListNew.push([read[0], read[1], read[2]])
    }
  }

  onPageHide(): void {
    this.saveData()
  }

  saveData() {
    let readList: string[] = []
    this.readBook.dialogueList = ''
    for (let item of this.dialogueListNew) {
       readList.push(item.join('|'))
    }
    for (let item of readList) {
      this.readBook.dialogueList += item + ','
    }
    for (let index = 0; index < this.readBookList.length; index ++) {
      if (this.readBookList[index].articleID == this.readBook.articleID) {
        this.readBookList[index] = this.readBook
      }
    }

    promptAction.showToast({
      message: "保存成功!"
    })
  }

  build() {
    Flex(){
      Column(){
        // 标题
        Row(){
          frameData()
            .width(50)
          Text(`第${this.index}幕`)
            .fontSize(this.frameData.typefaceSize + 8)
            .fontColor(this.ThisColor)
          Text('')
            .textAlign(TextAlign.End)
            .width(50)
        }.width('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        .border({
          width: {
            bottom: 2
          }
        })
        .padding({
          top: 16,
          left: 24,
          right: 24,
          bottom: 16
        })

        Scroll(this.scorllData){
          Column({ space: 12 }){
            ForEach(this.dialogueListNew, (item: string[], index) => {
              Row(){
                if (item[0] == 'left') {
                  this.leftUser(item[1], item[2])
                } else if (item[0] == 'right') {
                  this.rightUser(item[1], item[2])
                } else if (item[0] == 'pb') {
                  this.narratorUser(item[2])
                }
              }
              .onClick(() => {
                this.delIndex = index
                this.delPageOpen.open()
              })
            })
          }
          .alignItems(HorizontalAlign.Start)
          .padding({
            left: 24,
            right: 24,
            top: 16,
            bottom: 16
          })
          .width('100%')
          .alignItems(HorizontalAlign.Start)
        }
        .align(Alignment.Top)
        .edgeEffect(EdgeEffect.Spring)
        .height('86%')
        .onClick(() => {
          this.displayList[this.displayIndex++] = true
        })


        Row(){
          Text('')
            .textCare(this.frameData.typefaceSize + 2)
            .width(100)
          Text('编辑文本')
            .textCare(this.frameData.typefaceSize + 2)
            .onClick(() => {
              this.editTextPageOpen.open()
            })
          Text('保存')
            .textCare(this.frameData.typefaceSize + 2)
            .onClick(() => {
              this.saveData()
            })
            .width(100)
            .textAlign(TextAlign.End)
        }.width('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        .border({
          width: {
            top: 2
          }
        })
      }
      .height('100%')
    }
  }
}复制

以上便是"说书人"项目中部分重要代码的分享,由于字数限制,不能全部上传,完整代码已经上传AtomGit,大家可以进行下载

master · 说书人_单机版 · AtomGit

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2268034.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

报表工具DevExpress Reporting v24.2亮点 - AI功能进一步强化

DevExpress Reporting是.NET Framework下功能完善的报表平台&#xff0c;它附带了易于使用的Visual Studio报表设计器和丰富的报表控件集&#xff0c;包括数据透视表、图表&#xff0c;因此您可以构建无与伦比、信息清晰的报表。 报表工具DevExpress Reporting v24.2将于近期发…

每天40分玩转Django:Django表单集

Django表单集 一、知识要点概览表 类别知识点掌握程度要求基础概念FormSet、ModelFormSet深入理解内联表单集InlineFormSet、BaseInlineFormSet熟练应用表单集验证clean方法、验证规则熟练应用自定义配置extra、max_num、can_delete理解应用动态管理JavaScript动态添加/删除表…

MVCC实现原理以及解决脏读、不可重复读、幻读问题

MVCC实现原理以及解决脏读、不可重复读、幻读问题 MVCC是什么&#xff1f;有什么作用&#xff1f;MVCC的实现原理行隐藏的字段undo log日志版本链Read View MVCC在RC下避免脏读MVCC在RC造成不可重复读、丢失修改MVCC在RR下解决不可重复读问题RR下仍然存在幻读的问题 MVCC是什么…

自学记录鸿蒙API 13:实现人脸比对Core Vision Face Comparator

完成了文本识别和人脸检测的项目后&#xff0c;我发现人脸比对是一个更有趣的一个小技术玩意儿。我决定整一整&#xff0c;也就是对HarmonyOS Next最新版本API 13中的Core Vision Face Comparator API的学习&#xff0c;这项技术能够对人脸进行高精度比对&#xff0c;并给出相似…

代码解析:安卓VHAL的AIDL参考实现

以下内容基于安卓14的VHAL代码。 总体架构 参考实现采用双层架构。上层是 DefaultVehicleHal&#xff0c;实现了 VHAL AIDL 接口&#xff0c;并提供适用于所有硬件设备的通用 VHAL 逻辑。下层是 FakeVehicleHardware&#xff0c;实现了 IVehicleHardware 接口。此类可模拟与实…

通过 Ansys Electronics Desktop 中的高级仿真优化 IC 设计

半导体行业继续通过日益复杂的集成电路 (IC) 设计突破技术界限。随着工艺节点缩小和电路密度达到前所未有的水平&#xff0c;电磁效应对设备性能和可靠性变得越来越重要。现代 IC 设计面临着来自复杂的布局相关耦合机制、信号完整性问题和功率分布问题的挑战&#xff0c;这些问…

Kafka数据迁移全解析:同集群和跨集群

文章目录 一、同集群迁移二、跨集群迁移 Kafka两种迁移场景&#xff0c;分别是同集群数据迁移、跨集群数据迁移。 一、同集群迁移 应用场景&#xff1a; broker 迁移 主要使用的场景是broker 上线,下线,或者扩容等.基于同一套zookeeper的操作。 实践&#xff1a; 将需要新添加…

【OpenGL ES】GLSL基础语法

1 前言 本文将介绍 GLSL 中数据类型、数组、结构体、宏、运算符、向量运算、矩阵运算、函数、流程控制、精度限定符、变量限定符&#xff08;in、out、inout&#xff09;、函数参数限定符等内容&#xff0c;另外提供了一个 include 工具&#xff0c;方便多文件管理 glsl 代码&a…

ffmpeg之播放一个yuv视频

播放YUV视频的步骤 初始化SDL库&#xff1a; 目的&#xff1a;确保SDL库正确初始化&#xff0c;以便可以使用其窗口、渲染和事件处理功能。操作&#xff1a;调用 SDL_Init(SDL_INIT_VIDEO) 来初始化SDL的视频子系统。 创建窗口用于显示YUV视频&#xff1a; 目的&#xff1a;…

复习打卡大数据篇——Hadoop MapReduce

目录 1. MapReduce基本介绍 2. MapReduce原理 1. MapReduce基本介绍 什么是MapReduce MapReduce是一个分布式运算程序的编程框架&#xff0c;核心功能是将用户编写的业务逻辑代码和自带默认组件整合成一个完整的分布式运算程序&#xff0c;并发运行在Hadoop集群上。 MapRed…

小程序配置文件 —— 13 全局配置 - window配置

全局配置 - window配置 这里讲解根目录 app.json 中的 window 字段&#xff0c;window 字段用于设置小程序的状态栏、导航条、标题、窗口背景色&#xff1b; 状态栏&#xff1a;顶部位置&#xff0c;有网络信号、时间信息、电池信息等&#xff1b;导航条&#xff1a;有一个当…

el-pagination 为什么只能展示 10 条数据(element-ui@2.15.13)

好的&#xff0c;我来帮你分析前端为什么只能展示 10 条数据&#xff0c;以及如何解决这个问题。 问题分析&#xff1a; pageSize 的值&#xff1a; 你的 el-pagination 组件中&#xff0c;pageSize 的值被设置为 10&#xff1a;<el-pagination:current-page"current…

单片机与MQTT协议

MQTT 协议简述 MQTT&#xff08;Message Queuing Telemetry Transport&#xff0c;消息队列遥测传输协议&#xff09;&#xff0c;是一种基于发布 / 订阅&#xff08;publish/subscribe&#xff09;模式的 “轻量级” 通讯协议&#xff0c;该协议构建于 TCP/IP 协议上&#xf…

Debian-linux运维-docker安装和配置

腾讯云搭建docker官方文档&#xff1a;https://cloud.tencent.com/document/product/213/46000 阿里云安装Docker官方文档&#xff1a;https://help.aliyun.com/zh/ecs/use-cases/install-and-use-docker-on-a-linux-ecs-instance 天翼云常见docker源配置指导&#xff1a;htt…

使用Docker-compose部署SpringCloud项目

docker编写dockfile遇到的问题&#xff1a; 需要在docker-compose.yml文件下执行命令 docker-compose.yml文件格式的问题 1和2处空2格&#xff0c;3处空1格&#xff0c;4为本地配置文件目录&#xff0c;5为docker容器的目录&#xff0c;version为自己安装的docker-compose版本 …

KG4Diagnosis 分层多代理的医疗诊断框架,结合大模型与知识图谱构建,覆盖362种常见疾病

KG4Diagnosis 分层多代理的医疗诊断框架&#xff0c;结合大模型与知识图谱构建&#xff0c;覆盖362种常见疾病 论文大纲理解1. 提出背景是什么&#xff1f;2. 概念的性质是什么&#xff1f;是什么导致这个性质&#xff1f;3. 请举一个正例、一个反例&#xff0c;对比4. 请使用类…

【LLM综述】29种大模型Prompt Engineering技术

note 从零样本&#xff08;Zero-shot&#xff09;提示到最新进展的各种提示技术&#xff0c;包括推理和逻辑链&#xff08;Chain-of-Thought, CoT&#xff09;提示、自动链式思考&#xff08;Auto-CoT&#xff09;提示、自我一致性&#xff08;Self-Consistency&#xff09;提…

【黑马头条训练营】day02-黑马头条-App端文章展示

目录 描述app端首页从请求到数据显示的全部流程 描述文章微服务的组成及首页展示业务与实现 自己编写文章微服务关键逻辑 描述app端首页从请求到数据显示的全部流程 浏览器请求我们的app端 会通过nginx请求到我们app前端 app端输入手机号和密码 点击登录 请求 会到我们的…

DBeaver 咋手动配置sqlite 驱动

目录 1 问题2 下载 1 问题 离线安装了DBeaver 数据库软件&#xff0c;现在需要使用这个数据库打开sqlite 数据库&#xff0c;但是提示没有 驱动&#xff0c;那么我们就需要手动下载驱动&#xff0c;在这个软件里面导入 2 下载 https://repo1.maven.org/maven2/org/xerial/sql…

Linux 的历史与发展:从诞生到未来

Linux 的历史与发展&#xff1a;从诞生到未来 1. 起源之前&#xff1a;操作系统的历史背景 在 Linux 问世之前&#xff0c;操作系统的发展经历了多个重要阶段&#xff0c;这些阶段为 Linux 的诞生奠定了基础&#xff1a; 1940-1950 年代&#xff1a;计算机初期 早期计算机如 [[…