Implement #1098
This commit is contained in:
@@ -8,6 +8,10 @@ export default function<T extends object>(data: {
|
||||
props: {
|
||||
widget: {
|
||||
type: Object
|
||||
},
|
||||
isMobile: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -21,6 +25,7 @@ export default function<T extends object>(data: {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if (this.widget.data == null) this.widget.data = {};
|
||||
if (this.props) {
|
||||
Object.keys(this.props).forEach(prop => {
|
||||
if (this.widget.data.hasOwnProperty(prop)) {
|
||||
@@ -30,12 +35,21 @@ export default function<T extends object>(data: {
|
||||
}
|
||||
|
||||
this.$watch('props', 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;
|
||||
});
|
||||
if (this.isMobile) {
|
||||
(this as any).api('i/update_mobile_home', {
|
||||
id: this.id,
|
||||
data: newProps
|
||||
}).then(() => {
|
||||
(this as any).os.i.client_settings.mobile_home.find(w => w.id == this.id).data = newProps;
|
||||
});
|
||||
} else {
|
||||
(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
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user