mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-29 17:06:43 -06:00
43930e6a84
* wip
* wip
* wip
* wip
* wip
* Update storage.ts
* wip
* wip
* wip
* wip
* Update storage.ts
* Update storage.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update storage.ts
* wip
* wip
* wip
* wip
* 🍕
* wip
* wip
* wip
* wip
* wip
* wip
* Update deck-storage.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update store.ts
* wip
* wip
* wip
* wip
* Update init.ts
* wip
* wip
* Update pizzax.ts
* wip
* wip
* Update timeline.vue
* Update init.ts
* wip
* wip
* Update init.ts
75 lines
1.4 KiB
TypeScript
75 lines
1.4 KiB
TypeScript
import { defineComponent } from 'vue';
|
|
import { Form } from '@/scripts/form';
|
|
import * as os from '@/os';
|
|
|
|
export default function <T extends Form>(data: {
|
|
name: string;
|
|
props?: () => T;
|
|
}) {
|
|
return defineComponent({
|
|
props: {
|
|
widget: {
|
|
type: Object,
|
|
required: false
|
|
},
|
|
settingCallback: {
|
|
required: false
|
|
}
|
|
},
|
|
|
|
emits: ['updateProps'],
|
|
|
|
data() {
|
|
return {
|
|
props: this.widget ? JSON.parse(JSON.stringify(this.widget.data)) : {}
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
id(): string {
|
|
return this.widget ? this.widget.id : null;
|
|
},
|
|
},
|
|
|
|
created() {
|
|
this.mergeProps();
|
|
|
|
this.$watch('props', () => {
|
|
this.mergeProps();
|
|
}, { deep: true });
|
|
|
|
if (this.settingCallback) this.settingCallback(this.setting);
|
|
},
|
|
|
|
methods: {
|
|
mergeProps() {
|
|
if (data.props) {
|
|
const defaultProps = data.props();
|
|
for (const prop of Object.keys(defaultProps)) {
|
|
if (this.props.hasOwnProperty(prop)) continue;
|
|
this.props[prop] = defaultProps[prop].default;
|
|
}
|
|
}
|
|
},
|
|
|
|
async setting() {
|
|
const form = data.props();
|
|
for (const item of Object.keys(form)) {
|
|
form[item].default = this.props[item];
|
|
}
|
|
const { canceled, result } = await os.form(data.name, form);
|
|
if (canceled) return;
|
|
|
|
for (const key of Object.keys(result)) {
|
|
this.props[key] = result[key];
|
|
}
|
|
|
|
this.save();
|
|
},
|
|
|
|
save() {
|
|
this.$emit('updateProps', this.props);
|
|
}
|
|
}
|
|
});
|
|
}
|