pref: replace message to Message

This commit is contained in:
KUN1007 2023-10-13 23:05:30 +08:00
parent 233dd4a5d2
commit c425aac9b2
23 changed files with 98 additions and 98 deletions

View file

@ -4,7 +4,7 @@ import { ref, computed, watch } from 'vue'
import { questionsEN, Question } from './questionsEN'
import { questionsCN } from './questionsCN'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// store
import { useKUNGalgameMessageStore } from '@/store/modules/message'
//
@ -82,7 +82,7 @@ const submitAnswer = () => {
isCaptureSuccessful.value = true
//
isShowCapture.value = false
message(
Message(
'Human-machine identity verification successful ~',
'人机身份验证通过 ~',
'success'
@ -91,7 +91,7 @@ const submitAnswer = () => {
//
errorCounter.value++
message('Wrong answer!', '回答错误!', 'warn')
Message('Wrong answer!', '回答错误!', 'warn')
//
const randomIndex = randomizeQuestion()

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
//
import { useRoute, useRouter } from 'vue-router'
@ -42,7 +42,7 @@ const handleClickHelp = () => {
<p>网站的代码是手写的错误在所难免</p>
<p>如果您遇到错误<a style="color: var(--kungalgame-blue-4); border-bottom: 2px solid var(--kungalgame-blue-4);" href="/contact">联系我们</a></p>`
message(helpHtmlEN, helpHtmlCN, 'info', 5000)
Message(helpHtmlEN, helpHtmlCN, 'info', 5000)
}
}
</script>

View file

@ -7,7 +7,7 @@ import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
import backgroundImages from './background'
@ -45,7 +45,7 @@ const handleCustomBackground = () => {
showKUNGalgameBackground.value = '1007'
url.value = ''
} else {
message('Please input valid image url', '请输入合法的图片链接', 'warn')
Message('Please input valid image url', '请输入合法的图片链接', 'warn')
}
}
//

View file

@ -2,7 +2,7 @@
import { ref } from 'vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia'
@ -17,7 +17,7 @@ const handleSetFont = () => {
settingsStore.setKUNGalgameFontStyle(font.value)
font.value = ''
} else {
message('Please input valid font name', '请输入合法的字体名', 'warn')
Message('Please input valid font name', '请输入合法的字体名', 'warn')
}
}
</script>

View file

@ -2,7 +2,7 @@
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
//
import { useKUNGalgameMessageStore } from '@/store/modules/message'
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
@ -42,7 +42,7 @@ const logOut = async () => {
kungalgameStoreReset()
router.push('/login')
resetRouter()
message('Logout successfully!', '登出成功', 'success')
Message('Logout successfully!', '登出成功', 'success')
}
}

View file

@ -1,5 +1,5 @@
import type { Directive, DirectiveBinding } from 'vue'
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
import { currentUserInfo } from '@/utils/getCurrentUserInfo'
import router from '@/router'
@ -29,7 +29,7 @@ interface BindingProps {
const handleUnauthorizedAccess = (element: HTMLElement) => {
element.parentNode?.removeChild(element)
message(
Message(
'You do not have sufficient permissions!',
'您没有足够的权限!',
'error',

View file

@ -1,12 +1,12 @@
// 全局消息组件(顶部)
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
import { getErrorMessageEN, getErrorMessageCN } from './errorI18n'
const showMessage = (errorCode: number) => {
const messageType = 'error'
const messageTextEN = getErrorMessageEN(errorCode)
const messageTextCN = getErrorMessageCN(errorCode)
message(messageTextEN, messageTextCN, messageType)
Message(messageTextEN, messageTextCN, messageType)
}
/**

View file

@ -1,5 +1,5 @@
// 全局消息组件(顶部)
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
import { generateTokenByRefreshTokenApi } from '@/api'
// 使用用户 store
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
@ -30,7 +30,7 @@ export async function onRequestError(response: Response) {
location.reload()
} else {
// 否则提示用户重新登陆
message(
Message(
'Login expired, please log in again.',
'登陆过期,请重新登陆',
'error'
@ -42,7 +42,7 @@ export async function onRequestError(response: Response) {
}
if (response.status === 404) {
message(
Message(
'Not Found, request address is incorrect.',
'资源未找到,请求地址出错',
'error'

View file

@ -2,7 +2,7 @@
import { EditCreateTopicRequestData, EditUpdateTopicRequestData } from '@/api'
// 全局消息组件(顶部)
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// 类型守卫,确定 EditUpdateTopicRequestData 含有 tid
const isEditUpdateTopicData = (data: any): data is EditUpdateTopicRequestData =>
@ -17,7 +17,7 @@ export const checkTopicPublish = (
if (isEditUpdateTopicData(topicData)) {
// 话题 id 为零,应该。。。。不存在吧(
if (!topicData.tid) {
message('Failed to resolve topic', '未能解析话题 ID', 'error')
Message('Failed to resolve topic', '未能解析话题 ID', 'error')
return false
}
}
@ -25,30 +25,30 @@ export const checkTopicPublish = (
// 检查标题
if (!topicData.title.trim()) {
// 标题为空的话,警告
message('Title cannot be empty!', '标题不可为空!', 'warn')
Message('Title cannot be empty!', '标题不可为空!', 'warn')
return false
}
// 检查内容字数
if (!textCount) {
// 内容为空的话,警告
message('Content cannot be empty!', '内容不可为空!', 'warn')
Message('Content cannot be empty!', '内容不可为空!', 'warn')
return false
}
if (textCount > 100007) {
message('Content max length is 100007!', '内容最大长度为100007', 'warn')
Message('Content max length is 100007!', '内容最大长度为100007', 'warn')
return false
}
// 检查 tag
if (!topicData.tags.length) {
message('Please use at least one tag!', '请至少使用一个标签!', 'warn')
Message('Please use at least one tag!', '请至少使用一个标签!', 'warn')
return false
}
// 检查分类
if (!topicData.category.length) {
message(
Message(
'Please select at least one category!',
'请至少选择一个分类!',
'warn'

View file

@ -2,7 +2,7 @@
import { ref, computed, watch, onBeforeMount, onMounted } from 'vue'
import { useRoute } from 'vue-router'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// store
import { useKUNGalgameEditStore } from '@/store/modules/edit'
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
@ -96,7 +96,7 @@ const handleAddTag = () => {
// tag
if (selectedTags.value.includes(tagName)) {
message(
Message(
'Tag already exists, please choose another one',
'标签已存在,请更换',
'warn'

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue'
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
//
import {
checkImageValid,
@ -51,7 +51,7 @@ const handleDragOver = (event: DragEvent) => {
//
const handleChangeAvatar = () => {
message(
Message(
'Image API is not yet completed, stay tuned for updates',
'图片接口还未完成,敬请期待',
'warn'

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import Avatar from '../components/Avatar.vue'
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// store
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
@ -14,7 +14,7 @@ const bioValue = ref('')
const handleChangeBio = async () => {
//
if (bioValue.value.length > 107) {
message(
Message(
'Bio must not exceed a maximum length of 107 characters',
'签名的最大长度不可超过 107 个字符',
'warn'
@ -27,10 +27,10 @@ const handleChangeBio = async () => {
bioValue.value
)
if (res.code === 200) {
message('Rewrite bio successfully!', 'Rewrite 签名成功', 'success')
Message('Rewrite bio successfully!', 'Rewrite 签名成功', 'success')
bioValue.value = ''
} else {
message('Rewrite bio failed!', 'Rewrite 签名失败', 'error')
Message('Rewrite bio failed!', 'Rewrite 签名失败', 'error')
}
}
</script>

View file

@ -1,4 +1,4 @@
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
const dataURItoBlob = (dataURI: string) => {
const byteString = atob(dataURI.split(',')[1])
@ -15,7 +15,7 @@ export const checkImageValid = (file: File) => {
if (file.type === 'image/jpeg' || file.type === 'image/png') {
return true
} else {
message(
Message(
'Invalid file type. Please select a JPEG or PNG image.',
'非法的文件类型,请选择 JPG 或 PNG 图片!',
'warn'
@ -56,7 +56,7 @@ export const resizeImage = (file: File): Promise<Blob> => {
const resizedFile = dataURItoBlob(canvas.toDataURL('image/webp', 0.77))
if (resizedFile.size > 1007 * 1024) {
message(
Message(
'Image is too large. Please select an image smaller than 1007KB!',
'文件过大, 请选择小于 1007KB 的文件! ',
'warn'

View file

@ -7,7 +7,7 @@ import { useKUNGalgameMessageStore } from '@/store/modules/message'
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
import { storeToRefs } from 'pinia'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// 使
import Settings from './Settings.vue'
@ -45,13 +45,13 @@ const registerForm = reactive<Record<string, string>>({
//
const isEmptyInput = () => {
if (!registerForm.name.trim()) {
message('Username cannot be empty!', '用户名不可为空!', 'warn')
Message('Username cannot be empty!', '用户名不可为空!', 'warn')
return false
} else if (!registerForm.email.trim()) {
message('Email cannot be empty!', '邮箱不可为空!', 'warn')
Message('Email cannot be empty!', '邮箱不可为空!', 'warn')
return false
} else if (!registerForm.password.trim()) {
message('Password cannot be empty!', '密码不可为空!', 'warn')
Message('Password cannot be empty!', '密码不可为空!', 'warn')
return false
} else {
return true
@ -64,15 +64,15 @@ const isValidInput = (): boolean => {
return false
}
if (!isValidName(registerForm.name)) {
message('Invalid username format!', '非法的用户名格式!', 'warn')
Message('Invalid username format!', '非法的用户名格式!', 'warn')
return false
}
if (!isValidEmail(registerForm.email)) {
message('Invalid email format!', '非法的邮箱格式!', 'warn')
Message('Invalid email format!', '非法的邮箱格式!', 'warn')
return false
}
if (!isValidPassword(registerForm.password)) {
message('Invalid password format!', '非法的密码格式!', 'warn')
Message('Invalid password format!', '非法的密码格式!', 'warn')
return false
}
return true
@ -82,7 +82,7 @@ const isValidInput = (): boolean => {
const handleSendCode = () => {
//
if (!isValidInput()) {
message('Form cannot be empty', '表单不可为空', 'warn')
Message('Form cannot be empty', '表单不可为空', 'warn')
return
}
@ -99,7 +99,7 @@ const handleSendCode = () => {
const handleRegister = async () => {
if (!isSendCode.value) {
message(
Message(
'Need to send an email verification code',
'需要发送邮箱验证码',
'warn'
@ -108,7 +108,7 @@ const handleRegister = async () => {
}
if (!registerForm.code.trim()) {
message(
Message(
'Email verification code cannot be empty',
'邮箱验证码不可为空',
'warn'
@ -117,7 +117,7 @@ const handleRegister = async () => {
}
if (!isValidMailConfirmCode(registerForm.code)) {
message(
Message(
'Invalid email verification code format!',
'非法的邮箱验证码格式!',
'warn'
@ -136,10 +136,10 @@ const handleRegister = async () => {
//
if (res.code === 200) {
router.push('/')
message('Register successfully!', '注册成功!', 'success')
Message('Register successfully!', '注册成功!', 'success')
info.info(tm('AlertInfo.login.success'))
} else {
message('Register failed!', '注册失败!', 'error')
Message('Register failed!', '注册失败!', 'error')
}
}
</script>

View file

@ -11,7 +11,7 @@ import {
watch,
} from 'vue'
import { onBeforeRouteLeave, useRoute } from 'vue-router'
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
//
import { useKUNGalgameMessageStore } from '@/store/modules/message'
@ -161,7 +161,7 @@ watch(
childElement.classList.remove('active')
// DOM
} else {
message(
Message(
'Unable to find the specified reply for now. Please scroll down.',
'暂时找不到指定回复,请下滑',
'info'

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref } from 'vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
import { debounce } from '@/utils/debounce'
import { TopicComment } from '@/api/index'
@ -42,13 +42,13 @@ const handleInputComment = () => {
const isValidComment = () => {
//
if (!content.value.trim()) {
message('Comment content cannot be empty!', '评论内容不能为空!', 'warn')
Message('Comment content cannot be empty!', '评论内容不能为空!', 'warn')
return false
}
//
if (content.value.trim().length > 1007) {
message(
Message(
'The maximum length for comments should not exceed 1007 characters.',
'评论最大长度不可超过1007个字符',
'warn'
@ -76,7 +76,7 @@ const handlePublishComment = async () => {
emits('getCommentEmits', newComment)
//
message('Comment publish successfully!', '评论发布成功', 'success')
Message('Comment publish successfully!', '评论发布成功', 'success')
handleCloseCommentPanel()
}

View file

@ -5,7 +5,7 @@
import { ref, watch } from 'vue'
import { Icon } from '@iconify/vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// throttle
import { throttle } from '@/utils/throttle'
@ -35,7 +35,7 @@ watch(
// throttle
const throttleCallback = () => {
message(
Message(
'You can only perform one operation within 1007 milliseconds',
'您在 1007 毫秒内只能进行一次操作',
'warn'
@ -45,13 +45,13 @@ const throttleCallback = () => {
const dislikeComment = async () => {
//
if (isDisliked.value) {
message(`You've already disliked it`, '您已经点过踩了', 'warn')
Message(`You've already disliked it`, '您已经点过踩了', 'warn')
return
}
//
if (props.uid === props.toUid) {
message('You cannot dislike yourself', '您不可以给自己点踩', 'warn')
Message('You cannot dislike yourself', '您不可以给自己点踩', 'warn')
return
}
@ -65,9 +65,9 @@ const dislikeComment = async () => {
if (res.code === 200) {
dislikesCount.value++
isDisliked.value = true
message('Dislike successfully!', '点踩成功', 'success')
Message('Dislike successfully!', '点踩成功', 'success')
} else {
message('Dislike failed!', '点踩失败', 'error')
Message('Dislike failed!', '点踩失败', 'error')
}
}

View file

@ -5,7 +5,7 @@
import { ref, watch } from 'vue'
import { Icon } from '@iconify/vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// throttle
import { throttle } from '@/utils/throttle'
@ -36,7 +36,7 @@ watch(
// throttle
const throttleCallback = () => {
message(
Message(
'You can only perform one operation within 1007 milliseconds',
'您在 1007 毫秒内只能进行一次操作',
'warn'
@ -46,13 +46,13 @@ const throttleCallback = () => {
const likeComment = async () => {
//
if (isLiked.value) {
message(`You've already liked it`, '您已经点过赞了', 'warn')
Message(`You've already liked it`, '您已经点过赞了', 'warn')
return
}
//
if (props.uid === props.toUid) {
message('You cannot like yourself', '您不可以给自己点赞', 'warn')
Message('You cannot like yourself', '您不可以给自己点赞', 'warn')
return
}
@ -62,9 +62,9 @@ const likeComment = async () => {
if (res.code === 200) {
likesCount.value++
isLiked.value = true
message('Like successfully!', '点赞成功', 'success')
Message('Like successfully!', '点赞成功', 'success')
} else {
message('Like failed!', '点赞失败', 'error')
Message('Like failed!', '点赞失败', 'error')
}
}

View file

@ -3,7 +3,7 @@
import { watch, ref } from 'vue'
import { Icon } from '@iconify/vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// throttle
import { throttle } from '@/utils/throttle'
@ -34,7 +34,7 @@ watch(
// throttle
const throttleCallback = () => {
message(
Message(
'You can only perform one operation within 1007 milliseconds',
'您在 1007 毫秒内只能进行一次操作',
'warn'
@ -70,7 +70,7 @@ const dislikeOperation = async (
const toggleDislike = async () => {
//
if (props.uid === props.toUid) {
message('You cannot dislike yourself', '您不可以给自己点踩', 'warn')
Message('You cannot dislike yourself', '您不可以给自己点踩', 'warn')
return
}
@ -85,15 +85,15 @@ const toggleDislike = async () => {
dislikesCount.value += isPush ? 1 : -1
if (isPush) {
message('Dislike successfully!', '点踩成功!', 'success')
Message('Dislike successfully!', '点踩成功!', 'success')
} else {
message('Cancel dislike successfully!', '取消点踩成功!', 'success')
Message('Cancel dislike successfully!', '取消点踩成功!', 'success')
}
} else {
if (isPush) {
message('Dislike failed!', '点踩失败!', 'error')
Message('Dislike failed!', '点踩失败!', 'error')
} else {
message('Cancel dislike failed!', '取消点踩失败!', 'error')
Message('Cancel dislike failed!', '取消点踩失败!', 'error')
}
}
}

View file

@ -14,7 +14,7 @@ import Reply from './Reply.vue'
import Rewrite from './Rewrite.vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// store
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
@ -83,10 +83,10 @@ Link: https://www.kungal.com/topic/${props.info.tid}`
navigator.clipboard
.writeText(shareLink.value)
.then(() => {
message('Share Link copied successfully!', '分享链接复制成功', 'success')
Message('Share Link copied successfully!', '分享链接复制成功', 'success')
})
.catch((err) => {
message('Share Link copied failed!', '分享链接复制失败!', 'error')
Message('Share Link copied failed!', '分享链接复制失败!', 'error')
})
}
</script>

View file

@ -3,7 +3,7 @@
import { watch, ref } from 'vue'
import { Icon } from '@iconify/vue'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// throttle
import { throttle } from '@/utils/throttle'
@ -34,7 +34,7 @@ watch(
// throttle
const throttleCallback = () => {
message(
Message(
'You can only perform one operation within 1007 milliseconds',
'您在 1007 毫秒内只能进行一次操作',
'warn'
@ -66,7 +66,7 @@ const likeOperation = async (
const toggleLike = async () => {
//
if (props.uid === props.toUid) {
message('You cannot like yourself', '您不可以给自己点赞', 'warn')
Message('You cannot like yourself', '您不可以给自己点赞', 'warn')
return
}
@ -81,15 +81,15 @@ const toggleLike = async () => {
likesCount.value += isPush ? 1 : -1
if (isPush) {
message('Like successfully!', '点赞成功!', 'success')
Message('Like successfully!', '点赞成功!', 'success')
} else {
message('Cancel like successfully!', '取消点赞成功!', 'success')
Message('Cancel like successfully!', '取消点赞成功!', 'success')
}
} else {
if (isPush) {
message('Like failed!', '点赞失败!', 'error')
Message('Like failed!', '点赞失败!', 'error')
} else {
message('Cancel like failed!', '取消点赞失败!', 'error')
Message('Cancel like failed!', '取消点赞失败!', 'error')
}
}
}

View file

@ -5,7 +5,7 @@ import { Icon } from '@iconify/vue'
//
import { useKUNGalgameMessageStore } from '@/store/modules/message'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// store
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
@ -49,9 +49,9 @@ const upvoteTopic = async () => {
upvoteCount.value++
isUpvote.value = true
message('Topic upvote successfully', '推话题成功', 'success')
Message('Topic upvote successfully', '推话题成功', 'success')
} else {
message('Topic upvote failed!', '推话题失败', 'error')
Message('Topic upvote failed!', '推话题失败', 'error')
}
}
}
@ -79,9 +79,9 @@ const upvoteReply = async () => {
upvoteCount.value++
isUpvote.value = true
message('Reply upvote successfully', '推回复成功', 'success')
Message('Reply upvote successfully', '推回复成功', 'success')
} else {
message('Reply upvote failed!', '推回复失败', 'error')
Message('Reply upvote failed!', '推回复失败', 'error')
}
}
}
@ -90,7 +90,7 @@ const upvoteReply = async () => {
const handleClickUpvote = async () => {
//
if (props.uid === props.toUid) {
message('You cannot upvote your own topic', '您不可以推自己的话题', 'warn')
Message('You cannot upvote your own topic', '您不可以推自己的话题', 'warn')
return
}

View file

@ -2,7 +2,7 @@
//
import { useKUNGalgameMessageStore } from '@/store/modules/message'
//
import message from '@/components/alert/Message'
import Message from '@/components/alert/Message'
// store
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
//
@ -43,12 +43,12 @@ const publishReply = async () => {
//
isEdit.value = false
//
message('Publish reply successfully!', '发布回复成功!', 'success')
Message('Publish reply successfully!', '发布回复成功!', 'success')
} else {
message('Publish reply failed!', '发布回复失败!', 'error')
Message('Publish reply failed!', '发布回复失败!', 'error')
}
} else {
message('Reply content cannot be empty!', '回复内容不能为空!', 'warn')
Message('Reply content cannot be empty!', '回复内容不能为空!', 'warn')
}
}
@ -60,7 +60,7 @@ const handlePublish = async () => {
publishReply()
} else {
//
message('Cancel publish reply', '取消发布回复', 'info')
Message('Cancel publish reply', '取消发布回复', 'info')
}
}
@ -83,7 +83,7 @@ const handleRewrite = async () => {
if (responseData.code === 200) {
//
message('Reply rewrite successfully', '回复重新编辑成功', 'success')
Message('Reply rewrite successfully', '回复重新编辑成功', 'success')
// 稿
saveRewriteReply()
@ -93,7 +93,7 @@ const handleRewrite = async () => {
isShowAdvance.value = false
isEdit.value = false
} else {
message('Reply rewrite failed!', '回复重新编辑失败!', 'error')
Message('Reply rewrite failed!', '回复重新编辑失败!', 'error')
}
}
}
@ -103,7 +103,7 @@ const handleSave = () => {
// true
replyDraft.value.isSaveReply = true
//
message(
Message(
'The draft has been saved successfully!',
'草稿已经保存成功',
'success'