国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
3. Modify the icon and name" >3. Modify the icon and name
Modify desktop icons and names" >Modify desktop icons and names
4. Add relevant permissions" >4. Add relevant permissions
5. Define the data model" >5. Define the data model
6. Load network data" >6. Load network data
Interface Description" >Interface Description
測(cè)試接口" >測(cè)試接口
創(chuàng)建HTTP請(qǐng)求" >創(chuàng)建HTTP請(qǐng)求
七、UI" >七、UI
八、完整源碼" >八、完整源碼
錯(cuò)誤信息
錯(cuò)誤描述
可能原因
處理步驟
Home Computer Tutorials Computer Knowledge Hongmeng native application random poetry

Hongmeng native application random poetry

Feb 19, 2024 pm 01:36 PM
file com Hongmeng

Hongmeng native application random poetry

To learn more about open source, please visit:

51CTO Hongmeng Developer Community

https://ost.51cto.com

Running environment

DAYU200:4.0.10.16

SDK:4.0.10.15

IDE:4.0.600

1. Create an application

Click File->new File->Create Progect.

Select template:

【OpenHarmony】Empty Ability:

Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces).

Compile SDK10, Model: Stage.

Device Type is fine by default.

node, 16.20.1 is recommended.

After completing the above configuration, click Finish.

Choose to open in a new window and wait for the dependencies to be loaded. as the picture shows.

If you get an error when loading dependencies, check your network.

2. Run HelloWord

Power the development board and connect the development board to the computer, as shown in the figure:

sign:

Steps to sign:

Click File->Project struct.

Select the third item Signing Configs.

Here we only need to check Automatically generate. We do not need to check Support HarmonyOS because we are running a development board.

Click Apply or OK.

Now click the button to run the project.

Console printing information:

$ hdc uninstall com.nut.shici
$ hdc shell mkdir data/local/tmp/a1bdb2dbe1724c67a1106c360a3f1d35
$ hdc file send "/Users/jianguo/Desktop/teaching/ohcode/shici/entry/build/default/outputs/default/entry-default-signed.hap" "data/local/tmp/a1bdb2dbe1724c67a1106c360a3f1d35"
$ hdc shell bm install -p data/local/tmp/a1bdb2dbe1724c67a1106c360a3f1d35 
$ hdc shell rm -rf data/local/tmp/a1bdb2dbe1724c67a1106c360a3f1d35
$ hdc shell aa start -a EntryAbility -b com.nut.shici

Proof that the project has been successfully run on the development board.

3. Modify the icon and name

Modify application icon and name:

The directory is in AppScope/app.json5.

