From d60029636011a26a6da8e09d7cb77c0bda4c81b5 Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Mon, 16 Jan 2023 10:04:10 +0900 Subject: [PATCH] =?UTF-8?q?enhance(client):=20flash=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E6=99=82=E3=81=AE=E3=83=97=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 2 + packages/frontend/src/components/MkAsUi.vue | 2 +- .../frontend/src/pages/flash/flash-edit.vue | 53 ++++++++++++++++++- packages/frontend/src/pages/flash/flash.vue | 2 +- packages/frontend/src/pages/scratchpad.vue | 2 +- .../src/widgets/WidgetAiscriptApp.vue | 2 +- 6 files changed, 58 insertions(+), 5 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 786d41ca41..174c28f4a1 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -935,6 +935,8 @@ manageCustomEmojis: "カスタム絵文å—ã®ç®¡ç†" youCannotCreateAnymore: "ã“れ以上作æˆã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。" cannotPerformTemporary: "一時的ã«åˆ©ç”¨ã§ãã¾ã›ã‚“" cannotPerformTemporaryDescription: "æ“作回数ãŒåˆ¶é™ã‚’超éŽã™ã‚‹ãŸã‚一時的ã«åˆ©ç”¨ã§ãã¾ã›ã‚“。ã—ã°ã‚‰ã時間を置ã„ã¦ã‹ã‚‰å†åº¦ãŠè©¦ã—ãã ã•ã„。" +preset: "プリセット" +selectFromPresets: "プリセットã‹ã‚‰é¸æŠž" _role: new: "ãƒãƒ¼ãƒ«ã®ä½œæˆ" diff --git a/packages/frontend/src/components/MkAsUi.vue b/packages/frontend/src/components/MkAsUi.vue index 5844a18633..6aaf2f956c 100644 --- a/packages/frontend/src/components/MkAsUi.vue +++ b/packages/frontend/src/components/MkAsUi.vue @@ -32,7 +32,7 @@ <template v-if="c.caption" #caption>{{ c.caption }}</template> <option v-for="item in c.items" :key="item.value" :value="item.value">{{ item.text }}</option> </MkSelect> - <MkButton v-else-if="c.type === 'postFormButton'" :primary="c.primary" :rounded="c.rounded" :small="size === 'small'" @click="openPostForm">{{ c.text }}</MkButton> + <MkButton v-else-if="c.type === 'postFormButton'" :primary="c.primary" :rounded="c.rounded" :small="size === 'small'" inline @click="openPostForm">{{ c.text }}</MkButton> <MkFolder v-else-if="c.type === 'folder'" :default-open="c.opened"> <template #label>{{ c.title }}</template> <template v-for="child in c.children" :key="child"> diff --git a/packages/frontend/src/pages/flash/flash-edit.vue b/packages/frontend/src/pages/flash/flash-edit.vue index 5e2ca9a9f3..1ce7e46962 100644 --- a/packages/frontend/src/pages/flash/flash-edit.vue +++ b/packages/frontend/src/pages/flash/flash-edit.vue @@ -2,13 +2,14 @@ <MkStickyContainer> <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> <MkSpacer :content-max="700"> - <div class="_gaps_m"> + <div class="_gaps"> <MkInput v-model="title"> <template #label>{{ i18n.ts._play.title }}</template> </MkInput> <MkTextarea v-model="summary"> <template #label>{{ i18n.ts._play.summary }}</template> </MkTextarea> + <MkButton primary @click="selectPreset">{{ i18n.ts.selectFromPresets }}<i class="ti ti-chevron-down"></i></MkButton> <MkTextarea v-model="script" class="_monospace" tall spellcheck="false"> <template #label>{{ i18n.ts._play.script }}</template> </MkTextarea> @@ -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 ebd470ca4f..0e785f259c 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<Interpreter | null>(null); const root = ref<AsUiRoot>(); -const components: Ref<AsUiComponent>[] = []; +const components: Ref<AsUiComponent>[] = $ref([]); function start() { started = true; diff --git a/packages/frontend/src/pages/scratchpad.vue b/packages/frontend/src/pages/scratchpad.vue index ff5f06c8da..bd68df724e 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<any[]>([]); const root = ref<AsUiRoot>(); -let components: Ref<AsUiComponent>[] = []; +let components: Ref<AsUiComponent>[] = $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 1445e5b1ad..406fb92d86 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<AsUiRoot>(); -const components: Ref<AsUiComponent>[] = []; +const components: Ref<AsUiComponent>[] = $ref([]); async function run() { const aiscript = new Interpreter({ -- GitLab