整理国际化配置

完善论文上次页面
master
pan 5 years ago
parent af5c28a3aa
commit 8619804a87
  1. 10
      components/account/login.vue
  2. 35
      components/account/register.vue
  3. 9
      components/center/collect.vue
  4. 9
      components/center/myupload.vue
  5. 9
      components/center/security.vue
  6. 45
      components/lang.vue
  7. 35
      components/register.vue
  8. 6
      layouts/error.vue
  9. 52
      layouts/mainmenu.vue
  10. 86
      nuxt.config.js
  11. 3
      package.json
  12. 38
      pages/account/index.vue
  13. 24
      pages/index/center.vue
  14. 129
      pages/index/upload.vue
  15. 6
      plugins/global.js
  16. 4
      plugins/vue-cookies.js
  17. 5
      yarn.lock

@ -1,13 +1,13 @@
<template> <template>
<el-form ref="form" :model="form" label-width="80px"> <el-form ref="form" :model="form" label-width="80px">
<el-form-item label="帐号"> <el-form-item :label="$t('account.form.user')">
<el-input v-model="form.user" placeholder="请输入帐号"></el-input> <el-input v-model="form.user" :placeholder="$t('account.form.input_user',{user:$t('account.form.user')})"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="密码"> <el-form-item :label="$t('account.form.password')">
<el-input v-model="form.password" type="password" placeholder="请输入密码"></el-input> <el-input v-model="form.password" type="password" :placeholder="$t('account.form.input_password',{password:$t('account.form.password')})"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onLogin(form.user,form.password)">登录</el-button> <el-button type="primary" @click="onLogin(form.user,form.password)">{{$t('account.login')}}</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</template> </template>

@ -0,0 +1,35 @@
<template>
<el-form ref="form" :model="form" label-width="80px">
<el-form-item :label="$t('account.form.user')">
<el-input v-model="form.user" :placeholder="$t('account.form.input_user',{user:$t('account.form.user')})"></el-input>
</el-form-item>
<el-form-item :label="$t('account.form.password')">
<el-input v-model="form.password" type="password" :placeholder="$t('account.form.input_password',{password:$t('account.form.password')})"></el-input>
</el-form-item>
<el-form-item :label="$t('account.form.confirmPwd')">
<el-input v-model="form.confirmPwd" type="password" :placeholder="$t('account.form.input_password',{password:$t('account.form.password')})"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onRegister(form.user,form.password)">{{$t('account.register')}}</el-button>
</el-form-item>
</el-form>
</template>
<script lang="ts">
export default {
name: 'register',
data(){
return {
form:{
user:'',
password:'',
confirmPwd:''
}
}
},
props:{
onRegister:Function
}
}
</script>

@ -0,0 +1,9 @@
<template>
<h1>我的收藏</h1>
</template>
<script>
export default {
name: 'collect'
}
</script>

@ -0,0 +1,9 @@
<template>
<h1>我的上传</h1>
</template>
<script>
export default {
name: 'myupload'
}
</script>

@ -0,0 +1,9 @@
<template>
<h1>帐号安全</h1>
</template>
<script>
export default {
name: 'security'
}
</script>

@ -0,0 +1,45 @@
<template>
<el-row type="flex" justify="end">
<el-col>
<span class="title">{{ $t('app_name') }}</span>
</el-col>
<el-col>
<el-dropdown class="ml4">
<span class="el-dropdown-link">
{{$t('choose_lang')}}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item in ['zhCN', 'en']" :key="item">
<nuxt-link v-if="$i18n.locale !== item" :to="switchLocalePath(item)">
{{$t(item)}}
</nuxt-link>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-col>
<el-col v-if="$cookies.isKey(GLOBAL.user_key)">
<el-button @click="logout">{{$t('logout')}}</el-button>
</el-col>
</el-row>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'lang',
methods:{
logout:function() {
this.$cookies.remove(this.GLOBAL.user_key)
this.$router.push(this.localePath('/account'))
}
}
})
</script>
<style>
.title {
font-size: 25px;
font-weight: bold;
}
</style>

