@oxiaom/adoremix 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/config/webui.js +38 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxiaom/adoremix",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
5
5
  "bin": {
6
6
  "adoremix": "./bin/adoremix.js"
@@ -41,26 +41,46 @@ function deployWebui(workdir, variant) {
41
41
  return false;
42
42
  }
43
43
  const docroot = path.join(workdir, 'etc', 'docroot');
44
- // 备份原 docroot(如果存在且不是我们自己部署的)
45
- // 简单做法:直接覆盖(用户业务资源应该在其他地方,docroot 是纯前端 UI)
46
- if (fs.existsSync(docroot)) {
47
- // 保留 docroot/mp3/ 目录(广播系统运行时存 mp3 的地方)
48
- const mp3Backup = path.join(workdir, 'etc', 'docroot_mp3_backup');
49
- const mp3Dir = path.join(docroot, 'mp3');
50
- if (fs.existsSync(mp3Dir)) {
51
- fse.removeSync(mp3Backup);
52
- fse.moveSync(mp3Dir, mp3Backup);
53
- }
54
- fse.removeSync(docroot);
55
- } else {
56
- fse.ensureDirSync(path.join(workdir, 'etc'));
44
+ fse.ensureDirSync(docroot);
45
+
46
+ // 只替换 UI 相关文件(index.html + assets/ + js/)
47
+ // 保留其他用户数据:mp3/(上传的音频)、bangzhu/、luyin2/、static/、xcx/
48
+ // 这样切换 UI 不会丢失任何业务数据
49
+ const uiFiles = ['index.html'];
50
+ const uiDirs = ['assets', 'js'];
51
+
52
+ // 先删旧 UI 文件(如果存在)
53
+ for (const f of uiFiles) {
54
+ const p = path.join(docroot, f);
55
+ if (fs.existsSync(p)) fs.unlinkSync(p);
56
+ }
57
+ for (const d of uiDirs) {
58
+ const p = path.join(docroot, d);
59
+ if (fs.existsSync(p)) fse.removeSync(p);
57
60
  }
58
- fse.copySync(srcDir, docroot);
59
- // 恢复 mp3/
60
- const mp3Backup = path.join(workdir, 'etc', 'docroot_mp3_backup');
61
- if (fs.existsSync(mp3Backup)) {
62
- fse.moveSync(mp3Backup, path.join(docroot, 'mp3'));
61
+
62
+ // 复制新 UI 文件
63
+ for (const f of uiFiles) {
64
+ const src = path.join(srcDir, f);
65
+ if (fs.existsSync(src)) fse.copySync(src, path.join(docroot, f));
63
66
  }
67
+ for (const d of uiDirs) {
68
+ const src = path.join(srcDir, d);
69
+ if (fs.existsSync(src)) fse.copySync(src, path.join(docroot, d));
70
+ }
71
+
72
+ // 复制 webui 包里其他顶层文件(如 favicon.ico 等,但不碰用户已有的非 UI 文件)
73
+ // 注意:只复制 webui 包里"独有"的文件,不覆盖 docroot 已有的同名文件
74
+ const webuiEntries = fs.readdirSync(srcDir);
75
+ for (const entry of webuiEntries) {
76
+ if (uiFiles.includes(entry) || uiDirs.includes(entry)) continue;
77
+ const dst = path.join(docroot, entry);
78
+ if (!fs.existsSync(dst)) {
79
+ // 只在 docroot 不存在时复制(避免覆盖用户数据)
80
+ fse.copySync(path.join(srcDir, entry), dst);
81
+ }
82
+ }
83
+
64
84
  return true;
65
85
  }
66
86