This commit is contained in:
syuilo
2018-02-24 02:46:09 +09:00
parent 83f2e906bb
commit df8a2aea35
42 changed files with 823 additions and 511 deletions

View File

@@ -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
});