鸿蒙中自定义slider实现字体大小变化

news2025/1/15 13:11:15

ui:

import { display, mediaquery, router } from '@kit.ArkUI'
import CommonConstants from './CommonConstants';
import PreferencesUtil from './PreferencesUtil';
import StyleConstants from './StyleConstants';


// 字体大小
@Entry
@Component
struct FontSize {
  @State TopBar: string[] = ['取消', '字体大小预览', '确定']
  @State sliderTitle: string[] = ['A', '标准', '', 'A']
  @State changeFontSize: number = 12;
  @State outSetValueOne: number = 40
  @State offsetX: number = 0;
  @State lineW: number = 0
  @State circleW: number = 18
  @State circleH: number = 18
  @State minW: number = 0
  @State scaleArr: number[] = []
  @State acrossOrVertical: string = ''

  aboutToAppear() {


    PreferencesUtil.getChangeFontSize().then((value) => {
      this.changeFontSize = value;
      if (this.changeFontSize === CommonConstants.SET_SIZE_EXTRA_LARGE) {
        this.offsetX = CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL
      } else if (this.changeFontSize === CommonConstants.SET_SIZE_LARGE) {
        this.offsetX = CommonConstants.SET_SCALE_LARGE_VERTICAL
      } else if (this.changeFontSize === CommonConstants.SET_SIZE_NORMAL) {
        this.offsetX = CommonConstants.SET_SCALE_NORMAL_VERTICAL
      } else if (this.changeFontSize === CommonConstants.SET_SIZE_SMALL) {
        this.offsetX = CommonConstants.SET_SCALE_SMALL_VERTICAL
      }
    });
    this.scaleArr = [CommonConstants.SET_SCALE_SMALL_VERTICAL, CommonConstants.SET_SCALE_NORMAL_VERTICAL,
      CommonConstants.SET_SCALE_LARGE_VERTICAL, CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL]
    this.lineW = CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL //pad竖屏
  }

  callbackOffset() {
    // if (this.offsetX === 18) {
    //   return 0 - this.circleW / 2
    // }
    return this.offsetX - this.circleW / 2
  }

  changeFontSize_Across() {
    if (this.offsetX > CommonConstants.SET_SCALE_SMALL_ACROSS &&
      this.offsetX <= CommonConstants.SET_SCALE_NORMAL_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS) {
      this.changeFontSize = CommonConstants.SET_SIZE_SMALL
    } else if (this.offsetX >
      CommonConstants.SET_SCALE_NORMAL_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS / 2 &&
      this.offsetX <= CommonConstants.SET_SCALE_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS) {
      this.changeFontSize = CommonConstants.SET_SIZE_NORMAL
    } else if (this.offsetX >
      CommonConstants.SET_SCALE_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS &&
      this.offsetX <=
        CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS) {
      this.changeFontSize = CommonConstants.SET_SIZE_LARGE
    } else if (this.offsetX >
      CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS &&
      this.offsetX <= CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS) {
      this.changeFontSize = CommonConstants.SET_SIZE_EXTRA_LARGE
    }
  }

  changeFontSize_Vertical() {
    if (this.offsetX > CommonConstants.SET_SCALE_SMALL_VERTICAL &&
      this.offsetX <=
        CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
      this.changeFontSize = CommonConstants.SET_SIZE_SMALL
    } else if (this.offsetX >
      CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL / 2 &&
      this.offsetX <= CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
      this.changeFontSize = CommonConstants.SET_SIZE_NORMAL
    } else if (this.offsetX >
      CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
      this.offsetX <=
        CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
      this.changeFontSize = CommonConstants.SET_SIZE_LARGE
    } else if (this.offsetX >
      CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
      this.offsetX <= CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL) {
      this.changeFontSize = CommonConstants.SET_SIZE_EXTRA_LARGE
    }
  }

