Merge branch 'develop'

This commit is contained in:
syuilo 2022-07-18 05:07:12 +09:00
commit 85ce00adc0
32 changed files with 865 additions and 607 deletions

View file

@ -9,6 +9,14 @@
You should also include the user name that made the change. You should also include the user name that made the change.
--> -->
## 12.117.0 (2022/07/18)
### Improvements
- Client: ウィンドウを最大化できるように @syuilo
- Client: Shiftキーを押した状態でリンクをクリックするとアプリ内ウィンドウで開くように @syuilo
- Client: デッキを使用している際、Ctrlキーを押した状態でリンクをクリックするとページ遷移を強制できるように @syuilo
- Client: UIのブラッシュアップ @syuilo
## 12.116.1 (2022/07/17) ## 12.116.1 (2022/07/17)
### Bugfixes ### Bugfixes

View file

@ -1645,6 +1645,7 @@ _deck:
alwaysShowMainColumn: "সর্বদা মেইন কলাম দেখান" alwaysShowMainColumn: "সর্বদা মেইন কলাম দেখান"
columnAlign: "কলাম সাজান" columnAlign: "কলাম সাজান"
addColumn: "কলাম যুক্ত করুন" addColumn: "কলাম যুক্ত করুন"
configureColumn: "কলাম সেটিংস"
swapLeft: "বামে সরান" swapLeft: "বামে সরান"
swapRight: "ডানে সরান" swapRight: "ডানে সরান"
swapUp: "উপরে উঠান" swapUp: "উপরে উঠান"

View file

@ -890,6 +890,7 @@ activeEmailValidationDescription: "Aktivert strengere Überprüfung von E-Mail-A
navbar: "Navigationsleiste" navbar: "Navigationsleiste"
shuffle: "Mischen" shuffle: "Mischen"
account: "Benutzerkonto" account: "Benutzerkonto"
move: "Verschieben"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Ermöglicht eine Erleichterung der Servermoderation durch die automatische Erkennungen von NSFW-Medien unter Verwendung von Machine Learning. Hierdurch wird die Serverlast etwas erhöht." description: "Ermöglicht eine Erleichterung der Servermoderation durch die automatische Erkennungen von NSFW-Medien unter Verwendung von Machine Learning. Hierdurch wird die Serverlast etwas erhöht."
sensitivity: "Erkennungssensitivität" sensitivity: "Erkennungssensitivität"
@ -1696,6 +1697,7 @@ _deck:
alwaysShowMainColumn: "Hauptspalte immer zeigen" alwaysShowMainColumn: "Hauptspalte immer zeigen"
columnAlign: "Spaltenausrichtung" columnAlign: "Spaltenausrichtung"
addColumn: "Spalte hinzufügen" addColumn: "Spalte hinzufügen"
configureColumn: "Spalteneinstellungen"
swapLeft: "Mit linker Spalte tauschen" swapLeft: "Mit linker Spalte tauschen"
swapRight: "Mit rechter Spalte tauschen" swapRight: "Mit rechter Spalte tauschen"
swapUp: "Mit oberer Spalte tauschen" swapUp: "Mit oberer Spalte tauschen"

View file

@ -890,6 +890,7 @@ activeEmailValidationDescription: "Enables stricter validation of email addresse
navbar: "Navigation bar" navbar: "Navigation bar"
shuffle: "Shuffle" shuffle: "Shuffle"
account: "Account" account: "Account"
move: "Move"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server." description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server."
sensitivity: "Detection sensitivity" sensitivity: "Detection sensitivity"
@ -1696,6 +1697,7 @@ _deck:
alwaysShowMainColumn: "Always show main column" alwaysShowMainColumn: "Always show main column"
columnAlign: "Align columns" columnAlign: "Align columns"
addColumn: "Add column" addColumn: "Add column"
configureColumn: "Column settings"
swapLeft: "Swap with the left column" swapLeft: "Swap with the left column"
swapRight: "Swap with the right column" swapRight: "Swap with the right column"
swapUp: "Swap with the above column" swapUp: "Swap with the above column"

View file

@ -890,6 +890,7 @@ activeEmailValidationDescription: "ユーザーのメールアドレスのバリ
navbar: "ナビゲーションバー" navbar: "ナビゲーションバー"
shuffle: "シャッフル" shuffle: "シャッフル"
account: "アカウント" account: "アカウント"
move: "移動"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。"

View file

@ -886,6 +886,8 @@ beta: "베타"
enableAutoSensitive: "자동 NSFW 탐지" enableAutoSensitive: "자동 NSFW 탐지"
enableAutoSensitiveDescription: "이용 가능할 경우 기계학습을 통해 자동으로 미디어 NSFW를 설정합니다. 이 기능을 해제하더라도, 인스턴스 정책에 따라 자동으로 설정될 수 있습니다." enableAutoSensitiveDescription: "이용 가능할 경우 기계학습을 통해 자동으로 미디어 NSFW를 설정합니다. 이 기능을 해제하더라도, 인스턴스 정책에 따라 자동으로 설정될 수 있습니다."
activeEmailValidationDescription: "유저가 입력한 메일 주소가 일회용 메일인지, 실제로 통신할 수 있는 지 엄격하게 검사합니다. 해제할 경우 이메일 형식에 대해서만 검사합니다." activeEmailValidationDescription: "유저가 입력한 메일 주소가 일회용 메일인지, 실제로 통신할 수 있는 지 엄격하게 검사합니다. 해제할 경우 이메일 형식에 대해서만 검사합니다."
navbar: "네비게이션 바"
shuffle: "셔플"
account: "계정" account: "계정"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "기계학습을 통해 자동으로 민감한 미디어를 탐지하여, 모더레이션에 참고할 수 있도록 합니다. 서버의 부하를 약간 증가시킵니다." description: "기계학습을 통해 자동으로 민감한 미디어를 탐지하여, 모더레이션에 참고할 수 있도록 합니다. 서버의 부하를 약간 증가시킵니다."
@ -1692,6 +1694,7 @@ _deck:
alwaysShowMainColumn: "메인 칼럼 항상 표시" alwaysShowMainColumn: "메인 칼럼 항상 표시"
columnAlign: "칼럼 정렬" columnAlign: "칼럼 정렬"
addColumn: "칼럼 추가" addColumn: "칼럼 추가"
configureColumn: "칼럼 설정"
swapLeft: "왼쪽으로 이동" swapLeft: "왼쪽으로 이동"
swapRight: "오른쪽으로 이동" swapRight: "오른쪽으로 이동"
swapUp: "위로 이동" swapUp: "위로 이동"
@ -1699,6 +1702,8 @@ _deck:
stackLeft: "왼쪽에 쌓기" stackLeft: "왼쪽에 쌓기"
popRight: "오른쪽으로 빼기" popRight: "오른쪽으로 빼기"
profile: "프로파일" profile: "프로파일"
newProfile: "새 프로파일"
deleteProfile: "프로파일 삭제"
introduction: "칼럼을 조합해서 나만의 인터페이스를 구성해 보아요!" introduction: "칼럼을 조합해서 나만의 인터페이스를 구성해 보아요!"
introduction2: "나중에라도 화면 우측의 + 버튼을 눌러 새 칼럼을 추가할 수 있습니다." introduction2: "나중에라도 화면 우측의 + 버튼을 눌러 새 칼럼을 추가할 수 있습니다."
widgetsIntroduction: "칼럼 메뉴의 \"위젯 편집\"에서 위젯을 추가해 주세요" widgetsIntroduction: "칼럼 메뉴의 \"위젯 편집\"에서 위젯을 추가해 주세요"

