feat: 通報の即時解決機能の改善 (#132)
* feat: 通報の即時解決機能にplaceholderを設定 * PRから2134a793537c7ca57bd7de88d6099b
This commit is contained in:
		
							parent
							
								
									233d967b82
								
							
						
					
					
						commit
						33e21dd2ec
					
				|  | @ -108,15 +108,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { | |||
| 			} | ||||
| 			const now = new Date(); | ||||
| 			let expirationDate: Date | null = new Date(); | ||||
| 
 | ||||
| 			const previousMonth = expirationDate.getUTCMonth(); | ||||
| 			(ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : | ||||
| 				ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : | ||||
| 				ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : | ||||
| 				ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : | ||||
| 				ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1 + 1) / 12))); } : | ||||
| 				ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3 + 1) / 12 ))); } : | ||||
| 				ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6 + 1) / 12))); } : | ||||
| 				ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); | ||||
| 				ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 1 + 1) / 12))); } : | ||||
| 				ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 3 + 1) / 12))); } : | ||||
| 				ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 6 + 1) / 12))); } : | ||||
| 				ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })(); | ||||
| 
 | ||||
| 			return await this.abuseReportResolverRepository.insert({ | ||||
| 				id: this.idService.genId(), | ||||
|  |  | |||
|  | @ -95,14 +95,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { | |||
| 			if (ps.forward) properties.forward = ps.forward; | ||||
| 			if (ps.expiresAt) { | ||||
| 				let expirationDate: Date | null = new Date(); | ||||
| 				const previousMonth = expirationDate.getUTCMonth(); | ||||
| 				(ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : | ||||
| 					ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : | ||||
| 					ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : | ||||
| 					ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : | ||||
| 					ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1 + 1) / 12))); } : | ||||
| 					ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3 + 1) / 12))); } : | ||||
| 					ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6 + 1) / 12))); } : | ||||
| 					ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); | ||||
| 					ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 1 + 1) / 12))); } : | ||||
| 					ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 3 + 1) / 12))); } : | ||||
| 					ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 6 + 1) / 12))); } : | ||||
| 					ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })(); | ||||
| 
 | ||||
| 				properties.expiresAt = ps.expiresAt; | ||||
| 				properties.expirationDate = expirationDate; | ||||
|  |  | |||
|  | @ -5,18 +5,18 @@ | |||
| 	</MkInput> | ||||
| 	<div> | ||||
| 		<div :class="$style.label">{{ i18n.ts._abuse._resolver.targetUserPattern }}</div> | ||||
| 		<PrismEditor v-model="value.targetUserPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/> | ||||
| 		<PrismEditor v-model="value.targetUserPattern" placeholder="^(LocalUser|RemoteUser@RemoteHost)$" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :ignoreTabKey="true" :readonly="!props.editable"/> | ||||
| 	</div> | ||||
| 	<div> | ||||
| 		<div :class="$style.label">{{ i18n.ts._abuse._resolver.reporterPattern }}</div> | ||||
| 		<PrismEditor v-model="value.reporterPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/> | ||||
| 		<PrismEditor v-model="value.reporterPattern" placeholder="^(LocalUser|.*@RemoteHost)$" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :ignoreTabKey="true" :readonly="!props.editable"/> | ||||
| 	</div> | ||||
| 	<div> | ||||
| 		<div :class="$style.label">{{ i18n.ts._abuse._resolver.reportContentPattern }}</div> | ||||
| 		<PrismEditor v-model="value.reportContentPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/> | ||||
| 		<PrismEditor v-model="value.reportContentPattern" placeholder=".*" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :ignoreTabKey="true" :readonly="!props.editable"/> | ||||
| 	</div> | ||||
| 	<MkSelect v-model="value.expiresAt" :disabled="!props.editable"> | ||||
| 		<template #label>{{ i18n.ts._abuse._resolver.expiresAt }}<span v-if="expirationDate" style="float: right;">{{ expirationDate }}</span></template> | ||||
| 		<template #label>{{ i18n.ts._abuse._resolver.expiresAt }}<span v-if="expirationDate" style="float: right;"><MkDate :time="expirationDate" mode="absolute">{{ expirationDate }}</MkDate></span></template> | ||||
| 		<option value="1hour">{{ i18n.ts._abuse._resolver['1hour'] }}</option> | ||||
| 		<option value="12hours">{{ i18n.ts._abuse._resolver['12hours'] }}</option> | ||||
| 		<option value="1day">{{ i18n.ts._abuse._resolver['1day'] }}</option> | ||||
|  | @ -70,7 +70,7 @@ const props = defineProps<{ | |||
| 		previousExpiresAt?: string; | ||||
| 	} | ||||
| }>(); | ||||
| let expirationDate: string | null = $ref(null); | ||||
| let expirationDate: Date | null = $ref(null); | ||||
| 
 | ||||
| type NonNullType<T> = { | ||||
| 	[P in keyof T]: NonNullable<T[P]> | ||||
|  | @ -113,7 +113,7 @@ function highlighter(code) { | |||
| 
 | ||||
| function renderExpirationDate(empty = false) { | ||||
| 	if (value.value.expirationDate && !empty) { | ||||
| 		expirationDate = new Date(value.value.expirationDate).toLocaleString(); | ||||
| 		expirationDate = new Date(value.value.expirationDate); | ||||
| 	} else { | ||||
| 		expirationDate = null; | ||||
| 	} | ||||
|  |  | |||
|  | @ -57,7 +57,7 @@ | |||
| 						<MkAbuseReportResolver v-model="editingResolver" :data="(resolver as any)" :editable="editableResolver === resolver.id"> | ||||
| 							<template #button> | ||||
| 								<div v-if="editableResolver !== resolver.id"> | ||||
| 									<MkButton primary inline :class="$style.button-margin" @click="edit(resolver.id)"><i class="ti ti-pencil"></i> {{ i18n.ts.edit }}</MkButton> | ||||
| 									<MkButton primary inline :class="$style.buttonMargin" @click="edit(resolver.id)"><i class="ti ti-pencil"></i> {{ i18n.ts.edit }}</MkButton> | ||||
| 									<MkButton danger inline @click="deleteResolver(resolver.id)"><i class="ti ti-trash"></i> {{ i18n.ts.remove }}</MkButton> | ||||
| 								</div> | ||||
| 								<div v-else> | ||||
|  | @ -214,13 +214,13 @@ definePageMetadata({ | |||
| 	flex: 1; | ||||
| } | ||||
| 
 | ||||
| .button-margin { | ||||
| .buttonMargin { | ||||
| 	margin-right: 6px; | ||||
| } | ||||
| 
 | ||||
| .state { | ||||
| 	@extend .input-base; | ||||
| 	@extend .button-margin; | ||||
| 	@extend .buttonMargin; | ||||
| } | ||||
| .reporterOrigin { | ||||
| 	@extend .input-base; | ||||
|  | @ -228,7 +228,7 @@ definePageMetadata({ | |||
| 
 | ||||
| .targetUserOrigin { | ||||
| 	@extend .input-base; | ||||
| 	@extend .button-margin; | ||||
| 	@extend .buttonMargin; | ||||
| } | ||||
| 
 | ||||
| .margin { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue