udxcms 1.0.19 → 1.0.21

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ // 调试文件 - 查看实际的模块结构
2
+ const cmsStore = require('./dist/store/index.js');
3
+ console.log('=== 调试 cmsStore 结构 ===');
4
+ console.log('cmsStore:', cmsStore);
5
+ console.log('cmsStore 类型:', typeof cmsStore);
6
+ console.log('cmsStore 键:', Object.keys(cmsStore));
7
+ // 检查 CmsStore
8
+ console.log('\n=== CmsStore 详细信息 ===');
9
+ console.log('CmsStore:', cmsStore.CmsStore);
10
+ console.log('CmsStore 类型:', typeof cmsStore.CmsStore);
11
+ // 检查 default 导出
12
+ if (cmsStore.default) {
13
+ console.log('\n=== default 导出 ===');
14
+ console.log('default:', cmsStore.default);
15
+ console.log('default 键:', Object.keys(cmsStore.default));
16
+ }
17
+ // 尝试访问实际的 store 模块
18
+ if (cmsStore.CmsStore) {
19
+ console.log('\n=== CmsStore 模块结构 ===');
20
+ console.log('CmsStore.state:', cmsStore.CmsStore.state);
21
+ console.log('CmsStore.mutations:', cmsStore.CmsStore.mutations);
22
+ console.log('CmsStore 是否有 state:', !!cmsStore.CmsStore.state);
23
+ console.log('CmsStore 是否有 mutations:', !!cmsStore.CmsStore.mutations);
24
+ }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import * as cmsComponents from './components';
2
- import * as cmsRouter from './router';
3
- import * as cmsStore from './store';
4
- import * as localStorageConstant from './libs/localStorageConstant';
1
+ import * as cmsComponents from './components/index.js';
2
+ import * as cmsRouter from './router/index.js';
3
+ import * as cmsStore from './store/index.js';
4
+ import * as localStorageConstant from './libs/localStorageConstant.js';
5
5
  /**
6
6
  * 设置事件事务中心
7
7
  * @param {Object} events - 事件对象
package/dist/index.js CHANGED
@@ -8,10 +8,10 @@
8
8
  */
9
9
  // @ts-nocheck
10
10
  // 导入必要的模块
11
- import * as cmsComponents from './components';
12
- import * as cmsRouter from './router';
13
- import * as cmsStore from './store';
14
- import * as localStorageConstant from './libs/localStorageConstant';
11
+ import * as cmsComponents from './components/index.js';
12
+ import * as cmsRouter from './router/index.js';
13
+ import * as cmsStore from './store/index.js';
14
+ import * as localStorageConstant from './libs/localStorageConstant.js';
15
15
  // 定义内部事件事务中心
16
16
  let eventCenter = {};
17
17
  /**
@@ -38,6 +38,14 @@ export * as api from './api';
38
38
  export * from './utils';
39
39
  export * from './api';
40
40
  export { localStorageConstant };
41
+ // 添加详细的调试信息
42
+ console.log('=== CMS模块调试信息 ===');
43
+ console.log('cmsStore 原始结构:', cmsStore);
44
+ console.log('cmsStore 键:', Object.keys(cmsStore));
45
+ Object.keys(cmsStore).forEach(key => {
46
+ console.log(`cmsStore.${key}:`, cmsStore[key]);
47
+ console.log(`cmsStore.${key} 类型:`, typeof cmsStore[key]);
48
+ });
41
49
  /**
42
50
  * 初始化 UDX CMS 相关功能
43
51
  * 此方法可用于执行 UDX CMS 的初始化逻辑
@@ -84,18 +92,88 @@ export function init({ Vue, router, store, Parent, onComponentsRegistered, onRou
84
92
  }
85
93
  if (store) {
86
94
  console.log('注册模块:', cmsStore);
95
+ console.log('cmsStore 键列表:', Object.keys(cmsStore));
87
96
  Object.keys(cmsStore).map(v => {
88
- // 使用原始模块名注册,保持命名一致性
89
- console.log('注册模块:', v, cmsStore[v]);
97
+ console.log(`处理模块: ${v}`);
98
+ console.log(`模块内容:`, cmsStore[v]);
90
99
  // 确保模块有正确的结构
91
100
  const moduleConfig = cmsStore[v];
92
101
  if (moduleConfig && typeof moduleConfig === 'object') {
93
102
  // 检查是否是默认导出
94
103
  const actualModule = moduleConfig.default || moduleConfig;
104
+ console.log(`实际模块:`, actualModule);
105
+ console.log(`模块结构 - state:`, !!actualModule.state, 'mutations:', !!actualModule.mutations, 'actions:', !!actualModule.actions);
95
106
  if (actualModule.state || actualModule.mutations || actualModule.actions) {
96
- // preserveState: true 表示在注册模块时保留现有状态。
97
- // 当注册一个新的模块时,如果该模块路径下已经存在状态,设置此属性为 true 可以确保这些状态不会被清除。
98
- store.registerModule(v, actualModule, { preserveState: true });
107
+ console.log(`注册模块 ${v} 成功`);
108
+ // 特殊处理 CmsStore - 直接合并到根 store
109
+ if (v === 'CmsStore') {
110
+ console.log('将 CmsStore 直接合并到根 store');
111
+ // 1. 直接修改根 state 来添加 cms 命名空间
112
+ if (actualModule.state) {
113
+ if (!store.state.cms) {
114
+ store.state.cms = {};
115
+ }
116
+ Object.keys(actualModule.state).forEach(key => {
117
+ store.state.cms[key] = actualModule.state[key];
118
+ });
119
+ }
120
+ // 2. 直接修改 store._mutations 来添加根级别 mutations
121
+ if (actualModule.mutations) {
122
+ console.log('添加根级别 mutations:', Object.keys(actualModule.mutations));
123
+ console.log('当前 store._mutations:', Object.keys(store._mutations));
124
+ Object.keys(actualModule.mutations).forEach(mutationName => {
125
+ if (!store._mutations[mutationName]) {
126
+ store._mutations[mutationName] = [];
127
+ }
128
+ // 添加 mutation 处理器
129
+ store._mutations[mutationName].push(function (payload) {
130
+ // 获取当前模块状态
131
+ const moduleState = store.state.cms || actualModule.state;
132
+ // 调用原始 mutation
133
+ return actualModule.mutations[mutationName](moduleState, payload);
134
+ });
135
+ console.log(`已注册 mutation: ${mutationName}`);
136
+ });
137
+ console.log('注册后的 store._mutations:', Object.keys(store._mutations));
138
+ }
139
+ // 3. 直接修改 store._actions 来添加根级别 actions
140
+ if (actualModule.actions) {
141
+ console.log('添加根级别 actions:', Object.keys(actualModule.actions));
142
+ Object.keys(actualModule.actions).forEach(actionName => {
143
+ if (!store._actions[actionName]) {
144
+ store._actions[actionName] = [];
145
+ }
146
+ // 添加 action 处理器
147
+ store._actions[actionName].push(function (payload) {
148
+ // 创建正确的 context
149
+ const context = {
150
+ state: store.state.cms || actualModule.state,
151
+ rootState: store.state,
152
+ commit: store.commit,
153
+ dispatch: store.dispatch,
154
+ getters: store.getters,
155
+ rootGetters: store.getters
156
+ };
157
+ // 调用原始 action
158
+ return actualModule.actions[actionName](context, payload);
159
+ });
160
+ });
161
+ }
162
+ // 4. 直接修改 store._wrappedGetters 来添加根级别 getters
163
+ if (actualModule.getters) {
164
+ console.log('添加根级别 getters:', Object.keys(actualModule.getters));
165
+ Object.keys(actualModule.getters).forEach(getterName => {
166
+ store._wrappedGetters[getterName] = function () {
167
+ const moduleState = store.state.cms || actualModule.state;
168
+ return actualModule.getters[getterName](moduleState, store.getters, store.state, store.getters);
169
+ };
170
+ });
171
+ }
172
+ }
173
+ else {
174
+ // 其他模块按正常方式注册
175
+ store.registerModule(v, actualModule, { preserveState: true });
176
+ }
99
177
  }
100
178
  else {
101
179
  console.warn(`模块 ${v} 结构不正确:`, actualModule);
@@ -1,2 +1,2 @@
1
- export { default as CmsStore } from "./CmsStore";
2
- export { default as CmsStoreH5 } from "./CmsStoreH5";
1
+ export { default as CmsStore } from "./CmsStore.js";
2
+ export { default as CmsStoreH5 } from "./CmsStoreH5.js";
@@ -1,2 +1,2 @@
1
- export { default as CmsStore } from './CmsStore';
2
- export { default as CmsStoreH5 } from './CmsStoreH5';
1
+ export { default as CmsStore } from './CmsStore.js';
2
+ export { default as CmsStoreH5 } from './CmsStoreH5.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "udxcms",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "cms submodule",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",