Skip to content

Commit

Permalink
Merge pull request #167 from newpanjing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
newpanjing committed Oct 17, 2019
2 parents 78f3f61 + 59b3ac1 commit 1aff47b
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 99 deletions.
2 changes: 1 addition & 1 deletion simpleui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def get_version():
return '3.1'
return '3.2'
5 changes: 4 additions & 1 deletion simpleui/static/admin/simpleui-x/css/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion simpleui/static/admin/simpleui-x/css/index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion simpleui/static/admin/simpleui-x/css/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,17 @@ html, body {

.simpleui-table tr {
height: 35px;

&:hover{
th,td{
background-color: inherit!important;
}
}
}

.simpleui-table tr th {
text-align: right;
width: 60px;
//width: 60px;
border-bottom: #eaeef5 1px solid;
}

Expand Down
69 changes: 48 additions & 21 deletions simpleui/static/admin/simpleui-x/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@
var item = app.menuData[i]
if ((item.url || '/') == hash) {
app.openTab(item, item.eid, true);
//找到和item.eid同名的菜单
// var defaultIndex = '1';
//
// app.menus.forEach(n => {
// if (n.eid == item.eid) {
// console.log(n)
// defaultIndex = n.index;
// } else if (n.models) {
// n.models.forEach(k => {
// if (k.eid == item.eid) {
// console.log(k)
// defaultIndex = k.index;
// }
// })
// }
// });
// console.log(defaultIndex)
break;
}
}
Expand All @@ -50,9 +33,9 @@
}

var fontConfig = new Vue({
el: '#dynamicCss',
// el: '#dynamicCss',
data: {
fontSize: 14
fontSize: null
},
created: function () {
var val = getCookie('fontSize');
Expand All @@ -62,6 +45,26 @@
this.fontSize = 0;
}
},
watch: {
fontSize: function (newValue) {
if (newValue != 0) {
var fontStyle = document.getElementById('fontStyle');
if (!fontStyle) {
fontStyle = document.createElement('style');
fontStyle.id = 'fontStyle';
fontStyle.type = 'text/css';
document.head.append(fontStyle);
}
fontStyle.innerHTML = '*{font-size:' + newValue + 'px!important;}'

} else {
var fontStyle = document.getElementById('fontStyle');
if (fontStyle) {
fontStyle.remove();
}
}
}
},
methods: {}
});

Expand Down Expand Up @@ -200,6 +203,13 @@
menuData: []
},
watch: {
theme: function (newValue, oldValue) {
this.$nextTick(function () {
if (window.renderCallback) {
window.renderCallback(this);
}
});
},
fold: function (newValue, oldValue) {
// console.log(newValue)
},
Expand Down Expand Up @@ -229,6 +239,7 @@
},
created: function () {

// this.watch.theme('');

var val = getCookie('fold') == 'true';
this.small = this.fold = val;
Expand Down Expand Up @@ -277,6 +288,7 @@
this.theme = getCookie('theme');
this.themeName = getCookie('theme_name');


//接收子页面的事件注册
window.themeEvents = [];
window.fontEvents = [];
Expand All @@ -300,6 +312,11 @@
if (window.onresize) {
window.onresize();
}
this.$nextTick(function () {
if (window.renderCallback) {
window.renderCallback(this);
}
});
},
methods: {
syncTabs: function () {
Expand Down Expand Up @@ -414,6 +431,9 @@
}
,
openTab: function (data, index, selected) {
if (data.breadcrumbs) {
this.breadcrumbs = data.breadcrumbs;
}

//如果data没有eid就直接打开或者添加根据url
if (!data.eid) {
Expand Down Expand Up @@ -506,6 +526,10 @@
cancelButtonText: language.no,
type: 'warning'
}).then(function () {
//清除cookie主题设置和sessionStore数据
delete sessionStorage['tabs'];
setCookie('theme', '');
setCookie('theme_name', '');
window.location.href = window.urls.logout;
}).catch(function () {

Expand Down Expand Up @@ -544,8 +568,11 @@
displayTimeline: function () {
this.timeline = !this.timeline;
},
report: function () {
window.open('https://github.com/newpanjing/simpleui/issues')
report: function (url) {
if(!url){
url = 'https://github.com/newpanjing/simpleui/issues';
}
window.open(url);
}
}
})
Expand Down
1 change: 0 additions & 1 deletion simpleui/static/admin/simpleui-x/js/language.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
window.getLanuage = function (key) {
console.log(key)
if (!window.Lanuages) {
return "";
}
Expand Down
59 changes: 38 additions & 21 deletions simpleui/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<head>
<title>{% block title %}{% endblock %}</title>

{% if "SIMPLEUI_STATIC_OFFLINE"|get_config %}
{% if "SIMPLEUI_STATIC_OFFLINE"|get_config %}
<link rel="stylesheet" href="{% static '/admin/simpleui-x/elementui/theme-chalk/index.css' %}">
<link rel="stylesheet" href="{% static '/admin/simpleui-x/fontawesome-free-5.8.1-web/css/all.min.css' %}">
{% else %}
Expand All @@ -23,22 +23,23 @@
<link rel="stylesheet" href="{% static '/admin/simpleui-x/theme/simpleui.css' %}">


{% if "SIMPLEUI_STATIC_OFFLINE"|get_config %}
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/vue.min.js' %}"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/elementui/index.js' %}"></script>
{% else %}
{# <script src="https://cdn.jsdelivr.net/npm/vue"></script>#}
<script src="https://unpkg.com/vue@2.6.0/dist/vue.min.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
{% endif %}
{% if "SIMPLEUI_STATIC_OFFLINE"|get_config %}
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/vue.min.js' %}"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/elementui/index.js' %}"></script>
{% else %}
{# <script src="https://cdn.jsdelivr.net/npm/vue"></script>#}
<script src="https://unpkg.com/vue@2.6.0/dist/vue.min.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
{% endif %}

<script type="text/javascript" src="{% static '/admin/simpleui-x/js/language.js' %}?_=2.1.2"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/locale/en-us.js' %}?_=2.1.2"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/locale/' %}{% get_language %}.js"></script>

{% if ""|get_language_code != 'zh-hans' %}

<script type="text/javascript" src="{% static '/admin/simpleui-x/elementui/umd/locale/en.js' %}?_=2.1.2"></script>
<script type="text/javascript"
src="{% static '/admin/simpleui-x/elementui/umd/locale/en.js' %}?_=2.1.2"></script>
<script type="text/javascript">
ELEMENT.locale(ELEMENT.lang.en)
</script>
Expand All @@ -47,7 +48,8 @@
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/cookie.js' %}"></script>
{% block extrastyle %}{% endblock %}
{% if LANGUAGE_BIDI %}
<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}?_=20180905"/>{% endif %}
<link rel="stylesheet" type="text/css" href="
{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}?_=20180905"/>{% endif %}
{% block extrahead %}{% endblock %}
{% block responsive %}
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
Expand All @@ -66,26 +68,41 @@
data-admin-utc-offset="{% now "Z" %}">