  onTouchGetOffsetX_Vertical(touchesX: number) {
    AlertDialog.show({ message: "1" })
    if (touchesX > CommonConstants.SET_SCALE_SMALL_VERTICAL && touchesX <
      CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
      this.offsetX = CommonConstants.SET_SCALE_SMALL_VERTICAL
    }
    if (touchesX >
      CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
      touchesX <
        CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
      this.offsetX = CommonConstants.SET_SCALE_NORMAL_VERTICAL
    }
    if (touchesX >
      CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
      touchesX <
        CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
      this.offsetX = CommonConstants.SET_SCALE_LARGE_VERTICAL
    }
    if (touchesX >
      CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
      touchesX < CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL) {
      this.offsetX = CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL
    }
  }

  onTouchGetOffsetX_Across(touchesX: number) {
    AlertDialog.show({ message: "2" })
    if (touchesX > CommonConstants.SET_SCALE_SMALL_ACROSS &&
      touchesX < CommonConstants.SET_SCALE_NORMAL_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS) {
      this.offsetX = CommonConstants.SET_SCALE_SMALL_ACROSS
    }
    if (touchesX > CommonConstants.SET_SCALE_NORMAL_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS &&
      touchesX < CommonConstants.SET_SCALE_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS) {
      this.offsetX = CommonConstants.SET_SCALE_NORMAL_ACROSS
    }
    if (touchesX > CommonConstants.SET_SCALE_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS &&
      touchesX < CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS) {
      this.offsetX = CommonConstants.SET_SCALE_LARGE_ACROSS
    }
    if (touchesX > CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS - CommonConstants.SET_SCALE_AVERAGE_ACROSS &&
      touchesX < CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS) {
      this.offsetX = CommonConstants.SET_SCALE_EXTRA_LARGE_ACROSS
    }
  }

  build() {
    Column() {

      Text('实例文案-----你猜你猜猜').fontSize(this.changeFontSize + StyleConstants.UNIT_FP)
      Text(`相应字体大小:${this.changeFontSize}`).fontSize(this.changeFontSize + StyleConstants.UNIT_FP)
      Text(`偏移距离:${this.offsetX}`).fontSize(this.changeFontSize + StyleConstants.UNIT_FP)
      Column() {
        Row() {
          ForEach(this.sliderTitle, (item: string, i: number) => {
            Text(item).fontSize(i === 3 ? 16 : 13)
          })
        }.width('91%').justifyContent(FlexAlign.SpaceBetween)

        Stack() {
          Row() {
            ForEach([1, 2, 3, 4], (item: number) => {
              Text()
                .width(2)
                .height(12)
                .backgroundColor('#646464')
            })
          }.width(this.lineW).justifyContent(FlexAlign.SpaceBetween)

          Stack() {
            Line().width(this.lineW).height(2).backgroundColor('#646464')
            Text()
              .width(this.circleW)
              .height(this.circleH)
              .borderRadius(9)
              .backgroundColor(Color.White)
              .border({ width: 3, color: "#646464" })
              .draggable(true)
              .translate({ x: this.callbackOffset() })
          }
          .width('97%')
          .height(50)
          .alignContent(Alignment.Start)
          .onTouch(async (event) => {
            this.offsetX = event.touches[0].x
            if (event.touches[0].x < this.circleW) {
              this.offsetX = this.circleW
            }
            if (event.touches[0].x > this.lineW) {
              this.offsetX = this.lineW
            }

            if (this.offsetX > CommonConstants.SET_SCALE_SMALL_VERTICAL &&
              this.offsetX <=
                CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
              this.changeFontSize = CommonConstants.SET_SIZE_SMALL
            } else if (this.offsetX >
              CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL / 2 &&
              this.offsetX <= CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
              this.changeFontSize = CommonConstants.SET_SIZE_NORMAL
            } else if (this.offsetX >
              CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
              this.offsetX <=
                CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
              this.changeFontSize = CommonConstants.SET_SIZE_LARGE
            } else if (this.offsetX >
              CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
              this.offsetX <= CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL) {
              this.changeFontSize = CommonConstants.SET_SIZE_EXTRA_LARGE
            }

            // this.changeFontSize_Vertical()

            if (event.type === TouchType.Up) {
              if (event.touches[0].x > CommonConstants.SET_SCALE_SMALL_VERTICAL && event.touches[0].x <
                CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
                this.offsetX = CommonConstants.SET_SCALE_SMALL_VERTICAL
              }
              if (event.touches[0].x >
                CommonConstants.SET_SCALE_NORMAL_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
                event.touches[0].x <
                  CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
                this.offsetX = CommonConstants.SET_SCALE_NORMAL_VERTICAL
              }
              if (event.touches[0].x >
                CommonConstants.SET_SCALE_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
                event.touches[0].x <
                  CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL) {
                this.offsetX = CommonConstants.SET_SCALE_LARGE_VERTICAL
              }
              if (event.touches[0].x >
                CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL - CommonConstants.SET_SCALE_AVERAGE_VERTICAL &&
                event.touches[0].x < CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL) {
                this.offsetX = CommonConstants.SET_SCALE_EXTRA_LARGE_VERTICAL
              }
            }

            if (this.changeFontSize === 0) {
              this.changeFontSize = await PreferencesUtil.getChangeFontSize();
              return;
            }

          })

        }.width('93%')
      }
      .width('100%')
      .height(48)
      .margin({ bottom: 40, top: 5 })
    }
    .height('100%')
    .width('100%')
  }
}

utils_GlobalContext:

/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License,Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

export class GlobalContext {
  private constructor() { }
  private static instance: GlobalContext;
  private _objects = new Map<string, Object>();

  public static getContext(): GlobalContext {
    if (!GlobalContext.instance) {
      GlobalContext.instance = new GlobalContext();
    }
    return GlobalContext.instance;
  }

  getObject(value: string): Object | undefined {
    return this._objects.get(value);
  }

  setObject(key: string, objectClass: Object): void {
    this._objects.set(key, objectClass);
  }
}

utils_CommonConstants:

/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Common constants for all features.
 */
export default class CommonConstants {
  // fontSize
  static readonly SET_SIZE_SMALL: number = 13.6;
  static readonly SET_SIZE_NORMAL: number = 16;
  static readonly SET_SIZE_LARGE: number = 18.4;
  static readonly SET_SIZE_EXTRA_LARGE: number = 20.8;
  //   scale_pad_vertical
  static readonly SET_SCALE_SMALL_VERTICAL: number = 0
  static readonly SET_SCALE_NORMAL_VERTICAL: number = 214
  static readonly SET_SCALE_LARGE_VERTICAL: number = 428
  static readonly SET_SCALE_EXTRA_LARGE_VERTICAL: number = 642
  static readonly SET_SCALE_AVERAGE_VERTICAL: number = 107
  //   scale_pad_across
  static readonly SET_SCALE_SMALL_ACROSS: number = 0
  static readonly SET_SCALE_NORMAL_ACROSS: number = 342
  static readonly SET_SCALE_LARGE_ACROSS: number = 684
  static readonly SET_SCALE_EXTRA_LARGE_ACROSS: number = 1026
  static readonly SET_SCALE_AVERAGE_ACROSS: number = 171
}

utils_PreferencesUtil:

/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { preferences } from '@kit.ArkData';
import { GlobalContext } from './GlobalContext';

const TAG = '[PreferencesUtil]';
const PREFERENCES_NAME = 'myPreferences';
const KEY_APP_FONT_SIZE = 'appFontSize';

/**
 * The PreferencesUtil provides preferences of create, save and query.
 */
export class PreferencesUtil {
  createFontPreferences(context: Context) {
    let fontPreferences: Function = (() => {
      let preference: Promise<preferences.Preferences> = preferences.getPreferences(context, PREFERENCES_NAME);
      return preference;
    });
    GlobalContext.getContext().setObject('getFontPreferences', fontPreferences);
  }

  saveDefaultFontSize(fontSize: number) {
    let getFontPreferences: Function = GlobalContext.getContext().getObject('getFontPreferences') as Function;
    getFontPreferences().then((preferences: preferences.Preferences) => {
      preferences.has(KEY_APP_FONT_SIZE).then(async (isExist: boolean) => {
        if (!isExist) {
          await preferences.put(KEY_APP_FONT_SIZE, fontSize);
          preferences.flush();
        }
      }).catch((err: Error) => {
      });
    }).catch((err: Error) => {
    });
  }

  saveChangeFontSize(fontSize: number) {
    let getFontPreferences: Function = GlobalContext.getContext().getObject('getFontPreferences') as Function;
    getFontPreferences().then(async (preferences: preferences.Preferences) => {
      await preferences.put(KEY_APP_FONT_SIZE, fontSize);
      preferences.flush();
    }).catch((err: Error) => {
    });
  }

  async getChangeFontSize() {
    let fontSize: number = 0;
    let getFontPreferences: Function = GlobalContext.getContext().getObject('getFontPreferences') as Function;
    // const preferences: dataPreferences.Preferences = await getFontPreferences();
    fontSize = await (await getFontPreferences()).get(KEY_APP_FONT_SIZE, fontSize);
    return fontSize;
  }

  async deleteChangeFontSize() {
    let getFontPreferences: Function = GlobalContext.getContext().getObject('getFontPreferences') as Function;
    const preferences: preferences.Preferences = await getFontPreferences();
    let deleteValue = preferences.delete(KEY_APP_FONT_SIZE);
    deleteValue.then(() => {
    }).catch((err: Error) => {
    });
  }
}

export default new PreferencesUtil();

utils_StyleConstants:

/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Style constants for all features.
 */
export default class StyleConstants {
  /**
   * The head aspect ratio.
   */
  static readonly HEAD_ASPECT_RATIO: number = 1;

  /**
   * Weight to fill.
   */
  static readonly WEIGHT_FULL: number = 1;

  /**
   * Minimum height of two lines of text.
   */
  static readonly DOUBLE_ROW_MIN: number = 28;

  /**
   * Unit of fp.
   */
  static readonly UNIT_FP: string = 'fp';

  /**
   * Full the width.
   */
  static readonly FULL_WIDTH: string = '100%';

  /**
   * Full the height.
   */
  static readonly FULL_HEIGHT: string = '100%';

  /**
   * The percentage of 7.2.
   */
  static readonly TITLE_BAR_HEIGHT_PERCENT: string = '7.2%';

  /**
   * The percentage of 93.3.
   */
  static readonly BLOCK_WIDTH_PERCENT: string = '93.3%';

  /**
   * The percentage of 0.5.
   */
  static readonly BLOCK_TOP_MARGIN_FIRST_PERCENT: string = '0.5%';

  /**
   * The percentage of 1.5.
   */
  static readonly BLOCK_TOP_MARGIN_SECOND_PERCENT: string = '1.5%';

  /**
   * The percentage of 23.8.
   */
  static readonly DIVIDER_END_MARGIN_PERCENT: string = '23.8%';

  /**
   * The percentage of 6.7.
   */
  static readonly HEAD_RIGHT_PERCENT: string = '6.7%';

  /**
   * The percentage of 2.2.
   */
  static readonly HEAD_LEFT_PERCENT: string = '2.2%';

  /**
   * The percentage of 64.4.
   */
  static readonly MAX_CHAT_WIDTH_PERCENT: string = '64.4%';

  /**
   * The percentage of 3.1.
   */
  static readonly CHAT_TOP_MARGIN_PERCENT: string = '3.1%';

  /**
   * The percentage of 6.5.
   */
  static readonly SLIDER_LAYOUT_LEFT_PERCENT: string = '6.5%';

  /**
   * The percentage of 3.2.
   */
  static readonly SLIDER_LAYOUT_TOP_PERCENT: string = '3.2%';

  /**
   * The percentage of 8.9.
   */
  static readonly SET_CHAT_HEAD_SIZE_PERCENT: string = '8.9%';

  /**
   * The percentage of 12.5.
   */
  static readonly A_WIDTH_PERCENT: string = '12.5%';

  /**
   * The percentage of 75.
   */
  static readonly SLIDER_WIDTH_PERCENT: string = '75%';

  /**
   * The percentage of 3.3.
   */
  static readonly SLIDER_HORIZONTAL_MARGIN_PERCENT: string = '3.3%';

