This commit is contained in:
oneao committed 2026-04-23 17:22:34 +08:00
1 parent bddbb49e19
commit e42ebf916f
60 files changed
+941 -1

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
# PaddlePaddle(Python)
[飞桨(PaddlePaddle)](https://www.paddlepaddle.org.cn/)以百度多年的深度学习技术研究和业务应用为基础,集深度学习核心训练和推理框架、基础模型库、端到端开发套件、丰富的工具组件于一体,是中国首个自主研发、功能丰富、开源开放的产业级深度学习平台。 飞桨于2016 年正式开源,是主流深度学习框架中一款完全国产化的产品。
## 安装 PaddlePaddle
参考网站:https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/linux-pip.html
安装 GPU 版本:
```bash
python -m pip install paddlepaddle-gpu==3.3.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
```
安装 CPU 版本
```bash
python -m pip install paddlepaddle==3.3.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
```
如果是 **GPU版本** 需要注意自己的 `CUDA` 版本,不要过高即可,查看命令:
```bash
nvidia-smi
```
输出如下:
```
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.105.17 Driver Version: 525.105.17 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 On | 00000000:00:09.0 Off | 0 |
| N/A 27C P8 8W / 70W | 4MiB / 15360MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
```
当前电脑的 CUDA 版本为 12.0,所以下载 小于等于 12.0 版本的 `paddlepaddle` 即可:
```bash
python -m pip install paddlepaddle-gpu==3.1.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
```
检查是否安装成功:
```bash
python -c "import paddle; paddle.utils.run_check()"
```
输出以下内容即代表成功:
```
(ocr) root@VM-0-80-ubuntu:/workspace# python -c "import paddle; paddle.utils.run_check()"
/root/miniforge3/envs/ocr/lib/python3.11/site-packages/paddle/utils/cpp_extension/extension_utils.py:715: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
warnings.warn(warning_message)
Running verify PaddlePaddle program ...
I0710 06:19:32.810492 2651 pir_interpreter.cc:1524] New Executor is Running ...
W0710 06:19:32.813128 2651 gpu_resources.cc:114] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.0, Runtime API Version: 11.7
I0710 06:19:35.382279 2651 pir_interpreter.cc:1547] pir interpreter is running by multi-thread mode ...
PaddlePaddle works well on 1 GPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
```
## PaddleOCR
## PaddleX
[PaddleX 3.0](https://paddlepaddle.github.io/PaddleX/latest/index.html) 是基于飞桨框架构建的低代码开发工具,它集成了众多**开箱即用的预训练模型**,可以实现模型从训练到推理的**全流程开发**,支持国内外**多款主流硬件**,助力AI 开发者进行产业实践。
Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+384
View File
@@ -0,0 +1,384 @@
# Expo(React Native)
[Expo](https://docs.expo.dev/) 是一个基于 React Native 的框架,旨在简化移动应用开发。它提供了一套工具和服务,让开发者可以更快速地构建、测试和发布 React Native 应用。
## 初始化项目
```bash
pnpm create expo-app@latest --template blank-typescript
```
[官网模板](https://docs.expo.dev/more/create-expo/) 如下:
| 模板名称 | 描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [`default`](https://github.com/expo/expo/tree/main/templates/expo-template-default) | 默认模板,用于构建多页面应用。包含推荐工具,如 **Expo CLI**、**Expo Router** 路由库,并启用 **TypeScript** 配置。适合大多数应用。 |
| [`blank`](https://github.com/expo/expo/tree/main/templates/expo-template-blank) | 最简模板,仅安装最基本依赖,不包含导航配置。 |
| [`blank-typescript`](https://github.com/expo/expo/tree/main/templates/expo-template-blank-typescript) | 空白模板,但启用了 **TypeScript** 支持。 |
| [`tabs`](https://github.com/expo/expo/tree/main/templates/expo-template-tabs) | 启用基于文件的路由系统(Expo Router),并默认使用 **TypeScript**,适合多标签页结构的应用。 |
| [`bare-minimum`](https://github.com/expo/expo/tree/main/templates/expo-template-bare-minimum) | 带有原生目录(`android` 与 `ios`)的空白模板,创建时会自动运行 [`npx expo prebuild`](https://docs.expo.dev/workflow/prebuild)。适合需要直接修改原生代码的项目。 |
**启动项目:**
```bash
npx expo start
```
## 打包发布
### 本地打包
#### 1. 安装 [Android Studio]( https://developer.android.com/?hl=zh-cn)
1. 下载安装
- 按照官网提示依次安装 SDK 工具和必要组件。
- 安装完成后,记住 SDK 的安装路径(例如:`D:\data\sdk`,默认位置是:`C:\Users\<你的用户名>\AppData\Local\Android\Sdk`),后续需要用到。
2. 配置环境变量
- 打开 **系统属性 → 高级 → 环境变量**。
- 在 **系统变量** 中新增:
```
变量名:ANDROID_HOME
变量值:D:\data\sdk
```
- 在 **Path** 中新增:
```bash
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin
```
- 保存设置。
3. 验证安装
- 打开命令行,执行:
```
echo %ANDROID_HOME%
```
- 如果输出 SDK 路径,则说明配置成功。
#### 2. 安装 [jdk17](https://adoptium.net/zh-CN/temurin/releases?version=8&os=any&arch=any)
1. 下载安装
- 下载对应版本解压即可。
- 安装成功后,记住 jdk 的安装路径,后续需要用到。
2. 配置环境变量
- 打开 **系统属性 → 高级 → 环境变量**。
- 在 **系统变量** 中新增:
```bash
变量名:JAVA_HOME
变量值:D:\devtool\jdk\jdk-17.0.16+8
```
- 在 **Path** 中新增:
```bash
%JAVA_HOME%\bin
```
- 保存设置。
3. 验证安装
- 打开命令行,执行:
```bash
java --version
```
- 如果输出 jdk 的信息,则说明配置成功。
#### 3. Expo 项目启用 [Prebuild](https://docs.expo.dev/workflow/prebuild/)
1. 生成原生项目
```bash
npx expo prebuild
```
然后执行完毕后,会生成 `android` 目录。
2. 清除并重新生成原生项目
```bash
npx expo prebuild --clean
```
会删除已有的 `android` 和 `ios` 目录,然后重新生成。
#### 4. 配置 Keystore
##### 4.1 生成密钥
```bash
keytool -genkey -v -keystore android-release.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
```
说明:
- `my-release-key.keystore`:生成的密钥文件名,可自定义路径
- `my-key-alias`:密钥别名
- `RSA`:加密算法
- `2048`:密钥长度
- `10000`:有效期(天)
##### 4.2 手动配置
修改 `android/app/build.gradle` 文件
1. 修改 `signingConfigs`
```bash
signingConfigs {
release {
storeFile file('android-release.keystore') // keystore 文件路径
storePassword '你的Keystore密码' // keystore 密码
keyAlias '你的KeyAlias' // 密钥别名
keyPassword '你的Key密码' // key 密码
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
```
2. 在 `buildTypes` 中设置 release 使用 release 签名
```bash
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.debug
}
}
```
##### 4.3 脚本配置(推荐)
1. 在 expo 项目根目录下新增 `plugins\withAndroidSignature.js` 文件,内容如下:
```js
// plugins/withAndroidSignature.js
const { withAppBuildGradle } = require("@expo/config-plugins");
const fs = require("fs");
const path = require("path");
module.exports = function withAndroidSignature(config) {
return withAppBuildGradle(config, config => {
if (config.modResults.language === "groovy") {
config.modResults.contents = setAndroidSignature(config.modResults.contents);
} else {
throw new Error("如果不是 groovy,则无法在 app/build.gradle 中设置 signingConfigs");
}
return config;
});
};
function setAndroidSignature(appBuildGradle) {
if (!fs.existsSync(path.resolve(__dirname, "../credentials.json"))) {
console.warn("警告:没有设置正式版本的 Android Keystore 文件,因为 credentials.json 不存在。");
return appBuildGradle;
}
const info = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../credentials/credentials.json"), { encoding: "utf8" }));
// 使用正则表达式插入签名信息
let output = appBuildGradle.replace(
/(signingConfigs\s*\{)/,
`$1
release {
storeFile file(${JSON.stringify(path.resolve(__dirname, "../credentials/android-release.keystore"))})
storePassword ${JSON.stringify(info.android.keystore.keystorePassword)}
keyAlias ${JSON.stringify(info.android.keystore.keyAlias)}
keyPassword ${JSON.stringify(info.android.keystore.keyPassword)}
}`,
);
// 使用正则表达式替换 signingConfig
output = output.replace(
/(release\s*\{)[^}]*?signingConfig\s+signingConfigs\.debug/s,
`$1
signingConfig signingConfigs.release
`,
);
return output;
}
```
2. 在 expo 项目根目录下新增 `/credentials/credentials.json` 文件(该文件主要是 Keystore 的信息):
```json
{
"android": {
"keystore": {
"keystorePath": "credentials/android-release.keystore", // Android keystore 文件路径
"keystorePassword": "123456", // keystore 密码
"keyAlias": "my-key-alias", // Key 别名
"keyPassword": "123456" // Key 密码
}
},
"ios": {
"provisioningProfilePath": "ios/certs/profile.mobileprovision", // iOS 描述文件路径
"distributionCertificate": {
"path": "ios/certs/dist-cert.p12", // iOS 分发证书路径
"password": "password" // 证书密码
}
}
}
```
3. 在 `app.json` 中指定这个项目级插件:
```json
{
"expo": {
"plugins": [
"./plugins/withAndroidSignature"
]
}
}
```
#### 5. 打包
- 编译成 Google Play 商店用的 .aab 文件
```bash
./gradlew bundleRelease
```
- 直接安装的 .apk 文件
```bash
./gradlew assembleRelease
```
**注意**:这个时候可能会下载 `gradle` 、`apk` 等资源,网络速度可能过慢。
**解决方法**:在 `android/gradle.properties` 添加网络代理:
```bash
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890
```
打包结果在 `android/app/build/outputs/apt/release` 包下。
### 云打包
1. 安装 EAS CLI
```bash
npm install -g eas-cli
```
2. 注册并登录 Expo 账户
- 访问 https://expo.dev/ 注册账户,然后命令行登录:
```bash
expo login
```
3. 配置项目构建
- 输入以下命令,选择 Android 平台即可。
```bash
eas build:configure
```
4. 构建 Android 包
- 默认构建 AAB 包(上传 Google Play):
```bash
eas build --platform android
```
- 构建 APK(可直接安装):
```bash
eas build -p android --profile preview
```
### 安装包体积优化
#### 方法1(简单)
找到 `android/gradle.properties` 文件,找到 `reactNativeArchitectures` ,根据需要删除即可
```properties
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
```
保留 `arm64-v8a` 常用的即可
#### 方法2(原生方法 选择更多)
在 `android/app/build.gradle` 文件中添加或修改以下配置:
```
android {
// 其他配置...
splits {
abi {
enable true // 启用按 CPU 架构拆分
reset() // 重置默认架构列表
include 'arm64-v8a', 'armeabi-v7a'
universalApk false // 是否生成包含所有架构的通用 APK(false 表示只生成分架构的独立包)
// 还有一个 exclude 配置是排除指定架构的
}
}
// 其他配置...
}
```
**说明:**
- `enable true`:启用架构拆分功能。
- `reset()`:清空默认的架构配置,避免重复。
- `include`:指定要生成的架构包,比如只打 `arm64-v8a` 和 `armeabi-v7a`。
- `universalApk false`:不生成通用包(即包含所有架构的 APK)。
**举例:**
执行打包命令后,将生成多个包,例如:
```
app-arm64-v8a-release.apk
app-armeabi-v7a-release.apk
```
每个 APK 只包含对应架构的二进制文件,体积更小。
如果把 `universalApk` 设置为 `true`,则只会生成一个:
```
app-universal-release.apk
```
这个包能在 `arm64-v8a` 和 `armeabi-v7a` 架构的设备上运行,但体积最大。
+460
View File
@@ -0,0 +1,460 @@
# UniApp(Vue)
uni-app 是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、鸿蒙Next、Web(响应式)、以及各种小程序(微信/支付宝/百度/抖音/飞书/QQ/快手/钉钉/淘宝/京东/小红书)、快应用、鸿蒙元服务等多个平台。
## 低版本浏览器适配(H5)
### 原生Tabbar遮挡
如果Uniapp原生的Tabbar会遮挡一部分内容,这是因为部分低版本浏览器可能不支持 `env` 计算函数,所以导致整个样式设置失效。
**解决方案:**
新建 `/hooks/useSafeAreaBottom` 文件夹
在该目录下新建 `index.ts` 和 `index.css` 文件,添加一下内容
`index.css`:
```css
.safe-area-bottom {
padding-bottom: 50px;
padding-bottom: calc(50px + constant(safe-area-inset-bottom));
padding-bottom: calc(50px + env(safe-area-inset-bottom));
}
// 设置为50px是因为Uniapp的tabber的高度固定为50px。
```
`index.ts`:
```ts
import './index.css'
export function useSafeAreaBottom(): {
safeAreaInsets: UniApp.GetSystemInfoResult['safeAreaInsets']
needSafeAreaBottom: boolean
} {
const systemInfo = uni.getSystemInfoSync()
const safeAreaInsets: UniApp.GetSystemInfoResult['safeAreaInsets']
= systemInfo.safeAreaInsets ?? {
top: 0,
bottom: 0,
left: 0,
right: 0,
}
// ✅ 仅检测是否支持 env(safe-area-inset-bottom)
const supportsEnv
= typeof window !== 'undefined'
&& 'CSS' in window
&& typeof CSS.supports === 'function'
&& CSS.supports('padding-bottom', 'env(safe-area-inset-bottom)')
const needSafeAreaBottom = !supportsEnv
return {
safeAreaInsets,
needSafeAreaBottom,
}
}
```
使用:
```html
<template>
<view
:class="{ 'safe-area-bottom': needSafeAreaBottom }"
:style="{ marginTop: safeAreaInsets.top + 'px' }"
>
</view>
</template>
<script lang="ts" setup>
import { useSafeAreaBottom } from '@/hooks/useSafeAreaBottom/index'
const { safeAreaInsets, needSafeAreaBottom } = useSafeAreaBottom()
</script>
```
## 打包发布(Android)
> 背景:现在使用 HBuilderX 打自定义基座的话,一个账号会有限制次数。并且时间过慢。
### 1. 安装 Android Studio
使用该工具进行自定义基座。
下载地址:https://developer.android.com/studio?hl=zh-cn
按照顺序安装即可,注意SDK的位置不要安装到C盘
### 2. 下载 HBuilderX 离线SDK
下载地址:https://nativesupport.dcloud.net.cn/AppDocs/download/android.html
**注意:下载的 SDK 的版本需要与 HBuilderX 的版本保持一致。**
历史版本:https://pan.baidu.com/share/init?surl=KtOCtMZJSgfAayHNjTpdTg&pwd=4hvi
### 3. 导入 HBuilder-Integrate-AS 项目到 Android Studio
解压从 HBuilderX 下载后的 Android-SDK,使用 Android Studio 打开解压后的 HBuilder-Integrate-AS 项目。
![alt text](assets/1767860095770.png)
导入成功后,会发现目录只有部分内容。
![alt text](assets/1767860105639.png)
这时候需要将 Android 更新为 Project 既可查看到项目全部内容
![alt text](assets/1767860116406.png)
修改后的效果
![alt text](assets/1767860127749.png)
### 4. 配置 Andriod Studio
配置 JDK ,配置路径:Settings - Build - Build Tools - Gradle
将 Gradle JDK 的路径修改为本地的路径,修改后点击 `Apply` 即可。注意:JDK 的版本需要和 Gradle 的版本进行适配,如果不适配那么运行的时候也会有详细的报错信息。
![alt text](assets/1767860213983.png)
### 5. Uniapp开发者中心 申请相关信息
#### 5.1 创建应用
首先根据应用名称检查是否已经存在当前的项目。
![alt text](assets/1767860225084.png)
有过没有的话则点击右上角的 `创建应用` 按钮进行创建:
![alt text](assets/1767860300109.png)
创建成功后会添加到 **我的应用** 列表中
![alt text](assets/1767860311950.png)
点击对应的 **应用名称** 即可进入对应的应用
#### 5.2 申请云端证书
点击创建证书
![alt text](assets/1767860326407.png)
因为需要时间,过段时间刷新即可
![alt text](assets/1767860336247.png)
创建成功后,点击 **证书详情 ** 这里面有需要的一些信息。
需要的有 别名、MD5、SHA1、SHA256
![alt text](assets/1767860347571.png)
同时还需要证书密码,点击 **查看证书密码 ** 即可获取到。
![alt text](assets/1767860358483.png)
现在记录的信息有: 别名、MD5、SHA1、SHA256、证书密码
注意下载申请过的证书,后面需要用到
![alt text](assets/1767860370727.png)
#### 5.3 新增平台信息
进入 **各平台信息** ,点击 **新增** 按钮
![alt text](assets/1767860380849.png)
填写以下信息,注意填写包名(任意),该包名后面使用到。这个时候 SHA1、MD5、SHA256 就是在 [5.2 申请云端证书](#52-申请云端证书) 章节申请的信息。
![alt text](assets/1767860391828.png)
创建成功后就会显示
![alt text](assets/1767860402803.png)
创建离线Key,点击刚刚创建的平台信息的 创建离线Key 按钮
![alt text](assets/1767860413675.png)
点击进行创建,创建成功后,会显示 **查看离线Key**
![alt text](assets/1767860423452.png)
点击查看对应的离线Key,主要保留该值,后面会用到
### 6. 配置导入过的 HBuilder-Integrate-AS 项目
配置 `HBuilder-Integrate-AS\simpleDemo\build.gradle` ,这些修改的信息 已经都在 [5. Uniapp开发者中心 申请相关信息](#5-Uniapp开发者中心 申请相关信息) 申请过了,我已标注。注意下载云端证书,并放到 simpleDemo 目录下。
![alt text](assets/1767860437778.png)
替换 离线Key(该值就在 [5.3 新增平台信息](#53-新增平台信息) 申请过了),配置 `HBuilder-Integrate-AS\simpleDemo\src\main\AndroidManifest.xml` 文件。
![alt text](assets/1767860447485.png)
配置 `HBuilder-Integrate-AS\simpleDemo\src\main\assets\data\dcloud_control.xml` ,替换自己项目的appid。
![alt text](assets/1767860459644.png)
### 7. Hbuilder X 导出本地打包资源
注意 APPID 需要和创建应用的 appid 保持一致。如果不一致,可以去源码视图进行修改
![alt text](assets/1767860475275.png)
导出成功后,路径参考:
![alt text](assets/1767860484887.png)
复制 **resources** 文件夹下面文件夹,然后替换 **HBuilder-Integrate-AS** 项目中的 `HBuilder-Integrate-AS\simpleDemo\src\main\assets\apps\__UNI__A` 目录,将 `__UNI__A` 文件夹替换为导出的 `__UNI__9063282` 文件夹,替换后如下:
![alt text](assets/1767860494289.png)
确保 应用版本名称 和 应用版本号保持一致
![alt text](assets/1767860503374.png)
![alt text](assets/1767860510261.png)
### 8. 运行项目
先进行加载配置好的项目
![alt text](assets/1767860524973.png)
加载成功后即可出现蓝色运行按钮,点击运行即可
![alt text](assets/1767860536194.png)
### 9. 导入原生插件
> 如果不需要该步可以忽略,不影响自定义基座。
参考网站:https://zh.uniapp.dcloud.io/plugin/native-plugin.html#%E6%9C%AC%E5%9C%B0%E6%8F%92%E4%BB%B6-%E9%9D%9E%E5%86%85%E7%BD%AE%E5%8E%9F%E7%94%9F%E6%8F%92%E4%BB%B6
#### 9.1 下载插件
这里用 **DCloud-RichAlert** 举例,插件下载地址:https://ext.dcloud.net.cn/plugin?id=36
下载完毕后,新建 **nativeplugins** 文件夹,将解压后的插件放到该文件夹下面
![alt text](assets/1767860546989.png)
#### 9.2 配置本地插件
![alt text](assets/1767860556154.png)
选择插件
![alt text](assets/1767860566602.png)
配置成功页面
![alt text](assets/1767860575227.png)
然后就可以使用啦,在页面中添加测试代码
```html
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
}
},
onLoad() {
const dcRichAlert = uni.requireNativePlugin('DCloud-RichAlert')
dcRichAlert.show(
{
position: 'bottom',
title: '提示信息',
titleColor: '#FF0000',
content:
"<a href='https://uniapp.dcloud.io/' value='Hello uni-app'>uni-app</a> 是一个使用 Vue.js 开发跨平台应用的前端框架!\n免费的\n免费的\n免费的\n重要的事情说三遍",
contentAlign: 'left',
checkBox: {
title: '不再提示',
isSelected: true,
},
buttons: [
{
title: '取消',
},
{
title: '否',
},
{
title: '确认',
titleColor: '#3F51B5',
},
],
},
(result) => {
switch (result.type) {
case 'button':
console.log('callback---button--' + result.index)
break
case 'checkBox':
console.log('callback---checkBox--' + result.isSelected)
break
case 'a':
console.log('callback---a--' + JSON.stringify(result))
break
case 'backCancel':
console.log('callback---backCancel--')
break
}
},
)
},
methods: {},
}
</script>
```
当然,现在还没有结束,如果需要在本地看到效果,需要重复 [7. Hbuilder X 导出本地打包资源](#7-Hbuilder X 导出本地打包资源) 步骤,将新的打包资源将旧的替换掉。
#### 9.3 配置项目
**重要的下一步**,将 `nativeplugins\DCloud-RichAlert\android\uniplugin_richalert.aar` 复制到 `HBuilder-Integrate-AS\simpleDemo\libs` 文件夹下。
![alt text](assets/1767860605362.png)
然后呢,还没有结束哦。
在assets目录下创建 **dcloud_uniplugins.json** 文件,添加以下内容
```json
{
"nativePlugins": [
{
"plugins": [
{
"type": "module",
"name": "DCloud-RichAlert",
"class": "uni.dcloud.io.uniplugin_richalert.RichAlertWXModule"
}
]
}
]
}
```
![alt text](assets/1767860623138.png)
#### 9.4 配置gradle文件
添加制定依赖。
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.core:core:1.1.0'
implementation "androidx.fragment:fragment:1.1.0"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.facebook.fresco:fresco:2.5.0'
implementation "com.facebook.fresco:animated-gif:2.5.0"
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.alibaba:fastjson:1.2.83'
implementation 'androidx.webkit:webkit:1.5.0'
// 基座需要,必须添加。主要是这个是
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
```
![alt text](assets/1767860638268.png)
#### 9.5 运行项目
然后就是可以重新运行项目啦。运行成功的结果如下:
![alt text](assets/1767860648404.png)
### 10. 自定义基座
#### 10.1 Debug 配置
修改 `HBuilder-Integrate-AS\simpleDemo\src\main\assets\data\dcloud_control.xml` 文件,设置 Debug 模式:
```xml
<hbuilder debug="true" syncDebug="true">
<apps>
<app appid="__UNI__ID" appver=""/>
</apps>
</hbuilder>
```
![alt text](assets/1767860660364.png)
修改 `HBuilder-Integrate-AS\simpleDemo\build.gradle` 在该文件中添加 **okhttp3** 依赖
```
dependencies {
implementation "com.alibaba:fastjson:1.2.83"
implementation "com.squareup.okhttp3:okhttp:3.12.12"
}
```
![alt text](assets/1767860678022.png)
#### 10.2 导入 Debug SDK
需要导入的 SDK 位于 `Android-SDK@4.66.82418_20250520\SDK\libs` 中
![alt text](assets/1767860687556.png)
将 **debug-server-release.aar** 复制到 **libs** 下面
![alt text](assets/1767860696316.png)
#### 10.3 生成APK文件
![alt text](assets/1767860704777.png)
生成后会生成在 debug 目录下
![alt text](assets/1767860712216.png)
#### 10.4 复制APK文件到HBuilderX中
1. 在HBuilderX项目中创建创建 unpackage 目录,在 unpackage 目录中创建 debug 目录,将上述生成的APK文件拷贝到debug目录中。
2. **重命名**文件为 **android_debug.apk**,目录结构参考下图
![alt text](assets/1767860732712.png)
#### 10.5 运行自定义基座
![alt text](assets/1767860747593.png)
选择自定义基座
![alt text](assets/1767860756953.png)
点击运行,运行结果如下:
![alt text](assets/1767860772664.png)
需要把整个 **项目文件夹** 导入到 hbx编辑器 里面,然后运行,这样就可以热更新。
![alt text](assets/1767860784873.png)
### 11. 模块及三方 SDK 配置
参考官网:https://nativesupport.dcloud.net.cn/AppDocs/usemodule/androidModuleConfig/others.html
+1
View File
@@ -0,0 +1 @@
# Vue(JavaScript)