clay : init

This commit is contained in:
邓洁
2023-04-21 00:14:40 +08:00
commit daff2b9ff8
28 changed files with 14733 additions and 0 deletions

21
src/App.vue Normal file
View File

@@ -0,0 +1,21 @@
<template>
<div id="app">
<div>
123123123
</div>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
}
},
created() {
},
}
</script>
<style>
</style>

93
src/api/index.js Normal file
View File

@@ -0,0 +1,93 @@
/**
* @author: Clay
* @date: 2022/1/14 13:26
* @descriptionindex
* @email: clay@hchyun.com
*/
import request from '@/utils/request'
// 获取统计数据
export function getConfig(configKey) {
return request({
url: '/web/config/'+configKey,
method: 'get',
})
}
// 获取所有导航
export function getNavigation(data) {
return request({
url: '/web/getnavall',
method: 'post',
data:data
})
}
// 获取节点信息(通用接口)
export function getNode(data) {
return request({
url: '/web/node',
method: 'post',
data:data
})
}
export function getNodeNav(data) {
return request({
url: '/web/nodeNav',
method: 'post',
data:data
})
}
// 获取文章列表
export function getArticleList(data) {
return request({
url: '/web/articlelist',
method: 'post',
data:data
})
}
// 获取面包屑
export function crumbs(id) {
return request({
url: '/web/crumbs',
method: 'post',
data:{
id:id
}
})
}
// 获取banner图
export function banner(type) {
return request({
url: '/web/banner',
method: 'post',
data:{
type:type
}
})
}
// 获取文章详情
export function article(id) {
return request({
url: '/web/article',
method: 'post',
data:{
id:id
}
})
}
// 获取文章详情
export function info(id) {
return request({
url: '/web/info',
method: 'post',
data:{
id:id
}
})
}

16
src/i18n/i18n.js Normal file
View File

@@ -0,0 +1,16 @@
//i18n.js
import Vue from 'vue'
import locale from 'element-ui/lib/locale'
import VueI18n from 'vue-i18n'
import messages from './langs'
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: localStorage.lang || 'cn',
messages
})
locale.i18n((key, value) => i18n.t(key, value)) //重点为了实现element插件的多语言切换
export default i18n

55
src/i18n/langs/cn.js Normal file
View File

@@ -0,0 +1,55 @@
//cn.js
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
//{{ $t('message.news_ceter') }}
const cn = {
message: {
'student': '学生',
'staff': '教职工',
'alumni': '校友',
'examine': '考生',
'services_portal': '服务门户',
'switch': 'English',
'home': '学院首页',
'news_ceter': '新闻中心',
'more': '更多',
'research': '科学研究',
'academic': '学术交流',
'party': '党群工作',
'party_education': '党史教育',
'teaching_work': '教学工作',
'data_information': '数据中的信息',
'notice': '通知公告',
'scientific': '科学研究',
'undergraduate_education': '本科教育',
'postgraduate_education': '研究生教育',
'employees': '职工人数',
'number_students': '在校学生人数',
'graduate_tutor': '研究生导师',
'research_team': '科研团队',
'high_level_talents': '省部级以上高层次人才',
'major_projects': '国家级重大重点项目',
'contact_us': '联系我们',
'person': '人',
'pics': '个',
'adress': '犀浦校区地址:中国四川省成都市郫都区犀安路 999 号西南交通大学信息科学与技术学院',
'code': '邮政编码:611756',
'tel': '电话:+86 28 66366709(行政)',
'copyright': '版权所有◎2015西南交通大学信息科学与技术学院. All rights reserved.意见反馈',
'chinese_site': '西南交通大学(中文)',
'english_site': '西南交通大学(ENGLISH)',
'affairs_office': '西南交通大学国际合作与交流处',
'scholarship': '国家留学基金管理委员会',
'foreign': '中华人民共和国外交部',
'education': '中华人民共和国教育部门户网站',
'ieee': '电气和电子工程师协会(IEEE)',
'search': '搜索',
'placeholder': '请输入内容',
},
...zhLocale
}
export default cn

53
src/i18n/langs/en.js Normal file
View File

@@ -0,0 +1,53 @@
//en.js
import enLocale from 'element-ui/lib/locale/lang/en'
const en = {
message: {
'student': 'Student',
'staff': 'Staff',
'alumni': 'Alumni',
'examine': 'Examine',
'services_portal': 'Services Portal',
'switch': '简体中文',
'home': 'Home',
'news_ceter': 'News Center',
'more': 'More',
'research': 'Research',
'academic': 'Academic',
'party': 'Party',
'party_education': 'Party Education',
'teaching_work': 'Teaching work',
'data_information': 'DATA INFORMATION',
'notice': 'Notice',
'scientific': 'Scientific',
'undergraduate_education': 'Undergraduate education',
'postgraduate_education': 'Postgraduate education',
'employees': 'Faculty Members',
'number_students': 'Internal Students',
'graduate_tutor': 'Tutors',
'research_team': 'Scientific Research Team',
'high_level_talents': 'Outstanding Talents',
'major_projects': 'Major projects',
'contact_us': '',
'person': '',
'pics': '',
'adress': '',
'code': '',
'tel': '',
'copyright': 'Copyright © 2014 School of Information Science and Technology, SWJTU. All rights reserved. Feedback',
'chinese_site': 'Southwest Jiaotong University(中文)',
'english_site': 'Southwest Jiaotong University(ENGLISH)',
'affairs_office': 'SWJTU International Affairs Office',
'scholarship': 'China Scholarship Counsil',
'foreign': 'Ministry of Foreign Affairs',
'education': 'Ministry of Education',
'ieee': 'IEEE',
'search': 'search',
'placeholder': 'please input',
},
}
export default en

6
src/i18n/langs/index.js Normal file
View File

@@ -0,0 +1,6 @@
import en from './en'
import cn from './cn'
export default {
en,
cn
}

58
src/main.js Normal file
View File

@@ -0,0 +1,58 @@
import Vue from 'vue'
import Vuex from 'vuex'
import App from './App.vue'
import router from './router'
import i18n from './i18n/i18n'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'element-ui/lib/theme-chalk/display.css';
import en from 'element-ui/lib/locale/lang/en'
import cn from 'element-ui/lib/locale/lang/zh-CN'
//要添加的代码
router.beforeEach((to, from, next) => {
// chrome
document.body.scrollTop = 0
// firefox
document.documentElement.scrollTop = 0
// safari
window.pageYOffset = 0
next()
})
i18n.mergeLocaleMessage('en', en)
i18n.mergeLocaleMessage('zh', cn)
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
isEnglish: false,
menuList :{},
},
mutations: {
increment (state) {
state.count++
}
},
computed:{
setEnglish(isEnglish){
this.store.isEnglish = isEnglish
},
},
getters:{
getEnglish(){
return this.store.isEnglish
}
}
})
new Vue({
i18n,
router,
store: store,
render: h => h(App)
}).$mount('#app')

19
src/router/index.js Normal file
View File

@@ -0,0 +1,19 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
const routes = [
]
const router = new VueRouter({
mode: 'history',
routes
})
export default router

31
src/settings.js Normal file
View File

@@ -0,0 +1,31 @@
module.exports = {
title: 'SIST',
/**
* 是否系统布局配置
*/
showSettings: false,
/**
* 是否显示 tagsView
*/
tagsView: true,
/**
* 是否固定头部
*/
fixedHeader: false,
/**
* 是否显示logo
*/
sidebarLogo: true,
/**
* @type {string | array} 'production' | ['production', 'development']
* @description Need show err logs component.
* The default is only used in the production env
* If you want to also use it in dev, you can pass ['production', 'development']
*/
errorLog: 'production'
}

190
src/utils/ebts.js Normal file
View File

