Skip to content

Commit

Permalink
Merge pull request #14 from neos-love/develop
Browse files Browse the repository at this point in the history
13.3.4-neos-love.4
  • Loading branch information
rassi0429 authored Feb 6, 2023
2 parents e77b462 + e46fe59 commit 7b88929
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "13.3.4-neos-love.3",
"version": "13.3.4-neos-love.4",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
63 changes: 63 additions & 0 deletions packages/frontend/src/components/MkUrlPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@
</article>
</div>
</div>

<div v-else-if="neosWorldRecordId" :class="$style.twitter">
<div :class="[$style.link, { [$style.compact]: compact }]" rel="nofollow noopener" >
<div v-if="neosWorldData.thumbnail" :class="$style.thumbnail" :style="`background-image: url('${neosWorldData.thumbnail}')`">
</div>
<article :class="$style.body">
<header :class="$style.header">
<h1 :class="$style.title">{{neosWorldData.name}}</h1>
<h1 :class="$style.text">{{neosWorldData.ownerName}}</h1>
</header>
<div :class="$style.action">
<MkButton @click="copyWorldLink">{{neosWorldButtonCopyText}}</MkButton>
<MkButton @click="openWorldLink">ワールドを開く</MkButton>
</div>
</article>
</div>
</div>
<div v-else :class="$style.urlPreview">
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
<div v-if="thumbnail" :class="$style.thumbnail" :style="`background-image: url('${thumbnail}')`">
Expand Down Expand Up @@ -83,13 +100,25 @@ type neosSessionData = {
hostUserId: string | null,
thumbnail: string | null
}
type neosWorldData = {
name: string | null,
ownerName: string | null,
thumbnail: string | null
}
const defaultNeosSessionData = () => {
return {
name: null,
hostUserId: null,
thumbnail: null
}
}
const defaultNeosWorldData = () => {
return {
name: null,
ownerName: null,
thumbnail: null
}
}
const MOBILE_THRESHOLD = 500;
const isMobile = $ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
Expand All @@ -112,7 +141,9 @@ let playerEnabled = $ref(false);
let tweetId = $ref<string | null>(null);
let neosSessionId = $ref<string | null>(null);
let neosButtonCopyText = $ref<string>("参加コードをコピー");
let neosWorldButtonCopyText = $ref<string>("ワールドURLをコピー");
let neosSessionData = $ref<neosSessionData>(defaultNeosSessionData())
let neosWorldData = $ref<neosWorldData>(defaultNeosWorldData())
let neosWorldRecordId = $ref<string | null>(null);
let tweetExpanded = $ref(props.detail);
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
Expand All @@ -134,6 +165,10 @@ const openNeosLink = () => {
window.open("http://cloudx.azurewebsites.net/open/session/" + neosSessionId, '_blank');
}
const openWorldLink = () => {
window.open("http://cloudx.azurewebsites.net/open/world/" + neosWorldRecordId, '_blank');
}
const copySessionUrl = () => {
const result = copyToClipboard("https://util.kokoa.dev/v1/neos/join.json?url=neos-session:///" + neosSessionId)
if(result) {
Expand All @@ -144,6 +179,16 @@ const copySessionUrl = () => {
}
}
const copyWorldLink = () => {
const result = copyToClipboard("neosrec:///" + neosWorldRecordId);
if(result) {
neosWorldButtonCopyText = "OK! Neosに貼り付けてね"
setTimeout(() => {
neosWorldButtonCopyText = "ワールドURLをコピー"
}, 2000)
}
}
// detect neos session url
if (requestUrl.hostname === 'cloudx.azurewebsites.net') {
const m = requestUrl.pathname.match(/^\/.+\/session\/(.+)/);
Expand All @@ -164,6 +209,24 @@ if (requestUrl.hostname === 'cloudx.azurewebsites.net') {
neosSessionData.name = "(たぶん)プライベートセッション"
}
}
if(w) {
const record = w[1].split("/")
let d: any = null
if(w[1].startsWith("G")) {
d = await fetch(`https://neos-proxy.kokoa.live/api/groups/${record[0]}/records/${record[1]}`)
} else {
d = await fetch(`https://neos-proxy.kokoa.live/api/users/${record[0]}/records/${record[1]}`)
}
const json = await d.json()
if(d.status == 200) {
neosWorldData = {
name: json.name,
ownerName: json.ownerName,
thumbnail: json.thumbnailUri.split(".")[0].replace("neosdb:///","https://assets.neos.com/assets/")
}
}
}
}
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
Expand Down

0 comments on commit 7b88929

Please sign in to comment.