Merge branch 'more-share-page-querys' into swn

This commit is contained in:
tamaina 2021-08-20 14:28:28 +09:00
commit e5360a7d43
4 changed files with 81 additions and 29 deletions

View File

@ -14,6 +14,7 @@
- API: notifications/readは配列でも受け付けるように - API: notifications/readは配列でも受け付けるように
- localStorageのaccountsはindexedDBで保持するように - localStorageのaccountsはindexedDBで保持するように
- API: sw/unregisterを追加 - API: sw/unregisterを追加
- /share のクエリでリプライやファイル等の情報を渡せるように
### Bugfixes ### Bugfixes
- チャンネルを作成しているとアカウントを削除できないのを修正 - チャンネルを作成しているとアカウントを削除できないのを修正

View File

@ -1,7 +1,6 @@
<template> <template>
<div class=""> <div class="">
<section class="_section"> <section class="_section">
<div class="_title" v-if="title">{{ title }}</div>
<div class="_content"> <div class="_content">
<XPostForm <XPostForm
v-if="state === 'writing'" v-if="state === 'writing'"
@ -24,7 +23,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
// SPECIFICATION: https://wiki.misskey.io/ja/advanced-functions/share // SPECIFICATION: /src/docs/ja-JP/advanced/share-page.md
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import MkButton from '@client/components/ui/button.vue'; import MkButton from '@client/components/ui/button.vue';
@ -68,7 +67,7 @@ export default defineComponent({
const url = urlParams.get('url'); const url = urlParams.get('url');
let noteText = ''; let noteText = '';
if (this.title) noteText += `${this.title}\n`; if (this.title) noteText += `[ ${this.title} ]\n`;
// Google // Google
if (text?.startsWith(`${this.title}.\n`)) noteText += text.replace(`${this.title}.\n`, ''); if (text?.startsWith(`${this.title}.\n`)) noteText += text.replace(`${this.title}.\n`, '');
else if (text && this.title !== text) noteText += `${text}\n`; else if (text && this.title !== text) noteText += `${text}\n`;
@ -83,18 +82,17 @@ export default defineComponent({
if (this.visibility === 'specified') { if (this.visibility === 'specified') {
const visibleUserIds = urlParams.get('visibleUserIds'); const visibleUserIds = urlParams.get('visibleUserIds');
const visibleAccts = urlParams.get('visibleAccts'); const visibleAccts = urlParams.get('visibleAccts');
this.visibleUsers = await [ this.visibleUsers = await Promise.all([
...(visibleUserIds ? visibleUserIds.split(',').map(userId => ({ userId })) : []), ...(visibleUserIds ? visibleUserIds.split(',').map(userId => ({ userId })) : []),
...(visibleAccts ? visibleAccts.split(',').map(parseAcct) : []) ...(visibleAccts ? visibleAccts.split(',').map(parseAcct) : [])
].map(q => os.api('users/show', q) ].map(q => os.api('users/show', q)
.catch(() => Error(`invalid user query: ${JSON.stringify(q)}`))); .catch(() => console.error(`invalid user query: ${JSON.stringify(q)}`))));
} }
const localOnly = urlParams.get('localOnly'); const localOnly = urlParams.get('localOnly');
if (localOnly === '0') this.localOnly = false; if (localOnly === '0') this.localOnly = false;
else if (localOnly === '1') this.localOnly = true; else if (localOnly === '1') this.localOnly = true;
try { try {
//#region Reply //#region Reply
const replyId = urlParams.get('replyId'); const replyId = urlParams.get('replyId');
@ -114,29 +112,28 @@ export default defineComponent({
//#endregion //#endregion
//#region Renote //#region Renote
const renoteId = urlParams.get('renoteId'); const renoteId = urlParams.get('renoteId');
const renoteUri = urlParams.get('renoteUri'); const renoteUri = urlParams.get('renoteUri');
if (renoteId) { if (renoteId) {
this.renote = await os.api('notes/show', { this.renote = await os.api('notes/show', {
noteId: renoteId noteId: renoteId
}); });
} else if (renoteUri) { } else if (renoteUri) {
const obj = await os.api('ap/show', { const obj = await os.api('ap/show', {
uri: renoteUri uri: renoteUri
}) as any; }) as any;
if (obj.type === 'Note') { if (obj.type === 'Note') {
this.renote = obj.object; this.renote = obj.object;
}
} }
}
//#endregion //#endregion
//#region Drive files //#region Drive files
const fileIds = urlParams.get('fileIds'); const fileIds = urlParams.get('fileIds');
if (fileIds) { if (fileIds) {
const promises = Promise.all(fileIds.split(',') const promises = fileIds.split(',').map(fileId => os.api('drive/files/show', { fileId }).catch(() => console.error(`invalid fileId: ${fileId}`)));
.map(fileId => os.api('drive/files/show', { fileId }).catch(() => Error(`invalid fileId: ${fileId}`)))); await Promise.all(promises).then(files => this.files = files);
await promises.then(files => this.files = files); }
}
//#endregion //#endregion
} catch (e) { } catch (e) {
os.dialog({ os.dialog({

View File

@ -99,7 +99,7 @@ export default defineComponent({
type: Object, type: Object,
required: false required: false
}, },
instant: { share: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false default: false
@ -276,7 +276,7 @@ export default defineComponent({
this.$nextTick(() => { this.$nextTick(() => {
// 稿 // 稿
if (!this.instant && !this.mention && !this.specified) { if (!this.share && !this.mention && !this.specified) {
const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[this.draftKey]; const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[this.draftKey];
if (draft) { if (draft) {
this.text = draft.data.text; this.text = draft.data.text;
@ -506,8 +506,6 @@ export default defineComponent({
}, },
saveDraft() { saveDraft() {
if (this.instant) return;
const data = JSON.parse(localStorage.getItem('drafts') || '{}'); const data = JSON.parse(localStorage.getItem('drafts') || '{}');
data[this.draftKey] = { data[this.draftKey] = {

View File

@ -0,0 +1,56 @@
# シェアページ
`/share`を開くと、共有用の投稿フォームを開くことができます。
ここではシェアページで利用できるクエリ文字列の一覧を示します。
## クエリ文字列一覧
### 文字
<dl>
<dt>title</dt>
<dd>タイトルです。本文の先頭に[ … ]と挿入されます。</dd>
<dt>text</dt>
<dd>本文です。</dd>
<dt>url</dt>
<dd>URLです。末尾に挿入されます。</dd>
</dl>
### リプライ情報
以下のいずれか
<dl>
<dt>replyId</dt>
<dd>リプライ先のートid</dd>
<dt>replyUri</dt>
<dd>リプライ先のUrlリモートのートオブジェクトを指定</dd>
</dl>
### Renote情報
以下のいずれか
<dl>
<dt>renoteId</dt>
<dd>Renote先のートid</dd>
<dt>renoteUri</dt>
<dd>Renote先のUrlリモートのートオブジェクトを指定</dd>
</dl>
### 公開範囲
※specifiedに相当する値はvisibility=specifiedとvisibleAccts/visibleUserIdsで指定する
<dl>
<dt>visibility</dt>
<dd>公開範囲 ['public' | 'home' | 'followers' | 'specified']</dd>
<dt>localOnly</dt>
<dd>0(false) or 1(true)</dd>
<dt>visibleUserIds</dt>
<dd>specified時のダイレクト先のユーザーid カンマ区切りで</dd>
<dt>visibleAccts</dt>
<dd>specified時のダイレクト先のacct?username[host] カンマ区切りで</dd>
</dl>
### ファイル
<dl>
<dt>fileIds</dt>
<dd>添付したいファイルのidカンマ区切りで</dd>
</dl>