@@ -0,0 +1,190 @@
/**
* 通用js方法封装处理
* Copyright (c) 2021 ebts
*/
const baseURL = process.env.VUE_APP_BASE_API
// 日期格式化
export function parseTime(time, pattern) {
if (arguments.length === 0 || !time) {
return null
}
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
} else if (typeof time === 'string') {
time = time.replace(new RegExp(/-/gm), '/');
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}
// 表单重置
export function resetForm(refName) {
if (this.$refs[refName]) {
this.$refs[refName].resetFields();
}
}
// 添加日期范围
export function addDateRange(params, dateRange) {
var search = params;
search.beginTime = "";
search.endTime = "";
if (null != dateRange && '' != dateRange) {
search.beginTime = dateRange[0];
search.endTime = dateRange[1];
}
return search;
}
// 添加搜索创建时间日期范围
export function addCreateDateRange(params, dateRange) {
var search = params;
let data = {
beginCreateTime: "",
endCreateTime: "",
};
if (null != dateRange && '' != dateRange) {
data.beginCreateTime = dateRange[0];
data.endCreateTime = dateRange[1];
}
search.parameter = JSON.stringify(data)
return search;
}
// 回显数据字典
export function selectDictLabel(datas, value) {
try {
var actions = [];
Object.keys(datas).some((key) => {
if (datas[key].dictValue == ('' + value)) {
actions.push(datas[key].dictLabel);
return true;
}
})
return actions.join('');
}catch (e) {
console.log(e)
return null
}
}
// 回显数据字典
export function selectDictCode(datas, value) {
var actions = [];
Object.keys(datas).some((key) => {
if (datas[key].dictCode == ('' + value)) {
actions.push(datas[key].dictLabel);
return true;
}
})
return actions.join('');
}
// 回显数据字典(字符串数组)
export function selectDictLabels(datas, value, separator) {
var actions = [];
var currentSeparator = undefined === separator ? "," : separator;
var temp = value.split(currentSeparator);
Object.keys(value.split(currentSeparator)).some((val) => {
Object.keys(datas).some((key) => {
if (datas[key].dictValue == ('' + temp[val])) {
actions.push(datas[key].dictLabel + currentSeparator);
}
})
})
return actions.join('').substring(0, actions.join('').length - 1);
}
// 通用下载方法
export function download(fileName) {
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
}
// 字符串格式化(%s )
export function sprintf(str) {
var args = arguments, flag = true, i = 1;
str = str.replace(/%s/g, function () {
var arg = args[i++];
if (typeof arg === 'undefined') {
flag = false;
return '';
}
return arg;
});
return flag ? str : '';
}
// 转换字符串undefined,null等转化为""
export function praseStrEmpty(str) {
if (!str || str == "undefined" || str == "null") {
return "";
}
return str;
}
/**
* 构造树型结构数据
* @param {*} data 数据源
* @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
* @param {*} rootId 根Id 默认 0
*/
export function handleTree(data, id, parentId, children, rootId) {
try {
id = id || 'id'
parentId = parentId || 'parentId'
children = children || 'children'
rootId = rootId || Math.min.apply(Math, data.map(item => {
return item[parentId]
})) || 0
//对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
//循环所有项
const treeData = cloneData.filter(father => {
let branchArr = cloneData.filter(child => {
//返回每一项的子级数组
return father[id] === child[parentId]
});
branchArr.length > 0 ? father.children = branchArr : '';
//返回第一层
return father[parentId] === rootId;
});
return treeData != '' ? treeData : data;
} catch (e) {
console.log(e)
return null;
}
}

6
src/utils/errorCode.js Normal file
View File

@@ -0,0 +1,6 @@
export default {
'401': '认证失败,无法访问系统资源',
'403': '当前操作没有权限',
'404': '访问资源不存在',
'default': '系统未知错误,请反馈给管理员'
}

76
src/utils/request.js Normal file
View File

@@ -0,0 +1,76 @@
import axios from 'axios'
import {Notification, Message} from 'element-ui'
import errorCode from '@/utils/errorCode'
import {setAppLanguage} from "@/utils/sist";
//todo 显示消息处理
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const service = axios.create({
// axios中请求配置有baseURL选项表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API,
// 超时
timeout: 10000
})
解析
// request拦截器
service.interceptors.request.use(config => {
if (config.method == 'post') {
config.data['sitetype'] = 'NEd5n92EMIpyyBslaNqsRgE';
let lang = sessionStorage.getItem("lang");
config.data['lang'] = lang;
}
return config
}, error => {
console.log(error)
Promise.reject(error)
})
// 响应拦截器
service.interceptors.response.use(res => {
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 500) {
//Message({
// message: msg,
// type: 'error'
//})
return Promise.reject(new Error(msg))
} else if (code == 199) {
//Message({
// message: "查询结果为空!",
// type: 'info'
//})
return res.data
} else if (code !== 200) {
Notification.error({
title: msg
})
return Promise.reject('error')
} else {
return res.data
}
},
error => {
console.log('err' + error)
let {message} = error;
if (message === "Network Error") {
message = "后端接口连接异常";
} else if (message.includes("timeout")) {
message = "系统接口请求超时";
} else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
//Message({
// message: message,
// type: 'error',
// duration: 5 * 1000
//})
return Promise.reject(error)
}
)
export default service

