修改语言插件

master
lemon橪 2021-10-21 17:50:34 +08:00
parent 18ea8a4366
commit 0d1dbd0350
5 changed files with 80 additions and 55 deletions

View File

@ -197,6 +197,13 @@
<Table stripe :columns="tophotShopsColumns" :data="topHotShopsData"></Table> <Table stripe :columns="tophotShopsColumns" :data="topHotShopsData"></Table>
</div> </div>
<div>
<!-- 测试数据 -->
<Input v-model="test.a" />
{{test}}
<i18nBox :value="test.a" @language="(val)=>{test.languages = val}"></i18nBox>
<!-- 测试数据 -->
</div>
</div> </div>
</template> </template>
@ -205,11 +212,22 @@ import { homeStatistics, hotGoods, hotShops, getNoticePage } from "@/api/index";
import * as API_Goods from "@/api/goods"; import * as API_Goods from "@/api/goods";
import { Chart } from "@antv/g2"; import { Chart } from "@antv/g2";
import * as API_Member from "@/api/member"; import * as API_Member from "@/api/member";
// import i18nBox from '@/views/lili-components/i18n-translate'
export default { export default {
name: "home", name: "home",
// components:{
// i18nBox
// },
data() { data() {
return { return {
tophotShopsColumns: [ // //
test: {
a: "test",
languages:[]
},
//
tophotShopsColumns: [
//
{ {
type: "index", type: "index",
width: 100, width: 100,
@ -275,7 +293,8 @@ export default {
pvChart: "", // pvChart: "", //
orderChart: "", // orderChart: "", //
historyMemberChart: "", // historyMemberChart: "", //
params: { // params: {
//
searchType: "LAST_SEVEN", searchType: "LAST_SEVEN",
}, },
// //
@ -480,10 +499,8 @@ export default {
let data = this.chartList; let data = this.chartList;
data.forEach((item) => { data.forEach((item) => {
item.title = "历史在线人数"; item.title = "历史在线人数";
item.date = item.date.substring(5) item.date = item.date.substring(5);
}); });
this.historyMemberChart.data(data); this.historyMemberChart.data(data);
@ -495,16 +512,14 @@ export default {
this.historyMemberChart this.historyMemberChart
.line() .line()
.position("date*num") .position("date*num")
.color("title",['#ffaa71']) .color("title", ["#ffaa71"])
.shape("smooth") .shape("smooth");
;
this.historyMemberChart this.historyMemberChart
.point() .point()
.position("date*num") .position("date*num")
.color("title",['#ffaa71']) .color("title", ["#ffaa71"])
.shape("circle") .shape("circle");
;
this.historyMemberChart.render(); this.historyMemberChart.render();
}, },
// //

View File

@ -2,48 +2,52 @@
<div> <div>
<Button @click="enable = true">语言设定</Button> <Button @click="enable = true">语言设定</Button>
<Modal v-model="enable" draggable sticky scrollable :mask="false" :title="title"> <Modal v-model="enable" draggable sticky scrollable :mask="false" :title="title">
<div>
<RadioGroup v-model="language">
<Radio :label="item.value || item.label" :key="index" v-for="(item,index) in data">
<span>{{item.title || item.name}}</span>
</Radio>
</RadioGroup>
</div>
<Tabs closable type="card" @on-tab-remove="handleTabRemove" :value="language[0].title">
<TabPane v-for="(item,index) in language" :key="index" :label="item.title" :name="item.title">
<Input v-model="item.___i18n" />
</TabPane>
</Tabs>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import {language} from "./languages";
export default { export default {
/** /**
* data 循环的语言内容格式 [{'title':'test','value':'val'}] * tabs 循环的语言内容格式 [{'title':'test','value':'val'}]
*/ */
props: { props: {
data: { value: {
type: Array, type: null,
default: () => { default: "",
return [];
},
}, },
}, },
watch: { watch: {
/** language: {
* 回调语言内容 handler(val) {
*/ this.$emit("language", { language: [...val], val: this.value });
language(val) { },
if (val) { deep: true,
this.$emit("language", val);
}
}, },
}, },
data() { data() {
return { return {
language: "", // language,
tabVal: "",
enable: false, //modal enable: false, //modal
title: "转换语言", title: "转换语言",
}; };
}, },
methods: {
// tab
handleTabRemove(tab) {
this.language = this.language.filter((item) => {
return item.value != tab;
});
},
},
}; };
</script> </script>

View File

@ -0,0 +1 @@
export const language = [{ title: "中文",value:1 }, { title: "英文" ,value:2}];

View File

@ -2,48 +2,52 @@
<div> <div>
<Button @click="enable = true">语言设定</Button> <Button @click="enable = true">语言设定</Button>
<Modal v-model="enable" draggable sticky scrollable :mask="false" :title="title"> <Modal v-model="enable" draggable sticky scrollable :mask="false" :title="title">
<div>
<RadioGroup v-model="language">
<Radio :label="item.value || item.label" :key="index" v-for="(item,index) in data">
<span>{{item.title || item.name}}</span>
</Radio>
</RadioGroup>
</div>
<Tabs closable type="card" @on-tab-remove="handleTabRemove" :value="language[0].title">
<TabPane v-for="(item,index) in language" :key="index" :label="item.title" :name="item.title">
<Input v-model="item.___i18n" />
</TabPane>
</Tabs>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import {language} from "./languages";
export default { export default {
/** /**
* data 循环的语言内容格式 [{'title':'test','value':'val'}] * tabs 循环的语言内容格式 [{'title':'test','value':'val'}]
*/ */
props: { props: {
data: { value: {
type: Array, type: null,
default: () => { default: "",
return [];
},
}, },
}, },
watch: { watch: {
/** language: {
* 回调语言内容 handler(val) {
*/ this.$emit("language", { language: [...val], val: this.value });
language(val) { },
if (val) { deep: true,
this.$emit("language", val);
}
}, },
}, },
data() { data() {
return { return {
language: "", // language,
tabVal: "",
enable: false, //modal enable: false, //modal
title: "转换语言", title: "转换语言",
}; };
}, },
methods: {
// tab
handleTabRemove(tab) {
this.language = this.language.filter((item) => {
return item.value != tab;
});
},
},
}; };
</script> </script>

View File

@ -0,0 +1 @@
export const language = [{ title: "中文",value:1 }, { title: "英文" ,value:2}];