鸿蒙harmony天气预报Demo

news2024/9/23 23:34:17

1.准备工作

1.1创建项目

在这里插入图片描述

sdk为6版本,所以使用华为的远程模拟器p40即可。

1.2准备图片资源

这里把天气预报用到的天气提示的图片全放在资源目录下的media文件下。

具体资源在github仓库已包含,自行前往。

1.3配置文件

接着是修改配置文件,由于是发送网络请求请求api获取json天气数据,所以和安卓一样,需要修改配置文件,添加网络请求权限。

修改config.json,在module节点添加如下权限。

"reqPermissions": [
  {
    "name": "ohos.permission.INTERNET"
  },
  {
    "name": "ohos.permission.GET_NETWORK_INFO"
  },
  {
    "name": "ohos.permission.SET_NETWORK_INFO"
  }
],

接着还要配置http协议的api也能正常访问。在module和app同级添加如下。

"deviceConfig": {
  "default": {
    "network": {
      "cleartextTraffic": true
    }
  }
},

如果想要去除页面顶部的标题区域,接着添加如下配置。

"metaData": {
  "customizeData": [
    {
      "name": "hwc-theme",
      "value": "androidhwext:style/Theme.Emui.NoTitleBar"
    }
  ]
}

最后添加完成预览:
在这里插入图片描述

2.网络请求工具类

天气api以前文章提到过,自行前往–>简易的安卓天气app(一)——解析Json数据、数据类封装

最后得到的api形式为:

https://tianqiapi.com/api?version=v1&appid={your appid}&appsecret={your appsecret}

其中appid和appsecret需要自行申请,免费版有请求上限。

此api会默认根据访问者ip的地理位置进行定位。又因为虚拟手机没法获取设备位置且本人没有华为设备,没法加入定位功能,,所以暂时在代码中指定需要查询的城市,,,

2.1NetworkUtil

网络请求工具类,返回api获取的string字符串就行

public class NetworkUtil {
    /**
     * 18625561:27XjzrB7
     * 67342285:5XgTk31r
     * 19267789:Dhu3DShY
     */
    public static final String URL_WEATHER = "https://tianqiapi.com/api?version=v1&appid=67342285&appsecret=5XgTk31r";

    public static String httpGet(String cityName) {
        String urlGetJson = URL_WEATHER + "&city=" + cityName;
        StringBuilder sb = new StringBuilder();
        try {
            URL url = new URL(urlGetJson);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setReadTimeout(10000);
            connection.setConnectTimeout(10000);
            connection.connect();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String temp;
            while ((temp = reader.readLine()) != null) {
                sb.append(temp);
            }
            reader.close();
            connection.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }
        return sb.toString();
    }
}

2.2测试网络请求

为了保证主线程不受干扰,网络请求需要单独开辟一个异步线程请求数据。详情前往鸿蒙开发指南线程管理开发指导

创建一个异步线程:(使用lamda编程,不再new Runnable()实现 )