@ -1,35 +0,0 @@
<template>
<el-form ref="form" :model="form" label-width="80px">
<el-form-item :label="$t('user')">
<el-input v-model="form.user" placeholder="请输入帐号"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="form.password" type="password" placeholder="请输入密码"></el-input>
</el-form-item>
<el-form-item label="确认密码">
<el-input v-model="form.confirmPwd" type="password" placeholder="请确认密码"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onRegister(form.user,form.password)">注册</el-button>
</el-form-item>
</el-form>
</template>
<script lang="ts">
export default {
name: 'register',
data(){
return {
form:{
user:'',
password:'',
confirmPwd:''
}
}
},
props:{
onRegister:Function
}
}
</script>

@ -1,8 +1,8 @@
<template> <template>
<div class="container"> <div class="container">
<h1 v-if="error.statusCode === 404">页面不存在</h1> <h1 v-if="error.statusCode === 404">{{$t('error_404')}}</h1>
<h1 v-else>应用发生错误异常</h1> <h1 v-else-if="error.statusCode === 500">{{$t('error_500')}}</h1>
<nuxt-link to="/"> </nuxt-link> <nuxt-link :to="localePath('/')">{{$t('unknown_error')}}</nuxt-link>
</div> </div>
</template> </template>

@ -1,16 +1,16 @@
<template> <template>
<el-container> <el-container v-if="$cookies.isKey(GLOBAL.user_key)">
<el-aside> <el-aside>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-image src="/circle-star.svg"> <el-image src="/circle-star.svg">
</el-image> </el-image>
<h1 class="el-dialog--center"></h1> <h1 class="el-dialog--center"></h1>
<el-menu @select="selectItem" :router="true" default-active="/document"> <el-menu @select="selectItem" :router="true" :default-active="$route.path">
<el-menu-item :index="localePath('/'+item,$i18n.locale)" v-for="item in menus" :key="item"> <el-menu-item :index="localePath('/'+item,$i18n.locale)" v-for="item in menus" :key="item">
<template slot="title"> <template slot="title">
<i class="el-icon-location"></i> <i class="el-icon-location"></i>
<span>{{$t("menus."+item)}}</span> <span>{{$t('menus.'+item)}}</span>
</template> </template>
</el-menu-item> </el-menu-item>
</el-menu> </el-menu>
@ -19,35 +19,22 @@
</el-aside> </el-aside>
<el-container> <el-container>
<el-header> <el-header>
<el-row type="flex" justify="end"> <lang/>
<el-col>
<span class="title">{{ $t('app_name') }}</span>
</el-col>
<el-col>
<el-dropdown class="ml4">
<span class="el-dropdown-link">
{{$t('choose_lang')}}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item in ['zhCN', 'en']" :key="item">
<nuxt-link v-if="$i18n.locale !== item" :to="switchLocalePath(item)">
{{$t(item)}}
</nuxt-link>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-col>
</el-row>
</el-header> </el-header>
<el-main><nuxt/></el-main> <el-main>
<nuxt/>
</el-main>
</el-container> </el-container>
</el-container> </el-container>
</template> </template>
<script lang="ts"> <script lang="ts">
export default { import Vue from 'vue'
import Lang from '~/components/lang.vue'
export default Vue.extend({
name: 'mainmenu', name: 'mainmenu',
components: { Lang },
methods: { methods: {
selectItem(index: string, indexPath: Array<String>) { selectItem(index: string, indexPath: Array<String>) {
console.info(index, indexPath) console.info(index, indexPath)
@ -57,12 +44,15 @@
return { return {
menus: ['document', 'note', 'center', 'upload'] menus: ['document', 'note', 'center', 'upload']
} }
},
mounted() {
if(this.$cookies.isKey(this.GLOBAL.user_key)){
this.$router.push(this.localePath('/document'))
}else{
this.$router.push(this.localePath('/account'))
} }
} }
</script>
<style>
.title{
font-size: 25px;
font-weight: bold;
} }
</style> )
</script>

@ -37,7 +37,7 @@ export default {
** Plugins to load before mounting the App ** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins ** https://nuxtjs.org/guide/plugins
*/ */
plugins: ['@/plugins/element-ui'], plugins: ['@/plugins/element-ui','@/plugins/vue-cookies','@/plugins/global'],
/* /*
** Auto import components ** Auto import components
** See https://nuxtjs.org/api/configuration-components ** See https://nuxtjs.org/api/configuration-components
@ -96,7 +96,57 @@ export default {
}, },
zhCN: '简体中文', zhCN: '简体中文',
en: '英文', en: '英文',
user: '帐号' user: '帐号',
upload:{
form:{
type:'论文类型',
input_type:'请输入{type}',
author:'论文作者',
input_author:'请输入{author}',
profession:'学科专业',
input_profession:'请输入{profession}',
school:'学校',
input_school:'请输入{school}',
year:'学位年度',
input_year:'请输入{year}',
summary:'摘要',
input_summary:'请输入{summary}',
tag:'论文标签',
content:'论文',
upload:'点击上传',
upload_tip:'只能上传txt',
remove:'确定移除{file}'
}
},
account:{
login:'登录',
register:'注册',
form:{
user:'帐号',
input_user:'请输入{user}',
password:'密码',
input_password:'请输入{password}',
confirmPwd:'确认密码',
input_confirmPwd:'请确认{confirmPwd}',
valid_account:'帐号密码正确'
}
},
logout:'注销登录',
error_404:'页面不存在',
error_500:'发生严重异常,请联系管理员',
unknown_error:'未知错误',
center:{
collect:{
name:'我的收藏'
},
myupload:{
name:'我的上传'
},
security:{
name:'帐号安全'
}
},
submit:'提交'
}, },
en: { en: {
app_name:'cloudnote', app_name:'cloudnote',
@ -109,7 +159,37 @@ export default {
}, },
zhCN: 'Simplified Chinese', zhCN: 'Simplified Chinese',
en: 'english', en: 'english',
user: '帐号' user: '帐号',
upload:{
form:{
type:'论文类型',
input_type:'请输入{type}',
author:'论文作者',
input_author:'请输入{author}',
profession:'学科专业',
input_profession:'请输入{profession}',
school:'学校',
input_school:'请输入{school}',
year:'学位年度',
input_year:'请输入{year}',
summary:'摘要',
input_summary:'请输入{summary}',
tag:'论文标签',
content:'论文'
}
},
account:{
login:'登录',
register:'注册',
form:{
user:'帐号',
input_user:'请输入{user}',
password:'密码',
input_password:'请输入{password}',
confirmPwd:'确认密码',
input_confirmPwd:'请确认{confirmPwd}'
}
}
} }
} }
} }

@ -28,7 +28,8 @@
"@nuxtjs/pwa": "^3.0.0-beta.20", "@nuxtjs/pwa": "^3.0.0-beta.20",
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
"nuxt": "^2.13.0", "nuxt": "^2.13.0",
"nuxt-i18n": "^6.13.1" "nuxt-i18n": "^6.13.1",
"vue-cookies": "^1.7.2"
}, },
"devDependencies": { "devDependencies": {
"@nuxt/typescript-build": "^1.0.3", "@nuxt/typescript-build": "^1.0.3",

@ -1,38 +1,54 @@
<template> <template>
<el-container>
<el-header>
<lang/>
</el-header>
<el-main>
<el-row type="flex" justify="center">
<div class="container"> <div class="container">
<el-tabs v-model="activeName" type="card"> <el-tabs v-model="activeName" type="card">
<el-tab-pane label="登录" name="login"> <el-tab-pane :label="$t('account.login')" name="login">
<login :on-login="onLogin"/> <login :on-login="onLogin"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="注册" name="register"> <el-tab-pane :label="$t('account.register')" name="register">
<register :on-register="onRegister"/> <register :on-register="onRegister"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</el-row>
</el-main>
</el-container>
</template> </template>
<script> <script lang="ts">
import Login from '../../components/login' import Login from '~/components/account/login.vue'
import Register from '../../components/register' import Register from '~/components/account/register.vue'
import Lang from '~/components/lang.vue'
import Vue from 'vue'
export default { export default Vue.extend({
name: 'index', name: 'index',
components: { Register, Login }, components: { Lang, Register, Login },
data() { data() {
return { return {
activeName: 'login' activeName: 'login'
}; };
}, },
methods: { methods: {
onLogin(user,password){ onLogin(user:string,password:string){
console.info(user,password) console.info(user,password)
let that=this
let c:string=this.$t('account.form.valid_account').toString()
this.$message({message:c,duration:1000,onClose:function(){
that.$cookies.set(that.GLOBAL.user_key,user)
that.$router.push(that.localePath('/document'))
}})
}, },
onRegister(user,password){ onRegister(user:string,password:string){
console.info(user,password) console.info(user,password)
} }
} }
} })
</script> </script>
<style> <style>
.container { .container {

@ -1,10 +1,30 @@
<template> <template>
<h1>个人中心</h1> <el-tabs v-model="activeName" type="card">
<el-tab-pane :label="$t('center.security.name')" name="Security">
<security/>
</el-tab-pane>
<el-tab-pane :label="$t('center.collect.name')" name="Collect">
<collect/>
</el-tab-pane>
<el-tab-pane :label="$t('center.myupload.name')" name="Upload">
<myupload/>
</el-tab-pane>
</el-tabs>
</template> </template>
<script lang="ts"> <script lang="ts">
import Security from '~/components/center/security.vue'
import Collect from '~/components/center/collect.vue'
import Myupload from '~/components/center/myupload.vue'
export default { export default {
name: 'center' name: 'center',
components: { Myupload, Collect, Security },
data(){
return {
activeName:'Security'
}
}
} }
</script> </script>

@ -1,24 +1,83 @@
<template> <template>
<el-form ref="form" :model="form" label-width="80px"> <el-form ref="form" :model="form" label-width="80px">
<el-form-item label="论文类型"> <el-form-item :label="$t('upload.form.type')">
<el-select v-model="form.type"> <el-select v-model="form.type" :placeholder="$t('upload.form.input_type',{type:$t('upload.form.type')})">
<el-option v-for="item in options" :key="item.value" :value="item.value" placeholder="请输入论文类型">{{item.label}}</el-option> <el-option v-for="item in options" :key="item.value" :value="item.value">{{item.label}}</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="论文作者"> <el-form-item :label="$t('upload.form.author')">
<el-col :span="4"> <el-col :span="4">
<el-input v-model="form.author" placeholder="请输入论文作者"></el-input> <el-input v-model="form.author"
:placeholder="$t('upload.form.input_author',{author:$t('upload.form.author')})"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="学科专业"> <el-form-item :label="$t('upload.form.profession')">
<el-col :span="4"> <el-col :span="4">
<el-input v-model="form.profession" placeholder="请输入学科专业"></el-input> <el-input v-model="form.profession"
:placeholder="$t('upload.form.input_profession',{profession:$t('upload.form.profession')})"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item :label="$t('upload.form.school')">
<el-col :span="4">
<el-input v-model="form.school"
:placeholder="$t('upload.form.input_school',{school:$t('upload.form.school')})"></el-input>
</el-col>
</el-form-item>
<el-form-item :label="$t('upload.form.year')">
<el-select v-model="form.year" :placeholder="$t('upload.form.input_year',{year:$t('upload.form.year')})">
<el-option v-for="n in 10" :key="n" :value="2019-n">{{2019-n}}</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('upload.form.summary')">
<el-col :span="4">
<el-input v-model="form.summary" type="textarea"
:placeholder="$t('upload.form.input_summary',{summary:$t('upload.form.summary')})"></el-input>
</el-col>
</el-form-item>
<el-form-item :label="$t('upload.form.tag')">
<el-tag
:key="tag"
v-for="tag in form.tag.dynamicTags"
closable
:disable-transitions="false"
@close="handleClose(tag)">
{{tag}}
</el-tag>
<el-col :span="4" v-if="form.tag.inputVisible">
<el-input
class="input-new-tag"
v-model="form.tag.inputValue"
ref="saveTagInput"
size="small"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
</el-col>
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ {{$t('upload.form.tag')}}</el-button>
</el-form-item>
<el-form-item :label="$t('upload.form.content')">
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:file-list="form.fileList"
accept=".txt">
<el-button size="small" type="primary">{{$t('upload.form.upload')}}</el-button>
<div slot="tip" class="el-upload__tip">{{$t('upload.form.upload_tip')}}</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">{{$t('submit')}}</el-button>
</el-form-item>
</el-form> </el-form>
</template> </template>
<script lang="ts"> <script>
export default { export default {
name: 'upload', name: 'upload',
data() { data() {
@ -26,16 +85,64 @@
form: { form: {
type: '', type: '',
author: '', author: '',
profession:'' profession: '',
school: '',
year: '',
summary: '',
tag: {
dynamicTags: [],
inputVisible: false,
inputValue: ''
},
fileList: []
}, },
options: [{ options: [{
value: '选项1', value: '硕士论文',
label: '硕士论文' label: '硕士论文'
}, { }, {
value: '选项2', value: '博士论文',
label: '博士论文' label: '博士论文'
}] }]
} }
},
methods: {
//
handleClose(tag) {
this.form.tag.dynamicTags.splice(this.form.tag.dynamicTags.indexOf(tag), 1)
},
//
showInput() {
this.form.tag.inputVisible = true
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus()
})
},
//
handleInputConfirm() {
let inputValue = this.form.tag.inputValue
if (inputValue) {
this.form.tag.dynamicTags.push(inputValue)
}
console.info(this.form.tag.dynamicTags)
this.form.tag.inputVisible = false
this.form.tag.inputValue = ''
},
//
handleRemove(file, fileList) {
console.log(file, fileList)
},
//
handlePreview(file) {
console.log(file)
},
//
beforeRemove(file, fileList) {
return this.$confirm($t('upload.form.remove',{file:file.name}))
},
//
onSubmit(){
}
} }
} }
</script> </script>

@ -0,0 +1,6 @@
import Vue from 'vue'
Vue.prototype.GLOBAL ={
//用户cookie
user_key:'user'
}

@ -0,0 +1,4 @@
import Vue from 'vue'
import VueCookie from 'vue-cookies'
Vue.use(VueCookie)

@ -10386,6 +10386,11 @@ vue-client-only@^2.0.0:
resolved "https://registry.npm.taobao.org/vue-client-only/download/vue-client-only-2.0.0.tgz#ddad8d675ee02c761a14229f0e440e219de1da1c" resolved "https://registry.npm.taobao.org/vue-client-only/download/vue-client-only-2.0.0.tgz#ddad8d675ee02c761a14229f0e440e219de1da1c"
integrity sha1-3a2NZ17gLHYaFCKfDkQOIZ3h2hw= integrity sha1-3a2NZ17gLHYaFCKfDkQOIZ3h2hw=
vue-cookies@^1.7.2:
version "1.7.2"
resolved "https://registry.npm.taobao.org/vue-cookies/download/vue-cookies-1.7.2.tgz#805bd307f7015c2325cae1326730d7f914b14dcf"
integrity sha1-gFvTB/cBXCMlyuEyZzDX+RSxTc8=
vue-eslint-parser@^7.0.0: vue-eslint-parser@^7.0.0:
version "7.1.0" version "7.1.0"
resolved "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.1.0.tgz?cache=0&sync_timestamp=1589566521118&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-eslint-parser%2Fdownload%2Fvue-eslint-parser-7.1.0.tgz#9cdbcc823e656b087507a1911732b867ac101e83" resolved "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.1.0.tgz?cache=0&sync_timestamp=1589566521118&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-eslint-parser%2Fdownload%2Fvue-eslint-parser-7.1.0.tgz#9cdbcc823e656b087507a1911732b867ac101e83"

Loading…
Cancel
Save