View file

@ -1637,6 +1637,7 @@ _deck:
alwaysShowMainColumn: "Всегда показывать главную колонку" alwaysShowMainColumn: "Всегда показывать главную колонку"
columnAlign: "Выравнивание колонок" columnAlign: "Выравнивание колонок"
addColumn: "Добавить колонку" addColumn: "Добавить колонку"
configureColumn: "Настройки колонок"
swapLeft: "Переставить левее" swapLeft: "Переставить левее"
swapRight: "Переставить правее" swapRight: "Переставить правее"
swapUp: "Переставить выше" swapUp: "Переставить выше"

View file

@ -1696,6 +1696,7 @@ _deck:
alwaysShowMainColumn: "Luôn hiện cột chính" alwaysShowMainColumn: "Luôn hiện cột chính"
columnAlign: "Căn cột" columnAlign: "Căn cột"
addColumn: "Thêm cột" addColumn: "Thêm cột"
configureColumn: "Cài đặt cột"
swapLeft: "Hoán đổi với cột bên trái" swapLeft: "Hoán đổi với cột bên trái"
swapRight: "Hoán đổi với cột bên phải" swapRight: "Hoán đổi với cột bên phải"
swapUp: "Hoán đổi với cột trên" swapUp: "Hoán đổi với cột trên"

View file

@ -862,7 +862,7 @@ typeToConfirm: "输入 {x} 以确认操作。"
deleteAccount: "删除账户" deleteAccount: "删除账户"
document: "文档" document: "文档"
numberOfPageCache: "缓存页数" numberOfPageCache: "缓存页数"
numberOfPageCacheDescription: "设置较高的值会更方便用户,但服务器负载和内存使用量会增加。" numberOfPageCacheDescription: "设置较高的值会更方便用户,但设备的负载和内存使用量会增加。"
logoutConfirm: "是否确认登出?" logoutConfirm: "是否确认登出?"
lastActiveDate: "最后活跃时间" lastActiveDate: "最后活跃时间"
statusbar: "状态栏" statusbar: "状态栏"
@ -1691,13 +1691,16 @@ _deck:
alwaysShowMainColumn: "总是显示主列" alwaysShowMainColumn: "总是显示主列"
columnAlign: "列对齐" columnAlign: "列对齐"
addColumn: "添加列" addColumn: "添加列"
configureColumn: "列设置"
swapLeft: "向左移动" swapLeft: "向左移动"
swapRight: "向右移动" swapRight: "向右移动"
swapUp: "向上移动" swapUp: "向上移动"
swapDown: "向下移动" swapDown: "向下移动"
stackLeft: "向左折叠" stackLeft: "向左折叠"
popRight: "向右弹出" popRight: "向右弹出"
profile: "个人资料" profile: "配置文件"
newProfile: "新建配置文件"
deleteProfile: "删除配置文件"
_columns: _columns:
main: "主列" main: "主列"
widgets: "小工具" widgets: "小工具"

View file

@ -155,7 +155,7 @@ searchWith: "搜尋: {q}"
youHaveNoLists: "你沒有任何清單" youHaveNoLists: "你沒有任何清單"
followConfirm: "你真的要追隨{name}嗎?" followConfirm: "你真的要追隨{name}嗎?"
proxyAccount: "代理帳戶" proxyAccount: "代理帳戶"
proxyAccountDescription: "代理帳戶是在某些情況下充當其他伺服器用戶的帳戶。例如,當使用者將一個來自其他伺服器的帳戶放在列表中時,由於沒有其他使用者關注該帳戶,該指令不會傳送到該伺服器上,因此會由代理帳戶關注。" proxyAccountDescription: "代理帳戶是在某些情況下充當其他伺服器用戶的帳戶。例如,當使用者將一個來自其他伺服器的帳戶放在列表中時,由於沒有其他使用者追蹤該帳戶,該指令不會傳送到該伺服器上,因此會由代理帳戶追蹤。"
host: "主機" host: "主機"
selectUser: "選取使用者" selectUser: "選取使用者"
recipient: "收件人" recipient: "收件人"
@ -1695,6 +1695,7 @@ _deck:
alwaysShowMainColumn: "總是顯示主欄" alwaysShowMainColumn: "總是顯示主欄"
columnAlign: "對齊欄位" columnAlign: "對齊欄位"
addColumn: "新增欄位" addColumn: "新增欄位"
configureColumn: "欄位的設定"
swapLeft: "向左移動" swapLeft: "向左移動"
swapRight: "向右移動" swapRight: "向右移動"
swapUp: "往上移動" swapUp: "往上移動"

View file

