upd: Prompt for confirmation when Plugin:open_url is used
This commit is contained in:
@@ -291,6 +291,7 @@ removeAreYouSure: "Are you sure that you want to remove \"{x}\"?"
|
|||||||
deleteAreYouSure: "Are you sure that you want to delete \"{x}\"?"
|
deleteAreYouSure: "Are you sure that you want to delete \"{x}\"?"
|
||||||
resetAreYouSure: "Really reset?"
|
resetAreYouSure: "Really reset?"
|
||||||
areYouSure: "Are you sure?"
|
areYouSure: "Are you sure?"
|
||||||
|
confirmRemoteUrl: "Are you sure that you want to go to \"{x}\"?"
|
||||||
saved: "Saved"
|
saved: "Saved"
|
||||||
messaging: "Chat"
|
messaging: "Chat"
|
||||||
upload: "Upload"
|
upload: "Upload"
|
||||||
|
|||||||
Vendored
+4
@@ -1180,6 +1180,10 @@ export interface Locale extends ILocale {
|
|||||||
* よろしいですか?
|
* よろしいですか?
|
||||||
*/
|
*/
|
||||||
"areYouSure": string;
|
"areYouSure": string;
|
||||||
|
/**
|
||||||
|
* 「{x}」を開きますか?
|
||||||
|
*/
|
||||||
|
"confirmRemoteUrl": ParameterizedString<"x">;
|
||||||
/**
|
/**
|
||||||
* 保存しました
|
* 保存しました
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ removeAreYouSure: "「{x}」を削除しますか?"
|
|||||||
deleteAreYouSure: "「{x}」を削除しますか?"
|
deleteAreYouSure: "「{x}」を削除しますか?"
|
||||||
resetAreYouSure: "リセットしますか?"
|
resetAreYouSure: "リセットしますか?"
|
||||||
areYouSure: "よろしいですか?"
|
areYouSure: "よろしいですか?"
|
||||||
|
confirmRemoteUrl: "「{x}」を開きますか?"
|
||||||
saved: "保存しました"
|
saved: "保存しました"
|
||||||
messaging: "チャット"
|
messaging: "チャット"
|
||||||
upload: "アップロード"
|
upload: "アップロード"
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { Interpreter, Parser, utils, values } from '@syuilo/aiscript';
|
import { Interpreter, Parser, utils, values } from '@syuilo/aiscript';
|
||||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||||
import { inputText } from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
import { Plugin, noteActions, notePostInterruptors, noteViewInterruptors, postFormActions, userActions, pageViewInterruptors } from '@/store.js';
|
import { Plugin, noteActions, notePostInterruptors, noteViewInterruptors, postFormActions, userActions, pageViewInterruptors } from '@/store.js';
|
||||||
|
|
||||||
const parser = new Parser();
|
const parser = new Parser();
|
||||||
@@ -91,8 +92,15 @@ function createPluginEnv(opts: { plugin: Plugin; storageKey: string }): Record<s
|
|||||||
registerPageViewInterruptor({ pluginId: opts.plugin.id, handler });
|
registerPageViewInterruptor({ pluginId: opts.plugin.id, handler });
|
||||||
}),
|
}),
|
||||||
'Plugin:open_url': values.FN_NATIVE(([url]) => {
|
'Plugin:open_url': values.FN_NATIVE(([url]) => {
|
||||||
utils.assertString(url);
|
(async () => {
|
||||||
window.open(url.value, '_blank', 'noopener');
|
utils.assertString(url);
|
||||||
|
const { canceled } = await os.confirm({
|
||||||
|
type: 'question',
|
||||||
|
text: i18n.tsx.confirmRemoteUrl({x: url.value}),
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
window.open(url.value, '_blank', 'noopener');
|
||||||
|
})();
|
||||||
}),
|
}),
|
||||||
'Plugin:config': values.OBJ(config),
|
'Plugin:config': values.OBJ(config),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user