mirror of
https://github.com/sim1222/misskey.git
synced 2025-08-07 01:04:03 +09:00
refactor(client): refactor dialog functions to improve type inference
This commit is contained in:
@ -272,14 +272,14 @@ export default defineComponent({
|
||||
const onError = err => {
|
||||
if (err.id == '3d81ceae-475f-4600-b2a8-2bc116157532') {
|
||||
if (err.info.param == 'name') {
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: this.$ts._pages.invalidNameTitle,
|
||||
text: this.$ts._pages.invalidNameText
|
||||
});
|
||||
}
|
||||
} else if (err.code == 'NAME_ALREADY_EXISTS') {
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'error',
|
||||
text: this.$ts._pages.nameAlreadyExists
|
||||
});
|
||||
@ -291,7 +291,7 @@ export default defineComponent({
|
||||
os.api('pages/update', options)
|
||||
.then(page => {
|
||||
this.currentName = this.name.trim();
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'success',
|
||||
text: this.$ts._pages.updated
|
||||
});
|
||||
@ -301,7 +301,7 @@ export default defineComponent({
|
||||
.then(page => {
|
||||
this.pageId = page.id;
|
||||
this.currentName = this.name.trim();
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'success',
|
||||
text: this.$ts._pages.created
|
||||
});
|
||||
@ -311,16 +311,15 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
del() {
|
||||
os.dialog({
|
||||
os.confirm({
|
||||
type: 'warning',
|
||||
text: this.$t('removeAreYouSure', { x: this.title.trim() }),
|
||||
showCancelButton: true
|
||||
}).then(({ canceled }) => {
|
||||
if (canceled) return;
|
||||
os.api('pages/delete', {
|
||||
pageId: this.pageId,
|
||||
}).then(() => {
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'success',
|
||||
text: this.$ts._pages.deleted
|
||||
});
|
||||
@ -335,7 +334,7 @@ export default defineComponent({
|
||||
os.api('pages/create', this.getSaveOptions()).then(page => {
|
||||
this.pageId = page.id;
|
||||
this.currentName = this.name.trim();
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'success',
|
||||
text: this.$ts._pages.created
|
||||
});
|
||||
@ -344,13 +343,10 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
async add() {
|
||||
const { canceled, result: type } = await os.dialog({
|
||||
const { canceled, result: type } = await os.select({
|
||||
type: null,
|
||||
title: this.$ts._pages.chooseBlock,
|
||||
select: {
|
||||
groupedItems: this.getPageBlockList()
|
||||
},
|
||||
showCancelButton: true
|
||||
groupedItems: this.getPageBlockList()
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
@ -359,19 +355,15 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
async addVariable() {
|
||||
let { canceled, result: name } = await os.dialog({
|
||||
let { canceled, result: name } = await os.inputText({
|
||||
title: this.$ts._pages.enterVariableName,
|
||||
input: {
|
||||
type: 'text',
|
||||
},
|
||||
showCancelButton: true
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
name = name.trim();
|
||||
|
||||
if (this.hpml.isUsedName(name)) {
|
||||
os.dialog({
|
||||
os.alert({
|
||||
type: 'error',
|
||||
text: this.$ts._pages.variableNameIsAlreadyUsed
|
||||
});
|
||||
|
Reference in New Issue
Block a user