@TOC

纯血鸿蒙创业大赛_Vue.js

欢迎关注微信公众号:数据科学与艺术

功能:

  1. 晨间日记:每天早上用户可以记录当前的心情、目标、计划等内容,用于后续的复盘和分析。
  2. 代办:用户可以创建代办事项,并设置优先级和截止日期,以帮助他们更好地管理日常任务。
  3. 目标:用户可以设定人生使命、年目标、月目标和周目标,以帮助他们有个清晰的方向和计划。
  4. 习惯记录:用户可以记录每天的习惯执行情况,如锻炼、阅读、学习等,以形成健康的生活习惯。
  5. 番茄钟:用户可以使用番茄钟技术来提高工作效率,设定工作时间和休息时间,并进行倒计时。

一个实现番茄钟的简单代码示例:

import time

def pomodoro_timer(work_minutes, rest_minutes):
    print("Work for {} minutes".format(work_minutes))
    time.sleep(work_minutes * 60)  # 将分钟转换为秒,并进行倒计时

    print("Rest for {} minutes".format(rest_minutes))
    time.sleep(rest_minutes * 60)  # 将分钟转换为秒,并进行倒计时

work_duration = 25  # 工作时间(单位:分钟)
rest_duration = 5  # 休息时间(单位:分钟)

for _ in range(4):  # 进行四个番茄钟循环
    pomodoro_timer(work_duration, rest_duration)

使用了 time 模块中的 sleep 函数,以秒为单位进行倒计时。pomodoro_timer 函数接受两个参数:work_minutes(工作时间)和 rest_minutes(休息时间),首先输出工作时间,然后休眠指定的工作时间。接着输出休息时间,并休眠指定的休息时间。

在主程序中,我们设定了工作时间为 25 分钟,休息时间为 5 分钟,并使用一个循环来进行四个番茄钟的计时。您可以根据需要自定义工作时间和休息时间,以及循环次数。

AI功能:

  1. 目标复盘:AI会根据用户的日记进行复盘分析,并提供反馈和建议,帮助用户更好地理解自己的行为和进步。
  2. 代办建议:AI会根据代办任务的优先级和截止日期,提供建议和监督,帮助用户更好地管理任务。
  3. 习惯执行监督和建议:AI会根据用户的习惯记录,监督和提供建议,帮助用户养成良好的习惯。
  4. 激励语:AI会根据用户的目标和进度,提供激励和支持的话语,鼓励用户坚持努力。

目标复盘的代码实现:

def goal_review(diary):
    # 根据日记内容进行复盘分析
    # 分析用户是否达到了目标,并给出反馈和建议
    # 返回复盘结果
    if diary == "":
        return "请先写下今天的日记"
    else:
        # 进行复盘分析
        analysis = analyze_diary(diary)
        feedback = generate_feedback(analysis)
        suggestions = generate_suggestions(analysis)
        return f"复盘结果:{feedback}。\n建议:{suggestions}"

代办建议的代码实现:

def todo_suggestions(todos):
    # 根据代办任务的优先级和截止日期进行建议和监督
    # 返回建议结果
    if len(todos) == 0:
        return "当前没有待办任务"
    else:
        # 进行建议和监督
        suggestions = generate_suggestions(todos)
        supervision = generate_supervision(todos)
        return f"建议:{suggestions}\n监督:{supervision}"

习惯执行监督和建议的代码实现:

def habit_advice(habits):
    # 根据用户的习惯记录进行监督和建议
    # 返回建议结果
    if len(habits) == 0:
        return "当前没有习惯记录"
    else:
        # 进行监督和建议
        supervision = generate_supervision(habits)
        advice = generate_advice(habits)
        return f"监督:{supervision}\n建议:{advice}"

激励语的代码实现:

def motivation(goal, progress):
    # 根据用户的目标和进度,提供激励和支持的话语
    # 返回激励语
    if goal == "":
        return "请先设置目标"
    else:
        # 根据进度生成激励语
        motivation = generate_motivation(goal, progress)
        return motivation

