mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 07:03:08 +02:00
enhance(client): flash作成時のプリセットを追加
This commit is contained in:
parent
c9f5e60f43
commit
d600296360
6 changed files with 58 additions and 5 deletions
|
@ -935,6 +935,8 @@ manageCustomEmojis: "カスタム絵文字の管理"
|
||||||
youCannotCreateAnymore: "これ以上作成することはできません。"
|
youCannotCreateAnymore: "これ以上作成することはできません。"
|
||||||
cannotPerformTemporary: "一時的に利用できません"
|
cannotPerformTemporary: "一時的に利用できません"
|
||||||
cannotPerformTemporaryDescription: "操作回数が制限を超過するため一時的に利用できません。しばらく時間を置いてから再度お試しください。"
|
cannotPerformTemporaryDescription: "操作回数が制限を超過するため一時的に利用できません。しばらく時間を置いてから再度お試しください。"
|
||||||
|
preset: "プリセット"
|
||||||
|
selectFromPresets: "プリセットから選択"
|
||||||
|
|
||||||
_role:
|
_role:
|
||||||
new: "ロールの作成"
|
new: "ロールの作成"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
<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>
|
<option v-for="item in c.items" :key="item.value" :value="item.value">{{ item.text }}</option>
|
||||||
</MkSelect>
|
</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">
|
<MkFolder v-else-if="c.type === 'folder'" :default-open="c.opened">
|
||||||
<template #label>{{ c.title }}</template>
|
<template #label>{{ c.title }}</template>
|
||||||
<template v-for="child in c.children" :key="child">
|
<template v-for="child in c.children" :key="child">
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
<MkStickyContainer>
|
<MkStickyContainer>
|
||||||
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
||||||
<MkSpacer :content-max="700">
|
<MkSpacer :content-max="700">
|
||||||
<div class="_gaps_m">
|
<div class="_gaps">
|
||||||
<MkInput v-model="title">
|
<MkInput v-model="title">
|
||||||
<template #label>{{ i18n.ts._play.title }}</template>
|
<template #label>{{ i18n.ts._play.title }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<MkTextarea v-model="summary">
|
<MkTextarea v-model="summary">
|
||||||
<template #label>{{ i18n.ts._play.summary }}</template>
|
<template #label>{{ i18n.ts._play.summary }}</template>
|
||||||
</MkTextarea>
|
</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">
|
<MkTextarea v-model="script" class="_monospace" tall spellcheck="false">
|
||||||
<template #label>{{ i18n.ts._play.script }}</template>
|
<template #label>{{ i18n.ts._play.script }}</template>
|
||||||
</MkTextarea>
|
</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() {
|
async function save() {
|
||||||
if (flash) {
|
if (flash) {
|
||||||
os.apiWithDialog('flash/update', {
|
os.apiWithDialog('flash/update', {
|
||||||
|
|
|
@ -130,7 +130,7 @@ const parser = new Parser();
|
||||||
let started = $ref(false);
|
let started = $ref(false);
|
||||||
let aiscript = $shallowRef<Interpreter | null>(null);
|
let aiscript = $shallowRef<Interpreter | null>(null);
|
||||||
const root = ref<AsUiRoot>();
|
const root = ref<AsUiRoot>();
|
||||||
const components: Ref<AsUiComponent>[] = [];
|
const components: Ref<AsUiComponent>[] = $ref([]);
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
started = true;
|
started = true;
|
||||||
|
|
|
@ -53,7 +53,7 @@ let aiscript: Interpreter;
|
||||||
const code = ref('');
|
const code = ref('');
|
||||||
const logs = ref<any[]>([]);
|
const logs = ref<any[]>([]);
|
||||||
const root = ref<AsUiRoot>();
|
const root = ref<AsUiRoot>();
|
||||||
let components: Ref<AsUiComponent>[] = [];
|
let components: Ref<AsUiComponent>[] = $ref([]);
|
||||||
let uiKey = $ref(0);
|
let uiKey = $ref(0);
|
||||||
|
|
||||||
const saved = miLocalStorage.getItem('scratchpad');
|
const saved = miLocalStorage.getItem('scratchpad');
|
||||||
|
|
|
@ -50,7 +50,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
|
||||||
const parser = new Parser();
|
const parser = new Parser();
|
||||||
|
|
||||||
const root = ref<AsUiRoot>();
|
const root = ref<AsUiRoot>();
|
||||||
const components: Ref<AsUiComponent>[] = [];
|
const components: Ref<AsUiComponent>[] = $ref([]);
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const aiscript = new Interpreter({
|
const aiscript = new Interpreter({
|
||||||
|
|
Loading…
Reference in a new issue