{
"app": {
"bundleName": "com.nut.shici",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}

As shown in the figure after modification:

After the modification is successful, as shown in the figure:

Open method, in the Settings-Application Management column.

Modify desktop icons and names

Modify the label and icon in src/main/module.json5 as shown in the figure.

When we modify the label, we just need to modify it in the Chinese directory.

{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}

Modify the Chinese directory.

The effect is as shown in the figure:

4. Add relevant permissions

Because network data is needed, add the intent permission.

Add configuration in modele in src/main/module.json5, and then async.

"requestPermissions": [{
"name": "ohos.permission.INTERNET"
}],

5. Define the data model

Create a new model folder in the ets directory.

Create a new TS File.

export class ShiciModel {
code: number = 0
message: string = ""
data: ShiCi = new ShiCi()
}

export class ShiCi {
content: string = ""
author: string = ""

origin: string = ""
category: string = ""
c1: string = ""
c2: string = ""
c3: string = ""

// "content": "微雨過(guò),小荷翻。榴花開(kāi)欲然。",
// "author": "蘇軾",
// "origin": "阮郎歸·初夏",
// "category": "古詩(shī)文-植物-荷花",
// "c1": "gushiwen",
// "c2": "zhiwu",
// "c3": "hehua"
}

6. Load network data

Interface Description

Prepare the data,

interface

Interface address: https://v2.alapi.cn/api/shici

Request method: [ “GET”, “POST” ]

Request parameters:

name

Required

type

describe

Example

token

true

string

Request token and obtain it from the user center.

User center gets token

format

false

string

返回格式,支持json,text

json

type

string

詩(shī)詞類(lèi)型

all

  • type 參數(shù)值說(shuō)明
  • all 所有類(lèi)型
  • shuqing抒情
  • siji四季
  • shanshui山水
  • tianqi天氣
  • renwu人物
  • shenghuo生活
  • jieri節(jié)日
  • dongwu動(dòng)物
  • zhiwu植物

返回參數(shù):

名稱(chēng)

描述

content

詩(shī)詞內(nèi)容

author

作者

origin

詩(shī)詞題

測(cè)試接口

測(cè)試工具:Postamn。

{
"code": 200,
"msg": "success",
"data": {
"content": "地冷葉先盡,谷寒云不行。",
"author": "李白",
"origin": "冬日歸舊山",
"category": "古詩(shī)文-植物-葉子",
"c1": "gushiwen",
"c2": "zhiwu",
"c3": "yezi"
},
"time": 1704770459,
"usage": 0,
"log_id": "603184784204148736"
}

測(cè)試如圖所示:

創(chuàng)建HTTP請(qǐng)求

導(dǎo)入http模塊:

import http from '@ohos.net.http';
import { BusinessError } from '@ohos.base';

創(chuàng)建createHttp:

let httpRequest = http.createHttp();

填寫(xiě)HTTP地址:

httpRequest.request(// 填寫(xiě)HTTP請(qǐng)求的URL地址,可以帶參數(shù)也可以不帶參數(shù)。URL地址需要開(kāi)發(fā)者自定義。請(qǐng)求的參數(shù)可以在extraData中指定
"https://v2.alapi.cn/api/shici",
{
method: http.RequestMethod.GET, // 可選,默認(rèn)為http.RequestMethod.GET
// // 開(kāi)發(fā)者根據(jù)自身業(yè)務(wù)需要添加header字段
header: [{
'Content-Type': 'application/json'
}],
// 當(dāng)使用POST請(qǐng)求時(shí)此字段用于傳遞內(nèi)容
extraData: {
"token": "自己的token",
"type": "all",
"format": "json"
},
 
}, (err: BusinessError, data: http.HttpResponse) => {
 
}
);

對(duì)網(wǎng)絡(luò)數(shù)據(jù)的處理:

if (!err) {


// data.result為HTTP響應(yīng)內(nèi)容,可根據(jù)業(yè)務(wù)需要進(jìn)行解析
console.info('Result:' + JSON.stringify(data.result));
console.info('code:' + JSON.stringify(data.responseCode));
// data.header為HTTP響應(yīng)頭,可根據(jù)業(yè)務(wù)需要進(jìn)行解析
console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
// 當(dāng)該請(qǐng)求使用完畢時(shí),調(diào)用destroy方法主動(dòng)銷(xiāo)毀
httpRequest.destroy();
} else {
this.message = JSON.stringify(err)
console.error('error:' + JSON.stringify(err));
// 取消訂閱HTTP響應(yīng)頭事件
httpRequest.off('headersReceive');
// 當(dāng)該請(qǐng)求使用完畢時(shí),調(diào)用destroy方法主動(dòng)銷(xiāo)毀
httpRequest.destroy();
}

完成以上配置以后。

在應(yīng)用程序里測(cè)試網(wǎng)絡(luò)請(qǐng)求。

build() {

Column() {

Button("測(cè)試網(wǎng)絡(luò)請(qǐng)求").onClick(() => {
this.httpData()
})
}.width("100%").height("100%").justifyContent(FlexAlign.Center)
}
}

如圖所示:

測(cè)試成功。

如果2300006錯(cuò)誤碼,請(qǐng)檢查網(wǎng)絡(luò)。

七、UI

數(shù)據(jù)獲取到之后,我們就剩在頁(yè)面上顯示了。

U I布局如圖所示。

