feat: add warning of user-generated url
diff --git a/src/common/i18n.js b/src/common/i18n.js
index 018f24e..841e79b 100644
--- a/src/common/i18n.js
+++ b/src/common/i18n.js
@@ -45,8 +45,9 @@
share: {
title: 'Share',
- success: 'Sharable URL has been copied to your clipboard'
- }
+ success: 'Sharable URL has been copied to your clipboard',
+ hint: 'Please be aware that this chart is not an official demo of Apache ECharts but is made by user-generated code.'
+ },
},
chartTypes: {
@@ -137,7 +138,8 @@
share: {
title: '分享',
- success: '分享链接已复制到剪贴板'
+ success: '分享链接已复制到剪贴板',
+ hint: '请注意,该图表不是 Apache ECharts 官方示例,而是由用户代码生成的。请注意鉴别其内容。'
}
},
diff --git a/src/editor/Editor.vue b/src/editor/Editor.vue
index a14442e..6797a3f 100644
--- a/src/editor/Editor.vue
+++ b/src/editor/Editor.vue
@@ -251,6 +251,7 @@
loadExampleCode().then((code) => {
// No editor available. Set to runCode directly.
store.runCode = parseSourceCode(code);
+ this.showShareHint();
});
} else {
loadExampleCode().then((code) => {
@@ -259,6 +260,7 @@
if (store.initialCode !== CODE_CHANGED_FLAG) {
store.initialCode = this.initialCode;
}
+ this.showShareHint();
});
window.addEventListener('mousemove', (e) => {
@@ -276,6 +278,17 @@
},
methods: {
+ showShareHint() {
+ if (store.isSharedCode) {
+ this.$message.closeAll();
+ this.$message({
+ type: 'warning',
+ message: this.$t('editor.share.hint'),
+ duration: 5000,
+ showClose: true
+ });
+ }
+ },
toExternalEditor(vendor) {
const previewRef = this.$refs.preview;
if (!previewRef) {
diff --git a/src/editor/Preview.vue b/src/editor/Preview.vue
index ba27a91..2dafe44 100644
--- a/src/editor/Preview.vue
+++ b/src/editor/Preview.vue
@@ -329,6 +329,9 @@
mounted() {
this.run();
+ if (store.isSharedCode) {
+ this.showShareHint();
+ }
this.fetchVersionList();
},
@@ -412,6 +415,16 @@
(store.renderer === 'svg' ? 'svg' : 'png')
);
},
+ showShareHint() {
+ this.$message.closeAll();
+ this.$message({
+ type: 'warning',
+ message: this.$t('editor.share.hint'),
+ customClass: 'toast-shared-url',
+ duration: 5000,
+ showClose: true
+ });
+ },
share() {
const params = {};
if (store.initialCode !== store.sourceCode) {
diff --git a/src/editor/View.vue b/src/editor/View.vue
index a8b1ca1..6b43664 100644
--- a/src/editor/View.vue
+++ b/src/editor/View.vue
@@ -15,6 +15,22 @@
loadExampleCode().then((code) => {
store.runCode = parseSourceCode(code);
});
+
+ this.showShareHint();
+ },
+
+ methods: {
+ showShareHint() {
+ if (store.isSharedCode) {
+ this.$message.closeAll();
+ this.$message({
+ type: 'warning',
+ message: this.$t('editor.share.hint'),
+ duration: 5000,
+ showClose: true
+ });
+ }
+ }
}
};
</script>