Compare commits

..
@@ -83,8 +83,6 @@ import { useAvatarStore } from '@/store/avatar'
import {
getAuthorizationList,
updateAuthorization,
SQUARE_INTERACTION_TARGET_ID,
SQUARE_INTERACTION_PERMISSIONS,
type Authorization
} from '@/api'
import { pickAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
@@ -94,6 +92,8 @@ const avatarStore = useAvatarStore()
const authList = ref<Authorization[]>([])
const saving = ref(false)
const UNAVAILABLE_MESSAGE = '该功能尚未向公众用户开放,如需使用请联系会会运营团队'
const SQUARE_INTERACTION_TARGET_ID = 'huihui-square'
const SQUARE_INTERACTION_PERMISSIONS = ['like', 'collect', 'comment', 'reply'] as const
const unavailableFeatures = [
{ id: 'make-friends', name: '交友与添加好友', description: '暂未开放', icon: '👥' },
@@ -111,6 +111,9 @@ const squareAuthorization = computed<Authorization>(() => {
targetName: '会会广场互动',
permissions: [...SQUARE_INTERACTION_PERMISSIONS],
status: 'inactive',
takeoverEnabled: false,
takeoverMode: 'immediate',
takeoverDelaySeconds: 180,
createdAt: ''
}
})
@@ -120,7 +123,7 @@ const otherAuthorizations = computed(() =>
)
const isUnavailableFeature = (name: string) => unavailableFeatures.some((feature) =>
name.replaceAll('发布微博内容', '发布微播内容') === feature.name
name.replace(/发布微博内容/g, '发布微播内容') === feature.name
)
const currentAvatarId = async () => {
@@ -142,14 +145,12 @@ const toggleSquareAuthorization = async () => {
if (!avatarId || saving.value) return
saving.value = true
try {
authList.value = unwrapListData(await updateAuthorization(avatarId, {
id: squareAuthorization.value.id || undefined,
targetId: SQUARE_INTERACTION_TARGET_ID,
targetName: '会会广场互动',
targetType: 'application',
permissions: [...SQUARE_INTERACTION_PERMISSIONS],
if (!squareAuthorization.value.id) return
const updated = await updateAuthorization(avatarId, {
id: squareAuthorization.value.id,
status: squareAuthorization.value.status === 'active' ? 'inactive' : 'active'
}))
})
authList.value = authList.value.map((item) => item.id === updated.id ? updated : item)
} catch (error) {
alert('操作失败,请重试')
} finally {
@@ -162,10 +163,11 @@ const toggleExistingAuthorization = async (auth: Authorization) => {
if (!avatarId || saving.value) return
saving.value = true
try {
authList.value = unwrapListData(await updateAuthorization(avatarId, {
const updated = await updateAuthorization(avatarId, {
id: auth.id,
status: auth.status === 'active' ? 'inactive' : 'active'
}))
})
authList.value = authList.value.map((item) => item.id === updated.id ? updated : item)
} catch (error) {
alert('操作失败,请重试')
} finally {
@@ -177,7 +179,7 @@ const showUnavailableNotice = () => alert(UNAVAILABLE_MESSAGE)
const getAuthIcon = (type: string) => ({ user: '👤', organization: '🏢', application: '📱' }[type] || '🔑')
const getAuthTypeText = (type: string) => ({ user: '用户', organization: '组织', application: '应用' }[type] || type)
const getAuthTargetName = (name: string) => name.replaceAll('发布微博内容', '发布微播内容')
const getAuthTargetName = (name: string) => name.replace(/发布微博内容/g, '发布微播内容')
const getPermissionText = (permission: string) => ({
read: '读取', write: '写入', reply: '回复', edit: '编辑',
like: '点赞', collect: '收藏', comment: '评论'