Skip to content

Commit

Permalink
Improved some details / 改进了一些细节
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Aug 19, 2021
1 parent 3b464e4 commit 2dd9c2b
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 57 deletions.
4 changes: 2 additions & 2 deletions server/Application/Api/Controller/ItemController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ public function myList(){
$item_sort_data = json_decode(htmlspecialchars_decode($item_sort['item_sort_data']) , true) ;
//var_dump($item_sort_data);
foreach ($items as $key => &$value) {
//如果item_id有设置了序号,则赋值序号。没有则默认填上0
//如果item_id有设置了序号,则赋值序号。没有则默认填上项目id
if ($item_sort_data[$value['item_id']]) {
$value['s_number'] = $item_sort_data[$value['item_id']] ;
}else{
$value['s_number'] = 0 ;
$value['s_number'] = $value['item_id'] ;
}
}
$items = $this->_sort_by_key($items , 's_number' ) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ItemVariableController extends BaseController {
public function save(){
$item_id = I("item_id/d");
$env_id = I("env_id/d");
$var_name = I("var_name");
$var_value = I("var_value");
$var_name = trim(I("var_name"));
$var_value = trim( I("var_value"));
$login_user = $this->checkLogin();
$uid = $login_user['uid'] ;
if(!$this->checkItemEdit($uid , $item_id)){
Expand Down
1 change: 1 addition & 0 deletions server/Application/Api/Controller/UserController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public function resetPassword(){
if ($ret) {
$ret = D("User")->updatePwd($login_user['uid'],$new_password);
if ($ret) {
D("UserToken")->where(" uid = '%d' " ,array($login_user['uid']) )->delete();
$this->sendResult(array());
}else{
$this->sendError(10101,L('modify_faild'));
Expand Down
40 changes: 21 additions & 19 deletions web_src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="edge" />
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Cache" content="no-cache">
<title>ShowDoc</title>
<meta name="keywords" content="" />
<meta name="description" content="本网站基于开源版showdoc搭建,仅供私人使用。如需访问showdoc官网,请在搜索引擎里搜索showdoc字样或者直接访问showdoc.com.cn" />
<script type="text/javascript">

var Wwidth = window.innerWidth ;
window.addEventListener('resize', function() {
///宽度变化大于50像素的时候刷新整个窗口以适应新宽度
if ( Math.abs(Wwidth - window.innerWidth) > 50 ) {
//如果不在编辑页面,则在窗口变化后刷新窗口以适应宽度
if(window.location.href.indexOf("/edit") === -1){
window.location.reload();
}
var Wwidth = window.innerWidth
window.addEventListener('resize', function() {
/// 宽度变化大于50像素的时候刷新整个窗口以适应新宽度
if (Math.abs(Wwidth - window.innerWidth) > 50) {
// 如果不在编辑页面,则在窗口变化后刷新窗口以适应宽度
if (window.location.href.indexOf('/edit') === -1) {
window.location.reload()
}
};
})

});

//挂在window下的全局配置
window.DocConfig = {
//"server":'http://127.0.0.1/showdoc/server/index.php?s=',
"server": window.location.protocol +'//'+ window.location.host + window.location.pathname+ '../server/index.php?s=',
//"lang" :'en'
"lang" :'zh-cn'
}
// 挂在window下的全局配置
window.DocConfig = {
// "server":'http://127.0.0.1/showdoc/server/index.php?s=',
'server': window.location.protocol + '//' + window.location.host + window.location.pathname + '../server/index.php?s=',
// "lang" :'en'
'lang': 'zh-cn'
}
</script>
</head>
<body class="grey-bg">
<div id="app"></div>
<!-- built files will be auto injected -->
<div style="display:none">本网站基于开源版showdoc搭建,仅供私人使用。如需访问showdoc官网,请在搜索引擎里搜索showdoc字样或者直接访问showdoc.com.cn</div>
</body>
</html>
</html>
8 changes: 7 additions & 1 deletion web_src/src/components/attachment/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
drag
name="file"
:action="uploadUrl"
:before-upload="beforeUpload"
:on-success="uploadCallback"
:show-file-list="false"
>
Expand Down Expand Up @@ -139,7 +140,8 @@ export default {
used: 0,
used_flow: 0,
uploadUrl: DocConfig.server + '/api/page/upload',
dialogFormVisible: false
dialogFormVisible: false,
loading: ''
}
},
methods: {
Expand Down Expand Up @@ -192,6 +194,7 @@ export default {
this.$router.push({ path: '/item/index' })
},
uploadCallback(data) {
this.loading.close()
if (data.error_message) {
this.$alert(data.error_message)
}
Expand All @@ -203,6 +206,9 @@ export default {
this.$copyText(row.url).then(e => {
this.$message.success(this.$t('copy_success'))
})
},
beforeUpload() {
this.loading = this.$loading()
}
},
Expand Down
4 changes: 4 additions & 0 deletions web_src/src/components/common/Editormd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ export default {
editor_watch() {
return this.instance.watch()
},
setCursorToTop() {
return this.instance.setCursor({ line: 0, ch: 0 })
},
clear() {
return this.instance.clear()
},
Expand Down
41 changes: 35 additions & 6 deletions web_src/src/components/item/Search.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<template>
<div class="page">
<div
class="itemResultList"
v-for="item in itemResultList"
:key="item.item_id"
>
<hr />
<p class="title">
<router-link :to="'/' + item.item_id" tag="a" target="_blank"
><text-highlight :queries="queries">{{
item.item_name
}}</text-highlight></router-link
>
</p>
<p class="content">
{{ item.item_description }}
</p>
</div>
<div class="resultList" v-for="item in resultList" :key="item.item_id">
<div v-for="page in item.pages" :key="page.page_id">
<hr />
Expand Down Expand Up @@ -41,7 +58,8 @@ export default {
searchItemIds: [], // 要搜索的item_id们
resultList: [],
showLoading: false,
queries: []
queries: [],
itemResultList: []
}
},
watch: {
Expand All @@ -54,11 +72,12 @@ export default {
this.itemList.forEach(element => {
this.searchItemIds.push(element.item_id)
})
this.search()
this.searchItems()
this.searchPages()
}
},
methods: {
search() {
searchPages() {
this.showLoading = true
let item_id = this.searchItemIds.shift()
if (!item_id) {
Expand All @@ -73,7 +92,15 @@ export default {
if (json && json.pages && json.pages.length > 0) {
this.resultList.push(json)
}
this.search()
this.searchPages()
})
},
searchItems() {
this.itemResultList = []
this.itemList.map((one, index) => {
if (one && one.item_name && one.item_name.indexOf(this.keyword) > -1) {
this.itemResultList.push(one)
}
})
}
},
Expand All @@ -83,7 +110,8 @@ export default {
this.itemList.forEach(element => {
this.searchItemIds.push(element.item_id)
})
this.search()
this.searchItems()
this.searchPages()
},
beforeDestroy() {
this.searchItemIds = []
Expand All @@ -101,7 +129,8 @@ export default {
margin: 0 auto;
font-size: 20px;
}
.resultList {
.resultList,
.itemResultList {
width: 85%;
margin: 0 auto;
}
Expand Down
41 changes: 27 additions & 14 deletions web_src/src/components/item/add/Copy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,23 @@
></el-input>
</el-tooltip>
</el-form-item>
<el-form-item label>
<el-radio v-model="isOpenItem" :label="true">{{
$t('Open_item')
}}</el-radio>
<el-radio v-model="isOpenItem" :label="false">{{
$t('private_item')
}}</el-radio>
</el-form-item>

<el-form-item v-show="!isOpenItem">
<el-input
type="text"
auto-complete="off"
v-model="password"
:placeholder="$t('visit_password')"
></el-input>
</el-form-item>
<el-form-item label>
<el-button type="primary" style="width:100%;" @click="FormSubmit">{{
$t('submit')
Expand All @@ -54,7 +70,8 @@ export default {
itemList: {},
copy_item_id: '',
item_name: '',
item_description: ''
item_description: '',
password: ''
}
},
methods: {
Expand Down Expand Up @@ -84,25 +101,21 @@ export default {
},
FormSubmit() {
var that = this
var url = DocConfig.server + '/api/item/add'
if (!this.isOpenItem && !this.infoForm.password) {
if (!this.isOpenItem && !this.password) {
that.$alert(that.$t('private_item_passwrod'))
return false
}
if (this.isOpenItem) {
this.infoForm.password = ''
this.password = ''
}
var params = new URLSearchParams()
params.append('copy_item_id', this.copy_item_id)
params.append('item_name', this.item_name)
params.append('item_description', this.item_description)
that.axios.post(url, params).then(function(response) {
if (response.data.error_code === 0) {
that.$router.push({ path: '/item/index' })
} else {
that.$alert(response.data.error_message)
}
this.request('/api/item/add', {
copy_item_id: this.copy_item_id,
item_name: this.item_name,
password: this.password,
item_description: this.item_description
}).then(() => {
that.$router.push({ path: '/item/index' })
})
}
},
Expand Down
9 changes: 7 additions & 2 deletions web_src/src/components/item/show/show_regular_item/OpBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,16 @@ export default {
var element = document
.getElementById('page_md_content')
.getElementsByClassName('open-list')
element[0].style.top = '330px'
if (element && element[0]) element[0].style.top = '330px'
sessionStorage.setItem('show_more_' + this.item_id, 1)
},
hideMoreAction() {
this.showMore = false
var element = document
.getElementById('page_md_content')
.getElementsByClassName('open-list')
element[0].style.top = '230px'
if (element && element[0]) element[0].style.top = '230px'
sessionStorage.removeItem('show_more_' + this.item_id)
},
handleCommand(command) {
switch (command) {
Expand Down Expand Up @@ -555,6 +557,9 @@ export default {
this.show_menu_btn = true
this.show_op_bar = false
}
if (sessionStorage.getItem('show_more_' + this.item_id)) {
this.showMoreAction()
}
},
watch: {
page_info: function() {
Expand Down
33 changes: 32 additions & 1 deletion web_src/src/components/item/show/show_table_item/Index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<div class="hello">
<div
class="hello"
@keydown.ctrl.83.prevent="save"
@keydown.meta.83.prevent="save"
>
<link href="static/xspreadsheet/xspreadsheet.css" rel="stylesheet" />
<div id="header"></div>
<div class="edit-bar" v-if="item_info.item_edit">
Expand Down Expand Up @@ -406,6 +410,31 @@ export default {
}
}
reader.readAsArrayBuffer(f)
},
// 由于页面关闭事件无法直接发起异步的ajax请求,所以用浏览器的navigator.sendBeacon来实现
unLockOnClose() {
let user_token = ''
const userinfostr = localStorage.getItem('userinfo')
if (userinfostr) {
const userinfo = JSON.parse(userinfostr)
if (userinfo && userinfo.user_token) {
user_token = userinfo.user_token
}
}
let analyticsData = new URLSearchParams({
page_id: this.page_id,
item_id: this.item_info.item_id,
lock_to: 1000,
user_token: user_token
})
let url = DocConfig.server + '/api/page/setLock'
if ('sendBeacon' in navigator) {
navigator.sendBeacon(url, analyticsData)
} else {
var client = new XMLHttpRequest()
client.open('POST', url, false)
client.send(analyticsData)
}
}
},
mounted() {
Expand Down Expand Up @@ -434,11 +463,13 @@ export default {
)
$s([`static/xspreadsheet/xlsx.full.min.js`])
})
window.addEventListener('beforeunload', this.unLockOnClose)
},
beforeDestroy() {
this.$message.closeAll()
clearInterval(this.intervalId)
this.unlock()
window.removeEventListener('beforeunload', this.unLockOnClose)
}
}
</script>
Loading

0 comments on commit 2dd9c2b

Please sign in to comment.