0
0

テーマ関連の機能を強化

This commit is contained in:
syuilo 2018-10-03 02:57:31 +09:00
parent 7d11c8b767
commit 274cf1af1c
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
3 changed files with 53 additions and 9 deletions

View File

@ -311,6 +311,9 @@ common/views/components/theme.vue:
uninstalled: "「{}」をアンインストールしました"
author: "作者"
desc: "説明"
export: "エクスポート"
import: "インポート"
import-by-code: "またはコードをペースト"
common/views/components/cw-button.vue:
hide: "隠す"

View File

@ -44,10 +44,13 @@
<details>
<summary>%fa:download% %i18n:@install-a-theme%</summary>
<ui-button @click="import_()">%fa:file-import% %i18n:@import%</ui-button>
<input ref="file" type="file" style="display:none;" @change="onUpdateImportFile"/>
<p>%i18n:@import-by-code%:</p>
<ui-textarea v-model="installThemeCode">
<span>%i18n:@theme-code%</span>
</ui-textarea>
<ui-button @click="install()">%fa:check% %i18n:@install%</ui-button>
<ui-button @click="() => install(this.installThemeCode)">%fa:check% %i18n:@install%</ui-button>
</details>
<details>
@ -65,6 +68,7 @@
<ui-textarea readonly :value="selectedInstalledThemeCode">
<span>%i18n:@theme-code%</span>
</ui-textarea>
<ui-button @click="export_()" link :download="`${selectedInstalledTheme.name}.misskeytheme`" ref="export">%fa:box% %i18n:@export%</ui-button>
<ui-button @click="uninstall()">%fa:trash-alt R% %i18n:@uninstall%</ui-button>
</template>
</details>
@ -177,11 +181,11 @@ export default Vue.extend({
},
methods: {
install() {
install(code) {
let theme;
try {
theme = JSON5.parse(this.installThemeCode);
theme = JSON5.parse(code);
} catch (e) {
alert('%i18n:@invalid-theme%');
return;
@ -219,6 +223,29 @@ export default Vue.extend({
alert('%i18n:@uninstalled%'.replace('{}', theme.name));
},
import_() {
(this.$refs.file as any).click();
}
export_() {
const blob = new Blob([this.selectedInstalledThemeCode], {
type: 'application/json5'
});
this.$refs.export.$el.href = window.URL.createObjectURL(blob);
},
onUpdateImportFile() {
const f = (this.$refs.file as any).files[0];
const reader = new FileReader();
reader.onload = e => {
this.install(e.target.result);
};
reader.readAsText(f);
},
preview() {
applyTheme(this.myTheme, false);
},
@ -239,10 +266,14 @@ export default Vue.extend({
<style lang="stylus" scoped>
.nicnklzforebnpfgasiypmpdaaglujqm
> details
margin-top 16px
padding-top 16px
border-top solid 1px var(--faceDivider)
> summary
padding 16px 0
> *:last-child
margin-bottom 16px
> .creator
> div
padding 16px 0

View File

@ -1,7 +1,7 @@
<template>
<button class="dmtdnykelhudezerjlfpbhgovrgnqqgr" :class="[styl, { inline, primary }]" :type="type" @click="$emit('click')">
<component class="dmtdnykelhudezerjlfpbhgovrgnqqgr" :is="link ? 'a' : 'button'" :class="[styl, { inline, primary }]" :type="type" @click="$emit('click')">
<slot></slot>
</button>
</component>
</template>
<script lang="ts">
@ -21,6 +21,11 @@ export default Vue.extend({
type: Boolean,
required: false,
default: false
},
link: {
type: Boolean,
required: false,
default: false
}
},
data() {
@ -35,15 +40,20 @@ export default Vue.extend({
.dmtdnykelhudezerjlfpbhgovrgnqqgr
display block
width 100%
min-height 40px
margin 0
padding 0
padding 8px
text-align center
font-weight normal
font-size 16px
border none
border-radius 6px
outline none
box-shadow none
text-decoration none
user-select none
*
pointer-events none
&:focus
&:after