|
|
@ -261,11 +261,11 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref, computed, onMounted } from 'vue';
|
|
|
|
import { ref, computed, onMounted } from "vue";
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { defineComponent } from "vue";
|
|
|
|
import { useStore } from 'vuex';
|
|
|
|
import { useStore } from "vuex";
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
import { debounce } from "lodash";
|
|
|
|
import { getSuggestUsers, getSuggestTags } from '@/api/user';
|
|
|
|
import { getSuggestUsers, getSuggestTags } from "@/api/user";
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
ImageOutline,
|
|
|
|
ImageOutline,
|
|
|
@ -284,7 +284,7 @@ import { useRouter } from "vue-router";
|
|
|
|
import { MessageReactive } from "naive-ui";
|
|
|
|
import { MessageReactive } from "naive-ui";
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(e: 'post-success', post: Item.PostProps): void;
|
|
|
|
(e: "post-success", post: Item.PostProps): void;
|
|
|
|
}>();
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
|
|
const store = useStore();
|
|
|
|
const store = useStore();
|
|
|
@ -295,40 +295,53 @@ const loading = ref(false);
|
|
|
|
const submitting = ref(false);
|
|
|
|
const submitting = ref(false);
|
|
|
|
const showLinkSet = ref(false);
|
|
|
|
const showLinkSet = ref(false);
|
|
|
|
const showEyeSet = ref(false);
|
|
|
|
const showEyeSet = ref(false);
|
|
|
|
const content = ref('');
|
|
|
|
const content = ref("");
|
|
|
|
const links = ref([]);
|
|
|
|
const links = ref([]);
|
|
|
|
|
|
|
|
|
|
|
|
const uploadRef = ref<UploadInst>();
|
|
|
|
const uploadRef = ref<UploadInst>();
|
|
|
|
const attachmentPrice = ref(0);
|
|
|
|
const attachmentPrice = ref(0);
|
|
|
|
const uploadType = ref('public/image');
|
|
|
|
const uploadType = ref("public/image");
|
|
|
|
const fileQueue = ref<UploadFileInfo[]>([]);
|
|
|
|
const fileQueue = ref<UploadFileInfo[]>([]);
|
|
|
|
const imageContents = ref<Item.CommentItemProps[]>([]);
|
|
|
|
const imageContents = ref<Item.CommentItemProps[]>([]);
|
|
|
|
const videoContents = ref<Item.CommentItemProps[]>([]);
|
|
|
|
const videoContents = ref<Item.CommentItemProps[]>([]);
|
|
|
|
const attachmentContents = ref<Item.AttachmentProps[]>([]);
|
|
|
|
const attachmentContents = ref<Item.AttachmentProps[]>([]);
|
|
|
|
const visitType = ref<VisibilityEnum>(VisibilityEnum.PUBLIC);
|
|
|
|
const visitType = ref<VisibilityEnum>(VisibilityEnum.PUBLIC);
|
|
|
|
const defaultVisitType = ref<VisibilityEnum>(VisibilityEnum.PUBLIC)
|
|
|
|
const defaultVisitType = ref<VisibilityEnum>(VisibilityEnum.PUBLIC);
|
|
|
|
|
|
|
|
|
|
|
|
const useFriendship = (import.meta.env.VITE_USE_FRIENDSHIP.toLowerCase() === 'true')
|
|
|
|
const useFriendship =
|
|
|
|
const defaultTweetMaxLength = Number(import.meta.env.VITE_DEFAULT_TWEET_MAX_LENGTH)
|
|
|
|
import.meta.env.VITE_USE_FRIENDSHIP.toLowerCase() === "true";
|
|
|
|
const allowUserRegister = ref(import.meta.env.VITE_ALLOW_USER_REGISTER.toLowerCase() === 'true')
|
|
|
|
const defaultTweetMaxLength = Number(
|
|
|
|
const allowTweetVideo = ref(import.meta.env.VITE_ALLOW_TWEET_VIDEO.toLowerCase() === 'true')
|
|
|
|
import.meta.env.VITE_DEFAULT_TWEET_MAX_LENGTH
|
|
|
|
const allowTweetAttachment = ref(import.meta.env.VITE_ALLOW_TWEET_ATTACHMENT.toLowerCase() === 'true')
|
|
|
|
);
|
|
|
|
const allowTweetAttachmentPrice = ref(import.meta.env.VITE_ALLOW_TWEET_ATTACHMENT_PRICE.toLowerCase() === 'true')
|
|
|
|
const allowUserRegister = ref(
|
|
|
|
const allowTweetVisibility = ref(import.meta.env.VITE_ALLOW_TWEET_VISIBILITY.toLowerCase() === 'true')
|
|
|
|
import.meta.env.VITE_ALLOW_USER_REGISTER.toLowerCase() === "true"
|
|
|
|
const uploadGateway = import.meta.env.VITE_HOST + '/v1/attachment';
|
|
|
|
);
|
|
|
|
|
|
|
|
const allowTweetVideo = ref(
|
|
|
|
|
|
|
|
import.meta.env.VITE_ALLOW_TWEET_VIDEO.toLowerCase() === "true"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const allowTweetAttachment = ref(
|
|
|
|
|
|
|
|
import.meta.env.VITE_ALLOW_TWEET_ATTACHMENT.toLowerCase() === "true"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const allowTweetAttachmentPrice = ref(
|
|
|
|
|
|
|
|
import.meta.env.VITE_ALLOW_TWEET_ATTACHMENT_PRICE.toLowerCase() === "true"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const allowTweetVisibility = ref(
|
|
|
|
|
|
|
|
import.meta.env.VITE_ALLOW_TWEET_VISIBILITY.toLowerCase() === "true"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const uploadGateway = import.meta.env.VITE_HOST + "/v1/attachment";
|
|
|
|
|
|
|
|
|
|
|
|
const uploadToken = computed(() => {
|
|
|
|
const uploadToken = computed(() => {
|
|
|
|
return 'Bearer ' + localStorage.getItem('AIMO_TOKEN');
|
|
|
|
return "Bearer " + localStorage.getItem("AIMO_TOKEN");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const visibilities = computed(()=> {
|
|
|
|
const visibilities = computed(() => {
|
|
|
|
let res = [
|
|
|
|
let res = [
|
|
|
|
{value: VisibilityEnum.PUBLIC, label: "公开"},
|
|
|
|
{ value: VisibilityEnum.PUBLIC, label: "公开" },
|
|
|
|
{value: VisibilityEnum.PRIVATE, label: "私密"},
|
|
|
|
{ value: VisibilityEnum.PRIVATE, label: "私密" },
|
|
|
|
{value: VisibilityEnum.Following, label: "关注可见"},
|
|
|
|
{ value: VisibilityEnum.Following, label: "关注可见" },
|
|
|
|
];
|
|
|
|
];
|
|
|
|
if (useFriendship) {
|
|
|
|
if (useFriendship) {
|
|
|
|
res.push({value: VisibilityEnum.FRIEND, label: "好友可见"});
|
|
|
|
res.push({ value: VisibilityEnum.FRIEND, label: "好友可见" });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -336,14 +349,14 @@ const visibilities = computed(()=> {
|
|
|
|
const switchLink = () => {
|
|
|
|
const switchLink = () => {
|
|
|
|
showLinkSet.value = !showLinkSet.value;
|
|
|
|
showLinkSet.value = !showLinkSet.value;
|
|
|
|
if (showLinkSet.value && showEyeSet.value) {
|
|
|
|
if (showLinkSet.value && showEyeSet.value) {
|
|
|
|
showEyeSet.value = false
|
|
|
|
showEyeSet.value = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const switchEye = () => {
|
|
|
|
const switchEye = () => {
|
|
|
|
showEyeSet.value = !showEyeSet.value;
|
|
|
|
showEyeSet.value = !showEyeSet.value;
|
|
|
|
if (showEyeSet.value && showLinkSet.value) {
|
|
|
|
if (showEyeSet.value && showLinkSet.value) {
|
|
|
|
showLinkSet.value = false
|
|
|
|
showLinkSet.value = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -394,7 +407,7 @@ const handleSearch = (k: string, prefix: string) => {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loading.value = true;
|
|
|
|
loading.value = true;
|
|
|
|
if (prefix === '@') {
|
|
|
|
if (prefix === "@") {
|
|
|
|
loadSuggestionUsers(k);
|
|
|
|
loadSuggestionUsers(k);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
loadSuggestionTags(k);
|
|
|
|
loadSuggestionTags(k);
|
|
|
@ -414,10 +427,15 @@ const setUploadType = (type: string) => {
|
|
|
|
const updateUpload = (list: UploadFileInfo[]) => {
|
|
|
|
const updateUpload = (list: UploadFileInfo[]) => {
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
var name = list[i].name;
|
|
|
|
var name = list[i].name;
|
|
|
|
var basename: string = name.split('.').slice(0, -1).join('.');
|
|
|
|
var basename: string = name.split(".").slice(0, -1).join(".");
|
|
|
|
var ext: string = name.split('.').pop()!;
|
|
|
|
var ext: string = name.split(".").pop()!;
|
|
|
|
if (basename.length > 30) {
|
|
|
|
if (basename.length > 30) {
|
|
|
|
list[i].name = basename.substring(0, 18) + "..." + basename.substring(basename.length-9) + "." + ext;
|
|
|
|
list[i].name =
|
|
|
|
|
|
|
|
basename.substring(0, 18) +
|
|
|
|
|
|
|
|
"..." +
|
|
|
|
|
|
|
|
basename.substring(basename.length - 9) +
|
|
|
|
|
|
|
|
"." +
|
|
|
|
|
|
|
|
ext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fileQueue.value = list;
|
|
|
|
fileQueue.value = list;
|
|
|
@ -425,17 +443,17 @@ const updateUpload = (list: UploadFileInfo[]) => {
|
|
|
|
const beforeUpload = async (data: any) => {
|
|
|
|
const beforeUpload = async (data: any) => {
|
|
|
|
// 图片类型校验
|
|
|
|
// 图片类型校验
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
uploadType.value === 'public/image' &&
|
|
|
|
uploadType.value === "public/image" &&
|
|
|
|
!['image/png', 'image/jpg', 'image/jpeg', 'image/gif'].includes(
|
|
|
|
!["image/png", "image/jpg", "image/jpeg", "image/gif"].includes(
|
|
|
|
data.file.file?.type
|
|
|
|
data.file.file?.type
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
window.$message.warning('图片仅允许 png/jpg/gif 格式');
|
|
|
|
window.$message.warning("图片仅允许 png/jpg/gif 格式");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (uploadType.value === 'image' && data.file.file?.size > 10485760) {
|
|
|
|
if (uploadType.value === "image" && data.file.file?.size > 10485760) {
|
|
|
|
window.$message.warning('图片大小不能超过10MB');
|
|
|
|
window.$message.warning("图片大小不能超过10MB");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -661,19 +679,19 @@ const submitPost = () => {
|
|
|
|
// TODO: 临时过渡,暂时将Following等价于Public
|
|
|
|
// TODO: 临时过渡,暂时将Following等价于Public
|
|
|
|
let fixedVisit = visitType.value;
|
|
|
|
let fixedVisit = visitType.value;
|
|
|
|
if (fixedVisit == VisibilityEnum.Following) {
|
|
|
|
if (fixedVisit == VisibilityEnum.Following) {
|
|
|
|
fixedVisit = VisibilityEnum.PUBLIC
|
|
|
|
fixedVisit = VisibilityEnum.PUBLIC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createPost({
|
|
|
|
createPost({
|
|
|
|
contents,
|
|
|
|
contents,
|
|
|
|
tags: Array.from(new Set(tags)),
|
|
|
|
tags: Array.from(new Set(tags)),
|
|
|
|
users: Array.from(new Set(users)),
|
|
|
|
users: Array.from(new Set(users)),
|
|
|
|
attachment_price: +attachmentPrice.value * 100,
|
|
|
|
attachment_price: +attachmentPrice.value * 100,
|
|
|
|
visibility: fixedVisit
|
|
|
|
visibility: fixedVisit,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
window.$message.success('发布成功');
|
|
|
|
window.$message.success("发布成功");
|
|
|
|
submitting.value = false;
|
|
|
|
submitting.value = false;
|
|
|
|
emit('post-success', res);
|
|
|
|
emit("post-success", res);
|
|
|
|
|
|
|
|
|
|
|
|
// 置空
|
|
|
|
// 置空
|
|
|
|
showLinkSet.value = false;
|
|
|
|
showLinkSet.value = false;
|
|
|
@ -752,7 +770,7 @@ const handlePaste = async (event: ClipboardEvent) => {
|
|
|
|
updateUpload(combinedFileList);
|
|
|
|
updateUpload(combinedFileList);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 使用compressionFile函数来压缩图片(自建的)
|
|
|
|
// 使用compressionFile函数来压缩图片
|
|
|
|
const compressedFile = await compressionFile(file);
|
|
|
|
const compressedFile = await compressionFile(file);
|
|
|
|
|
|
|
|
|
|
|
|
// 使用压缩后的文件来创建Uint8Array和Blob对象
|
|
|
|
// 使用压缩后的文件来创建Uint8Array和Blob对象
|
|
|
@ -791,6 +809,8 @@ const handlePaste = async (event: ClipboardEvent) => {
|
|
|
|
pasteFile.status = "error";
|
|
|
|
pasteFile.status = "error";
|
|
|
|
pasteFile.percentage = 0;
|
|
|
|
pasteFile.percentage = 0;
|
|
|
|
updateUploadList(pasteFile, combinedFileList);
|
|
|
|
updateUploadList(pasteFile, combinedFileList);
|
|
|
|
|
|
|
|
messageReactive?.destroy();
|
|
|
|
|
|
|
|
messageReactive = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -807,27 +827,23 @@ const updateUploadList = (
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
onMounted(() => {
|
|
|
|
const defaultVisibility = import.meta.env.VITE_DEFAULT_TWEET_VISIBILITY.toLowerCase()
|
|
|
|
const defaultVisibility =
|
|
|
|
if (useFriendship && defaultVisibility === 'friend') {
|
|
|
|
import.meta.env.VITE_DEFAULT_TWEET_VISIBILITY.toLowerCase();
|
|
|
|
defaultVisitType.value = VisibilityEnum.FRIEND
|
|
|
|
if (useFriendship && defaultVisibility === "friend") {
|
|
|
|
} else if (defaultVisibility === 'following') {
|
|
|
|
defaultVisitType.value = VisibilityEnum.FRIEND;
|
|
|
|
defaultVisitType.value = VisibilityEnum.Following
|
|
|
|
} else if (defaultVisibility === "following") {
|
|
|
|
} else if (defaultVisibility === 'public') {
|
|
|
|
defaultVisitType.value = VisibilityEnum.Following;
|
|
|
|
defaultVisitType.value = VisibilityEnum.PUBLIC
|
|
|
|
} else if (defaultVisibility === "public") {
|
|
|
|
|
|
|
|
defaultVisitType.value = VisibilityEnum.PUBLIC;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
defaultVisitType.value = VisibilityEnum.PRIVATE
|
|
|
|
defaultVisitType.value = VisibilityEnum.PRIVATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
visitType.value = defaultVisitType.value;
|
|
|
|
visitType.value = defaultVisitType.value;
|
|
|
|
uploadToken.value = "Bearer " + localStorage.getItem("AIMO_TOKEN");
|
|
|
|
uploadToken.value = "Bearer " + localStorage.getItem("AIMO_TOKEN");
|
|
|
|
// 获取完整URL
|
|
|
|
|
|
|
|
const fullURL = window.location.href;
|
|
|
|
const fullURL = window.location.href;
|
|
|
|
// 从完整URL中获取hash部分(包括#号)
|
|
|
|
|
|
|
|
const hash = fullURL.split("#/")[1];
|
|
|
|
const hash = fullURL.split("#/")[1];
|
|
|
|
// 如果存在hash部分,继续处理
|
|
|
|
|
|
|
|
if (hash) {
|
|
|
|
if (hash) {
|
|
|
|
// 使用URLSearchParams解析hash参数
|
|
|
|
|
|
|
|
const urlParams = new URLSearchParams(hash);
|
|
|
|
const urlParams = new URLSearchParams(hash);
|
|
|
|
// 从URL参数中获取value值
|
|
|
|
|
|
|
|
const valueFromURL = urlParams.get("share");
|
|
|
|
const valueFromURL = urlParams.get("share");
|
|
|
|
const contentValue = ref("");
|
|
|
|
const contentValue = ref("");
|
|
|
|
|
|
|
|
|
|
|
@ -838,22 +854,17 @@ onMounted(() => {
|
|
|
|
if (store.state.userInfo.id > 0) {
|
|
|
|
if (store.state.userInfo.id > 0) {
|
|
|
|
// 用户已登录,组装contentValue
|
|
|
|
// 用户已登录,组装contentValue
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//帮助用户登录
|
|
|
|
|
|
|
|
userLogin({
|
|
|
|
userLogin({
|
|
|
|
username: parts[4],
|
|
|
|
username: parts[4],
|
|
|
|
password: "share[52570552A393]" + parts[5],
|
|
|
|
password: "share[52570552A393]" + parts[5],
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
const token = res?.token || "";
|
|
|
|
const token = res?.token || "";
|
|
|
|
// 写入用户信息
|
|
|
|
|
|
|
|
localStorage.setItem("AIMO_TOKEN", token);
|
|
|
|
localStorage.setItem("AIMO_TOKEN", token);
|
|
|
|
|
|
|
|
|
|
|
|
return userInfo(token);
|
|
|
|
return userInfo(token);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
// window.$message.success('登录成功');
|
|
|
|
|
|
|
|
loading.value = false;
|
|
|
|
loading.value = false;
|
|
|
|
|
|
|
|
|
|
|
|
store.commit("updateUserinfo", res);
|
|
|
|
store.commit("updateUserinfo", res);
|
|
|
|
store.commit("triggerAuth", false);
|
|
|
|
store.commit("triggerAuth", false);
|
|
|
|
store.commit("refresh");
|
|
|
|
store.commit("refresh");
|
|
|
|