@ -1,6 +1,6 @@
{ {
"name": "misskey", "name": "misskey",
"version": "12.116.1", "version": "12.117.0",
"codename": "indigo", "codename": "indigo",
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -206,17 +206,16 @@ export async function openAccountMenu(opts: {
to: `/@${ $i.username }`, to: `/@${ $i.username }`,
avatar: $i, avatar: $i,
}, null, ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, { }, null, ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, {
type: 'parent',
icon: 'fas fa-plus', icon: 'fas fa-plus',
text: i18n.ts.addAccount, text: i18n.ts.addAccount,
action: () => { children: [{
popupMenu([{
text: i18n.ts.existingAccount, text: i18n.ts.existingAccount,
action: () => { showSigninDialog(); }, action: () => { showSigninDialog(); },
}, { }, {
text: i18n.ts.createAccount, text: i18n.ts.createAccount,
action: () => { createAccount(); }, action: () => { createAccount(); },
}], ev.currentTarget ?? ev.target); }],
},
}, { }, {
type: 'link', type: 'link',
icon: 'fas fa-users', icon: 'fas fa-users',

View file

@ -50,7 +50,7 @@ function onContextmenu(ev) {
icon: 'fas fa-expand-alt', icon: 'fas fa-expand-alt',
text: i18n.ts.showInPage, text: i18n.ts.showInPage,
action: () => { action: () => {
router.push(props.to); router.push(props.to, 'forcePage');
}, },
}, null, { }, null, {
icon: 'fas fa-external-link-alt', icon: 'fas fa-external-link-alt',
@ -79,7 +79,7 @@ function popout() {
popout_(props.to); popout_(props.to);
} }
function nav() { function nav(ev: MouseEvent) {
if (props.behavior === 'browser') { if (props.behavior === 'browser') {
location.href = props.to; location.href = props.to;
return; return;
@ -93,6 +93,10 @@ function nav() {
} }
} }
router.push(props.to); if (ev.shiftKey) {
return openWindow();
}
router.push(props.to, ev.ctrlKey ? 'forcePage' : null);
} }
</script> </script>

View file

@ -8,6 +8,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { } from 'vue'; import { } from 'vue';
import { instanceName } from '@/config'; import { instanceName } from '@/config';
import { instance as Instance } from '@/instance';
const props = defineProps<{ const props = defineProps<{
instance?: { instance?: {
@ -19,7 +20,7 @@ const props = defineProps<{
// if no instance data is given, this is for the local instance // if no instance data is given, this is for the local instance
const instance = props.instance ?? { const instance = props.instance ?? {
faviconUrl: '/favicon.ico', faviconUrl: Instance.iconUrl || Instance.faviconUrl || '/favicon.ico',
name: instanceName, name: instanceName,
themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement)?.content themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement)?.content
}; };

View file

@ -15,20 +15,6 @@
</MkA> </MkA>
</template> </template>
</div> </div>
<div class="sub">
<button v-click-anime class="_button" @click="help">
<i class="fas fa-question-circle icon"></i>
<div class="text">{{ $ts.help }}</div>
</button>
<MkA v-click-anime to="/about" @click.passive="close()">
<i class="fas fa-info-circle icon"></i>
<div class="text">{{ $ts.instanceInfo }}</div>
</MkA>
<MkA v-click-anime to="/about-misskey" @click.passive="close()">
<img src="/static-assets/favicon.png" class="icon"/>
<div class="text">{{ $ts.aboutMisskey }}</div>
</MkA>
</div>
</div> </div>
</MkModal> </MkModal>
</template> </template>
@ -74,28 +60,6 @@ const items = Object.keys(navbarItemDef).filter(k => !menu.includes(k)).map(k =>
function close() { function close() {
modal.close(); modal.close();
} }
function help(ev: MouseEvent) {
os.popupMenu([{
type: 'link',
to: '/mfm-cheat-sheet',
text: i18n.ts._mfm.cheatSheet,
icon: 'fas fa-code',
}, {
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'fas fa-terminal',
}, null, {
text: i18n.ts.document,
icon: 'fas fa-question-circle',
action: () => {
window.open('https://misskey-hub.net/help.html', '_blank');
},
}], ev.currentTarget ?? ev.target);
close();
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View file

@ -50,14 +50,14 @@ const emit = defineEmits<{
} }
> .name { > .name {
font-size: 0.9em; font-size: 1em;
} }
} }
> .users { > .users {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
font-size: 0.9em; font-size: 0.95em;
border-left: solid 0.5px var(--divider); border-left: solid 0.5px var(--divider);
padding-left: 10px; padding-left: 10px;
margin-left: 10px; margin-left: 10px;

View file

@ -46,7 +46,7 @@ export default defineComponent({
rounded: { rounded: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: true,
}, },
inline: { inline: {
type: Boolean, type: Boolean,

View file

@ -1,16 +1,16 @@
<template> <template>
<transition :name="$store.state.animation ? 'fade' : ''" appear> <transition :name="$store.state.animation ? 'fade' : ''" appear>
<div ref="rootEl" class="nvlagfpb" :style="{ zIndex }" @contextmenu.prevent.stop="() => {}"> <div ref="rootEl" class="nvlagfpb" :style="{ zIndex }" @contextmenu.prevent.stop="() => {}">
<MkMenu :items="items" class="_popup _shadow" :align="'left'" @close="$emit('closed')"/> <MkMenu :items="items" :align="'left'" @close="$emit('closed')"/>
</div> </div>
</transition> </transition>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, onBeforeUnmount } from 'vue'; import { onMounted, onBeforeUnmount } from 'vue';
import contains from '@/scripts/contains';
import MkMenu from './menu.vue'; import MkMenu from './menu.vue';
import { MenuItem } from './types/menu.vue'; import { MenuItem } from './types/menu.vue';
import contains from '@/scripts/contains';
import * as os from '@/os'; import * as os from '@/os';
const props = defineProps<{ const props = defineProps<{

View file

@ -0,0 +1,65 @@
<template>
<div ref="el" class="sfhdhdhr">
<MkMenu ref="menu" :items="items" :align="align" :width="width" :as-drawer="false" @close="onChildClosed"/>
</div>
</template>
<script lang="ts" setup>
import { on } from 'events';
import { nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue';
import MkMenu from './menu.vue';
import { MenuItem } from '@/types/menu';
import * as os from '@/os';
const props = defineProps<{
items: MenuItem[];
targetElement: HTMLElement;
rootElement: HTMLElement;
width?: number;
viaKeyboard?: boolean;
}>();
const emit = defineEmits<{
(ev: 'closed'): void;
(ev: 'actioned'): void;
}>();
const el = ref<HTMLElement>();
const align = 'left';
function setPosition() {
const rootRect = props.rootElement.getBoundingClientRect();
const rect = props.targetElement.getBoundingClientRect();
const left = props.targetElement.offsetWidth;
const top = (rect.top - rootRect.top) - 8;
el.value.style.left = left + 'px';
el.value.style.top = top + 'px';
}
function onChildClosed(actioned?: boolean) {
if (actioned) {
emit('actioned');
} else {
emit('closed');
}
}
onMounted(() => {
setPosition();
nextTick(() => {
setPosition();
});
});
defineExpose({
checkHit: (ev: MouseEvent) => {
return (ev.target === el.value || el.value.contains(ev.target));
},
});
</script>
<style lang="scss" scoped>
.sfhdhdhr {
position: absolute;
}
</style>

View file

@ -1,7 +1,8 @@
<template> <template>
<div>
<div <div
ref="itemsEl" v-hotkey="keymap" ref="itemsEl" v-hotkey="keymap"
class="rrevdjwt" class="rrevdjwt _popup _shadow"
:class="{ center: align === 'center', asDrawer }" :class="{ center: align === 'center', asDrawer }"
:style="{ width: (width && !asDrawer) ? width + 'px' : '', maxHeight: maxHeight ? maxHeight + 'px' : '' }" :style="{ width: (width && !asDrawer) ? width + 'px' : '', maxHeight: maxHeight ? maxHeight + 'px' : '' }"
@contextmenu.self="e => e.preventDefault()" @contextmenu.self="e => e.preventDefault()"
@ -14,25 +15,30 @@
<span v-else-if="item.type === 'pending'" :tabindex="i" class="pending item"> <span v-else-if="item.type === 'pending'" :tabindex="i" class="pending item">
<span><MkEllipsis/></span> <span><MkEllipsis/></span>
</span> </span>
<MkA v-else-if="item.type === 'link'" :to="item.to" :tabindex="i" class="_button item" @click.passive="close()"> <MkA v-else-if="item.type === 'link'" :to="item.to" :tabindex="i" class="_button item" @click.passive="close(true)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i> <i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/> <MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span> <span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</MkA> </MkA>
<a v-else-if="item.type === 'a'" :href="item.href" :target="item.target" :download="item.download" :tabindex="i" class="_button item" @click="close()"> <a v-else-if="item.type === 'a'" :href="item.href" :target="item.target" :download="item.download" :tabindex="i" class="_button item" @click="close(true)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i> <i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span> <span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</a> </a>
<button v-else-if="item.type === 'user'" :tabindex="i" class="_button item" :class="{ active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)"> <button v-else-if="item.type === 'user'" :tabindex="i" class="_button item" :class="{ active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<MkAvatar :user="item.user" class="avatar"/><MkUserName :user="item.user"/> <MkAvatar :user="item.user" class="avatar"/><MkUserName :user="item.user"/>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span> <span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</button> </button>
<span v-else-if="item.type === 'switch'" :tabindex="i" class="item"> <span v-else-if="item.type === 'switch'" :tabindex="i" class="item" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<FormSwitch v-model="item.ref" :disabled="item.disabled" class="form-switch">{{ item.text }}</FormSwitch> <FormSwitch v-model="item.ref" :disabled="item.disabled" class="form-switch">{{ item.text }}</FormSwitch>
</span> </span>
<button v-else :tabindex="i" class="_button item" :class="{ danger: item.danger, active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)"> <button v-else-if="item.type === 'parent'" :tabindex="i" class="_button item parent" :class="{ childShowing: childShowingItem === item }" @mouseenter="showChildren(item, $event)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<span>{{ item.text }}</span>
<span class="caret"><i class="fas fa-caret-right fa-fw"></i></span>
</button>
<button v-else :tabindex="i" class="_button item" :class="{ danger: item.danger, active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i> <i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/> <MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
@ -43,13 +49,19 @@
<span>{{ $ts.none }}</span> <span>{{ $ts.none }}</span>
</span> </span>
</div> </div>
<div v-if="childMenu" class="child">
<XChild ref="child" :items="childMenu" :target-element="childTarget" :root-element="itemsEl" showing @actioned="childActioned"/>
</div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, onMounted, watch } from 'vue'; import { defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from 'vue';
import { focusPrev, focusNext } from '@/scripts/focus'; import { focusPrev, focusNext } from '@/scripts/focus';
import FormSwitch from '@/components/form/switch.vue'; import FormSwitch from '@/components/form/switch.vue';
import { MenuItem, InnerMenuItem, MenuPending, MenuAction } from '@/types/menu'; import { MenuItem, InnerMenuItem, MenuPending, MenuAction } from '@/types/menu';
import * as os from '@/os';
const XChild = defineAsyncComponent(() => import('./menu.child.vue'));
const props = defineProps<{ const props = defineProps<{
items: MenuItem[]; items: MenuItem[];
@ -61,19 +73,23 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'close'): void; (ev: 'close', actioned?: boolean): void;
}>(); }>();
let itemsEl = $ref<HTMLDivElement>(); let itemsEl = $ref<HTMLDivElement>();
let items2: InnerMenuItem[] = $ref([]); let items2: InnerMenuItem[] = $ref([]);
let child = $ref<InstanceType<typeof XChild>>();
let keymap = $computed(() => ({ let keymap = $computed(() => ({
'up|k|shift+tab': focusUp, 'up|k|shift+tab': focusUp,
'down|j|tab': focusDown, 'down|j|tab': focusDown,
'esc': close, 'esc': close,
})); }));
let childShowingItem = $ref<MenuItem | null>();
watch(() => props.items, () => { watch(() => props.items, () => {
const items: (MenuItem | MenuPending)[] = [...props.items].filter(item => item !== undefined); const items: (MenuItem | MenuPending)[] = [...props.items].filter(item => item !== undefined);
@ -93,21 +109,53 @@ watch(() => props.items, () => {
immediate: true, immediate: true,
}); });
onMounted(() => { let childMenu = $ref<MenuItem[] | null>();
if (props.viaKeyboard) { let childTarget = $ref<HTMLElement | null>();
nextTick(() => {
focusNext(itemsEl.children[0], true, false); function closeChild() {
}); childMenu = null;
childShowingItem = null;
}
function childActioned() {
closeChild();
close(true);
}
function onGlobalMousedown(event: MouseEvent) {
if (childTarget && (event.target === childTarget || childTarget.contains(event.target))) return;
if (child && child.checkHit(event)) return;
closeChild();
}
let childCloseTimer: null | number = null;
function onItemMouseEnter(item) {
childCloseTimer = window.setTimeout(() => {
closeChild();
}, 300);
}
function onItemMouseLeave(item) {
if (childCloseTimer) window.clearTimeout(childCloseTimer);
}
async function showChildren(item: MenuItem, ev: MouseEvent) {
if (props.asDrawer) {
os.popupMenu(item.children, ev.currentTarget ?? ev.target);
close();
} else {
childTarget = ev.currentTarget ?? ev.target;
childMenu = item.children;
childShowingItem = item;
}
} }
});
function clicked(fn: MenuAction, ev: MouseEvent) { function clicked(fn: MenuAction, ev: MouseEvent) {
fn(ev); fn(ev);
close(); close(true);
} }
function close() { function close(actioned = false) {
emit('close'); emit('close', actioned);
} }
function focusUp() { function focusUp() {
@ -117,6 +165,20 @@ function focusUp() {
function focusDown() { function focusDown() {
focusNext(document.activeElement); focusNext(document.activeElement);
} }
onMounted(() => {
if (props.viaKeyboard) {
nextTick(() => {
focusNext(itemsEl.children[0], true, false);
});
}
document.addEventListener('mousedown', onGlobalMousedown, { passive: true });
});
onBeforeUnmount(() => {
document.removeEventListener('mousedown', onGlobalMousedown);
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -225,6 +287,25 @@ function focusDown() {
opacity: 0.7; opacity: 0.7;
} }
&.parent {
display: flex;
align-items: center;
cursor: default;
> .caret {
margin-left: auto;
}
&.childShowing {
color: var(--accent);
text-decoration: none;
&:before {
background: var(--accentedBg);
}
}
}
> i { > i {
margin-right: 5px; margin-right: 5px;
width: 20px; width: 20px;

View file

@ -1,6 +1,6 @@
<template> <template>
<MkModal ref="modal" v-slot="{ type, maxHeight }" :z-priority="'high'" :src="src" :transparent-bg="true" @click="modal.close()" @closed="emit('closed')"> <MkModal ref="modal" v-slot="{ type, maxHeight }" :z-priority="'high'" :src="src" :transparent-bg="true" @click="modal.close()" @closed="emit('closed')">
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :as-drawer="type === 'drawer'" class="sfhdhdhq _popup _shadow" :class="{ drawer: type === 'drawer' }" @close="modal.close()"/> <MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :as-drawer="type === 'drawer'" class="sfhdhdhq" :class="{ drawer: type === 'drawer' }" @close="modal.close()"/>
</MkModal> </MkModal>
</template> </template>

View file

@ -12,6 +12,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, onMounted, onUnmounted, ref } from 'vue'; import { nextTick, onMounted, onUnmounted, ref } from 'vue';
import * as os from '@/os'; import * as os from '@/os';
import { calcPopupPosition } from '@/scripts/popup-position';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
showing: boolean; showing: boolean;
@ -36,152 +37,21 @@ const emit = defineEmits<{
const el = ref<HTMLElement>(); const el = ref<HTMLElement>();
const zIndex = os.claimZIndex('high'); const zIndex = os.claimZIndex('high');
const setPosition = () => { function setPosition() {
if (el.value == null) return; const data = calcPopupPosition(el.value, {
anchorElement: props.targetElement,
direction: props.direction,
align: 'center',
innerMargin: props.innerMargin,
x: props.x,
y: props.y,
});
const contentWidth = el.value.offsetWidth; el.value.style.transformOrigin = data.transformOrigin;
const contentHeight = el.value.offsetHeight; el.value.style.left = data.left + 'px';
el.value.style.top = data.top + 'px';
let rect: DOMRect;
if (props.targetElement) {
rect = props.targetElement.getBoundingClientRect();
} }
const calcPosWhenTop = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = rect.left + window.pageXOffset + (props.targetElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset - contentHeight) - props.innerMargin;
} else {
left = props.x;
top = (props.y - contentHeight) - props.innerMargin;
}
left -= (el.value.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenBottom = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = rect.left + window.pageXOffset + (props.targetElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset + props.targetElement.offsetHeight) + props.innerMargin;
} else {
left = props.x;
top = (props.y) + props.innerMargin;
}
left -= (el.value.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenLeft = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = (rect.left + window.pageXOffset - contentWidth) - props.innerMargin;
top = rect.top + window.pageYOffset + (props.targetElement.offsetHeight / 2);
} else {
left = (props.x - contentWidth) - props.innerMargin;
top = props.y;
}
top -= (el.value.offsetHeight / 2);
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calcPosWhenRight = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = (rect.left + props.targetElement.offsetWidth + window.pageXOffset) + props.innerMargin;
top = rect.top + window.pageYOffset + (props.targetElement.offsetHeight / 2);
} else {
left = props.x + props.innerMargin;
top = props.y;
}
top -= (el.value.offsetHeight / 2);
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calc = (): {
left: number;
top: number;
transformOrigin: string;
} => {
switch (props.direction) {
case 'top': {
const [left, top] = calcPosWhenTop();
//
if (top - window.pageYOffset < 0) {
const [left, top] = calcPosWhenBottom();
return { left, top, transformOrigin: 'center top' };
}
return { left, top, transformOrigin: 'center bottom' };
}
case 'bottom': {
const [left, top] = calcPosWhenBottom();
// TODO:
return { left, top, transformOrigin: 'center top' };
}
case 'left': {
const [left, top] = calcPosWhenLeft();
//
if (left - window.pageXOffset < 0) {
const [left, top] = calcPosWhenRight();
return { left, top, transformOrigin: 'left center' };
}
return { left, top, transformOrigin: 'right center' };
}
case 'right': {
const [left, top] = calcPosWhenRight();
// TODO:
return { left, top, transformOrigin: 'left center' };
}
}
};
const { left, top, transformOrigin } = calc();
el.value.style.transformOrigin = transformOrigin;
el.value.style.left = left + 'px';
el.value.style.top = top + 'px';
};
let loopHandler; let loopHandler;
onMounted(() => { onMounted(() => {

View file

@ -1,6 +1,6 @@
<template> <template>
<transition :name="$store.state.animation ? 'window' : ''" appear @after-leave="$emit('closed')"> <transition :name="$store.state.animation ? 'window' : ''" appear @after-leave="$emit('closed')">
<div v-if="showing" class="ebkgocck"> <div v-if="showing" ref="rootEl" class="ebkgocck" :class="{ maximized }">
<div class="body _shadow _narrow_" @mousedown="onBodyMousedown" @keydown="onKeydown"> <div class="body _shadow _narrow_" @mousedown="onBodyMousedown" @keydown="onKeydown">
<div class="header" :class="{ mini }" @contextmenu.prevent.stop="onContextmenu"> <div class="header" :class="{ mini }" @contextmenu.prevent.stop="onContextmenu">
<span class="left"> <span class="left">
@ -11,6 +11,8 @@
</span> </span>
<span class="right"> <span class="right">
<button v-for="button in buttonsRight" v-tooltip="button.title" class="button _button" :class="{ highlighted: button.highlighted }" @click="button.onClick"><i :class="button.icon"></i></button> <button v-for="button in buttonsRight" v-tooltip="button.title" class="button _button" :class="{ highlighted: button.highlighted }" @click="button.onClick"><i :class="button.icon"></i></button>
<button v-if="canResize && maximized" class="button _button" @click="unMaximize()"><i class="fas fa-window-restore"></i></button>
<button v-else-if="canResize && !maximized" class="button _button" @click="maximize()"><i class="fas fa-window-maximize"></i></button>
<button v-if="closeButton" class="button _button" @click="close()"><i class="fas fa-times"></i></button> <button v-if="closeButton" class="button _button" @click="close()"><i class="fas fa-times"></i></button>
</span> </span>
</div> </div>
@ -32,15 +34,16 @@
</transition> </transition>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { onBeforeUnmount, onMounted, provide } from 'vue';
import contains from '@/scripts/contains'; import contains from '@/scripts/contains';
import * as os from '@/os'; import * as os from '@/os';
import { MenuItem } from '@/types/menu';
const minHeight = 50; const minHeight = 50;
const minWidth = 250; const minWidth = 250;
function dragListen(fn) { function dragListen(fn: (ev: MouseEvent) => void) {
window.addEventListener('mousemove', fn); window.addEventListener('mousemove', fn);
window.addEventListener('touchmove', fn); window.addEventListener('touchmove', fn);
window.addEventListener('mouseleave', dragClear.bind(null, fn)); window.addEventListener('mouseleave', dragClear.bind(null, fn));
@ -56,117 +59,117 @@ function dragClear(fn) {
window.removeEventListener('touchend', dragClear); window.removeEventListener('touchend', dragClear);
} }
export default defineComponent({ const props = withDefaults(defineProps<{
provide: { initialWidth?: number;
inWindow: true, initialHeight?: number | null;
}, canResize?: boolean;
closeButton?: boolean;
mini?: boolean;
front?: boolean;
contextmenu?: MenuItem[] | null;
buttonsLeft?: any[];
buttonsRight?: any[];
}>(), {
initialWidth: 400,
initialHeight: null,
canResize: false,
closeButton: true,
mini: false,
front: true,
contextmenu: null,
buttonsLeft: () => [],
buttonsRight: () => [],
});
props: { const emit = defineEmits<{
initialWidth: { (ev: 'closed'): void;
type: Number, }>();
required: false,
default: 400,
},
initialHeight: {
type: Number,
required: false,
default: null,
},
canResize: {
type: Boolean,
required: false,
default: false,
},
closeButton: {
type: Boolean,
required: false,
default: true,
},
mini: {
type: Boolean,
required: false,
default: false,
},
front: {
type: Boolean,
required: false,
default: false,
},
contextmenu: {
type: Array,
required: false,
},
buttonsLeft: {
type: Array,
required: false,
default: () => [],
},
buttonsRight: {
type: Array,
required: false,
default: () => [],
},
},
emits: ['closed'], provide('inWindow', true);
data() { let rootEl = $ref<HTMLElement | null>();
return { let showing = $ref(true);
showing: true, let beforeClickedAt = 0;
id: Math.random().toString(), // TODO: UUID let maximized = $ref(false);
}; let unMaximizedTop = '';
}, let unMaximizedLeft = '';
let unMaximizedWidth = '';
let unMaximizedHeight = '';
mounted() { function close() {
if (this.initialWidth) this.applyTransformWidth(this.initialWidth); showing = false;
if (this.initialHeight) this.applyTransformHeight(this.initialHeight); }
this.applyTransformTop((window.innerHeight / 2) - (this.$el.offsetHeight / 2)); function onKeydown(evt) {
this.applyTransformLeft((window.innerWidth / 2) - (this.$el.offsetWidth / 2));
//
this.top();
window.addEventListener('resize', this.onBrowserResize);
},
unmounted() {
window.removeEventListener('resize', this.onBrowserResize);
},
methods: {
close() {
this.showing = false;
},
onKeydown(evt) {
if (evt.which === 27) { // Esc if (evt.which === 27) { // Esc
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
this.close(); close();
}
} }
},
onContextmenu(ev: MouseEvent) { function onContextmenu(ev: MouseEvent) {
if (this.contextmenu) { if (props.contextmenu) {
os.contextMenu(this.contextmenu, ev); os.contextMenu(props.contextmenu, ev);
}
} }
},
// //
top() { function top() {
(this.$el as any).style.zIndex = os.claimZIndex(this.front ? 'middle' : 'low'); if (rootEl) {
}, rootEl.style.zIndex = os.claimZIndex(props.front ? 'middle' : 'low');
}
}
onBodyMousedown() { function maximize() {
this.top(); maximized = true;
}, unMaximizedTop = rootEl.style.top;
unMaximizedLeft = rootEl.style.left;
unMaximizedWidth = rootEl.style.width;
unMaximizedHeight = rootEl.style.height;
rootEl.style.top = '0';
rootEl.style.left = '0';
rootEl.style.width = '100%';
rootEl.style.height = '100%';
}
onHeaderMousedown(evt: MouseEvent) { function unMaximize() {
maximized = false;
rootEl.style.top = unMaximizedTop;
rootEl.style.left = unMaximizedLeft;
rootEl.style.width = unMaximizedWidth;
rootEl.style.height = unMaximizedHeight;
}
function onBodyMousedown() {
top();
}
function onDblClick() {
maximize();
}
function onHeaderMousedown(evt: MouseEvent) {
// //
if (evt.button === 2) return; if (evt.button === 2) return;
const main = this.$el as any; let beforeMaximized = false;
if (maximized) {
beforeMaximized = true;
unMaximize();
}
//
if (Date.now() - beforeClickedAt < 300) {
beforeClickedAt = Date.now();
onDblClick();
return;
}
beforeClickedAt = Date.now();
const main = rootEl;
if (!contains(main, document.activeElement)) main.focus(); if (!contains(main, document.activeElement)) main.focus();
@ -174,18 +177,14 @@ export default defineComponent({
const clickX = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientX : evt.clientX; const clickX = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientX : evt.clientX;
const clickY = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientY : evt.clientY; const clickY = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientY : evt.clientY;
const moveBaseX = clickX - position.left; const moveBaseX = beforeMaximized ? parseInt(unMaximizedWidth, 10) / 2 : clickX - position.left; // TODO: parseInt
const moveBaseY = clickY - position.top; const moveBaseY = beforeMaximized ? 20 : clickY - position.top;
const browserWidth = window.innerWidth; const browserWidth = window.innerWidth;
const browserHeight = window.innerHeight; const browserHeight = window.innerHeight;
const windowWidth = main.offsetWidth; const windowWidth = main.offsetWidth;
const windowHeight = main.offsetHeight; const windowHeight = main.offsetHeight;
// function move(x: number, y: number) {
dragListen(me => {
const x = me.touches && me.touches.length > 0 ? me.touches[0].clientX : me.clientX;
const y = me.touches && me.touches.length > 0 ? me.touches[0].clientY : me.clientY;
let moveLeft = x - moveBaseX; let moveLeft = x - moveBaseX;
let moveTop = y - moveBaseY; let moveTop = y - moveBaseY;
@ -201,14 +200,26 @@ export default defineComponent({
// //
if (moveLeft + windowWidth > browserWidth) moveLeft = browserWidth - windowWidth; if (moveLeft + windowWidth > browserWidth) moveLeft = browserWidth - windowWidth;
this.$el.style.left = moveLeft + 'px'; rootEl.style.left = moveLeft + 'px';
this.$el.style.top = moveTop + 'px'; rootEl.style.top = moveTop + 'px';
}
if (beforeMaximized) {
move(clickX, clickY);
}
//
dragListen(me => {
const x = me.touches && me.touches.length > 0 ? me.touches[0].clientX : me.clientX;
const y = me.touches && me.touches.length > 0 ? me.touches[0].clientY : me.clientY;
move(x, y);
}); });
}, }
// //
onTopHandleMousedown(evt) { function onTopHandleMousedown(evt) {
const main = this.$el as any; const main = rootEl;
const base = evt.clientY; const base = evt.clientY;
const height = parseInt(getComputedStyle(main, '').height, 10); const height = parseInt(getComputedStyle(main, '').height, 10);
@ -219,22 +230,22 @@ export default defineComponent({
const move = me.clientY - base; const move = me.clientY - base;
if (top + move > 0) { if (top + move > 0) {
if (height + -move > minHeight) { if (height + -move > minHeight) {
this.applyTransformHeight(height + -move); applyTransformHeight(height + -move);
this.applyTransformTop(top + move); applyTransformTop(top + move);
} else { // } else { //
this.applyTransformHeight(minHeight); applyTransformHeight(minHeight);
this.applyTransformTop(top + (height - minHeight)); applyTransformTop(top + (height - minHeight));
} }
} else { // } else { //
this.applyTransformHeight(top + height); applyTransformHeight(top + height);
this.applyTransformTop(0); applyTransformTop(0);
} }
}); });
}, }
// //
onRightHandleMousedown(evt) { function onRightHandleMousedown(evt) {
const main = this.$el as any; const main = rootEl;
const base = evt.clientX; const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10); const width = parseInt(getComputedStyle(main, '').width, 10);
@ -246,19 +257,19 @@ export default defineComponent({
const move = me.clientX - base; const move = me.clientX - base;
if (left + width + move < browserWidth) { if (left + width + move < browserWidth) {
if (width + move > minWidth) { if (width + move > minWidth) {
this.applyTransformWidth(width + move); applyTransformWidth(width + move);
} else { // } else { //
this.applyTransformWidth(minWidth); applyTransformWidth(minWidth);
} }
} else { // } else { //
this.applyTransformWidth(browserWidth - left); applyTransformWidth(browserWidth - left);
} }
}); });
}, }
// //
onBottomHandleMousedown(evt) { function onBottomHandleMousedown(evt) {
const main = this.$el as any; const main = rootEl;
const base = evt.clientY; const base = evt.clientY;
const height = parseInt(getComputedStyle(main, '').height, 10); const height = parseInt(getComputedStyle(main, '').height, 10);
@ -270,19 +281,19 @@ export default defineComponent({
const move = me.clientY - base; const move = me.clientY - base;
if (top + height + move < browserHeight) { if (top + height + move < browserHeight) {
if (height + move > minHeight) { if (height + move > minHeight) {
this.applyTransformHeight(height + move); applyTransformHeight(height + move);
} else { // } else { //
this.applyTransformHeight(minHeight); applyTransformHeight(minHeight);
} }
} else { // } else { //
this.applyTransformHeight(browserHeight - top); applyTransformHeight(browserHeight - top);
} }
}); });
}, }
// //
onLeftHandleMousedown(evt) { function onLeftHandleMousedown(evt) {
const main = this.$el as any; const main = rootEl;
const base = evt.clientX; const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10); const width = parseInt(getComputedStyle(main, '').width, 10);
@ -293,78 +304,97 @@ export default defineComponent({
const move = me.clientX - base; const move = me.clientX - base;
if (left + move > 0) { if (left + move > 0) {
if (width + -move > minWidth) { if (width + -move > minWidth) {
this.applyTransformWidth(width + -move); applyTransformWidth(width + -move);
this.applyTransformLeft(left + move); applyTransformLeft(left + move);
} else { // } else { //
this.applyTransformWidth(minWidth); applyTransformWidth(minWidth);
this.applyTransformLeft(left + (width - minWidth)); applyTransformLeft(left + (width - minWidth));
} }
} else { // } else { //
this.applyTransformWidth(left + width); applyTransformWidth(left + width);
this.applyTransformLeft(0); applyTransformLeft(0);
} }
}); });
}, }
// //
onTopLeftHandleMousedown(evt) { function onTopLeftHandleMousedown(evt) {
this.onTopHandleMousedown(evt); onTopHandleMousedown(evt);
this.onLeftHandleMousedown(evt); onLeftHandleMousedown(evt);
}, }
// //
onTopRightHandleMousedown(evt) { function onTopRightHandleMousedown(evt) {
this.onTopHandleMousedown(evt); onTopHandleMousedown(evt);
this.onRightHandleMousedown(evt); onRightHandleMousedown(evt);
}, }
// //
onBottomRightHandleMousedown(evt) { function onBottomRightHandleMousedown(evt) {
this.onBottomHandleMousedown(evt); onBottomHandleMousedown(evt);
this.onRightHandleMousedown(evt); onRightHandleMousedown(evt);
}, }
// //
onBottomLeftHandleMousedown(evt) { function onBottomLeftHandleMousedown(evt) {
this.onBottomHandleMousedown(evt); onBottomHandleMousedown(evt);
this.onLeftHandleMousedown(evt); onLeftHandleMousedown(evt);
}, }
// //
applyTransformHeight(height) { function applyTransformHeight(height) {
if (height > window.innerHeight) height = window.innerHeight; if (height > window.innerHeight) height = window.innerHeight;
(this.$el as any).style.height = height + 'px'; rootEl.style.height = height + 'px';
}, }
// //
applyTransformWidth(width) { function applyTransformWidth(width) {
if (width > window.innerWidth) width = window.innerWidth; if (width > window.innerWidth) width = window.innerWidth;
(this.$el as any).style.width = width + 'px'; rootEl.style.width = width + 'px';
}, }
// Y // Y
applyTransformTop(top) { function applyTransformTop(top) {
(this.$el as any).style.top = top + 'px'; rootEl.style.top = top + 'px';
}, }
// X // X
applyTransformLeft(left) { function applyTransformLeft(left) {
(this.$el as any).style.left = left + 'px'; rootEl.style.left = left + 'px';
}, }
onBrowserResize() { function onBrowserResize() {
const main = this.$el as any; const main = rootEl;
const position = main.getBoundingClientRect(); const position = main.getBoundingClientRect();
const browserWidth = window.innerWidth; const browserWidth = window.innerWidth;
const browserHeight = window.innerHeight; const browserHeight = window.innerHeight;
const windowWidth = main.offsetWidth; const windowWidth = main.offsetWidth;
const windowHeight = main.offsetHeight; const windowHeight = main.offsetHeight;
if (position.left < 0) main.style.left = 0; // if (position.left < 0) main.style.left = '0'; //
if (position.top + windowHeight > browserHeight) main.style.top = browserHeight - windowHeight + 'px'; // if (position.top + windowHeight > browserHeight) main.style.top = browserHeight - windowHeight + 'px'; //
if (position.left + windowWidth > browserWidth) main.style.left = browserWidth - windowWidth + 'px'; // if (position.left + windowWidth > browserWidth) main.style.left = browserWidth - windowWidth + 'px'; //
if (position.top < 0) main.style.top = 0; // if (position.top < 0) main.style.top = '0'; //
}, }
},
onMounted(() => {
if (props.initialWidth) applyTransformWidth(props.initialWidth);
if (props.initialHeight) applyTransformHeight(props.initialHeight);
applyTransformTop((window.innerHeight / 2) - (rootEl.offsetHeight / 2));
applyTransformLeft((window.innerWidth / 2) - (rootEl.offsetWidth / 2));
//
top();
window.addEventListener('resize', onBrowserResize);
});
onBeforeUnmount(() => {
window.removeEventListener('resize', onBrowserResize);
});
defineExpose({
close,
}); });
</script> </script>
@ -384,7 +414,7 @@ export default defineComponent({
left: 0; left: 0;
> .body { > .body {
overflow: hidden; overflow: clip;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
contain: content; contain: content;
@ -522,5 +552,11 @@ export default defineComponent({
cursor: nesw-resize; cursor: nesw-resize;
} }
} }
&.maximized {
> .body {
border-radius: 0;
}
}
} }
</style> </style>

View file

@ -330,13 +330,11 @@ definePageMetadata(INFO);
width: 34%; width: 34%;
padding-right: 32px; padding-right: 32px;
box-sizing: border-box; box-sizing: border-box;
overflow: auto;
} }
> .main { > .main {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
overflow: auto;
} }
} }
} }

View file

@ -1,11 +1,11 @@
<template> <template>
<div class="_formRoot"> <div class="_formRoot">
<div class="llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }"> <div class="llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
<div class="avatar _acrylic"> <div class="avatar">
<MkAvatar class="avatar" :user="$i" :disable-link="true" @click="changeAvatar"/> <MkAvatar class="avatar" :user="$i" :disable-link="true" @click="changeAvatar"/>
<MkButton primary class="avatarEdit" @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton> <MkButton primary rounded class="avatarEdit" @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton>
</div> </div>
<MkButton primary class="bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton> <MkButton primary rounded class="bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton>
</div> </div>
<FormInput v-model="profile.name" :max="30" manual-save class="_formBlock"> <FormInput v-model="profile.name" :max="30" manual-save class="_formBlock">
@ -187,6 +187,7 @@ definePageMetadata({
position: relative; position: relative;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
border: solid 1px var(--divider);
border-radius: 10px; border-radius: 10px;
overflow: clip; overflow: clip;

View file

@ -0,0 +1,158 @@
import { Ref } from 'vue';
export function calcPopupPosition(el: HTMLElement, props: {
anchorElement: HTMLElement | null;
innerMargin: number;
direction: 'top' | 'bottom' | 'left' | 'right';
align: 'top' | 'bottom' | 'left' | 'right' | 'center';
alignOffset?: number;
x?: number;
y?: number;
}): { top: number; left: number; transformOrigin: string; } {
const contentWidth = el.offsetWidth;
const contentHeight = el.offsetHeight;
let rect: DOMRect;
if (props.anchorElement) {
rect = props.anchorElement.getBoundingClientRect();
}
const calcPosWhenTop = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = rect.left + window.pageXOffset + (props.anchorElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset - contentHeight) - props.innerMargin;
} else {
left = props.x;
top = (props.y - contentHeight) - props.innerMargin;
}
left -= (el.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenBottom = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = rect.left + window.pageXOffset + (props.anchorElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset + props.anchorElement.offsetHeight) + props.innerMargin;
} else {
left = props.x;
top = (props.y) + props.innerMargin;
}
left -= (el.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenLeft = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = (rect.left + window.pageXOffset - contentWidth) - props.innerMargin;
top = rect.top + window.pageYOffset + (props.anchorElement.offsetHeight / 2);
} else {
left = (props.x - contentWidth) - props.innerMargin;
top = props.y;
}
top -= (el.offsetHeight / 2);
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calcPosWhenRight = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = (rect.left + props.anchorElement.offsetWidth + window.pageXOffset) + props.innerMargin;
if (props.align === 'top') {
top = rect.top + window.pageYOffset;
if (props.alignOffset != null) top += props.alignOffset;
} else if (props.align === 'bottom') {
// TODO
} else { // center
top = rect.top + window.pageYOffset + (props.anchorElement.offsetHeight / 2);
top -= (el.offsetHeight / 2);
}
} else {
left = props.x + props.innerMargin;
top = props.y;
top -= (el.offsetHeight / 2);
}
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calc = (): {
left: number;
top: number;
transformOrigin: string;
} => {
switch (props.direction) {
case 'top': {
const [left, top] = calcPosWhenTop();
// ツールチップを上に向かって表示するスペースがなければ下に向かって出す
if (top - window.pageYOffset < 0) {
const [left, top] = calcPosWhenBottom();
return { left, top, transformOrigin: 'center top' };
}
return { left, top, transformOrigin: 'center bottom' };
}
case 'bottom': {
const [left, top] = calcPosWhenBottom();
// TODO: ツールチップを下に向かって表示するスペースがなければ上に向かって出す
return { left, top, transformOrigin: 'center top' };
}
case 'left': {
const [left, top] = calcPosWhenLeft();
// ツールチップを左に向かって表示するスペースがなければ右に向かって出す
if (left - window.pageXOffset < 0) {
const [left, top] = calcPosWhenRight();
return { left, top, transformOrigin: 'left center' };
}
return { left, top, transformOrigin: 'right center' };
}
case 'right': {
const [left, top] = calcPosWhenRight();
// TODO: ツールチップを右に向かって表示するスペースがなければ左に向かって出す
return { left, top, transformOrigin: 'left center' };
}
}
};
return calc();
}

View file

@ -270,7 +270,7 @@ type Plugin = {
* () * ()
*/ */
import lightTheme from '@/themes/l-light.json5'; import lightTheme from '@/themes/l-light.json5';
import darkTheme from '@/themes/d-dark.json5'; import darkTheme from '@/themes/d-green-lime.json5';
export class ColdDeviceStorage { export class ColdDeviceStorage {
public static default = { public static default = {

View file

@ -11,10 +11,11 @@ export type MenuA = { type: 'a', href: string, target?: string, download?: strin
export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction }; export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction };
export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, disabled?: boolean }; export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, disabled?: boolean };
export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar?: Misskey.entities.User; action: MenuAction }; export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar?: Misskey.entities.User; action: MenuAction };
export type MenuParent = { type: 'parent', text: string, icon?: string, children: OuterMenuItem[] };
export type MenuPending = { type: 'pending' }; export type MenuPending = { type: 'pending' };
type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton>; type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent>;
export type MenuItem = OuterMenuItem | OuterPromiseMenuItem; export type MenuItem = OuterMenuItem | OuterPromiseMenuItem;
export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;

View file

@ -1,5 +1,6 @@
<template> <template>
<component :is="popup.component" <component
:is="popup.component"
v-for="popup in popups" v-for="popup in popups"
:key="popup.id" :key="popup.id"
v-bind="popup.props" v-bind="popup.props"
@ -15,32 +16,30 @@
<div v-if="dev" id="devTicker"><span>DEV BUILD</span></div> <div v-if="dev" id="devTicker"><span>DEV BUILD</span></div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineAsyncComponent, defineComponent } from 'vue'; import { defineAsyncComponent } from 'vue';
import { swInject } from './sw-inject';
import { popup, popups, pendingApiRequestsCount } from '@/os'; import { popup, popups, pendingApiRequestsCount } from '@/os';
import { uploads } from '@/scripts/upload'; import { uploads } from '@/scripts/upload';
import * as sound from '@/scripts/sound'; import * as sound from '@/scripts/sound';
import { $i } from '@/account'; import { $i } from '@/account';
import { swInject } from './sw-inject';
import { stream } from '@/stream'; import { stream } from '@/stream';
export default defineComponent({ const XStreamIndicator = defineAsyncComponent(() => import('./stream-indicator.vue'));
components: { const XUpload = defineAsyncComponent(() => import('./upload.vue'));
XStreamIndicator: defineAsyncComponent(() => import('./stream-indicator.vue')),
XUpload: defineAsyncComponent(() => import('./upload.vue')), const dev = _DEV_;
},
setup() {
const onNotification = notification => { const onNotification = notification => {
if ($i.mutingNotificationTypes.includes(notification.type)) return; if ($i.mutingNotificationTypes.includes(notification.type)) return;
if (document.visibilityState === 'visible') { if (document.visibilityState === 'visible') {
stream.send('readNotification', { stream.send('readNotification', {
id: notification.id id: notification.id,
}); });
popup(defineAsyncComponent(() => import('@/components/notification-toast.vue')), { popup(defineAsyncComponent(() => import('@/components/notification-toast.vue')), {
notification notification,
}, {}, 'closed'); }, {}, 'closed');
} }
@ -56,15 +55,6 @@ export default defineComponent({
swInject(); swInject();
} }
} }
return {
uploads,
popups,
pendingApiRequestsCount,
dev: _DEV_,
};
},
});
</script> </script>
<style lang="scss"> <style lang="scss">

View file

@ -87,6 +87,36 @@ function openInstanceMenu(ev: MouseEvent) {
text: i18n.ts.federation, text: i18n.ts.federation,
icon: 'fas fa-globe', icon: 'fas fa-globe',
to: '/about#federation', to: '/about#federation',
}, null, {
type: 'parent',
text: i18n.ts.help,
icon: 'fas fa-question-circle',
children: [{
type: 'link',
to: '/mfm-cheat-sheet',
text: i18n.ts._mfm.cheatSheet,
icon: 'fas fa-code',
}, {
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'fas fa-terminal',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'fas fa-terminal',
}, null, {
text: i18n.ts.document,
icon: 'fas fa-question-circle',
action: () => {
window.open('https://misskey-hub.net/help.html', '_blank');
},
}],
}, {
type: 'link',
text: i18n.ts.aboutMisskey,
to: '/about-misskey',
}], ev.currentTarget ?? ev.target, { }], ev.currentTarget ?? ev.target, {
align: 'left', align: 'left',
}); });

View file

@ -110,6 +110,36 @@ function openInstanceMenu(ev: MouseEvent) {
text: i18n.ts.federation, text: i18n.ts.federation,
icon: 'fas fa-globe', icon: 'fas fa-globe',
to: '/about#federation', to: '/about#federation',
}, null, {
type: 'parent',
text: i18n.ts.help,
icon: 'fas fa-question-circle',
children: [{
type: 'link',
to: '/mfm-cheat-sheet',
text: i18n.ts._mfm.cheatSheet,
icon: 'fas fa-code',
}, {
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'fas fa-terminal',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'fas fa-terminal',
}, null, {
text: i18n.ts.document,
icon: 'fas fa-question-circle',
action: () => {
window.open('https://misskey-hub.net/help.html', '_blank');
},
}],
}, {
type: 'link',
text: i18n.ts.aboutMisskey,
to: '/about-misskey',
}], ev.currentTarget ?? ev.target, { }], ev.currentTarget ?? ev.target, {
align: 'left', align: 'left',
}); });

View file

@ -128,7 +128,11 @@ function getMenu() {
if (canceled) return; if (canceled) return;
updateColumn(props.column.id, result); updateColumn(props.column.id, result);
}, },
}, null, { }, {
type: 'parent',
text: i18n.ts.move + '...',
icon: 'fas fa-arrows-up-down-left-right',
children: [{
icon: 'fas fa-arrow-left', icon: 'fas fa-arrow-left',
text: i18n.ts._deck.swapLeft, text: i18n.ts._deck.swapLeft,
action: () => { action: () => {
@ -152,7 +156,8 @@ function getMenu() {
action: () => { action: () => {
swapDownColumn(props.column.id); swapDownColumn(props.column.id);
}, },
} : undefined, null, { } : undefined],
}, {
icon: 'fas fa-window-restore', icon: 'fas fa-window-restore',
text: i18n.ts._deck.stackLeft, text: i18n.ts._deck.stackLeft,
action: () => { action: () => {