{% verbatim dynamicCss %}
<style type="text/css" id="dynamicCss" v-if="fontSize!=0">
*{
font-size: {{ fontSize }}px!important;
}
</style>
{% endverbatim dynamicCss %}

<div id="theme">
<link v-if="theme && theme!=''" rel="stylesheet" :href="theme">

{% if "SIMPLEUI_DEFAULT_THEME"|get_config %}
<link v-else rel="stylesheet" href="{% static 'admin/simpleui-x/theme/' %}{{ "SIMPLEUI_DEFAULT_THEME"|get_config }}">
<link v-else rel="stylesheet"
href="{% static 'admin/simpleui-x/theme/' %}{{ "SIMPLEUI_DEFAULT_THEME"|get_config }}">
{% endif %}
</div>
<script type="text/javascript">

var fontConfig = new Vue({
el: '#dynamicCss',
var fontConfig = new Vue({
data: {
fontSize: 14
fontSize: null
},
watch: {
fontSize: function (newValue) {
if (newValue != 0) {
var fontStyle = document.getElementById('fontStyle');
if (!fontStyle) {
fontStyle = document.createElement('style');
fontStyle.id = 'fontStyle';
fontStyle.type = 'text/css';
document.head.append(fontStyle);
}
fontStyle.innerHTML = '*{font-size:' + newValue + 'px!important;}'

} else {
var fontStyle = document.getElementById('fontStyle');
if (fontStyle) {
fontStyle.remove();
}
}
}
},
created: function () {
var val = getCookie('fontSize');
Expand Down Expand Up @@ -122,7 +139,7 @@
}
})
window.addEventListener('beforeunload', () => {
if(window.beforeLoad){
if (window.beforeLoad) {
window.beforeLoad();
}
});
Expand Down
15 changes: 2 additions & 13 deletions simpleui/templates/admin/change_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_urls static admin_modify %}
{% load i18n admin_urls static admin_modify simpletags%}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
Expand Down Expand Up @@ -104,18 +104,7 @@
el:'.page-header',
methods:{
goBack:function () {
//找到上级
var array = location.pathname.split('/')
if (array.length == 5||array.length==6) {
window.location.href = '/' + array[1] + '/' + array[2];
} else {
var referrer = document.referrer;
if (referrer && document.URL != referrer) {
window.location.href = referrer;
} else {
window.history.go(-1);
}
}
window.location.href='{% get_model_url %}'
}
}
})
Expand Down
Loading

0 comments on commit 1aff47b

Please sign in to comment.