feat: 添加多站点支持,引入site_id字段
- 在Comment表中添加site_id字段,用于区分不同站点的评论 - 更新前后端API以支持site_id参数传递 - 修改自动迁移脚本,添加site_id字段迁移逻辑 - 更新前端组件配置,支持设置siteId参数
This commit is contained in:
@@ -29,6 +29,9 @@ export class CWDComments {
|
||||
*/
|
||||
constructor(config) {
|
||||
this.config = { ...config };
|
||||
if (config.siteId) {
|
||||
this.config.siteId = config.siteId;
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
this.config.postSlug = window.location.pathname;
|
||||
}
|
||||
@@ -571,6 +574,9 @@ export class CWDComments {
|
||||
const prevConfig = { ...this.config };
|
||||
|
||||
Object.assign(this.config, newConfig);
|
||||
if (newConfig.siteId !== undefined) {
|
||||
this.config.siteId = newConfig.siteId;
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
this.config.postSlug = window.location.pathname;
|
||||
}
|
||||
@@ -589,7 +595,8 @@ export class CWDComments {
|
||||
const shouldReload =
|
||||
this.config.apiBaseUrl !== prevConfig.apiBaseUrl ||
|
||||
this.config.pageSize !== prevConfig.pageSize ||
|
||||
this.config.postSlug !== prevConfig.postSlug;
|
||||
this.config.postSlug !== prevConfig.postSlug ||
|
||||
this.config.siteId !== prevConfig.siteId;
|
||||
|
||||
if (shouldReload) {
|
||||
const api = createApiClient(this.config);
|
||||
|
||||
Reference in New Issue
Block a user