mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 08:20:10 +00:00
feat(client): プラグインを無効にできるように
This commit is contained in:
parent
6b8354ccbf
commit
595ad04ddb
5 changed files with 45 additions and 5 deletions
|
@ -555,6 +555,7 @@ smtpSecureInfo: "STARTTLS使用時はオフにします。"
|
||||||
testEmail: "配信テスト"
|
testEmail: "配信テスト"
|
||||||
wordMute: "ワードミュート"
|
wordMute: "ワードミュート"
|
||||||
userSaysSomething: "{name}が何かを言いました"
|
userSaysSomething: "{name}が何かを言いました"
|
||||||
|
makeActive: "アクティブにする"
|
||||||
|
|
||||||
_wordMute:
|
_wordMute:
|
||||||
muteWords: "ミュートするワード"
|
muteWords: "ミュートするワード"
|
||||||
|
|
|
@ -242,7 +242,7 @@ os.init(async () => {
|
||||||
//store.commit('instance/set', );
|
//store.commit('instance/set', );
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const plugin of store.state.deviceUser.plugins) {
|
for (const plugin of store.state.deviceUser.plugins.filter(p => p.active)) {
|
||||||
console.info('Plugin installed:', plugin.name, 'v' + plugin.version);
|
console.info('Plugin installed:', plugin.name, 'v' + plugin.version);
|
||||||
|
|
||||||
const aiscript = new AiScript(createPluginEnv(app, {
|
const aiscript = new AiScript(createPluginEnv(app, {
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
<option v-for="x in $store.state.deviceUser.plugins" :value="x.id" :key="x.id">{{ x.name }}</option>
|
<option v-for="x in $store.state.deviceUser.plugins" :value="x.id" :key="x.id">{{ x.name }}</option>
|
||||||
</mk-select>
|
</mk-select>
|
||||||
<template v-if="selectedPlugin">
|
<template v-if="selectedPlugin">
|
||||||
|
<div style="margin: -8px 0 8px 0;">
|
||||||
|
<mk-switch :value="selectedPlugin.active" @change="changeActive(selectedPlugin, $event)">{{ $t('makeActive') }}</mk-switch>
|
||||||
|
</div>
|
||||||
<div class="_keyValue">
|
<div class="_keyValue">
|
||||||
<div>{{ $t('version') }}:</div>
|
<div>{{ $t('version') }}:</div>
|
||||||
<div>{{ selectedPlugin.version }}</div>
|
<div>{{ selectedPlugin.version }}</div>
|
||||||
|
@ -49,6 +52,7 @@ import MkButton from '../../components/ui/button.vue';
|
||||||
import MkTextarea from '../../components/ui/textarea.vue';
|
import MkTextarea from '../../components/ui/textarea.vue';
|
||||||
import MkSelect from '../../components/ui/select.vue';
|
import MkSelect from '../../components/ui/select.vue';
|
||||||
import MkInfo from '../../components/ui/info.vue';
|
import MkInfo from '../../components/ui/info.vue';
|
||||||
|
import MkSwitch from '../../components/ui/switch.vue';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
components: {
|
components: {
|
||||||
|
@ -56,6 +60,7 @@ export default Vue.extend({
|
||||||
MkTextarea,
|
MkTextarea,
|
||||||
MkSelect,
|
MkSelect,
|
||||||
MkInfo,
|
MkInfo,
|
||||||
|
MkSwitch,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -171,6 +176,17 @@ export default Vue.extend({
|
||||||
config: result
|
config: result
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
changeActive(plugin, active) {
|
||||||
|
this.$store.commit('deviceUser/changePluginActive', {
|
||||||
|
id: plugin.id,
|
||||||
|
active: active
|
||||||
|
});
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,9 +14,9 @@ export function createAiScriptEnv(vm, opts) {
|
||||||
text: text.value,
|
text: text.value,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
'Mk:confirm': values.FN_NATIVE(async ([title, text]) => {
|
'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => {
|
||||||
const confirm = await vm.$root.dialog({
|
const confirm = await vm.$root.dialog({
|
||||||
type: 'warning',
|
type: type ? type.value : 'question',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
title: title.value,
|
title: title.value,
|
||||||
text: text.value,
|
text: text.value,
|
||||||
|
@ -44,12 +44,13 @@ export function createAiScriptEnv(vm, opts) {
|
||||||
|
|
||||||
export function createPluginEnv(vm, opts) {
|
export function createPluginEnv(vm, opts) {
|
||||||
const config = new Map();
|
const config = new Map();
|
||||||
for (const [k, v] of Object.entries(opts.plugin.config)) {
|
for (const [k, v] of Object.entries(opts.plugin.config || {})) {
|
||||||
config.set(k, jsToVal(opts.plugin.configData[k] || v.default));
|
config.set(k, jsToVal(opts.plugin.configData[k] || v.default));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...createAiScriptEnv(vm, { ...opts, token: opts.plugin.token }),
|
...createAiScriptEnv(vm, { ...opts, token: opts.plugin.token }),
|
||||||
|
//#region Deprecated
|
||||||
'Mk:register_post_form_action': values.FN_NATIVE(([title, handler]) => {
|
'Mk:register_post_form_action': values.FN_NATIVE(([title, handler]) => {
|
||||||
vm.$store.commit('registerPostFormAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
vm.$store.commit('registerPostFormAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
||||||
}),
|
}),
|
||||||
|
@ -59,6 +60,16 @@ export function createPluginEnv(vm, opts) {
|
||||||
'Mk:register_note_action': values.FN_NATIVE(([title, handler]) => {
|
'Mk:register_note_action': values.FN_NATIVE(([title, handler]) => {
|
||||||
vm.$store.commit('registerNoteAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
vm.$store.commit('registerNoteAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
||||||
}),
|
}),
|
||||||
|
//#endregion
|
||||||
|
'Plugin:register_post_form_action': values.FN_NATIVE(([title, handler]) => {
|
||||||
|
vm.$store.commit('registerPostFormAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
||||||
|
}),
|
||||||
|
'Plugin:register_user_action': values.FN_NATIVE(([title, handler]) => {
|
||||||
|
vm.$store.commit('registerUserAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
||||||
|
}),
|
||||||
|
'Plugin:register_note_action': values.FN_NATIVE(([title, handler]) => {
|
||||||
|
vm.$store.commit('registerNoteAction', { pluginId: opts.plugin.id, title: title.value, handler });
|
||||||
|
}),
|
||||||
'Plugin:config': values.OBJ(config),
|
'Plugin:config': values.OBJ(config),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,14 @@ export const defaultDeviceUserSettings = {
|
||||||
columns: [],
|
columns: [],
|
||||||
layout: [],
|
layout: [],
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: [] as {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
active: boolean;
|
||||||
|
configData: Record<string, any>;
|
||||||
|
token: string;
|
||||||
|
ast: any[];
|
||||||
|
}[],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultDeviceSettings = {
|
export const defaultDeviceSettings = {
|
||||||
|
@ -591,6 +598,7 @@ export default () => new Vuex.Store({
|
||||||
installPlugin(state, { meta, ast, token }) {
|
installPlugin(state, { meta, ast, token }) {
|
||||||
state.plugins.push({
|
state.plugins.push({
|
||||||
...meta,
|
...meta,
|
||||||
|
active: true,
|
||||||
configData: {},
|
configData: {},
|
||||||
token: token,
|
token: token,
|
||||||
ast: ast
|
ast: ast
|
||||||
|
@ -604,6 +612,10 @@ export default () => new Vuex.Store({
|
||||||
configPlugin(state, { id, config }) {
|
configPlugin(state, { id, config }) {
|
||||||
state.plugins.find(p => p.id === id).configData = config;
|
state.plugins.find(p => p.id === id).configData = config;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changePluginActive(state, { id, active }) {
|
||||||
|
state.plugins.find(p => p.id === id).active = active;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue