wip
This commit is contained in:
parent
1eecc1fa3d
commit
de6d77d0cb
29 changed files with 422 additions and 426 deletions
|
|
@ -2,7 +2,7 @@ import Vue from 'vue';
|
|||
|
||||
export default function<T extends object>(data: {
|
||||
name: string;
|
||||
props?: T;
|
||||
props?: () => T;
|
||||
}) {
|
||||
return Vue.extend({
|
||||
props: {
|
||||
|
|
@ -17,20 +17,9 @@ export default function<T extends object>(data: {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
props: data.props || {} as T
|
||||
props: data.props ? data.props() : {} as T
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
props(newProps, oldProps) {
|
||||
if (JSON.stringify(newProps) == JSON.stringify(oldProps)) return;
|
||||
(this as any).api('i/update_home', {
|
||||
id: this.id,
|
||||
data: newProps
|
||||
}).then(() => {
|
||||
(this as any).os.i.client_settings.home.find(w => w.id == this.id).data = newProps;
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.props) {
|
||||
Object.keys(this.props).forEach(prop => {
|
||||
|
|
@ -39,6 +28,18 @@ export default function<T extends object>(data: {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.$watch('props', newProps => {
|
||||
console.log(this.id, newProps);
|
||||
(this as any).api('i/update_home', {
|
||||
id: this.id,
|
||||
data: newProps
|
||||
}).then(() => {
|
||||
(this as any).os.i.client_settings.home.find(w => w.id == this.id).data = newProps;
|
||||
});
|
||||
}, {
|
||||
deep: true
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue