mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 12:13:48 +01:00
ページURLが他と重複してたらエラーを投げるように (#5354)
* [Page]nameが重複したときの処理を追加 * page-editor側のerr.idにuuidを適用 * refactor * uuidをわけた
This commit is contained in:
parent
70b0a395dc
commit
bfc369d8ea
@ -1817,6 +1817,7 @@ pages:
|
|||||||
read-page: "Viewing the source"
|
read-page: "Viewing the source"
|
||||||
page-created: "Created the page!"
|
page-created: "Created the page!"
|
||||||
page-updated: "Updated the page"
|
page-updated: "Updated the page"
|
||||||
|
name-already-exists: "Specified page url already exists"
|
||||||
are-you-sure-delete: "Do you want to delete this page?"
|
are-you-sure-delete: "Do you want to delete this page?"
|
||||||
page-deleted: "The page has been deleted"
|
page-deleted: "The page has been deleted"
|
||||||
edit-this-page: "Edit this page"
|
edit-this-page: "Edit this page"
|
||||||
|
@ -2015,6 +2015,7 @@ pages:
|
|||||||
read-page: "ソースを表示中"
|
read-page: "ソースを表示中"
|
||||||
page-created: "ページを作成しました"
|
page-created: "ページを作成しました"
|
||||||
page-updated: "ページを更新しました"
|
page-updated: "ページを更新しました"
|
||||||
|
name-already-exists: "指定されたページURLは既に存在しています"
|
||||||
are-you-sure-delete: "このページを削除しますか?"
|
are-you-sure-delete: "このページを削除しますか?"
|
||||||
page-deleted: "ページを削除しました"
|
page-deleted: "ページを削除しました"
|
||||||
edit-this-page: "このページを編集"
|
edit-this-page: "このページを編集"
|
||||||
|
@ -220,37 +220,38 @@ export default Vue.extend({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
save() {
|
save() {
|
||||||
|
const options = {
|
||||||
|
title: this.title.trim(),
|
||||||
|
name: this.name.trim(),
|
||||||
|
summary: this.summary,
|
||||||
|
font: this.font,
|
||||||
|
hideTitleWhenPinned: this.hideTitleWhenPinned,
|
||||||
|
alignCenter: this.alignCenter,
|
||||||
|
content: this.content,
|
||||||
|
variables: this.variables,
|
||||||
|
eyeCatchingImageId: this.eyeCatchingImageId,
|
||||||
|
};
|
||||||
|
|
||||||
if (this.pageId) {
|
if (this.pageId) {
|
||||||
this.$root.api('pages/update', {
|
options.pageId = this.pageId;
|
||||||
pageId: this.pageId,
|
this.$root.api('pages/update', options)
|
||||||
title: this.title.trim(),
|
.then(page => {
|
||||||
name: this.name.trim(),
|
|
||||||
summary: this.summary,
|
|
||||||
font: this.font,
|
|
||||||
hideTitleWhenPinned: this.hideTitleWhenPinned,
|
|
||||||
alignCenter: this.alignCenter,
|
|
||||||
content: this.content,
|
|
||||||
variables: this.variables,
|
|
||||||
eyeCatchingImageId: this.eyeCatchingImageId,
|
|
||||||
}).then(page => {
|
|
||||||
this.currentName = this.name.trim();
|
this.currentName = this.name.trim();
|
||||||
this.$root.dialog({
|
this.$root.dialog({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
text: this.$t('page-updated')
|
text: this.$t('page-updated')
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
if(err.id == '2298a392-d4a1-44c5-9ebb-ac1aeaa5a9ab'){
|
||||||
|
this.$root.dialog({
|
||||||
|
type: 'error',
|
||||||
|
text: this.$t('name-already-exists')
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$root.api('pages/create', {
|
this.$root.api('pages/create', options)
|
||||||
title: this.title.trim(),
|
.then(page => {
|
||||||
name: this.name.trim(),
|
|
||||||
summary: this.summary,
|
|
||||||
font: this.font,
|
|
||||||
hideTitleWhenPinned: this.hideTitleWhenPinned,
|
|
||||||
alignCenter: this.alignCenter,
|
|
||||||
content: this.content,
|
|
||||||
variables: this.variables,
|
|
||||||
eyeCatchingImageId: this.eyeCatchingImageId,
|
|
||||||
}).then(page => {
|
|
||||||
this.pageId = page.id;
|
this.pageId = page.id;
|
||||||
this.currentName = this.name.trim();
|
this.currentName = this.name.trim();
|
||||||
this.$root.dialog({
|
this.$root.dialog({
|
||||||
@ -258,6 +259,13 @@ export default Vue.extend({
|
|||||||
text: this.$t('page-created')
|
text: this.$t('page-created')
|
||||||
});
|
});
|
||||||
this.$router.push(`/i/pages/edit/${this.pageId}`);
|
this.$router.push(`/i/pages/edit/${this.pageId}`);
|
||||||
|
}).catch(err => {
|
||||||
|
if(err.id == '4650348e-301c-499a-83c9-6aa988c66bc1'){
|
||||||
|
this.$root.dialog({
|
||||||
|
type: 'error',
|
||||||
|
text: this.$t('name-already-exists')
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -76,6 +76,11 @@ export const meta = {
|
|||||||
code: 'NO_SUCH_FILE',
|
code: 'NO_SUCH_FILE',
|
||||||
id: 'b7b97489-0f66-4b12-a5ff-b21bd63f6e1c'
|
id: 'b7b97489-0f66-4b12-a5ff-b21bd63f6e1c'
|
||||||
},
|
},
|
||||||
|
nameAlreadyExists: {
|
||||||
|
message: 'Specified name already exists.',
|
||||||
|
code: 'NAME_ALREADY_EXISTS',
|
||||||
|
id: '4650348e-301c-499a-83c9-6aa988c66bc1'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,6 +97,15 @@ export default define(meta, async (ps, user) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Pages.find({
|
||||||
|
userId: user.id,
|
||||||
|
name: ps.name
|
||||||
|
}).then(result => {
|
||||||
|
if (result.length > 0) {
|
||||||
|
throw new ApiError(meta.errors.nameAlreadyExists);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const page = await Pages.save(new Page({
|
const page = await Pages.save(new Page({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
@ -4,6 +4,7 @@ import define from '../../define';
|
|||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Pages, DriveFiles } from '../../../../models';
|
import { Pages, DriveFiles } from '../../../../models';
|
||||||
import { ID } from '../../../../misc/cafy-id';
|
import { ID } from '../../../../misc/cafy-id';
|
||||||
|
import { Not } from 'typeorm';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -85,6 +86,11 @@ export const meta = {
|
|||||||
code: 'NO_SUCH_FILE',
|
code: 'NO_SUCH_FILE',
|
||||||
id: 'cfc23c7c-3887-490e-af30-0ed576703c82'
|
id: 'cfc23c7c-3887-490e-af30-0ed576703c82'
|
||||||
},
|
},
|
||||||
|
nameAlreadyExists: {
|
||||||
|
message: 'Specified name already exists.',
|
||||||
|
code: 'NAME_ALREADY_EXISTS',
|
||||||
|
id: '2298a392-d4a1-44c5-9ebb-ac1aeaa5a9ab'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -109,6 +115,16 @@ export default define(meta, async (ps, user) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Pages.find({
|
||||||
|
id: Not(ps.pageId),
|
||||||
|
userId: user.id,
|
||||||
|
name: ps.name
|
||||||
|
}).then(result => {
|
||||||
|
if (result.length > 0) {
|
||||||
|
throw new ApiError(meta.errors.nameAlreadyExists);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await Pages.update(page.id, {
|
await Pages.update(page.id, {
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
title: ps.title,
|
title: ps.title,
|
||||||
|
Loading…
Reference in New Issue
Block a user