forked from FoundKeyGang/FoundKey
refactor: sample.vue to composition api
This commit is contained in:
parent
16833b8cd8
commit
9e8b59f886
1 changed files with 52 additions and 72 deletions
|
@ -27,90 +27,70 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { ref } from 'vue';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import MkInput from '@/components/form/input.vue';
|
import MkInput from '@/components/form/input.vue';
|
||||||
import MkSwitch from '@/components/form/switch.vue';
|
import MkSwitch from '@/components/form/switch.vue';
|
||||||
import MkTextarea from '@/components/form/textarea.vue';
|
|
||||||
import MkRadio from '@/components/form/radio.vue';
|
import MkRadio from '@/components/form/radio.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as config from '@/config';
|
import * as config from '@/config';
|
||||||
|
import { $i } from '@/account';
|
||||||
|
|
||||||
export default defineComponent({
|
const text = ref('');
|
||||||
components: {
|
const flag = ref(true);
|
||||||
MkButton,
|
const radio = ref('misskey');
|
||||||
MkInput,
|
const mfm = ref(`Hello world! This is an @example mention. BTW you are @${$i ? $i.username : 'guest'}.\nAlso, here is ${config.url} and [example link](${config.url}). for more details, see https://example.com.\nAs you know #misskey is open-source software.`);
|
||||||
MkSwitch,
|
|
||||||
MkTextarea,
|
|
||||||
MkRadio,
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
function openDialog(): void {
|
||||||
return {
|
|
||||||
text: '',
|
|
||||||
flag: true,
|
|
||||||
radio: 'misskey',
|
|
||||||
mfm: `Hello world! This is an @example mention. BTW you are @${this.$i ? this.$i.username : 'guest'}.\nAlso, here is ${config.url} and [example link](${config.url}). for more details, see https://example.com.\nAs you know #misskey is open-source software.`
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
async openDialog() {
|
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
title: 'Oh my Aichan',
|
title: 'Oh my Aichan',
|
||||||
text: 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
text: 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
async openForm() {
|
function openForm(): void {
|
||||||
os.form('Example form', {
|
os.form('Example form', {
|
||||||
foo: {
|
foo: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: true,
|
default: true,
|
||||||
label: 'This is a boolean property'
|
label: 'This is a boolean property',
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 300,
|
default: 300,
|
||||||
label: 'This is a number property'
|
label: 'This is a number property',
|
||||||
},
|
},
|
||||||
baz: {
|
baz: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'Misskey makes you happy.',
|
default: 'Misskey makes you happy.',
|
||||||
label: 'This is a string property'
|
label: 'This is a string property',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
async openDrive() {
|
function openDrive(): void {
|
||||||
os.selectDriveFile();
|
os.selectDriveFile(true);
|
||||||
},
|
}
|
||||||
|
|
||||||
async selectUser() {
|
function openMenu(ev): void {
|
||||||
os.selectUser();
|
|
||||||
},
|
|
||||||
|
|
||||||
async openMenu(ev) {
|
|
||||||
os.popupMenu([{
|
os.popupMenu([{
|
||||||
type: 'label',
|
type: 'label',
|
||||||
text: 'Fruits'
|
text: 'Fruits'
|
||||||
}, {
|
}, {
|
||||||
text: 'Create some apples',
|
text: 'Create some apples',
|
||||||
action: () => {},
|
action: (): void => {},
|
||||||
}, {
|
}, {
|
||||||
text: 'Read some oranges',
|
text: 'Read some oranges',
|
||||||
action: () => {},
|
action: (): void => {},
|
||||||
}, {
|
}, {
|
||||||
text: 'Update some melons',
|
text: 'Update some melons',
|
||||||
action: () => {},
|
action: (): void => {},
|
||||||
}, null, {
|
}, null, {
|
||||||
text: 'Delete some bananas',
|
text: 'Delete some bananas',
|
||||||
danger: true,
|
danger: true,
|
||||||
action: () => {},
|
action: (): void => {},
|
||||||
}], ev.currentTarget ?? ev.target);
|
}], ev.currentTarget ?? ev.target);
|
||||||
},
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue