feat:养马岛对应的智念端分支
This commit is contained in:
1 parent
5d0198b17a
commit
a8645c2b18
6 files changed
+127
-28
No files matched your search
@@ -12,6 +12,19 @@
|
|||||||
"theme-color-50": "#F0F8F3"
|
"theme-color-50": "#F0F8F3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"niannian": {
|
||||||
|
"clientId": "8",
|
||||||
|
"appId": "wx5e79df5996572539",
|
||||||
|
"name": "念念",
|
||||||
|
"logo": "https://one-feel-config-images-bucket.oss-cn-chengdu.aliyuncs.com/znjqfw.png",
|
||||||
|
"theme": {
|
||||||
|
"theme-color-800": "#174BB6",
|
||||||
|
"theme-color-700": "#145EE1",
|
||||||
|
"theme-color-500": "#2D91FF",
|
||||||
|
"theme-color-100": "#D9EEFF",
|
||||||
|
"theme-color-50": "#EEF8FF"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nianhelper": {
|
"nianhelper": {
|
||||||
"clientId": "11",
|
"clientId": "11",
|
||||||
"appId": "wx6fcf7b3db3deee6c",
|
"appId": "wx6fcf7b3db3deee6c",
|
||||||
|
|||||||
+4
-1
@@ -38,7 +38,10 @@
|
|||||||
"build:quickapp-webview": "uni build -p quickapp-webview",
|
"build:quickapp-webview": "uni build -p quickapp-webview",
|
||||||
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
||||||
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
||||||
"switch-client": "node scripts/update-appid.js"
|
"switch-client": "node scripts/update-appid.js",
|
||||||
|
"switch-client:niannian": "npm run switch-client -- niannian",
|
||||||
|
"dev:mp-weixin:niannian": "npm run switch-client:niannian && npm run dev:mp-weixin",
|
||||||
|
"build:mp-weixin:niannian": "npm run switch-client:niannian && npm run build:mp-weixin"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dcloudio/uni-app": "3.0.0-4070620250821001",
|
"@dcloudio/uni-app": "3.0.0-4070620250821001",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 客户端配置切换脚本使用说明
|
# 客户端配置切换脚本使用说明
|
||||||
|
|
||||||
这个脚本用于在不同客户端配置之间快速切换,支持智念、朵花、天沐等多个客户端。
|
这个脚本用于在不同客户端配置之间快速切换,支持智念、念念、智念助手、朵朵和沐沐。
|
||||||
|
|
||||||
## 主要功能
|
## 主要功能
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"zhinian": {
|
"zhinian": {
|
||||||
"clientId": "2",
|
"clientId": "6",
|
||||||
"appId": "wx5e79df5996572539",
|
"appId": "wx5e79df5996572539",
|
||||||
"name": "智念",
|
"name": "智念",
|
||||||
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/dh_logo.png"
|
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/dh_logo.png"
|
||||||
@@ -24,13 +24,13 @@
|
|||||||
"duohua": {
|
"duohua": {
|
||||||
"clientId": "2",
|
"clientId": "2",
|
||||||
"appId": "wx23f86d809ae80259",
|
"appId": "wx23f86d809ae80259",
|
||||||
"name": "朵花",
|
"name": "朵朵",
|
||||||
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/dh_logo.png"
|
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/dh_logo.png"
|
||||||
},
|
},
|
||||||
"tianmu": {
|
"tianmu": {
|
||||||
"clientId": "4",
|
"clientId": "4",
|
||||||
"appId": "wx0be424e1d22065a9",
|
"appId": "wx0be424e1d22065a9",
|
||||||
"name": "天沐",
|
"name": "沐沐",
|
||||||
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/tm_logo.png"
|
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/tm_logo.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,9 +41,12 @@
|
|||||||
| 客户端名称 | 显示名称 | AppID |
|
| 客户端名称 | 显示名称 | AppID |
|
||||||
| ------------ | -------- | ------------------ |
|
| ------------ | -------- | ------------------ |
|
||||||
| `zhinian` | 智念 | wx5e79df5996572539 |
|
| `zhinian` | 智念 | wx5e79df5996572539 |
|
||||||
| `duohua` | 朵花 | wx23f86d809ae80259 |
|
| `niannian` | 念念 | wx5e79df5996572539 |
|
||||||
| `tianmu` | 天沐 | wx0be424e1d22065a9 |
|
| `duohua` | 朵朵 | wx23f86d809ae80259 |
|
||||||
| `nianhelper` | 念念 | wx6fcf7b3db3deee6c |
|
| `tianmu` | 沐沐 | wx0be424e1d22065a9 |
|
||||||
|
| `nianhelper` | 智念助手 | wx6fcf7b3db3deee6c |
|
||||||
|
|
||||||
|
AppID 以 `client-configs.json` 为准。当前念念与智念使用相同的 AppID;若念念使用独立小程序,请先修改 `niannian.appId`,再执行切换或构建命令。
|
||||||
|
|
||||||
## 使用方法
|
## 使用方法
|
||||||
|
|
||||||
@@ -53,16 +56,34 @@
|
|||||||
# 切换到智念客户端
|
# 切换到智念客户端
|
||||||
npm run switch-client zhinian
|
npm run switch-client zhinian
|
||||||
|
|
||||||
# 切换到念念助手客户端
|
# 切换到念念客户端
|
||||||
|
npm run switch-client -- niannian
|
||||||
|
|
||||||
|
# 切换到智念助手客户端
|
||||||
npm run switch-client nianhelper
|
npm run switch-client nianhelper
|
||||||
|
|
||||||
# 切换到朵花客户端
|
# 切换到朵朵客户端
|
||||||
npm run switch-client duohua
|
npm run switch-client duohua
|
||||||
|
|
||||||
# 切换到天沐客户端
|
# 切换到沐沐客户端
|
||||||
npm run switch-client tianmu
|
npm run switch-client tianmu
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 念念端快捷命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 仅切换配置
|
||||||
|
npm run switch-client:niannian
|
||||||
|
|
||||||
|
# 切换到念念并启动微信小程序开发编译
|
||||||
|
npm run dev:mp-weixin:niannian
|
||||||
|
|
||||||
|
# 切换到念念并构建微信小程序生产包
|
||||||
|
npm run build:mp-weixin:niannian
|
||||||
|
```
|
||||||
|
|
||||||
|
这些命令会修改工作区中的当前客户端配置;开发和构建命令仅在切换成功后继续执行。不同端请勿在同一工作区并行编译。
|
||||||
|
|
||||||
### 直接运行脚本
|
### 直接运行脚本
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -93,8 +114,10 @@ node scripts/update-appid.js tianmu
|
|||||||
3. **src/constant/base.js**
|
3. **src/constant/base.js**
|
||||||
- 更新 `getCurrentConfig()` 函数返回的客户端配置
|
- 更新 `getCurrentConfig()` 函数返回的客户端配置
|
||||||
|
|
||||||
4. **client-configs.json**
|
4. **src/uni.scss**
|
||||||
- 统一的配置文件,所有客户端配置的单一数据源
|
- 根据客户端的 `theme` 更新主题色变量
|
||||||
|
|
||||||
|
`client-configs.json` 是读取的配置源,切换脚本不会修改它。
|
||||||
|
|
||||||
## 执行结果示例
|
## 执行结果示例
|
||||||
|
|
||||||
@@ -102,12 +125,12 @@ node scripts/update-appid.js tianmu
|
|||||||
|
|
||||||
```
|
```
|
||||||
🚀 开始更新配置...
|
🚀 开始更新配置...
|
||||||
🎯 检测到客户端配置: 天沐 (tianmu)
|
🎯 检测到客户端配置: 沐沐 (tianmu)
|
||||||
目标客户端: 天沐 (tianmu)
|
目标客户端: 沐沐 (tianmu)
|
||||||
目标appid: wx0be424e1d22065a9
|
目标appid: wx0be424e1d22065a9
|
||||||
|
|
||||||
📝 正在更新 base.js...
|
📝 正在更新 base.js...
|
||||||
✅ base.js 更新成功,切换到 天沐 配置
|
✅ base.js 更新成功,切换到 沐沐 配置
|
||||||
📝 正在更新 manifest.json...
|
📝 正在更新 manifest.json...
|
||||||
✅ manifest.json 更新成功
|
✅ manifest.json 更新成功
|
||||||
📝 正在更新 project.config.json...
|
📝 正在更新 project.config.json...
|
||||||
@@ -116,7 +139,7 @@ node scripts/update-appid.js tianmu
|
|||||||
新appid: wx0be424e1d22065a9
|
新appid: wx0be424e1d22065a9
|
||||||
|
|
||||||
🎉 所有文件更新完成!
|
🎉 所有文件更新完成!
|
||||||
💡 已切换到 天沐 客户端配置
|
💡 已切换到 沐沐 客户端配置
|
||||||
💡 提示: 请检查文件内容确认更新正确
|
💡 提示: 请检查文件内容确认更新正确
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -132,7 +155,7 @@ node scripts/update-appid.js tianmu
|
|||||||
|
|
||||||
## 注意事项
|
## 注意事项
|
||||||
|
|
||||||
1. **配置同步**: 确保 `client-configs.json` 与 `src/constant/base.js` 中的基础配置保持同步
|
1. **配置同步**: `src/constant/base.js` 自动读取 JSON 配置;新增端还需补齐 `ClientType` 和 `currentClientType()` 映射,确保各端登录缓存键相互独立
|
||||||
2. **测试建议**: 切换配置后建议先进行测试,确认功能正常
|
2. **测试建议**: 切换配置后建议先进行测试,确认功能正常
|
||||||
3. **备份建议**: 重要更新前建议备份相关配置文件
|
3. **备份建议**: 重要更新前建议备份相关配置文件
|
||||||
|
|
||||||
@@ -142,7 +165,7 @@ node scripts/update-appid.js tianmu
|
|||||||
A: 请确保在项目根目录执行脚本,并检查文件路径是否正确。
|
A: 请确保在项目根目录执行脚本,并检查文件路径是否正确。
|
||||||
|
|
||||||
**Q: 脚本提示不支持的客户端名称怎么办?**
|
**Q: 脚本提示不支持的客户端名称怎么办?**
|
||||||
A: 请检查输入的客户端名称是否正确,支持的客户端名称有:zhinian、duohua、tianmu。
|
A: 请检查输入的客户端名称是否正确,支持名称以 `client-configs.json` 的键为准,当前有:zhinian、niannian、nianhelper、duohua、tianmu。
|
||||||
|
|
||||||
**Q: 如何恢复到之前的配置?**
|
**Q: 如何恢复到之前的配置?**
|
||||||
A: 可以使用版本控制系统恢复,或者再次运行脚本切换到其他客户端配置。
|
A: 可以使用版本控制系统恢复,或者再次运行脚本切换到其他客户端配置。
|
||||||
@@ -155,11 +178,19 @@ A: 在 `client-configs.json` 中添加新的客户端配置:
|
|||||||
"clientId": "客户端ID",
|
"clientId": "客户端ID",
|
||||||
"appId": "微信小程序AppID",
|
"appId": "微信小程序AppID",
|
||||||
"name": "客户端显示名称",
|
"name": "客户端显示名称",
|
||||||
"logo": "@/pages/login/images/logo.png",
|
"logo": "@/pages/login/images/logo.png"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`src/constant/base.js` 会自动读取并处理新配置,无需手动修改。
|
切换脚本会自动识别新配置。还需在 `src/constant/base.js` 中添加对应的 `ClientType` 和名称映射;如需切换主题色,在配置中添加与现有客户端相同结构的 `theme` 字段。最后运行 `npm run switch-client -- new_client` 应用配置。
|
||||||
|
|
||||||
**Q: 脚本提示"读取配置文件失败"怎么办?**
|
**Q: 脚本提示"读取配置文件失败"怎么办?**
|
||||||
A: 检查 `client-configs.json` 文件是否存在且格式正确。
|
A: 检查 `client-configs.json` 文件是否存在且格式正确。
|
||||||
|
|
||||||
|
## 验证客户端切换
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node --test scripts/update-appid.test.cjs
|
||||||
|
```
|
||||||
|
|
||||||
|
测试在临时目录中切换五个客户端,检查配置、客户端类型、AppID 和主题色,不修改工作区当前配置。
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
const assert = require("node:assert/strict");
|
||||||
|
const { execFileSync } = require("node:child_process");
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const os = require("node:os");
|
||||||
|
const path = require("node:path");
|
||||||
|
const { pathToFileURL } = require("node:url");
|
||||||
|
const { test } = require("node:test");
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, "..");
|
||||||
|
const configs = require("../client-configs.json");
|
||||||
|
|
||||||
|
for (const client of ["zhinian", "niannian", "nianhelper", "duohua", "tianmu"]) {
|
||||||
|
test(`switch ${client}: configuration, identity and theme stay consistent`, async (t) => {
|
||||||
|
const fixture = fs.mkdtempSync(path.join(os.tmpdir(), "client-switch-"));
|
||||||
|
t.after(() => fs.rmSync(fixture, { recursive: true, force: true }));
|
||||||
|
for (const file of [
|
||||||
|
"client-configs.json",
|
||||||
|
"project.config.json",
|
||||||
|
"src/manifest.json",
|
||||||
|
"src/constant/base.js",
|
||||||
|
"src/uni.scss",
|
||||||
|
]) {
|
||||||
|
const target = path.join(fixture, file);
|
||||||
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
||||||
|
fs.copyFileSync(path.join(root, file), target);
|
||||||
|
}
|
||||||
|
fs.mkdirSync(path.join(fixture, "scripts"));
|
||||||
|
fs.copyFileSync(
|
||||||
|
path.join(__dirname, "update-appid.js"),
|
||||||
|
path.join(fixture, "scripts/update-appid.cjs")
|
||||||
|
);
|
||||||
|
fs.writeFileSync(path.join(fixture, "package.json"), '{"type":"module"}');
|
||||||
|
execFileSync(process.execPath, [path.join(fixture, "scripts/update-appid.cjs"), client]);
|
||||||
|
|
||||||
|
const base = await import(pathToFileURL(path.join(fixture, "src/constant/base.js")).href);
|
||||||
|
assert.deepEqual(base.getCurrentConfig(), configs[client]);
|
||||||
|
assert.equal(base.currentClientType(), client.toUpperCase());
|
||||||
|
assert.equal(base.isZhiNian, client === "zhinian");
|
||||||
|
const project = JSON.parse(fs.readFileSync(path.join(fixture, "project.config.json"), "utf8"));
|
||||||
|
assert.equal(project.appid, configs[client].appId);
|
||||||
|
const manifest = fs.readFileSync(path.join(fixture, "src/manifest.json"), "utf8");
|
||||||
|
assert.equal(manifest.match(/"mp-weixin":\s*{[^}]*"appid":\s*"([^"]*)"/)[1], configs[client].appId);
|
||||||
|
const scss = fs.readFileSync(path.join(fixture, "src/uni.scss"), "utf8");
|
||||||
|
for (const [key, value] of Object.entries(configs[client].theme)) {
|
||||||
|
assert.ok(scss.includes(`$${key}: ${value};`), `${key} should be ${value}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import rawConfigs from "../../client-configs.json" with { type: "json" };
|
|||||||
export const CLIENT_CONFIGS = rawConfigs;
|
export const CLIENT_CONFIGS = rawConfigs;
|
||||||
|
|
||||||
// 获取当前用户端配置
|
// 获取当前用户端配置
|
||||||
export const getCurrentConfig = () => CLIENT_CONFIGS.zhinian;
|
export const getCurrentConfig = () => CLIENT_CONFIGS.niannian;
|
||||||
export const clientId = getCurrentConfig().clientId;
|
export const clientId = getCurrentConfig().clientId;
|
||||||
export const appId = getCurrentConfig().appId;
|
export const appId = getCurrentConfig().appId;
|
||||||
|
|
||||||
@@ -20,11 +20,13 @@ export const appId = getCurrentConfig().appId;
|
|||||||
export const ClientType = {
|
export const ClientType = {
|
||||||
// 智念
|
// 智念
|
||||||
ZHINIAN: "ZHINIAN",
|
ZHINIAN: "ZHINIAN",
|
||||||
|
// 念念
|
||||||
|
NIANNIAN: "NIANNIAN",
|
||||||
// 朵花
|
// 朵花
|
||||||
DUOHUA: "DUOHUA",
|
DUOHUA: "DUOHUA",
|
||||||
// 天沐
|
// 天沐
|
||||||
TIANMU: "TIANMU",
|
TIANMU: "TIANMU",
|
||||||
// 念念助手
|
// 智念助手
|
||||||
NIANHELPER: "NIANHELPER",
|
NIANHELPER: "NIANHELPER",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,6 +40,8 @@ export const currentClientType = () => {
|
|||||||
case "沐沐":
|
case "沐沐":
|
||||||
return ClientType.TIANMU;
|
return ClientType.TIANMU;
|
||||||
case "念念":
|
case "念念":
|
||||||
|
return ClientType.NIANNIAN;
|
||||||
|
case "智念助手":
|
||||||
return ClientType.NIANHELPER;
|
return ClientType.NIANHELPER;
|
||||||
default:
|
default:
|
||||||
return ClientType.ZHINIAN;
|
return ClientType.ZHINIAN;
|
||||||
|
|||||||
+5
-5
@@ -13,11 +13,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* 主题颜色(由 switch-client 命令自动更新) */
|
/* 主题颜色(由 switch-client 命令自动更新) */
|
||||||
$theme-color-800: #0B7034;
|
$theme-color-800: #174BB6;
|
||||||
$theme-color-700: #0B5C2D;
|
$theme-color-700: #145EE1;
|
||||||
$theme-color-500: #0CCD58;
|
$theme-color-500: #2D91FF;
|
||||||
$theme-color-100: #E8FFF1;
|
$theme-color-100: #D9EEFF;
|
||||||
$theme-color-50: #F0F8F3;
|
$theme-color-50: #EEF8FF;
|
||||||
|
|
||||||
// text 颜色
|
// text 颜色
|
||||||
$text-color-900: #181B25;
|
$text-color-900: #181B25;
|
||||||
|
|||||||
Reference in new issue
Block a user