当前位置: 首页 > news >正文

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

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

文章最后给出了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 = ThisPagefontColorbuild() {Text('Back').fontColor(this.ThisColor).fontSize(this.frameData.typefaceSize + 6).onClick(() => {router.back()})}
}复制
readBookCharpter.ets

此处存储了章节信息

// 章节信息
export interface readBookCharpterTemplate{// 章节IDarticleID: number,// 章节索引chapterIndex: string,// 章节内容dialogueList: string,// 造物者之IDcreateUserID: 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 = 0onPageShow(): 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: CustomDialogControlleronCancel: () => void = () => {}onJUJUE: () => void = () => {}@StorageProp('frame') frameData: frame = frameDataSet@StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColorbuild() {/* 用户名和需要修改的参数都由外部传递此处只涉及数据修改任务*/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 = ThisPagefontColorbuild() {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 = 0build() {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 = 0build() {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 = itembreak}}}@StorageProp('frame') frameData: frame = frameDataSet@StorageProp('fontColor') ThisColor: ResourceColor = ThisPagefontColor@StorageProp('roleDataList') roleDataList: roleDataTemplate[] = roleDataList@State roleData: roleDataTemplate = roleData@State openText: boolean = falsebuild() {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)}// IDRow(){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 = itembreak}}}@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 = 0build() {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 = falsebuild() {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 }){// 封面标题作者标签IDRow({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)}// IDRow(){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] = textValuethis.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 = indexthis.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

相关文章:

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

前段时间开发了一个软件&#xff0c;取名为“说书人”&#xff0c;后由于备案暂时没有通过&#xff0c;于是删除了联网功能&#xff0c;重新做了一个单机版&#xff0c;这里对于单机版的开发实践案例进行一个发出&#xff0c;希望能帮助到大家 文章最后给出了AtomGit仓库地址 p…...

Vue3 + ElementPlus动态合并数据相同的单元格(超级详细版)

最近的新项目有个需求需要合并单元列表。ElementPlus 的 Table 提供了合并行或列的方法&#xff0c;可以参考一下https://element-plus.org/zh-CN/component/table.html 但项目中&#xff0c;后台数据返回格式和指定合并是动态且没有规律的&#xff0c;Element 的示例过于简单&…...

前端开发中依赖包有问题怎么办

在前端开发中&#xff0c;如果你发现某个依赖包存在问题&#xff0c;可以考虑以下步骤来解决&#xff1a; 一、简单方案 1. 检查问题来源&#xff1a; 确认问题是否由依赖包引起&#xff0c;而不是你的代码或其他配置问题。查看错误信息、文档和相关的 GitHub issue&#xf…...

Oracle exp和imp命令导出导入dmp文件

目录 一. 安装 instantclient-tools 工具包二. exp 命令导出数据三. imp 命令导入数据四. expdp 和 impdp 命令 一. 安装 instantclient-tools 工具包 ⏹官方网站 https://www.oracle.com/cn/database/technologies/instant-client/linux-x86-64-downloads.html ⏹因为我们在…...

阿里云人工智能工程师ACA认证免费课程学习笔记

阿里云人工智能工程师ACA认证免费课程学习笔记 0. 引言第1章&#xff1a;人工智能基础课时1&#xff1a;人工智能概述课时2&#xff1a;人工智能产业结构课时3&#xff1a;人工智能项目开发的基本流程 第2章&#xff1a;机器学习PAI平台基础第3章&#xff1a;数据处理基础课时8…...

单片机库函数-io输出操作

1、需要使用模块 使用库函数做跑马灯&#xff0c;要用到: misc.h misc.c 时钟模块&#xff1a; stm32f10x_rcc.h stm32f10x_rcc.c gpio模块&#xff1a; 头文件:stm32f10x_gpio.h 源文件:stm32f10x_gpio.c 2、库函数 2.1、初始化GPIO void GPIO_Init(GPIO_TypeDef* …...

SpringAI从入门到熟练

学习SpringAI的记录情况 文章目录 前言 因公司需要故而学习SpringAI文档&#xff0c;故将自己所见所想写成文章&#xff0c;供大佬们参考 主要是为什么这么写呢&#xff0c;为何不抽出来呢&#xff0c;还是希望可以用的时候更加方便一点&#xff0c;如果大家有需求可以自行去…...

Javascript-web API-day04

文章目录 01-实例化日期对象02-常见的日期对象方法03-年月日案例04-年月日简化05-得到时间戳06-倒计时07-关闭节点08-子节点09-增加节点10-克隆节点11-删除节点12-m端时间13-(swiper插件的使用)移动端轮播图游乐园项目 学成在线重构 01-实例化日期对象 <!DOCTYPE html> …...

等待事件 ‘latch: row cache objects‘ 说明及解决方法

早上刚来的时候&#xff0c;收到zabbix 数据库连接数增长的告警&#xff0c;同时应用负责人也说查询很慢、很卡 查看该时间段 最多的等待事件 SELECT event,COUNT(1) num FROM V$ACTIVE_SESSION_HISTORY A WHERE A.SAMPLE_TIME BETWEEN TO_DATE(2025-01-02 09:00:00, YYYY-M…...

Mac电脑python多版本环境安装与切换

我当前是python3.9.6环境&#xff0c;需要使用3.9.8环境&#xff0c;通过brew安装3.9.8版本&#xff0c;然后通过pyenv切换环境 步骤 1: 安装 pyenv brew install pyenv brew install pyenv-virtualenv 步骤 2: 安装 Python 3.9.8&#xff08;使用 pyenv 安装指定版本的 Pyth…...

MySQL 锁那些事

Q1 : MySQL有哪些锁,功能是什么,如何项目中使用?Q2 : 行锁是如何实现的?什么情况下会使用行锁?Q3 : 四种事务隔离形式的行锁有什么不一样?读未提交读提交可重复读串行 Q4 : MySQL 的读写都是怎样加锁的?Q5 : 需要注意什么? Q1 : MySQL有哪些锁,功能是什么,如何项目中使用…...

面试手撕笔记ML/DL

数据集 数据集的批处理迭代器 Deep-ML | Batch Iterator for Dataset 实现一个批量可迭代函数&#xff0c;该函数在numpy数组X和可选numpy数组y中进行采样。该函数应该生成指定大小的批量。如果提供了y&#xff0c;则该函数应生成&#xff08;X, y&#xff09;对的批次&#…...

WPF使用ContentControl控件实现区域导航,并使用Prism依赖注入优化

背景&#xff1a;使用ContentControl控件实现区域导航是有Mvvm框架的WPF都能使用的&#xff0c;不限于Prism 主要是将ContenControl控件的Content内容在ViewModel中切换成不同的用户控件 下面是MainViewModel&#xff1a; private object body;public object Body {get { retu…...

NineData 荣获年度“创新解决方案奖”

近日&#xff0c;国内知名 IT 垂直媒体 & 技术社区 IT168 再次启动“技术卓越奖”评选&#xff0c;由行业 CIO/CTO 大咖、技术专家及 IT 媒体多方联合评审&#xff0c;NineData 凭借技术性能和产品创新等方面表现出色&#xff0c;在数据库工具领域荣获“2024 年度创新解决方…...

Windows 11 系统中npm-cache优化

在 Windows 11 系统中&#xff0c;C:\Users\K\AppData\Local\npm-cache 文件夹是 npm&#xff08;Node Package Manager&#xff09; 用于缓存已下载的包的目录。缓存的存在可以加快包的安装速度&#xff0c;因为当再次安装相同的包时&#xff0c;npm 可以直接从缓存中获取&…...

【运维工具】Ansible一款好用的自动化工具

Ansible一款好用的自动化工具 概述一、基本概念与特点二、核心组件三、主要功能与应用场景四、优缺点 如何使用一、安装Ansible二、配置Ansible三、使用Ansible四、注意事项 Playbook语法详解一、YAML文件的基本结构二、Playbook的主要组成部分三、Playbook示例四、注意事项 概…...

4.Web安全——JavaScript基础

一、JavaScript是什么&#xff1f; JavaScript 是一种高级的、解释型的编程语言&#xff0c;广泛应用于网页开发和各种软件应用程序中。 二、为什么要学习JavaScript XSS&#xff08;跨站脚本攻击&#xff09;防范 XSS 是一种常见的 Web 安全漏洞&#xff0c;攻击者将恶意脚…...

mysql删除无用用户

1、删除不用的账户 (1) 查看当前已存在账户 mysql> select user,host,password from mysql.user; 或下面的命令 #mysql> sELECT DISTINCT CONCAT(User: ,user,,host,;) AS query FROM mysql.user; --------------------------------------- | query …...

2025元旦源码免费送

我们常常在当下感到时间慢&#xff0c;觉得未来遥远&#xff0c;但一旦回头看&#xff0c;时间已经悄然流逝。对于未来&#xff0c;尽管如此&#xff0c;也应该保持一种从容的态度&#xff0c;相信未来仍有许多可能性等待着我们。 免费获取源码。 更多内容敬请期待。如有需要可…...

静态库封装之ComFile类

ComFile.h /* author:EricsT data:20241024 version:V1.0 history:author data version contentEricsT 20241024 V1.0 新增ComFile类[common、FILE以及stream部分] */#pragma once#include <string> #include <fstream> using namespace std;class ComFile { publi…...

概率论与数理统计

概率论占比更多&#xff0c;三分之二左右 数理统计会少一些 事件之间的概率 ab互斥&#xff0c;不是ab独立 古典概型吃高中基础&#xff0c;考的不会很多 条件概率公式&#xff0c;要记 公式不要全记&#xff0c;很多有名称的公式是通过基础公式转换而来的 目的在于解决一…...

鸿蒙HarmonyOS开发:基于Swiper组件和自定义指示器实现多图片进度条轮播功能

文章目录 一、概述1、场景介绍2、技术选型 二、实现方案1、图片区域实现2、底部导航点设计3、手动切换 三、所有代码1、设置沉浸式2、外层Tabs效果3、ImageSwiper组件 四、效果展示 一、概述 在短视频平台上&#xff0c;经常可以见到多图片合集。它的特点是&#xff1a;由多张…...

django --递归查询评论

表数据 树状结构 action(methods(GET, ), detailFalse) def get_info_pinglun(self, request, *args, **kwargs) -> Response:根据评论id查所有回复params wenxian_pinglun_id --> 评论id;wenxian_pinglun_id self.request.GET.get(wenxian_pinglun_id)results se…...

kafka怎么保证顺序消费?

kafka怎么保证顺序消费&#xff1f; 1. 分区内的顺序保证2. 并发消费3. 实现顺序消费的策略4. 注意事项 kafka创建 topic 的时候没有指定分区数量&#xff0c;那么默认只会有一个分区。如果你想要创建一个具有多个分区的 topic&#xff0c;你可以在创建 topic 的命令中指定 --p…...

springboot原生socket通讯教程

需求背景 最近需要对接一些硬件设备,他们选择了socket通讯,并且使用的是私有化协议加密通讯。这种情况下适合原生的socket加解密解析,不适合NettySocket,这在开发中增加了难度。所有的代码都要手动去敲。如果你的只想通过socket传输一些数据,而且都是json的数据,例如聊天…...

革新排版机产线:一体式IO模块引领自动化高效控制新时代

在瞬息万变的制造业浪潮中&#xff0c;自动化与智能化已成为推动产业升级的关键力量。特别是在印刷行业&#xff0c;排版机的效率与精度直接关系到产品的质量与市场竞争力。近年来&#xff0c;随着技术的不断革新&#xff0c;明达技术MR20一体式IO模块凭借其高度集成、灵活配置…...

《深度学习梯度消失问题:原因与解决之道》

在深度学习的训练过程中&#xff0c;梯度消失是一个常见且棘手的问题&#xff0c;它会严重影响模型的训练效果和性能。以下是对该问题的原因分析与解决办法。 梯度消失问题的原因 首先是激活函数选择不当。像Sigmoid和Tanh这类传统激活函数&#xff0c;在输入值较大或较小时&…...

IP-MS常见问题(一)

用于IP-MS实验的样品&#xff0c;需要多少样品量&#xff1f; 建议使用约2107数量的细胞&#xff08;约5 mg蛋白&#xff09;进行IP实验。 其他类型的IP起始样品&#xff0c;如组织、细菌等可根据蛋白含量进行换算。 经过IP实验步骤或纯化富集的蛋白通常不超过10 μg&#xf…...

四种线程池的创建及任务提交

1. 线程池概述 1.1 线程池的定义 线程池是管理和控制线程使用的一种手段。它通过提前创建一定数量的线程&#xff0c;并将任务提交给这些线程执行&#xff0c;来实现资源的合理分配和任务的高效处理。 关键点&#xff1a; 线程复用&#xff1a;线程池在任务执行完毕后&#…...

【优选算法】查找总价格为目标值的两个商品

链接&#xff1a;LCR 179. 查找总价格为目标值的两个商品 - 力扣&#xff08;LeetCode&#xff09; 解法&#xff1a;利用单调性&#xff0c;使用双指针算法解决问题 1.先从小到大排序 2. sum > t : right--; sum < t : left; sum t : return class Solution {public…...

从零开始学架构——互联网架构的演进

1 技术演进 1.1 技术演进的动力 对于新技术&#xff0c;我们应该站在行业的角度上思考&#xff0c;哪些技术我们要采取&#xff0c;哪些技术我们不能用&#xff0c;投入成本过大会不会导致满盘皆输&#xff1f;市场、技术、管理三者组成的业务发展铁三角&#xff0c;任何一个…...

Linux 系统常见问题

SSH问题 SSH连接服务器时报错&#xff1a; ssh_exchange_identification: read: Connection reset by peer 报错信息&#xff1a; ssh_exchange_identification: read: Connection reset by peer可以通过ssh -p root -v查看连接时详情 解决方法&#xff1a; vi /etc/host…...

工厂模式与抽象工厂模式在Unity中的实际应用案例

一、实验目的 实践工厂模式和抽象工厂模式的实际应用。 创建一个小型的游戏场景&#xff0c;通过应用这些设计模式提升游戏的趣味性和可扩展性。 掌握在复杂场景中管理和使用不同类型的对象。 比较在实际游戏开发中不同设计模式的实际效果和应用场景。 学习如何进行简单的性…...

AI定义汽车/跨域融合/整车智能,汽车智能化2.0时代新机会来了

汽车智能化2.0&#xff0c;产业正在发生深度变革。 一方面&#xff0c;AI大模型开始在多个域同步赋能智能汽车&#xff0c;从智能座舱到智能驾驶&#xff0c;再到底盘域&#xff0c;AI大模型正在快速推动汽车变革为超级智能体&#xff0c;AI定义汽车时代开始来临。 另一方面&…...

QT----------多媒体

实现思路 多媒体模块功能概述&#xff1a; QT 的多媒体模块提供了丰富的功能&#xff0c;包括音频播放、录制、视频播放和摄像头操作等。 播放音频&#xff1a; 使用 QMediaPlayer 播放完整的音频文件。使用 QSoundEffect 播放简短的音效文件。 录制音频&#xff1a; 使用 QMe…...

[ubuntu-22.04]ubuntu不识别rtl8153 usb转网口

问题描述 ubuntu22.04插入rtl8153 usb转网口不识别 解决方案 安装依赖包 sudo apt-get install libelf-dev build-essential linux-headers-uname -r sudo apt-get install gcc-12 下载源码 Realtek USB FE / GBE / 2.5G / 5G Ethernet Family Controller Softwarehttps:/…...

洛谷P1525 [NOIP2010 提高组] 关押罪犯(种子并查集基础)

题目链接:P1525 [NOIP2010 提高组] 关押罪犯 - 洛谷 | 计算机科学教育新生态 题目难度:普及+/提高 题目描述: S 城现有两座监狱,一共关押着 N 名罪犯,编号分别为 1∼N,有m对罪犯,每对之间有仇恨值,问如何分配罪犯使得现 Z 市长要看到其中最大的矛盾值最小。 输入格…...

Android笔试面试题AI答之Android基础(11)

Android入门请看《Android应用开发项目式教程》&#xff0c;视频、源码、答疑&#xff0c;手把手教 文章目录 1.Android的权限有哪些&#xff1f;**1. 普通权限****常见普通权限** **2. 危险权限****权限分组****常见危险权限组及权限** **3. 特殊权限****常见特殊权限** **4. …...

【智行安全】基于Synaptics SL1680的AI疲劳驾驶检测方案

随著车载技术的快速进步&#xff0c;驾驶安全越来越受到重视&#xff0c;而疲劳驾驶是造成交通事故的重要原因之一。传统的驾驶监控技术因精度不足或反应迟缓&#xff0c;无法满足实时监测需求。因此&#xff0c;结合人工智能技术的疲劳驾驶检测系统成为行业新方向&#xff0c;…...

多分类的损失函数

在多分类任务中,常用的损失函数能够衡量模型输出的类别分布与目标类别之间的差异,帮助模型学习更准确的分类能力。以下是多分类任务中常用的损失函数: 1. 交叉熵损失(Cross-Entropy Loss) 公式: CrossEntropyLoss = − 1 N ∑ i =...

探索数据之美,Plotly引领可视化新风尚

在数据如潮的今天&#xff0c;如何精准捕捉信息的脉搏&#xff0c;让数据说话&#xff1f;Plotly&#xff0c;这款强大的数据可视化工具&#xff0c;正以其卓越的性能和丰富的功能&#xff0c;成为数据分析师、科学家及工程师们的得力助手。 Plotly不仅仅是一个绘图库&#xf…...

青少年编程与数学 02-006 前端开发框架VUE 02课题、创建工程

青少年编程与数学 02-006 前端开发框架VUE 02课题、创建工程 一、开发环境&#xff08;一&#xff09;WebStorm安装WebStorm配置WebStorm安装中文语言包安装 Translation插件 &#xff08;二&#xff09;Node.jsWindows系统安装Node.jsLinux系统安装Node.jsNode.js与Vue.js的关…...

高并发场景下的秒杀系统架构设计与实现

引言 秒杀系统是一种高并发场景的典型应用&#xff0c;广泛存在于电商平台、抢票系统和促销活动中。秒杀活动的特点是短时间内吸引大量用户同时访问并尝试抢购商品&#xff0c;这对系统的高并发处理能力、稳定性和用户体验提出了极高的要求。 在秒杀系统中&#xff0c;常见的…...

局域网中单台交换机VLAN应用

网络拓扑 其中交换机接口类型都为access接口。 Ethernet 0/0/1 VLAN ID为10 Ethernet 0/0/2 VLAN ID为10 Ethernet 0/0/5 VLAN ID为20 Ethernet 0/0/6 VLAN ID为20 Host-1 ip为192.168.64.11/24 Host-2 ip为192.168.64.12/24 Host-3 ip为192.168.64.21/24 Host-4 ip为192.168…...

UNI-APP_i18n国际化引入

官方文档&#xff1a;https://uniapp.dcloud.net.cn/tutorial/i18n.html vue2中使用 1. 新建文件 locale/index.js import en from ./en.json import zhHans from ./zh-Hans.json import zhHant from ./zh-Hant.json const messages {en,zh-Hans: zhHans,zh-Hant: zhHant }…...

纯血鸿蒙ArkUI选项卡布局详解

当页面信息较多的时候&#xff0c;为了让用户能够聚焦于当前显示的内容&#xff0c;需要对页面的内容进行分类&#xff0c;提高页面空间利用率。Tabs组件可以在一个页面内实现快速的视图内容切换&#xff0c;一方面提升查找信息的效率&#xff0c;另一方面精简用户单词获取到的…...

从0开始的opencv之旅(1)cv::Mat的使用

目录 Mat 存储方法 创建一个指定像素方式的图像。 尽管我们完全可以把cv::Mat当作一个黑盒&#xff0c;但是笔者的建议是仍然要深入理解和学习cv::Mat自身的构造逻辑和存储原理&#xff0c;这样在查找问题&#xff0c;或者是遇到一些奇奇怪怪的图像显示问题的时候能够快速的想…...

uniapp 微信小程序开发使用高德地图、腾讯地图

一、高德地图 1.注册高德地图开放平台账号 &#xff08;1&#xff09;创建应用 这个key 第3步骤&#xff0c;配置到项目中locationGps.js 2.下载高德地图微信小程序插件 &#xff08;1&#xff09;下载地址 高德地图API | 微信小程序插件 &#xff08;2&#xff09;引入项目…...

Activation Functions

Chapter4&#xff1a;Activation Functions 声明&#xff1a;本篇博客笔记来源于《Neural Networks from scratch in Python》&#xff0c;作者的youtube 其实关于神经网络的入门博主已经写过几篇了&#xff0c;这里就不再赘述&#xff0c;附上链接。 1.一文窥见神经网络 2.神经…...

【TextIn—智能文档解析与DocFlow票据AI自动化处理:赋能企业文档数字化管理与数据治理的双重利器】

TextIn—智能文档解析与票据AI自动化处理&#xff1a;赋能企业文档数字化管理与数据治理的双重利器 ​ 在数据驱动的时代&#xff0c;企业面临的挑战不仅在于海量数据的整理和响应速度的提高&#xff0c;更在于如何有效管理和利用这些日益增长的海量信息。尤其是在信息日趋多样…...