build() {

Column() {
Text(this.shici.origin).fontSize(30).fontWeight(800)
Text(this.shici.author).fontSize(20).fontWeight(300).fontColor(Color.Orange)
Text(this.shici.category).fontSize(20).fontWeight(300).fontColor(Color.Green)


}.width("100%").height("100%").justifyContent(FlexAlign.Center)
}

八、完整源碼

import http from '@ohos.net.http';
import { BusinessError } from '@ohos.base';
import promptAction from '@ohos.promptAction';
import { ShiCi, ShiciModel } from '../../model/ShiCiModel';


class shiciType {
title: string = ""
desc: string = ""
}

@Entry
@Component
struct Index {
@State shici: ShiCi = new ShiCi()
@State typeList: Array = [
{ title: "抒情",
desc: "shuqing"

},
{ title: "四季",
desc: "siji"

},
{ title: "山水",
desc: "shanshui"

}
,
{ title: "天氣",
desc: "tianqi"

}


]

aboutToAppear() {
this.httpData("all")
}

httpData(type: string) {


// 3.每一個(gè)httpRequest對(duì)應(yīng)一個(gè)HTTP請(qǐng)求任務(wù),不可復(fù)用
let httpRequest = http.createHttp();
//4.
httpRequest.request(// 填寫(xiě)HTTP請(qǐng)求的URL地址,可以帶參數(shù)也可以不帶參數(shù)。URL地址需要開(kāi)發(fā)者自定義。請(qǐng)求的參數(shù)可以在extraData中指定
"https://v2.alapi.cn/api/shici",
{
method: http.RequestMethod.GET, // 可選,默認(rèn)為http.RequestMethod.GET
// // 開(kāi)發(fā)者根據(jù)自身業(yè)務(wù)需要添加header字段
header: [{
'Content-Type': 'application/json'
}],
// 當(dāng)使用POST請(qǐng)求時(shí)此字段用于傳遞內(nèi)容
extraData: {
"token": "你的token",

"type": type,
"format": "json"
},

}, (err: BusinessError, data: http.HttpResponse) => {
if (!err) {
// data.result為HTTP響應(yīng)內(nèi)容,可根據(jù)業(yè)務(wù)需要進(jìn)行解析
console.info('Result:' + JSON.stringify(data.result));
let ShiciModel: ShiciModel = JSON.parse(data.result.toString())
this.shici = ShiciModel.data

console.info('code:' + JSON.stringify(data.responseCode));
 
// 當(dāng)該請(qǐng)求使用完畢時(shí),調(diào)用destroy方法主動(dòng)銷(xiāo)毀
httpRequest.destroy();
} else {

console.error('error:' + JSON.stringify(err));
// 取消訂閱HTTP響應(yīng)頭事件
httpRequest.off('headersReceive');
// 當(dāng)該請(qǐng)求使用完畢時(shí),調(diào)用destroy方法主動(dòng)銷(xiāo)毀
httpRequest.destroy();
}
}
);
}

build() {

Column() {


Row() {
ForEach(this.typeList, (item: shiciType) => {

Text(item.title).fontSize(30).margin(20)
.onClick(() => {

this.httpData(item.desc)
})
})

}

Button(
"抒情"
).onClick(() => {
this.httpData("shuqing")
})

Button(
"四季"
).onClick(() => {
this.httpData("siji")
})


Text(this.shici.origin).fontSize(30).fontWeight(800)
Text(this.shici.author).fontSize(20).fontWeight(300).fontColor(Color.Orange)
Text(this.shici.category).fontSize(20).fontWeight(300).fontColor(Color.Green)


}.width("100%").height("100%").justifyContent(FlexAlign.Center)
}
}

九、總結(jié)

本文我們學(xué)習(xí)了基礎(chǔ)組件的使用,網(wǎng)絡(luò)請(qǐng)求,以及狀態(tài)管理。

十、FAQ

2300006 域名解析失敗

錯(cuò)誤信息

Couldn’t resolve host name。

錯(cuò)誤描述

服務(wù)器的域名無(wú)法解析。

可能原因

  • 傳入的服務(wù)器的URL不正確。
  • 網(wǎng)絡(luò)不通暢。

