fix: 修改语言切换

This commit is contained in:
MTrun
2021-12-22 15:31:20 +08:00
parent 5b98d5703f
commit a02877e38f
16 changed files with 151 additions and 140 deletions
+1 -2
View File
@@ -114,7 +114,6 @@
import { reactive, ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useMessage } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { requireUrl } from '@/utils'
import { routerTurnByName } from '@/utils'
import shuffle from 'lodash/shuffle'
@@ -142,7 +141,7 @@ const autoLogin = ref(true)
const show = ref(false)
const showBg = ref(false)
const designStore = useDesignStore()
const { t } = useI18n()
const t = window['$t']
onMounted(() => {
setTimeout(() => {
@@ -12,7 +12,7 @@
/>
</div>
<!-- 中间 -->
<div class="list-content-img" @click="resizeHandle">
<div class="list-content-img" @click="resizeHandle">
<n-image
object-fit="contain"
height="200"
@@ -38,7 +38,11 @@
dot
:color="cardData.release ? '#34c749' : '#fcbc40'"
/>
{{ cardData.release ? '已发布' : '未发布' }}
{{
cardData.release
? $t('project.release')
: $t('project.unreleased')
}}
</n-text>
<template v-for="item in fnBtnList" :key="item.key">
@@ -66,7 +70,7 @@
</template>
</n-button>
</template>
<span> {{ item.label }}</span>
<span> {{ item.label }} </span>
</n-tooltip>
</template>
</n-space>
@@ -78,11 +82,13 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { reactive, h } from 'vue'
import { renderIcon, requireUrl, requireFallbackImg } from '@/utils'
import { icon } from '@/plugins'
import { AppleControlBtn } from '@/components/AppleControlBtn'
import { useMessage, useDialog } from 'naive-ui'
import { NText } from 'naive-ui'
const t = window['$t']
const {
EllipsisHorizontalCircleSharpIcon,
@@ -95,41 +101,40 @@ const {
SendIcon
} = icon.ionicons5
const dialog = useDialog()
const message = useMessage()
const emit = defineEmits(['delete', 'resize', 'edit'])
const props = defineProps({
cardData: Object
})
const fnBtnList = [
const renderNText = (set = {}) => {
return () => h(NText, set, { default: () => h('312321') })
}
const fnBtnList = reactive([
{
label: '编辑',
label: t('global.r_edit'),
key: 'edit',
icon: renderIcon(HammerIcon)
},
{
lable: '更多',
lable: t('global.r_more'),
key: 'select',
icon: renderIcon(EllipsisHorizontalCircleSharpIcon)
}
]
])
const selectOptions = [
const selectOptions = reactive([
{
label: '预览',
label: t('global.r_preview'),
key: 'preview',
icon: renderIcon(ApertureSharpIcon)
},
{
label: '复制',
label: t('global.r_copy'),
key: 'copy',
icon: renderIcon(CopyIcon)
},
{
label: '重命名',
label: t('global.r_rename'),
key: 'rename',
icon: renderIcon(PencilIcon)
},
@@ -138,12 +143,14 @@ const selectOptions = [
key: 'd1'
},
{
label: props.cardData?.release ? '取消发布' : '发布',
label: props.cardData?.release
? t('global.r_unpublish')
: t('global.r_publish'),
key: 'send',
icon: renderIcon(SendIcon)
},
{
label: '下载',
label: t('global.r_download'),
key: 'download',
icon: renderIcon(DownloadIcon)
},
@@ -152,11 +159,11 @@ const selectOptions = [
key: 'd2'
},
{
label: '删除',
label: t('global.r_delete'),
key: 'delete',
icon: renderIcon(TrashIcon)
}
]
])
const handleSelect = (key: string) => {
switch (key) {
@@ -36,7 +36,7 @@
<template #action>
<n-space class="list-footer" justify="space-between">
<n-text depth="3">
最后编辑于
{{$t('project.last_edit')}}
<n-time :time="new Date()" format="yyyy-MM-dd hh:mm" />
</n-text>
<!-- 工具 -->
@@ -47,7 +47,7 @@
dot
:color="cardData?.release ? '#34c749' : '#fcbc40'"
/>
{{ cardData?.release ? '已发布' : '未发布' }}
{{ cardData?.release ? $t('project.release') : $t('project.unreleased') }}
</n-text>
<template v-for="item in fnBtnList" :key="item.key">
@@ -71,14 +71,17 @@
</template>
<script setup lang="ts">
import { watchEffect } from 'vue'
import { watchEffect, reactive } from 'vue'
import { renderIcon, requireUrl, requireFallbackImg } from '@/utils'
import { icon } from '@/plugins'
import { AppleControlBtn } from '@/components/AppleControlBtn'
const { HammerIcon } = icon.ionicons5
const emit = defineEmits(['close'])
const t = window['$t']
const props = defineProps({
show: Boolean,
cardData: Object
@@ -91,13 +94,13 @@ watchEffect(() => {
}
})
const fnBtnList = [
const fnBtnList = reactive([
{
label: '编辑',
label: t('global.r_edit'),
key: 'edit',
icon: renderIcon(HammerIcon)
}
]
])
// 关闭对话框
const closeHandle = () => {
@@ -3,7 +3,7 @@
<n-space size="large">
<n-card class="card-box" hoverable>
<template #header>
<n-text class="card-box-tite">从哪里出发好呢</n-text>
<n-text class="card-box-tite">{{ $t('project.create_tip') }}</n-text>
</template>
<template #header-extra>
<n-text @click="closeHandle">
@@ -36,32 +36,33 @@
</template>
<script lang="ts" setup>
import { watch, ref } from 'vue'
import { watch, reactive } from 'vue'
import { icon } from '@/plugins'
import { PageEnum, ChartEnum } from '@/enums/pageEnum'
import { routerTurnByName } from '@/utils'
const { FishIcon, LaptopOutlineIcon, BeerIcon, CloseIcon } = icon.ionicons5
const t = window['$t']
const emit = defineEmits(['close'])
const props = defineProps({
show: Boolean
})
const typeList = ref([
const typeList = reactive([
{
title: '新项目',
title: t('project.new_project'),
key: ChartEnum.CHART_HOME_NAME,
icon: FishIcon,
disabled: false
},
{
title: '我的模板',
title: t('project.my_templete'),
key: PageEnum.BASE_HOME_TEMPLATE_NAME,
icon: LaptopOutlineIcon,
disabled: true
},
{
title: '市场模板',
title: t('project.template_market'),
key: PageEnum.BASE_HOME_TEMPLATE_MARKET_NAME,
icon: BeerIcon,
disabled: true
@@ -87,13 +88,15 @@ const btnHandle = (key: string) => {
}
</script>
<style lang="scss" scoped>
$cardWidth: 570px;
@include go('create-modal') {
position: fixed;
top: 200px;
left: 50%;
transform: translateX(-50%);
.card-box {
width: 500px;
width: $cardWidth;
cursor: pointer;
border: 1px solid rgba(0, 0, 0, 0);
@extend .go-transition;
@@ -12,7 +12,7 @@
</n-button>
</template>
<span>
新建
{{ $t('project.create_btn') }}
</span>
</n-tooltip>
<n-button v-else ghost type="primary" size="large">
@@ -23,7 +23,7 @@
</n-icon>
</template>
<span>
新建
{{ $t('project.create_btn') }}
</span>
</n-button>
</div>
@@ -13,19 +13,22 @@ export const renderMenuLabel = (option: MenuOption | MenuGroupOption) => {
export const expandedKeys = () => ['all-project']
export const menuOptionsInit = () => {
const t = window['$t']
return reactive([
{
key: 'divider-1',
type: 'divider'
},
{
label: '项目',
label: t('project.project'),
key: 'all-project',
icon: renderIcon(GridIcon),
children: [
{
type: 'group',
label: '我的',
label: t('project.my'),
key: 'my-project',
children: [
{
@@ -37,7 +40,7 @@ export const menuOptionsInit = () => {
name: PageEnum.BASE_HOME_ITEMS_NAME
}
},
{ default: () => '全部项目' }
{ default: () => t('project.all_project') }
),
key: PageEnum.BASE_HOME_ITEMS_NAME,
icon: renderIcon(DesktopIcon)
@@ -51,7 +54,7 @@ export const menuOptionsInit = () => {
name: PageEnum.BASE_HOME_TEMPLATE_NAME
}
},
{ default: () => '我的物料' }
{ default: () => t('project.my_templete') }
),
key: PageEnum.BASE_HOME_TEMPLATE_NAME,
icon: renderIcon(LaptopOutlineIcon)
@@ -74,7 +77,7 @@ export const menuOptionsInit = () => {
name: PageEnum.BASE_HOME_TEMPLATE_MARKET_NAME
}
},
{ default: () => '物料市场' }
{ default: () => t('project.template_market') }
),
key: PageEnum.BASE_HOME_TEMPLATE_MARKET_NAME,
icon: renderIcon(BeerIcon)