diff --git a/src/assets/scripts/config.js b/src/assets/scripts/config.js
index e8319eb..612f27c 100644
--- a/src/assets/scripts/config.js
+++ b/src/assets/scripts/config.js
@@ -88,6 +88,33 @@ export default {
desc: `dark`,
},
],
+ legendOption: [
+ {
+ label: `title 优先`,
+ value: `title-alt`,
+ desc: ``,
+ },
+ {
+ label: `alt 优先`,
+ value: `alt-title`,
+ desc: ``,
+ },
+ {
+ label: `只显示 title`,
+ value: `title`,
+ desc: ``,
+ },
+ {
+ label: `只显示 alt`,
+ value: `alt`,
+ desc: ``,
+ },
+ {
+ label: `不显示`,
+ value: `none`,
+ desc: ``,
+ },
+ ],
form: {
rows: 1,
cols: 1,
diff --git a/src/assets/scripts/renderers/wx-renderer.js b/src/assets/scripts/renderers/wx-renderer.js
index 8fe8c42..20fd2ce 100644
--- a/src/assets/scripts/renderers/wx-renderer.js
+++ b/src/assets/scripts/renderers/wx-renderer.js
@@ -175,8 +175,22 @@ class WxRenderer {
return `${s}`;
};
-
- const subText = createSubText(title || text);
+ const transform = (title, alt) => {
+ const legend = localStorage.getItem("legend");
+ switch (legend) {
+ case "alt":
+ return alt;
+ case "title":
+ return title;
+ case "alt-title":
+ return alt || title;
+ case "title-alt":
+ return title || alt;
+ default:
+ return "";
+ }
+ };
+ const subText = createSubText(transform(title, text));
const figureStyles = getStyles("figure");
const imgStyles = getStyles("image");
return ``;
diff --git a/src/components/CodemirrorEditor/EditorHeader/index.vue b/src/components/CodemirrorEditor/EditorHeader/index.vue
index 937792f..9335696 100644
--- a/src/components/CodemirrorEditor/EditorHeader/index.vue
+++ b/src/components/CodemirrorEditor/EditorHeader/index.vue
@@ -110,6 +110,14 @@
:charge="codeThemeChanged"
>
+
+
+
state.currentSize,
currentColor: (state) => state.currentColor,
codeTheme: (state) => state.codeTheme,
+ legend: (state) => state.legend,
nightMode: (state) => state.nightMode,
currentCiteStatus: (state) => state.citeStatus,
currentIsMacCodeBlock: (state) => state.isMacCodeBlock,
@@ -332,6 +342,11 @@ export default {
this.selectCodeTheme = theme
this.$emit(`refresh`)
},
+ legendChanged(legend) {
+ this.setCurrentLegend(legend)
+ this.selectLegend = legend
+ this.$emit(`refresh`)
+ },
statusChanged() {
this.citeStatus = !this.citeStatus
this.setCiteStatus(this.citeStatus)
@@ -420,6 +435,7 @@ export default {
this.colorChanged(this.config.colorOption[0].value)
this.sizeChanged(this.config.sizeOption[2].value)
this.codeThemeChanged(this.config.codeThemeOption[2].value)
+ this.legendChanged(this.config.legendOption[3].value)
this.$emit(`cssChanged`)
this.selectFont = this.currentFont
this.selectSize = this.currentSize
@@ -441,6 +457,7 @@ export default {
`setCurrentSize`,
`setCssEditorValue`,
`setCurrentCodeTheme`,
+ `setCurrentLegend`,
`setWxRendererOptions`,
`setIsMacCodeBlock`,
`setIsEditOnLeft`,
@@ -451,6 +468,7 @@ export default {
this.selectSize = this.currentSize
this.selectColor = this.currentColor
this.selectCodeTheme = this.codeTheme
+ this.selectLegend = this.legend
this.citeStatus = this.currentCiteStatus
this.isMacCodeBlock = this.currentIsMacCodeBlock
this.isEditOnLeft = this.currentIsEditOnLeft
diff --git a/src/stores/index.js b/src/stores/index.js
index 89c3d90..37e8ff3 100644
--- a/src/stores/index.js
+++ b/src/stores/index.js
@@ -25,6 +25,7 @@ export const useStore = defineStore(`store`, {
citeStatus: false,
nightMode: false,
codeTheme: config.codeThemeOption[2].value,
+ legend: config.legendOption[3].value,
isMacCodeBlock: true,
isEditOnLeft: true,
}),
@@ -58,6 +59,10 @@ export const useStore = defineStore(`store`, {
this.codeTheme = data
localStorage.setItem(`codeTheme`, data)
},
+ setCurrentLegend(data) {
+ this.legend = data
+ localStorage.setItem(`legend`, data)
+ },
setIsMacCodeBlock(data) {
this.isMacCodeBlock = data
localStorage.setItem(`isMacCodeBlock`, data)
@@ -79,6 +84,8 @@ export const useStore = defineStore(`store`, {
localStorage.getItem(`size`) || config.sizeOption[2].value
this.codeTheme =
localStorage.getItem(`codeTheme`) || config.codeThemeOption[2].value
+ this.legend =
+ localStorage.getItem(`legend`) || config.legendOption[3].value
this.citeStatus = localStorage.getItem(`citeStatus`) === `true`
this.nightMode = localStorage.getItem(`nightMode`) === `true`
this.isMacCodeBlock = !(