處理步驟

  • 請(qǐng)檢查輸入的服務(wù)器的URL是否合理。
  • 請(qǐng)檢查網(wǎng)絡(luò)連接情況

想了解更多關(guān)于開(kāi)源的內(nèi)容,請(qǐng)?jiān)L問(wèn):

51CTO 鴻蒙開(kāi)發(fā)者社區(qū)

https://ost.51cto.com

The above is the detailed content of Hongmeng native application random poetry. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
Yu Chengdong steps down as CEO of Huawei Terminal BG, He Gang will take over Yu Chengdong steps down as CEO of Huawei Terminal BG, He Gang will take over May 02, 2024 pm 04:01 PM

According to multiple media reports, Huawei internally issued a personnel adjustment document on the afternoon of April 30, announcing that Yu Chengdong would step down as CEO of Huawei Terminal BG. Yu Chengdong will remain as chairman of Terminal BG. He Gang, the former Huawei Terminal BG and Chief Operating Officer, will take over the position of CEO of Huawei Terminal BG. According to reports, apart from the above-mentioned personal changes and adjustments, the document does not contain any more information. There is no further explanation on the background of this major personnel change and Yu Chengdong’s new business focus after stepping down as CEO of Terminal BG. Some sources said that this adjustment is a routine business structure adjustment, which will allow Yu Chengdong to have more energy to create high-quality products for consumers. Yu Chengdong was born in 1969. He graduated from the Automatic Control Department of Northwestern Polytechnical University with a bachelor's degree and a master's degree from Tsinghua University.

HarmonyOS NEXT native intelligence opens up a new OS experience in the AI ????big model era! Huawei Xiaoyi turns into a smart body HarmonyOS NEXT native intelligence opens up a new OS experience in the AI ????big model era! Huawei Xiaoyi turns into a smart body Jun 22, 2024 am 02:30 AM

AI large models have become a hot topic in the current technology circle. More and more companies are beginning to deploy large model capabilities, and more and more products are beginning to emphasize AI. However, judging from the current experience, most of the AI ??products flooding into the market often simply integrate large model applications at the application level, and do not realize systematic AI technology changes from the bottom up. At HDC2024, with the opening of HarmonyOSNEXT Beta to developers and pioneer users, Huawei demonstrated to the industry what true "native intelligence" is - with system-level AI capabilities, AI is no longer just an add-on to mobile phones, but is integrated with The operating system is deeply integrated and becomes a system-level core capability. According to reports, through the integration of software, hardware and core cloud, HarmonyO

Xiaoyi upgraded to an intelligent agent! HarmonyOS NEXT Hongmeng native intelligence opens a new AI era Xiaoyi upgraded to an intelligent agent! HarmonyOS NEXT Hongmeng native intelligence opens a new AI era Jun 22, 2024 am 01:56 AM

On June 21, Huawei Developer Conference 2024 (HDC2024) gathered again in Songshan Lake, Dongguan. At this conference, the most eye-catching thing is that HarmonyOSNEXT officially launched Beta for developers and pioneer users, and comprehensively demonstrated the three "king-breaking" innovative features of HarmonyOSNEXT in all scenarios, native intelligence and native security. HarmonyOSNEXT native intelligence: Opening a new AI era After abandoning the Android framework, HarmonyOSNEXT has become a truly independent operating system independent of Android and iOS, which can be called an unprecedented rebirth. Among its many new features, native intelligence is undoubtedly the new feature that can best bring users intuitive feelings and experience upgrades.

Deploy large language models locally in OpenHarmony Deploy large language models locally in OpenHarmony Jun 07, 2024 am 10:02 AM

This article will open source the results of "Local Deployment of Large Language Models in OpenHarmony" demonstrated at the 2nd OpenHarmony Technology Conference. Open source address: https://gitee.com/openharmony-sig/tpc_c_cplusplus/blob/master/thirdparty/InferLLM/docs/ hap_integrate.md. The implementation ideas and steps are to transplant the lightweight LLM model inference framework InferLLM to the OpenHarmony standard system, and compile a binary product that can run on OpenHarmony. InferLLM is a simple and efficient L

