From 44281e89c1ec6fa5bfe8ef7d1fa2ed228c5b0cb1 Mon Sep 17 00:00:00 2001 From: clh Date: Mon, 30 Dec 2024 13:36:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/utils.ts | 18 +++- docs/front/mini/hb2cli/index.md | 1 + docs/front/mini/{uniapp => trap}/index.md | 0 .../mini/{uniapp => trap}/spaceError.png | Bin .../mini/{uniapp => trap}/spaceRight.png | Bin ...9_C1CCC9F1-7EBC-4365-A0DC-59D9360449E0.png | Bin 0 -> 8902 bytes docs/front/mini/var/index.md | 85 ++++++++++++++++++ docs/others/operation/git/index.md | 24 +++++ 8 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 docs/front/mini/hb2cli/index.md rename docs/front/mini/{uniapp => trap}/index.md (100%) rename docs/front/mini/{uniapp => trap}/spaceError.png (100%) rename docs/front/mini/{uniapp => trap}/spaceRight.png (100%) create mode 100644 docs/front/mini/var/1735524581039_C1CCC9F1-7EBC-4365-A0DC-59D9360449E0.png create mode 100644 docs/front/mini/var/index.md create mode 100644 docs/others/operation/git/index.md diff --git a/docs/.vitepress/utils.ts b/docs/.vitepress/utils.ts index 19100ae..1d6f0ad 100644 --- a/docs/.vitepress/utils.ts +++ b/docs/.vitepress/utils.ts @@ -40,20 +40,28 @@ export default { ], }, { - text: "小程序", + text: "Uniapp跨端开发", items: [ { text: "包体积优化", link: "/front/mini/packageSize/", }, { - text: "Uniapp踩坑合集", - link: "/front/mini/uniapp/", + text: "自定义编译变量及环境变量", + link: "/front/mini/var/", + }, + { + text: "从Hbuilder迁移到命令行编译", + link: "/front/mini/hb2cli", }, { text: "Uniapp对接微信原生SDK", link: "/front/mini/thirdSDK/", }, + { + text: "Uniapp踩坑合集", + link: "/front/mini/trap/", + }, ], }, { @@ -87,6 +95,10 @@ export default { { text: "常用操作指令", items: [ + { + text: "Git", + link: "/others/operation/git/", + }, { text: "MarkDown", link: "/others/operation/md/", diff --git a/docs/front/mini/hb2cli/index.md b/docs/front/mini/hb2cli/index.md new file mode 100644 index 0000000..395ba95 --- /dev/null +++ b/docs/front/mini/hb2cli/index.md @@ -0,0 +1 @@ +# 从 HbuilderX 迁移到命令行编译 diff --git a/docs/front/mini/uniapp/index.md b/docs/front/mini/trap/index.md similarity index 100% rename from docs/front/mini/uniapp/index.md rename to docs/front/mini/trap/index.md diff --git a/docs/front/mini/uniapp/spaceError.png b/docs/front/mini/trap/spaceError.png similarity index 100% rename from docs/front/mini/uniapp/spaceError.png rename to docs/front/mini/trap/spaceError.png diff --git a/docs/front/mini/uniapp/spaceRight.png b/docs/front/mini/trap/spaceRight.png similarity index 100% rename from docs/front/mini/uniapp/spaceRight.png rename to docs/front/mini/trap/spaceRight.png diff --git a/docs/front/mini/var/1735524581039_C1CCC9F1-7EBC-4365-A0DC-59D9360449E0.png b/docs/front/mini/var/1735524581039_C1CCC9F1-7EBC-4365-A0DC-59D9360449E0.png new file mode 100644 index 0000000000000000000000000000000000000000..68e4bf3eb649c7d63ea2de48b29331bde4ec6429 GIT binary patch literal 8902 zcmb7qc{r3`*uMy0*($PRnMx>GB4LEFlp*_;WGhs5F?KVfl4P41yKF;b86wKQ3>C)6 z&ey(#G4^E`#*F2i-uJzJ@Adxi{_*?cdCqgr^<39E=eh6u^SM9wd7@2?!JOwVpJQNP z;MCW4%TKU?-gF5ch0`lGSXsTs6?_KJ!7W#*3_b`LAxv&T z-f#779X9Om60?ZM&BUgy%aq@{YGD=C`x71&%?FTPS{5;A?Rl-Yy=S{n&goIC50OMazN+KR)umZ>iB6&SZr_i|q^gg#XpX<2&>&F_iXhk#rxU`jy_S{XJO?l(<4 zzrrrHM#(6%NYZMP#ZMOGc7D|O$pqAucYLb9tTZVgusy)o^?J>_jpuFqVaa4|c(JUc zz41R6;~Gm0%g?#!-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9(%kch!bTd2kJxa)Xl;7lK*(Sg-x_lP>l359%t*sYS!4Q>2uaLZ zu`!!*V@rJjfKg;cY>mefZi=wqN;`0tv5*%`fJHtu@q03-mHA$YjB&K^6?oHByU+rp ze1P>%2X>r6{Y)iZ2)tXKxZ{!F_k*@Vz;w6F%W2?V=AFE#M>2VNv}k(IZK6ksD!p&y zRyu{h8_@U@|erg_>v})t0+@)Fw>0s^2KtWIQoTRQvdjo2syuqT5 z@l3VG4GqupSqGC=Xxkg=@3U_8E-%}ioWF;se~;t9k)CH-EWNeVUtdQ$G^-Lg=p)3Z zS2g8mA6qJ(eGl$uk^c;E(D+0;leyQ`sTZqOC5`F#v4+VSdrLkS&)-)Gg#!KJ%QWII zI3HfcHdT}_g@xR16F=C~!6rf6EyOMEn=tajRA<<6v4VAlpwZAo|&^e*561YjQ z$TL4VdwR_A?)a!1(~FXb`v5k&OQkW%mv5HaFY&I_mMR%z?W^hKc%a9BpDq4Rb>4$x zwuflJOE0TJ=q34QJqv|IMr3__jy2jjHeL(4vx0OzzHd5Y7vyb!1X{Z&ZGM-r{5JjH P69)YU#`nv$pT7MMwku!S literal 0 HcmV?d00001 diff --git a/docs/front/mini/var/index.md b/docs/front/mini/var/index.md new file mode 100644 index 0000000..11e9a7e --- /dev/null +++ b/docs/front/mini/var/index.md @@ -0,0 +1,85 @@ +# Uniapp 中自定义环境变量及编译变量 + +## 前言 + +在我们进行跨端开发中,基本都会遇到因为环境导致的代码差异需要兼容,比如生产环境和测试环境需要调用不同的接口地址,又比如 H5 和小程序上需要运行不同的交互逻辑 + +本文主要讨论如何在 Uniapp 中使用自定义的环境变量及条件编译变量,达到一套代码兼容多端多环境的目的 + +## 环境变量 + +在 Uniapp 中其实有内置的配置环境变量的方案,[参考地址](https://uniapp.dcloud.net.cn/collocation/package);但是经过亲测后,发现 H5 中是可用的,但是小程序中是不可用的,具体报错如下 +![alt text](1735524581039_C1CCC9F1-7EBC-4365-A0DC-59D9360449E0.png) + +为了同时兼容两端,我们在此引用三方包 cross-env 来实现需求 + +### Cross env + +#### 简介 + +cross-env 是一个常用的 npm 包,用于在不同操作系统中设置环境变量,确保在跨平台时环境变量的设置方式一致。它特别有用,因为不同操作系统设置环境变量的方式不同 + +#### 使用步骤 + +1. 安装:npm install --save-dev cross-env +2. 配置 script 脚本前加上 cross-env 运行脚本并注入环境变量 + + 配置前 + + ```json + { + "scripts": { + "start": "node server.js" + } + } + ``` + + 配置后 + + ```json + { + "scripts": { + "start": "cross-env TEST_VAR=dev node server.js", + "test": "cross-env TEST_VAR=test node server.js" + } + } + ``` + + 3.访问环境变量 + +一般来说,在完成上述配置后,我们便可以通过 process.env.TEST_VAR 来访问到环境变量了,但是 Uniapp 因为编译比较特殊,使用这种办法是访问不到的,而需要通过 vite.config(或者 vue.config)文件来中转 + +```js +const TEST_VAR = process.env.TEST_VAR; +export default defineConfig({ + ..., + define: { + TEST_VAR: JSON.stringify(TEST_VAR), + }, +}); +``` + +这样就能将 TEST_VAR 作为全局变量去进行使用了 + +```js +const baseUrlMap = { + dev: "https://dev/api/xx", + test: "https://test/api/xx", +}; + +export const getBaseUrl = () => { + return baseUrlMap[TEST_VAR]; +}; +``` + +## 编译变量 + +通过上述操作后,我们已经可以通过环境变量来进行一些差异化的适配开发了,那么编译变量又是什么作用呢? + +环境变量一般定义在编译时,但是使用在运行时,但是如果我们需要在编译时去判断哪些代码需要在哪个环境下才编译到 dist 里,这个时候环境变量就无法实现了,Uniapp 提供了自定义编译变量来实现目的,[参考文档](https://uniapp.dcloud.net.cn/collocation/package.html) + +该文档中有具体的 HbuilderX 编译或者 Cli 编译时如何使用编译变量,在此不再赘述,最终我们将 cross-env 和这个方案相结合,就能同时实现环境变量及编译变量 + +```json +"dev:h5-dev": "cross-env COMP_ENV=DEV uni -p h5-dev", +``` diff --git a/docs/others/operation/git/index.md b/docs/others/operation/git/index.md new file mode 100644 index 0000000..aab6865 --- /dev/null +++ b/docs/others/operation/git/index.md @@ -0,0 +1,24 @@ +# Git 常用指令介绍 + +Git 是一个分布式版本控制工具,它被广泛应用于开源和私有项目的管理中。掌握 Git 的常用指令是每个开发者必备的技能,本文将介绍 Git 中一些常见的操作命令 + +## 1. 配置操作 + +```bash +git config --list # 查看当前git的所有配置 +git config --global user.name "Your Name" # 设置全局用户名 +git config --global user.email "youremail@example.com" # 设置全局邮箱 + +git config --global http.proxy http://proxy.example.com:8080 # 设置全局http代理 +git config --global https.proxy https://proxy.example.com:8080 # 设置全局https代理 + +git config --global https."github.com".proxy https://proxy.example.com:8080 # 仅对某个域名进行代理 +``` + +## 2. 初始化及克隆仓库 + +```bash +git init # 初始化git,创建git目录 +git clone https://github.com/dcloudio/uni-ui.git # 克隆仓库 + +```