TaskDispatcher globalTaskDispatcher = getGlobalTaskDispatcher(TaskPriority.DEFAULT);
globalTaskDispatcher.asyncDispatch(() -> {
	//网络请求,城市名指定即可,此处指定北京
    //String result = NetworkUtil.httpGet(cityName);
    String result = NetworkUtil.httpGet("北京");
    System.out.println(result);
}

成功获取数据:

在这里插入图片描述

2.3api返回数据结构

在这里插入图片描述

3.实体类封装

需要两个实体类封装数据:

在这里插入图片描述

WeatherBean封装城市名称更新时间即可,其中还包含DayWeatherBean的数组存放七天天气。

DayWeatherBean就是七天的每一天的天气详情,每天的天气还包含24小时详细天气,本文不再详细探讨。

public class WeatherBean implements Serializable {

    @SerializedName("cityid")
    private String cityid;

    private String city;//城市名称

    private String update_time;//更新时间

    private List<DayWeatherBean> data;//获取今日天气,get[0]
    // get set toString。。。
}
public class DayWeatherBean implements Serializable {
    @SerializedName("date")
    private String date;
    private String wea;//天气
    private String wea_img;//天气图标
    private String week;//周几
    private String tem;//温度
    //tv_tem_low_high=tem2+tem1拼接一起
    private String tem2;//低温
    private String tem1;//高温
    //tv_win=win+win_speed
    private String[] win;//风力
    private String win_speed;//风力等级
    //tv_air=air+air_level+air_tips拼接一起
    private String air;//
    private String air_level;//
    private String air_tips;//

//    @SerializedName("hours")
//    private List<HoursWeatherBean> hoursWeatherBeanList;

//    @SerializedName("index")
//    private List<TipsBean> mTipsBeans;

    // get set toString。。。
}

封装数据使用Google的gson进行

首先引入gson依赖:打开build.gradle添加依赖,别忘了右上角Sync Now同步一下

implementation 'com.google.code.gson:gson:2.8.5'

在这里插入图片描述

对获取到的数据result进行封装:得到WeatherBean对象

Gson gson = new Gson();
WeatherBean weatherBean = gson.fromJson(result, WeatherBean.class);

在这里插入图片描述

之后就是把数据渲染到ui上即可。

4.ui

4.1首页ui设计

使用StackLayout把壁纸放在最下面一层,接着就是DirectionalLayout布局。

使用ScrollView组件包裹DirectionalLayout可以使布局上下滑动,超出屏幕布局可滑动屏幕查看。

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<StackLayout
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent">

    <Image
        ohos:id="$+id:bg"
        ohos:height="match_parent"
        ohos:width="match_parent"
        ohos:background_element="$media:bg"
        ohos:scale_mode="center"/>

    <DirectionalLayout
        ohos:height="match_parent"
        ohos:width="match_parent"
        ohos:orientation="vertical">

        <!--头部bar-->
        <DirectionalLayout
            ohos:height="match_content"
            ohos:width="match_parent"
            ohos:bottom_margin="8vp"
            ohos:orientation="horizontal"
            ohos:top_margin="8vp">

            <Image
                ohos:id="$+id:add"
                ohos:height="30vp"
                ohos:width="30vp"
                ohos:image_src="$media:add"
                ohos:layout_alignment="horizontal_center"
                ohos:left_margin="20vp"
                ohos:scale_mode="clip_center"/>

            <Text
                ohos:id="$+id:text_city"
                ohos:height="match_parent"
                ohos:width="260vp"
                ohos:layout_alignment="horizontal_center"
                ohos:text="郑州"
                ohos:text_alignment="horizontal_center"
                ohos:text_color="#000"
                ohos:text_size="26fp"/>

            <Image
                ohos:id="$+id:more"
                ohos:height="30vp"
                ohos:width="30vp"
                ohos:image_src="$media:more"
                ohos:layout_alignment="horizontal_center"
                ohos:right_margin="20vp"
                ohos:scale_mode="clip_center"/>

        </DirectionalLayout>

        <!--分割白横线-->
        <ProgressBar
            ohos:id="$+id:progressbar"
            ohos:height="6vp"
            ohos:width="match_parent"
            ohos:max="100"
            ohos:min="0"
            ohos:progress="100"
            ohos:progress_element="#FFF6F0F0"
            ohos:progress_width="10vp"/>

        <ScrollView
            ohos:rebound_effect="true"
            ohos:height="match_parent"
            ohos:width="match_parent">

        <DirectionalLayout
            ohos:height="match_parent"
            ohos:width="match_parent"
            ohos:layout_alignment="horizontal_center"
            ohos:orientation="vertical"
            ohos:top_margin="10vp"
            >
            <!--ohos:scale_mode="stretch"表示将原图缩放到与Image大小一致-->
            <Image
                ohos:id="$+id:weather_img"
                ohos:height="100vp"
                ohos:width="120vp"
                ohos:image_src="$media:weather_yin"
                ohos:layout_alignment="horizontal_center"
                ohos:scale_mode="stretch"/>

            <Text
                ohos:id="$+id:text_weather"
                ohos:height="match_content"
                ohos:width="match_content"
                ohos:layout_alignment="horizontal_center"
                ohos:text="阴转多云"
                ohos:text_color="#000"
                ohos:text_size="20fp"/>

            <Text
                ohos:id="$+id:text_tem"
                ohos:height="match_content"
                ohos:width="match_content"
                ohos:layout_alignment="horizontal_center"
                ohos:text="26°C"
                ohos:text_color="#000"
                ohos:text_size="50fp"/>

            <Text
                ohos:id="$+id:text_tem_low_high"
                ohos:height="match_content"
                ohos:width="match_content"
                ohos:layout_alignment="horizontal_center"
                ohos:text="20°C/30°C"
                ohos:text_color="#000"
                ohos:text_size="20fp"/>

            <Text
                ohos:id="$+id:text_week"
                ohos:height="match_content"
                ohos:width="match_content"
                ohos:layout_alignment="horizontal_center"
                ohos:text="星期日"
                ohos:text_color="#000"
                ohos:text_size="20fp"/>

            <!--风向以及出行建议-->
            <DirectionalLayout
                ohos:height="match_content"
                ohos:width="match_parent"
                ohos:left_margin="10vp"
                ohos:right_margin="10vp"
                ohos:top_padding="6vp"
                ohos:bottom_padding="6vp"
                ohos:background_element="$graphic:background_ability_main"
                ohos:layout_alignment="horizontal_center"
                ohos:orientation="horizontal"
                >
                <!--左侧-->
                <DirectionalLayout
                    ohos:height="match_content"
                    ohos:width="match_content"
                    ohos:left_margin="10vp"
                    ohos:right_margin="10vp"
                    ohos:layout_alignment="horizontal_center"
                    ohos:orientation="vertical"
                    >
                    <Image
                        ohos:height="60vp"
                        ohos:width="60vp"
                        ohos:image_src="$media:fengli"
                        ohos:layout_alignment="horizontal_center"
                        ohos:scale_mode="stretch"/>
                    <Text
                        ohos:id="$+id:text_win"
                        ohos:height="match_content"
                        ohos:width="match_content"
                        ohos:layout_alignment="horizontal_center"
                        ohos:text="西北风3~4级"
                        ohos:text_color="#fff"
                        ohos:text_size="16fp"/>
                </DirectionalLayout>
                <!--右侧-->
                <DirectionalLayout
                    ohos:height="match_content"
                    ohos:width="match_parent"
                    ohos:left_margin="10vp"
                    ohos:right_margin="10vp"
                    ohos:layout_alignment="horizontal_center"
                    ohos:orientation="vertical"
                    >
                    <!--空气质量-->
                    <DirectionalLayout
                        ohos:height="match_content"
                        ohos:width="match_parent"
                        ohos:orientation="horizontal"
                        ohos:layout_alignment="horizontal_center"
                        ohos:alignment="right"
                        >
                        <Image
                            ohos:height="30vp"
                            ohos:width="30vp"
                            ohos:image_src="$media:kongqi"
                            ohos:layout_alignment="horizontal_center"
                            ohos:scale_mode="stretch"/>
                        <Text
                            ohos:id="$+id:text_air"
                            ohos:height="match_content"
                            ohos:width="match_content"
                            ohos:layout_alignment="horizontal_center"
                            ohos:text="43 | 优"
                            ohos:text_color="#fff"
                            ohos:text_size="16fp"/>

                    </DirectionalLayout>

                    <!--出行建议-->
                    <DirectionalLayout
                        ohos:height="match_content"
                        ohos:width="match_parent"
                        >
                        <Text
                            ohos:id="$+id:text_tips"
                            ohos:height="match_parent"
                            ohos:width="match_content"
                            ohos:multiple_lines="true"
                            ohos:max_text_lines="3"
                            ohos:truncation_mode="ellipsis_at_end"
                            ohos:text="儿童、老年人及心脏病、呼吸系统疾病患者应尽量减少体力消耗大的户外活动。"
                            ohos:text_color="#FF9F02FF"
                            ohos:text_size="13fp"/>

                    </DirectionalLayout>

                </DirectionalLayout>

            </DirectionalLayout>

            <ListContainer
                ohos:id="$+id:list_container"
                ohos:height="match_content"
                ohos:width="match_parent"
                ohos:left_margin="10vp"
                ohos:right_margin="10vp"
                ohos:top_margin="10vp"
                ohos:top_padding="6vp"
                ohos:bottom_padding="6vp"
                ohos:background_element="$graphic:background_ability_main"
                ohos:layout_alignment="horizontal_center"
                ohos:orientation="vertical"/>

        </DirectionalLayout>
        </ScrollView>

    </DirectionalLayout>

</StackLayout>

还包含一个ListContainer渲染未来七天天气数据。list_item的模板设计:

<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:left_margin="20vp"
    ohos:right_margin="20vp"
    ohos:orientation="horizontal"
    ohos:alignment="horizontal_center">
    <Text
        ohos:id="$+id:text_date"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:weight="1"
        ohos:text="11-11"
        ohos:text_color="#fff"
        ohos:text_size="20fp"/>
    <Image
        ohos:id="$+id:day_weather_img"
        ohos:height="30vp"
        ohos:width="30vp"
        ohos:weight="1"
        ohos:image_src="$media:weather_yin"
        ohos:scale_mode="inside"/>
    <Text
        ohos:id="$+id:text_tem_low_high"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_alignment="right"
        ohos:weight="1"
        ohos:text="20°C/30°C"
        ohos:text_color="#fff"
        ohos:text_size="20fp"/>
</DirectionalLayout>

实现效果:

在这里插入图片描述

4.2获取图片位置工具

获取到api返回的数据后,把数据封装成实体类,其中wea_img属性接受一个string字符串,判断字符串的值返回对应图片资源的int整型。

package com.roydon.weatherforcast.utils;

import com.roydon.weatherforcast.ResourceTable;

public class WeatherImgUtil {

    public static int getImgResOfWeather(String weaStr) {
        int result = 0;
        switch (weaStr) {
            case "qing":
                result = ResourceTable.Media_weather_yin;
                break;
            case "yin":
                result = ResourceTable.Media_weather_yin;
                break;
            case "yu":
                result = ResourceTable.Media_weather_dayu;
                break;
            case "yun":
                result = ResourceTable.Media_weather_duoyun;
                break;
            case "bingbao":
                result = ResourceTable.Media_weather_leizhenyubingbao;
                break;
            case "wu":
                result = ResourceTable.Media_weather_wu;
                break;
            case "shachen":
                result = ResourceTable.Media_weather_shachenbao;
                break;
            case "lei":
                result = ResourceTable.Media_weather_leizhenyu;
                break;
            case "xue":
                result = ResourceTable.Media_weather_daxue;
                break;
            default:
                result = ResourceTable.Media_weather_qing;
                break;
        }
        return result;
    }
}

4.3渲染数据

组件全部注册好之后,封装一个渲染数据的方法。

public void dataShow(WeatherBean weatherBean) {
    if (weatherBean == null) {
        return;
    }
    city.setText(weatherBean.getCity());
    DayWeatherBean dayWeather = weatherBean.getData().get(0);//当天天气
    if (dayWeather == null) {
        return;
    }
    // 当天天气
    weatherImg.setPixelMap(WeatherImgUtil.getImgResOfWeather(dayWeather.getWea_img()));
    weather.setText(dayWeather.getWea());
    tem.setText(dayWeather.getTem());
    temLowHigh.setText(dayWeather.getTem2() + "/" + dayWeather.getTem1());
    week.setText(dayWeather.getWeek());
    win.setText(dayWeather.getWin()[0] + dayWeather.getWin_speed());
    air.setText(dayWeather.getAir() + " | " + dayWeather.getAir_level());
    tips.setText("👒:" + dayWeather.getAir_tips());
    // ListContainer展示未来七天天气
    List<DayWeatherBean> dayWeatherBeanList = weatherBean.getData();
    DayWeatherBeanProvider dayWeatherBeanProvider = new DayWeatherBeanProvider(dayWeatherBeanList, this);
    listContainer.setItemProvider(dayWeatherBeanProvider);
}

获取api数据与渲染ui独立封装一个方法:

其中渲染ui需要开辟ui异步线程getUITaskDispatcher().asyncDispatch()

/**
 * GlobalTaskDispatcher 派发异步任务
 */
public void getWeather(String cityName) {
    //网络请求
    TaskDispatcher globalTaskDispatcher = getGlobalTaskDispatcher(TaskPriority.DEFAULT);
    globalTaskDispatcher.asyncDispatch(() -> {
        String result = NetworkUtil.httpGet(cityName);
        // System.out.println(result);
        Gson gson = new Gson();
        WeatherBean weatherBean = gson.fromJson(result, WeatherBean.class);
        if (weatherBean == null) {
            getUITaskDispatcher().asyncDispatch(() -> {
                ToastUtil.showToast(this, "貌似出了点问题~");
            });
        } else {
            System.out.println(weatherBean);
            getUITaskDispatcher().asyncDispatch(() -> {
                ToastUtil.showToast(this, weatherBean.getCity() + "天气更新");
                dataShow(weatherBean);
            });
        }
    });
}

4.3.1ListContainer

跟安卓一样,也是需要适配器。用来渲染哪个模板,并把数据渲染到模板。

①新建provider包,包中新建DayWeatherBeanProvider适配器继承自BaseItemProvider

②重写BaseItemProvider中的方法,鼠标悬停会提示。

 @Override
public int getCount() {
    return list == null ? 0 : list.size();
}

@Override
public Object getItem(int i) {
    if (list != null && i >= 0 && i < list.size()){
        return list.get(i);
    }
    return null;
}

@Override
public long getItemId(int i) {
    //可添加具体处理逻辑
    return i;
}

Override
public Component getComponent(int i, Component component, ComponentContainer componentContainer) {
    return null;
}

③添加数据集合List与AbilitySlice,并创建构造方法。

private List<DayWeatherBean> list;
private AbilitySlice slice;

public DayWeatherBeanProvider(List<DayWeatherBean> list, AbilitySlice slice) {
    this.list = list;
    this.slice = slice;
}

④重写getComponent(),渲染模板

@Override
public Component getComponent(int i, Component component, ComponentContainer componentContainer) {
    final Component cpt;
    if (component == null) {
        cpt = LayoutScatter.getInstance(slice).parse(ResourceTable.Layout_item_day_weather, null, false);
    } else {
        cpt = component;
    }
    DayWeatherBean dayWeatherBean = list.get(i);
    Text date = (Text) cpt.findComponentById(ResourceTable.Id_text_date);
    Text tem = (Text) cpt.findComponentById(ResourceTable.Id_text_tem_low_high);
    Image image = (Image) cpt.findComponentById(ResourceTable.Id_day_weather_img);
    date.setText(dayWeatherBean.getDate().substring(5,10));
    image.setPixelMap(WeatherImgUtil.getImgResOfWeather(dayWeatherBean.getWea_img()));
    tem.setText(dayWeatherBean.getTem2() + "/" + dayWeatherBean.getTem1());
    return cpt;
}
  • 官方开发文档见下方链接
  • ListContainer

如果非得想加入每小时天气数据展示,可前往简易的安卓天气app(二)——适配器、每小时数据展示。
折线图设计可参考安卓WeatherForcast4。
最终效果:

在这里插入图片描述

4.4Toast封装

自定义Toast弹框鸿蒙开发指南也为我们提供好了。详情前往鸿蒙开发指南ToastDialog。

此处封装一个带图片的Toast工具类。渲染时需要开辟ui异步线程。

getUITaskDispatcher().asyncDispatch(() -> {
     ToastUtil.showToast(this, weatherBean.getCity() + "天气更新");
 });

新建两个xml,一个是布局设置主要样式,一个是ui美化设置圆角与背景
在这里插入图片描述

layout_toast.xml

<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:height="match_content"
    ohos:width="match_content"
    ohos:padding="10vp"
    ohos:background_element="$graphic:background_toast_element"
    ohos:orientation="horizontal">
    <Image
        ohos:width="16vp"
        ohos:height="16vp"
        ohos:scale_mode="inside"
        ohos:image_src="$media:icon"/>

    <Text
        ohos:id="$+id:msg_toast"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:layout_alignment="vertical_center"
        ohos:text_size="12fp"/>

</DirectionalLayout>

background_toast_element.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
       ohos:shape="rectangle">
    <solid
        ohos:color="#6B172F6D"/>
    <corners
    	ohos:radius="10vp"/>
</shape>

ToastUtil:

先加载layout_toast布局文件把渲染的消息放进去然后让new出来的ToastDialog加载布局即可。

public class ToastUtil {

    /**
     * @param context 上下文参数
     * @param msg     内容
     */
    public static void showToast(Context context, String msg) {
        DirectionalLayout layout = (DirectionalLayout) LayoutScatter.getInstance(context)
                .parse(ResourceTable.Layout_layout_toast, null, false);
        Text msg_toast = layout.findComponentById(ResourceTable.Id_msg_toast);
        msg_toast.setText(msg);
        new ToastDialog(context)
                .setContentCustomComponent(layout)
                .setSize(DirectionalLayout.LayoutConfig.MATCH_CONTENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT)
                .setAlignment(LayoutAlignment.TOP)
                .show();
    }

    public static void showTips(Context context, String msg) {
        new ToastDialog(context).setText(msg).setAlignment(LayoutAlignment.TOP).show();
    }
}

5.Github源码

源码地址:WeatherDemo

视star情况更新。

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

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

相关文章

[附源码]Python计算机毕业设计SSM家教管理系统(程序+LW)

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

DevComponents.DotNetBar2之SuperTabControl使用技巧

关于类似SuperTabControl的使用如何动态调整其TAB标签的顺序问题&#xff0c;搜了全网也没有找到类似答案&#xff0c;都提到tab键的顺序或者是通过控件界面进行调整其顺序&#xff0c;都不是想要的结果&#xff0c;有个网友问的类似问题但是没有一个答案可用。经过反复测试总结…

华为云Nginx配置

配置yum源 mkdir -p /etc/yum.repos.d/repo_bak/ mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo_bak/ cd /etc/yum.repos.d wget http://mirrors.myhuaweicloud.com/repo/mirrors_source.sh && sh mirrors_source.sh清除原有yum缓存 yum clean all 执行生成新的…

Win10编译Android版本的FFmpeg库

安装MSYS2 下载地址&#xff1a;MSYS2 安装完成后打开MSYS2执行如下命令&#xff0c; 安装所需要的工具链 pacman -S --needed base-devel mingw-w64-x86_64-toolchain下载android NDK 我在Android Studio里面已经下载过了&#xff0c;没有的可以自己百度去官网下载NDK 我…

[矩阵论] Unit 4. 矩阵的广义逆 - 知识点整理

注: 以下内容均由个人整理, 不保证完全准确, 如有纰漏, 欢迎交流讨论参考: 杨明, 刘先忠. 矩阵论(第二版)[M]. 武汉: 华中科技大学出版社, 2005 4 矩阵的广义逆 4.1 矩阵的左逆与右逆 左逆 右逆 Def’ 4.1: 设 A∈CmnA\in C^{m\times n}A∈Cmn ∃B∈Cnm\exists B\in C^{n\t…

MySQL数据库的性能优化及自动化运维与Mysql高并发优化详细教程

首先&#xff0c;我们来看看DBA的具体工作&#xff0c;我觉得 DBA 真的很忙&#xff1a;备份和恢复、监控状态、集群搭建与扩容、数据迁移和高可用&#xff0c;这是我们 DBA 的功能。 了解这些功能以后要对体系结构有更加深入的了解&#xff0c;你不知道怎么处理这些故障和投诉…

FastReport Online Designer 2023

FastReport Online Designer 2023 添加了以ESRI形状文件格式显示图形地图的新地图组件。 添加了一个用于在数据源中选择表的新按钮。 添加了使用“Shift”或“Ctrl”键在报告树中选择多个项目的选项。 现在可以更改多个选定对象的特性值。 在您使用新配置重置选项后,设计器现在…

Servlet—servlet概述

文章目录servlet概述狭义广义总结图示部分细化&#xff1a;tomcat和servlet关系统一资源定位符统一资源定位符详细内容&#xff1a;协议http协议总结图示ip地址————————————————————————————————servlet概述 本质上是java专门用来处理web数据…

Effective C++条款27:尽量少做转型动作(Minimize casting)

Effective C条款27&#xff1a;尽量少做转型动作&#xff08;Minimize casting&#xff09;条款27&#xff1a;尽量少做转型动作1、数据类型转型语法回顾1.1 C风格的cast1.2 C风格的cast1.3 新风格转型更受欢迎2、使用cast会产生运行时代码——不要认为你以为的就是你以为的3、…

“一人负债,全家背锅”,严厉打击信用卡套现欺诈

不可否认&#xff0c;负债消费往往与高风险密不可分。 近日&#xff0c;一则关于网购的新闻冲上热搜。故事的主人公沉迷于网购&#xff0c;工资不足便利用信用卡透支&#xff0c;长期的积累已至入不敷出&#xff0c;只能向家人求助&#xff0c;家人也因此欠下巨额债务。最终&a…

文本-图像生成(Text-to-Image Generation)的评价指标介绍——CLIPScore、TISE

目录CLIPScore: A Reference-free Evaluation Metric for Image Captioning背景公式总结TISE: Bag of Metrics for Text-to-Image Synthesis Evaluation背景文本-图像生成基本评价指标图像质量和多样性图像和文本相关性创新点1&#xff1a;IS*创新点2&#xff1a;多目标文本-图…

GIS基础测量、地形分析、位置分析、空间分析功能介绍与实操应用

通知 入门级、进阶级一、二、三期、高阶级一期已完成&#xff0c;大家可进入公众号“图新地球”查看底部菜单&#xff1a;2022教程&#xff0c;获得软件直播课程的相关资料&#xff0c;包括直播讲解、直播PPT、直播的示例数据。 另外&#xff0c;本周周三12月7日将举行进阶级…

2020全栈学习Demo大合集 AllDemo-996station GitHub鉴赏官

推荐理由&#xff1a; 2020全栈学习Demo大合集 包含最新 hooks TS 等 还有umidva,数据可视化等实战项目 (持续更新中) 全栈学习 Demo 大合集 说明: 本项目包含常用的技术点和技术栈,时间为 2020 年度最新的技术栈,大范围的包含(Vue,Vuex,SSR,vue 源码解析,vue 实战,vue 单元测…

使用php解压缩ZipArchive类实现后台管理升级的解决方案

项目说明 开发php项目管理系统&#xff0c;由于是新项目且已经部署在生产环境&#xff0c;导致需要根据实际使用情况&#xff0c;进行及时的功能升级或bug修复。 每次升级&#xff0c;进行程序打包&#xff0c;然后通过FTP上传覆盖&#xff1b;后期因服务器转为内网&#xff…

自然语言处理基本概念 natural_language_processing-996station GitHub鉴赏官

推荐理由&#xff1a;自然语言处理基本概念 自然语言处理技术 第1章 语言模型 第2章 隐马尔可夫模型 第3章 最大熵模型 第4章 条件随机场模型 适用人群&#xff1a;自然语言 推荐指数&#xff1a;3 项目名称&#xff1a;natural_language_processing 自然语言处理基本概念 …

二叉树的遍历

二叉树的遍历 文章目录二叉树的遍历•二叉树的遍历定义• 二叉树的三种遍历方式先序遍历的递归算法中序和后序遍历的递归算法二叉树遍历的相关问题♥问题1解题模型▪算法构思:▪代码实现:♥问题2解题模型构建思路:代码如下:♥问题3算法构思:代码构建:♥问题4算法思路:解题模型:…

mysql读写分离

MySQL读写分离 原理 读写分离基本的原理是让主数据库处理事务性增、改、删操作&#xff08;INSERT、UPDATE、DELETE&#xff09;&#xff0c;而从数据库处理SELECT查询操作。数据库复制被用来把事务性操作导致的变更同步到集群中的从数据库。 读写分离就是只在主服务器上写&…

自学前端到什么程度,可以去找工作呢?

前言 可以看看现在市面上关于前端工程师职业招聘的相关要求&#xff0c;从以下两个的招聘可以看出&#xff0c;无论是普通的前端构造工程师还是高级前端开发工程师&#xff0c;对于h5、css3、es6以及相关框架如vue、react等都需要有深入的认知并能熟练运用 基于上面的相关要求…

刷爆力扣之第三大的数

刷爆力扣之第三大的数 HELLO&#xff0c;各位看官大大好&#xff0c;我是阿呆 &#x1f648;&#x1f648;&#x1f648; 今天阿呆继续记录下力扣刷题过程&#xff0c;收录在专栏算法中 &#x1f61c;&#x1f61c;&#x1f61c; 该专栏按照不同类别标签进行刷题&#xff0c;每…

(四)Spring Security Oauth2.0 源码分析--客户端端鉴权(token校验)

一 引言 在上篇文章我们分析了token的获取过程,那么拿到token后,将token放在请求头中进行资源的访问,客户端是如如何对token进行解析的呢,本文带你走进token校验的源码解析,基本流程如下所示 客户端向资源服务器发起请求时,在请求头Authorization携带申请的token请求被Filte…