Hongmeng Smart Travel S9 and full-scenario new product launch conference, a number of blockbuster new products were released together Hongmeng Smart Travel S9 and full-scenario new product launch conference, a number of blockbuster new products were released together Aug 08, 2024 am 07:02 AM

This afternoon, Hongmeng Zhixing officially welcomed new brands and new cars. On August 6, Huawei held the Hongmeng Smart Xingxing S9 and Huawei full-scenario new product launch conference, bringing the panoramic smart flagship sedan Xiangjie S9, the new M7Pro and Huawei novaFlip, MatePad Pro 12.2 inches, the new MatePad Air, Huawei Bisheng With many new all-scenario smart products including the laser printer X1 series, FreeBuds6i, WATCHFIT3 and smart screen S5Pro, from smart travel, smart office to smart wear, Huawei continues to build a full-scenario smart ecosystem to bring consumers a smart experience of the Internet of Everything. Hongmeng Zhixing: In-depth empowerment to promote the upgrading of the smart car industry Huawei joins hands with Chinese automotive industry partners to provide

The last link of Huawei's pure-blood Hongmeng ecosystem! Self-developed Cangjie programming language will make its debut The last link of Huawei's pure-blood Hongmeng ecosystem! Self-developed Cangjie programming language will make its debut Jun 21, 2024 pm 03:23 PM

According to news on June 21, this afternoon, Huawei Developer Conference 2024 will be officially opened. "Pure-blood Hongmeng" Harmony OS NEXT is naturally a top priority. According to the plan previously revealed by Yu Chengdong, the public beta may be officially announced this afternoon, and ordinary consumers can also try out "pure-blood Harmony". According to reports, the first batch of supported mobile phones are the Mate60 series and Pura70 series. It is worth noting that as a "pure-blooded Hongmeng", HarmonyOSNEXT has removed the traditional Linux kernel and AOSP Android open source code and developed the entire stack in-house. According to the latest report from Sina Technology, Huawei will also complete the last link of Hongmeng Ecosystem and expand its presence in the world.

Huawei's light field screen technology debuts at new product launch conference, creating a new immersive in-car viewing experience Huawei's light field screen technology debuts at new product launch conference, creating a new immersive in-car viewing experience May 07, 2024 pm 03:30 PM

Huawei announced that it will hold a grand new product launch conference for smart car solutions in Beijing on May 7, 2024. At the meeting, Huawei focused on promoting its innovative product, light field screen, and shared its latest progress and breakthroughs in the field of automotive display technology. This in-vehicle display is a new product with built-in capabilities to create an immersive visual experience within the limited space inside the vehicle. It can project a clear picture of 35 inches to 40 inches at a viewing distance of 3 meters to 40 feet, which not only provides passengers with a wider field of view, but also effectively reduces visual fatigue and motion sickness caused by watching the screen for a long time. The light field screen is the only product on the market today that has won the SGS automotive display low motion sickness gold label certification, and its performance in mitigating motion sickness has been professionally certified. In addition, the

Huawei Hongmeng system supports mobile phone models revealed (Huawei Hongmeng system has strong compatibility) Huawei Hongmeng system supports mobile phone models revealed (Huawei Hongmeng system has strong compatibility) May 05, 2024 pm 12:01 PM

People are very concerned about the mobile phone models supported by this system, with the release of Huawei Hongmeng system. This article will introduce in detail the mobile phone models supported by Huawei Hongmeng system as well as their features and advantages. 1: Huawei Mate series - the powerful flagship model is naturally one of the first mobile phones to support Hongmeng system. The Huawei Mate series is Huawei's flagship model. For models such as Mate30 or Mate20, you can experience the new functions and optimizations brought by Hongmeng system through system upgrades, whether it is Mate40. 2: Huawei P series - powerful imaging mobile phone Huawei P series has always been sought after by the majority of users for its excellent camera capabilities. Users can enjoy a smoother and smoother operating experience during the photo taking process. The good news is that Huawei P series

See all articles