鸿蒙功能:

  1. 多屏协同:用户可以在多个设备上同步数据和使用功能,实现更好的使用体验。
  2. 手表同步睡眠习惯:用户可以通过手表记录睡眠习惯,以帮助他们了解自己的睡眠质量。
  3. 手机服务卡片:提供快速记录、执行番茄钟、展示目标和激励语等功能,方便用户在手机上快速使用。
  4. 提醒:通过鸿蒙的提醒功能,定时提醒用户进行习惯记录、复盘和代办任务。
  5. 侧端模型:利用鸿蒙的侧端模型,对用户的数据进行分析和处理,保护用户的隐私和数据安全。
  6. 日历联动:将用户的目标、习惯和代办任务与手机日历进行联动,方便用户在日常生活中查看和调整。

代码实现

在鸿蒙开发中,可以使用多个组件来实现手机服务卡片的功能,包括Text、Button、Timer、Image等。以下是一个简单的示例,演示了如何实现快速记录、执行番茄钟、展示目标和激励语等功能。

  1. 在xml布局文件中添加所需的组件:
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
        xmlns:ohos="http://schemas.huawei.com/res/ohos"
        ohos:height="match_parent"
        ohos:width="match_parent">

    <!-- 快速记录 -->
    <TextField
            ohos:height="50vp"
            ohos:width="match_parent"
            ohos:hint="输入记录"
            ohos:input-type="textPersonName" />

    <!-- 执行番茄钟 -->
    <Button
            ohos:height="50vp"
            ohos:width="match_parent"
            ohos:text="开始番茄钟"
            ohos:id="$+id/pomodoro_button" />

    <!-- 目标展示 -->
    <Text
            ohos:height="wrap_content"
            ohos:width="match_parent"
            ohos:text="今日目标:学习鸿蒙开发" />

    <!-- 激励语展示 -->
    <Text
            ohos:height="wrap_content"
            ohos:width="match_parent"
            ohos:text="加油,你可以的!" />

</DirectionalLayout>
  1. 在Java代码中设置按钮点击事件和番茄钟功能:
package com.example.myapplication;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;

public class MainAbility extends Ability {

    private Button pomodoroButton;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        // 获取番茄钟按钮
        pomodoroButton = (Button) findComponentById(ResourceTable.Id_pomodoro_button);

        // 设置番茄钟按钮点击事件
        pomodoroButton.setClickedListener(component -> startPomodoro());

    }

    // 执行番茄钟
    private void startPomodoro() {
        // 在此处添加番茄钟功能的代码
    }
}
  1. 添加具体的番茄钟功能代码:

可以使用Timer类来实现番茄钟功能,如下所示:

import ohos.global.resource.NotExistException;
import ohos.global.resource.Resource;
import ohos.global.resource.ResourceManager;
import ohos.global.resource.WrongTypeException;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import ohos.hiviewdfx.HiLogType;
import ohos.timer.Timer;
import ohos.utils.zson.ZSONObject;

import java.io.IOException;

public class MainAbility extends Ability {

    private static final HiLogLabel LABEL_LOG = new HiLogLabel(HiLog.LOG_APP, 0x00101, "MY_TAG");

    private Button pomodoroButton;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        // 获取番茄钟按钮
        pomodoroButton = (Button) findComponentById(ResourceTable.Id_pomodoro_button);

        // 设置番茄钟按钮点击事件
        pomodoroButton.setClickedListener(component -> startPomodoro());

    }

    // 执行番茄钟
    private void startPomodoro() {
        Timer timer = new Timer();

        // 设置番茄钟时间(25分钟)
        long pomodoroTime = 25 * 60 * 1000;

        // 设置休息时间(5分钟)
        long restTime = 5 * 60 * 1000;

        // 启动番茄钟
        timer.startTimer(pomodoroTime, (timerId, millSeconds) -> {
            // 通过HiLog打印番茄钟剩余时间
            HiLog.debug(LABEL_LOG, "Pomodoro timer: " + millSeconds / 1000 + "s");
        });

        // 启动休息时间
        timer.startTimer(pomodoroTime + restTime, (timerId, millSeconds) -> {
            // 通过HiLog打印休息时间剩余时间
            HiLog.debug(LABEL_LOG, "Rest timer: " + millSeconds / 1000 + "s");
        });
    }
}

解决的问题:

HabitAI旨在帮助现代社会上进但容易沉迷于虚无事物的青年群体。通过集合晨间日记、代办、目标、习惯记录和番茄钟等功能,以及AI的智能分析和反馈,帮助用户培养良好的习惯和达成人生目标。与其他单一功能的APP不同,HabitAI提供综合且智能化的解决方案,帮助用户在信息爆炸的时代更好地管理自己的时间和行为,实现个人成长和进步。