Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
42833cd9
Unverified
Commit
42833cd9
authored
2 years ago
by
タービン
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix #10261 (#10323)
parent
c05c504c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/frontend/src/pages/page.vue
+12
-1
12 additions, 1 deletion
packages/frontend/src/pages/page.vue
packages/frontend/src/plugin.ts
+16
-1
16 additions, 1 deletion
packages/frontend/src/plugin.ts
packages/frontend/src/store.ts
+6
-1
6 additions, 1 deletion
packages/frontend/src/store.ts
with
34 additions
and
3 deletions
packages/frontend/src/pages/page.vue
+
12
−
1
View file @
42833cd9
...
...
@@ -75,6 +75,8 @@ import MkPagination from '@/components/MkPagination.vue';
import
MkPagePreview
from
'
@/components/MkPagePreview.vue
'
;
import
{
i18n
}
from
'
@/i18n
'
;
import
{
definePageMetadata
}
from
'
@/scripts/page-metadata
'
;
import
{
pageViewInterruptors
}
from
'
@/store
'
;
import
{
deepClone
}
from
'
@/scripts/clone
'
;
const
props
=
defineProps
<
{
pageName
:
string
;
...
...
@@ -97,8 +99,17 @@ function fetchPage() {
os
.
api
(
'
pages/show
'
,
{
name
:
props
.
pageName
,
username
:
props
.
username
,
}).
then
(
_page
=>
{
}).
then
(
async
_page
=>
{
page
=
_page
;
// plugin
if
(
pageViewInterruptors
.
length
>
0
)
{
let
result
=
deepClone
(
_page
);
for
(
const
interruptor
of
pageViewInterruptors
)
{
result
=
await
interruptor
.
handler
(
result
);
}
page
=
result
;
}
}).
catch
(
err
=>
{
error
=
err
;
});
...
...
This diff is collapsed.
Click to expand it.
packages/frontend/src/plugin.ts
+
16
−
1
View file @
42833cd9
import
{
Interpreter
,
Parser
,
utils
,
values
}
from
'
@syuilo/aiscript
'
;
import
{
createAiScriptEnv
}
from
'
@/scripts/aiscript/api
'
;
import
{
inputText
}
from
'
@/os
'
;
import
{
Plugin
,
noteActions
,
notePostInterruptors
,
noteViewInterruptors
,
postFormActions
,
userActions
}
from
'
@/store
'
;
import
{
Plugin
,
noteActions
,
notePostInterruptors
,
noteViewInterruptors
,
postFormActions
,
userActions
,
pageViewInterruptors
}
from
'
@/store
'
;
const
parser
=
new
Parser
();
const
pluginContexts
=
new
Map
<
string
,
Interpreter
>
();
...
...
@@ -80,6 +80,9 @@ function createPluginEnv(opts: { plugin: Plugin; storageKey: string }): Record<s
'
Plugin:register_note_post_interruptor
'
:
values
.
FN_NATIVE
(([
handler
])
=>
{
registerNotePostInterruptor
({
pluginId
:
opts
.
plugin
.
id
,
handler
});
}),
'
Plugin:register_page_view_interruptor
'
:
values
.
FN_NATIVE
(([
handler
])
=>
{
registerPageViewInterruptor
({
pluginId
:
opts
.
plugin
.
id
,
handler
});
}),
'
Plugin:open_url
'
:
values
.
FN_NATIVE
(([
url
])
=>
{
utils
.
assertString
(
url
);
window
.
open
(
url
.
value
,
'
_blank
'
);
...
...
@@ -156,3 +159,15 @@ function registerNotePostInterruptor({ pluginId, handler }): void {
},
});
}
function
registerPageViewInterruptor
({
pluginId
,
handler
}):
void
{
pageViewInterruptors
.
push
({
handler
:
async
(
page
)
=>
{
const
pluginContext
=
pluginContexts
.
get
(
pluginId
);
if
(
!
pluginContext
)
{
return
;
}
return
utils
.
valToJs
(
await
pluginContext
.
execFn
(
handler
,
[
utils
.
jsToVal
(
page
)]));
},
});
}
This diff is collapsed.
Click to expand it.
packages/frontend/src/store.ts
+
6
−
1
View file @
42833cd9
...
...
@@ -24,11 +24,16 @@ interface NotePostInterruptor {
handler
:
(
note
:
FIXME
)
=>
unknown
;
}
interface
PageViewInterruptor
{
handler
:
(
page
:
Page
)
=>
unknown
;
}
export
const
postFormActions
:
PostFormAction
[]
=
[];
export
const
userActions
:
UserAction
[]
=
[];
export
const
noteActions
:
NoteAction
[]
=
[];
export
const
noteViewInterruptors
:
NoteViewInterruptor
[]
=
[];
export
const
notePostInterruptors
:
NotePostInterruptor
[]
=
[];
export
const
pageViewInterruptors
:
PageViewInterruptor
[]
=
[];
// TODO: それぞれいちいちwhereとかdefaultというキーを付けなきゃいけないの冗長なのでなんとかする(ただ型定義が面倒になりそう)
// あと、現行の定義の仕方なら「whereが何であるかに関わらずキー名の重複不可」という制約を付けられるメリットもあるからそのメリットを引き継ぐ方法も考えないといけない
...
...
@@ -318,7 +323,7 @@ interface Watcher {
import
{
miLocalStorage
}
from
'
./local-storage
'
;
import
lightTheme
from
'
@/themes/l-light.json5
'
;
import
darkTheme
from
'
@/themes/d-green-lime.json5
'
;
import
{
Note
,
UserDetailed
}
from
'
misskey-js/built/entities
'
;
import
{
Note
,
UserDetailed
,
Page
}
from
'
misskey-js/built/entities
'
;
export
class
ColdDeviceStorage
{
public
static
default
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment