{{ i18n.ts._play.title }}
{{ i18n.ts._play.summary }}
+
{{ i18n.ts.selectFromPresets }}
{{ i18n.ts._play.script }}
@@ -67,6 +68,56 @@ Ui:render([
])
`);
+function selectPreset(ev: MouseEvent) {
+ os.popupMenu([{
+ text: 'Omikuji',
+ action: () => {
+ script = `/// @ 0.12.2
+// ユーザーごとに日替わりのおみくじのプリセット
+
+// 選択肢
+let choices = [
+ "ギガ吉"
+ "大吉"
+ "吉"
+ "中吉"
+ "小吉"
+ "末吉"
+ "凶"
+ "大凶"
+]
+
+// シードが「ユーザーID+今日の日付」である乱数生成器を用意
+let random = Math:gen_rng(\`{USER_ID}{Date:day()}\`)
+
+// ランダムに選択肢を選ぶ
+let chosen = choices[random(0 (choices.len - 1))]
+
+// 結果のテキスト
+let result = \`今日のあなたの運勢は **{chosen}** です。\`
+
+// UIを表示
+Ui:render([
+ Ui:C:container({
+ align: 'center'
+ children: [
+ Ui:C:mfm({ text: result })
+ Ui:C:postFormButton({
+ text: "投稿する"
+ rounded: true
+ primary: true
+ form: {
+ text: \`{result}{Str:lf}{THIS_URL}\`
+ }
+ })
+ ]
+ })
+])
+`;
+ },
+ }], ev.currentTarget ?? ev.target);
+}
+
async function save() {
if (flash) {
os.apiWithDialog('flash/update', {
diff --git a/packages/frontend/src/pages/flash/flash.vue b/packages/frontend/src/pages/flash/flash.vue
index ebd470ca4..0e785f259 100644
--- a/packages/frontend/src/pages/flash/flash.vue
+++ b/packages/frontend/src/pages/flash/flash.vue
@@ -130,7 +130,7 @@ const parser = new Parser();
let started = $ref(false);
let aiscript = $shallowRef
(null);
const root = ref();
-const components: Ref[] = [];
+const components: Ref[] = $ref([]);
function start() {
started = true;
diff --git a/packages/frontend/src/pages/scratchpad.vue b/packages/frontend/src/pages/scratchpad.vue
index ff5f06c8d..bd68df724 100644
--- a/packages/frontend/src/pages/scratchpad.vue
+++ b/packages/frontend/src/pages/scratchpad.vue
@@ -53,7 +53,7 @@ let aiscript: Interpreter;
const code = ref('');
const logs = ref([]);
const root = ref();
-let components: Ref[] = [];
+let components: Ref[] = $ref([]);
let uiKey = $ref(0);
const saved = miLocalStorage.getItem('scratchpad');
diff --git a/packages/frontend/src/widgets/WidgetAiscriptApp.vue b/packages/frontend/src/widgets/WidgetAiscriptApp.vue
index 1445e5b1a..406fb92d8 100644
--- a/packages/frontend/src/widgets/WidgetAiscriptApp.vue
+++ b/packages/frontend/src/widgets/WidgetAiscriptApp.vue
@@ -50,7 +50,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
const parser = new Parser();
const root = ref();
-const components: Ref[] = [];
+const components: Ref[] = $ref([]);
async function run() {
const aiscript = new Interpreter({