  /**
   * The percentage of 1.
   */
  static readonly SLIDER_TOP_MARGIN_PERCENT: string = '1%';

  /**
   * The percentage of 6.2.
   */
  static readonly SLIDER_BOTTOM_MARGIN_PERCENT: string = '6.2%';
}

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

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

相关文章

Springboot + vue 小区物业管理系统

&#x1f942;(❁◡❁)您的点赞&#x1f44d;➕评论&#x1f4dd;➕收藏⭐是作者创作的最大动力&#x1f91e; &#x1f496;&#x1f4d5;&#x1f389;&#x1f525; 支持我&#xff1a;点赞&#x1f44d;收藏⭐️留言&#x1f4dd;欢迎留言讨论 &#x1f525;&#x1f525;&…

uni-app编写微信小程序使用uni-popup搭配uni-popup-dialog组件在ios自动弹出键盘。

uni-popup-dialog 对话框 将 uni-popup 的type属性改为 dialog&#xff0c;并引入对应组件即可使用对话框 &#xff0c;该组件不支持单独使用 示例 <button click"open">打开弹窗</button> <uni-popup ref"popup" type"dialog"…

RabbitMQ中有哪几种交换机类型?

大家好&#xff0c;我是锋哥。今天分享关于【RabbitMQ中有哪几种交换机类型&#xff1f;】面试题。希望对大家有帮助&#xff1b; RabbitMQ中有哪几种交换机类型&#xff1f; 1000道 互联网大厂Java工程师 精选面试题-Java资源分享网 在RabbitMQ中&#xff0c;交换机&#xf…

Uniapp中实现加载更多、下拉刷新、返回顶部功能

一、加载更多&#xff1a; 在到达底部时&#xff0c;将新请求过来的数据追加到原来的数组即可&#xff1a; import {onReachBottom } from "dcloudio/uni-app";const pets ref([]); // 显示数据function network() {uni.request({url: "https://api.thecatap…

Kotlin 循环语句详解

文章目录 循环类别for-in 循环区间整数区间示例1&#xff1a;正向遍历示例2&#xff1a;反向遍历 示例1&#xff1a;遍历数组示例2&#xff1a;遍历区间示例3&#xff1a;遍历字符串示例4&#xff1a;带索引遍历 while 循环示例&#xff1a;计算阶乘 do-while 循环示例&#xf…

【零基础租赁实惠GPU推荐及大语言模型部署教程01】

租赁GPU推荐及大语言模型部署简易教程 1 官网地址2 注册账号及登录3 租用GPU3.1 充值&#xff08;不限制充值最低金额&#xff0c;1元亦可&#xff09;3.2 容器实例&#xff08;实际就是你租用的GPU电脑&#xff09;3.3 选择镜像&#xff08;选择基础环境&#xff1a;框架版本和…

Centos 宝塔安装

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh 安装成功界面 宝塔说明文档 https://www.bt.cn/admin/servers#wcu 或者可以注册宝塔账号 1 快速部署 安装docker 之后 2 需要在usr/bin下下载do…

新版AndroidStudio通过系统快捷创建带BottomNavigationView的项目踩坑记录

选择上面这个玩意创建的项目 坑点1 &#xff1a;配置的写法和不一样了 镜像的写法&#xff1a; 新的settings.gradle.kts中配置镜像的代码&#xff1a; pluginManagement {repositories {mavenCentral()google {content {includeGroupByRegex("com\\.android.*")…

Java中网络编程的学习

目录 网络编程概述 网络模型 网络通信三要素: IP 端口号 通信协议 IP地址&#xff08;Internet Protocol Address&#xff09; 端口号 网络通信协议 TCP 三次握手 四次挥手 UDP TCP编程 客户端Socket的工作过程包含以下四个基本的步骤&#xff1a; 服务器程序…

浅谈云计算03 | 云计算的技术支撑(云使能技术)

云计算的技术支撑 一、定义与内涵1.1 定义与内涵 二、云计算使能技术架构2.1 宽带网络和 Internet 架构2.2 数据中心技术2.3 虚拟化技术2.4 Web 技术2.5 多租户技术2.6 服务技术 一、定义与内涵 1.1 定义与内涵 云计算技术包含一些基础的关键技术&#xff0c;这里称为使能技术…

腾讯云AI代码助手编程挑战赛-智能聊天助手

作品简介 本作品开发于腾讯云 AI 代码助手编程挑战赛&#xff0c;旨在体验腾讯云 AI 代码助手在项目开发中的助力。通过这一开发过程&#xff0c;体验到了 AI 辅助编程的高效性。 技术架构 前端: 使用 VUE3、TypeScript、TDesign 和 ElementUI 实现。 后端: 基于 Python 开发…

pip install hnswlib安装不成功

参考这个文章解决了问题&#xff1a;ERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects 以下是我安装的时候&#xff0c;报错&#xff1a; Building wheel for hnswlib (pyproject.toml) ... errorerror: subprocess-e…

OpenGL学习笔记(四):Shader 着色器(GLSL、Shader类封装)

文章目录 GLSL数据类型输入与输出Uniform的使用Shader类封装练习0练习1练习2练习3 前面的文章提到&#xff0c;着色器(Shader)是运行在GPU上的小程序。这些小程序为图形渲染管线的某个特定部分运行。从本质上来说&#xff0c;着色器只是一种把输入转化为输出的程序。着色器也是…

移动云自研云原生数据库入围国采!

近日&#xff0c;中央国家机关2024年度事务型数据库软件框架协议联合征集采购项目产品名单正式公布&#xff0c;移动云自主研发的云原生数据库产品顺利入围。这一成就不仅彰显了移动云在数据库领域深耕多年造就的领先技术优势&#xff0c;更标志着国家权威评审机构对移动云在数…

vLLM私有化部署大语言模型LLM

目录 一、vLLM介绍 二、安装vLLM 1、安装环境 2、安装步骤 三、运行vLLM 1、运行方式 2、切换模型下载源 3、运行本地已下载模型 四、通过http访问vLLM 一、vLLM介绍 vLLM&#xff08;官方网址&#xff1a;https://www.vllm.ai&#xff09;是一种用于大规模语言模型&#x…

Dify社区版部署,更换docker.io避免出现安装失败

这几天在部署Dify的社区版&#xff0c;用docker compose进行部署&#xff0c;看Dify里面的部署文档也是相当简单&#xff0c;只需要几个命令就可以执行完成了&#xff0c;但当开始执行的时候就发现会有各种问题。 Docker Compose最好是升级到最新的版本&#xff0c;我们以前用…

IntelliJ IDEA Type Hierarchy Scope Pattern 学习指南

IntelliJ IDEA Type Hierarchy Scope Pattern 学习指南 什么是 Type Hierarchy&#xff1f; Type Hierarchy 是 IntelliJ IDEA 提供的一个工具&#xff0c;允许开发者查看某个类的继承关系及其实现的接口结构。它是理解类关系的重要工具&#xff0c;尤其在处理复杂的继承体系…

Redis数据结构服务器

Redis数据结构服务器 什么是Redis数据结构服务器 的概念和特点 是一个开源&#xff08;BSD许可&#xff09;&#xff0c;内存中的数据结构存储服务器&#xff0c;可用作数据库、缓存和消息中间件。它支持多种类型的数据结构&#xff0c;如字符串&#xff08;strings&#xff09…

【Linux】进程结束和进程等待

进程的结束 退出码的认识 在我们学习C/C的时候我们通常在进行写main函数时&#xff0c;main函数主体写完后通常会进行写一条语句 " return 0 " &#xff0c;这里的这条语句到底是什么意思呢&#xff1f;&#xff1f; 我们知道当在主函数中调用其他函数或者在其他函…

Spring Boot教程之五十五:Spring Boot Kafka 消费者示例

Spring Boot Kafka 消费者示例 Spring Boot 是 Java 编程语言中最流行和使用最多的框架之一。它是一个基于微服务的框架&#xff0c;使用 Spring Boot 制作生产就绪的应用程序只需很少的时间。Spring Boot 可以轻松创建独立的、生产级的基于 Spring 的应用程序&#xff0c;您可…