190
src/utils/sist.js Normal file
View File

@@ -0,0 +1,190 @@
/**
* @author: Clay
* @date: 2022/1/16 11:13
* @descriptionsist
* @email: clay@hchyun.com
*/
let vm = null
import {info} from "@/api";
export function setThis(that) {
vm = that
}
export function getParentNode(id) {
try {
let menuList = JSON.parse(sessionStorage.getItem("menu"));
for (let menu of menuList) {
for (let child of menu.children) {
if (id == child.encodeId) {
menu.children = []
child.children = []
return {
stair: menu, second: child,
}
}
for (let item of child.children) {
if (id == item.encodeId) {
menu.children = []
child.children = []
item.children = []
return {
stair: menu, second: child, three: item
}
}
}
}
}
return null
} catch (e) {
return null
}
}
export function getNodeMenu(id) {
try {
let menuList = JSON.parse(sessionStorage.getItem("menu"));
for (let menu of menuList) {
for (let child of menu.children) {
for (let item of child.children) {
if (id == item.encodeId) {
return item
}
}
}
}
return null
} catch (e) {
return null
}
}
export function setAppLanguage() {
let lang = sessionStorage.getItem("lang");
if (lang != null) {
vm.$i18n.locale = lang
return
}
var language = window.navigator.userLanguage || window.navigator.language;
if (language == 'zh-CN') {
lang = 'cn'
} else {
lang = 'en'
}
vm.$i18n.locale = lang
sessionStorage.setItem("lang", lang)
}
export function setLanguage() {
let lang = vm.$route.query && vm.$route.query.lang
if (lang != undefined) {
vm.$i18n.locale = lang
sessionStorage.setItem("lang", lang)
}
}
export function toArticle(news, width) {
console.log(width, "width")
info(news.id).then(res => {
let info = null
try {
info = getParentNode(res.data.encodeId)
console.log(info)
} catch (e) {
}
if (info == null) {
return
}
let routeData = null;
if (info.three == null) {
if (width) {
routeData = "/pc/" + info.second.encodeId + "?id=" + news.id + "&type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang");
} else {
routeData = "/mobile/" + info.second.encodeId + "?id=" + news.id + "&type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang");
}
} else {
console.log(info.three, "toArticle,info.three")
if (width) {
routeData = "/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang");
} else {
routeData = "/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang");
}
}
linkTo(routeData)
})
}
function linkTo(routeData) {
let userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
if (userAgent.indexOf("Safari") > -1) {
window.location.href = window.location.origin + routeData
} else {
window.open(routeData.href, "_blank")
}
}
export function lookMoreComment(item, width) {
info(item.id).then(res => {
let info = null
try {
info = getParentNode(res.data.encodeId)
} catch (e) {
}
if (info == null) {
return
}
if (info.three == null) {
if (width) {
vm.$router.push("/pc/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
} else {
vm.$router.push("/mobile/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
}
} else {
if (width) {
vm.$router.push("/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
} else {
vm.$router.push("/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"));
}
}
})
}
export function lookMoreFixedComment(id, width) {
let info = null
try {
info = getParentNode(id)
console.log(info)
} catch (e) {
}
if (info == null) {
return
let routeData = null;
if (info.three == null) {
if (width) {
routeData = "/pc/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang");
} else {
routeData = "/mobile/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang");
}
} else {
if (width) {
routeData = "/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang");
} else {
routeData = "/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang");
}
}
linkTo(routeData)
// window.location.href = window.location.origin + routeData.href
// window.open(window.location.origin + routeData.href, "_blank")
}
}