forked from github/dataease
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
0a6e55247a
@ -68,7 +68,7 @@ public class DePermissionAnnotationHandler {
|
||||
return point.proceed(point.getArgs());
|
||||
} catch (Throwable throwable) {
|
||||
LogUtil.error(throwable.getMessage(), throwable);
|
||||
throw new RuntimeException(throwable);
|
||||
throw new RuntimeException(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
package io.dataease.auth.api;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/data")
|
||||
public class demo {
|
||||
@ApiOperation("查询")
|
||||
@GetMapping("demo")
|
||||
public Object listByTableId() {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for(int i=0;i<10;i++){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for(int j=0;j<1;j++){
|
||||
jsonObject.set("column" +i + j, "value"+i+j);
|
||||
}
|
||||
jsonArray.put(jsonObject);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
@ -20,7 +20,6 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
// ----------------------------------------------------------
|
||||
// 放行Swagger2页面,需要放行这些
|
||||
|
||||
filterChainDefinitionMap.put("/api/data/demo", ANON);
|
||||
filterChainDefinitionMap.put("/doc.html**", "doc");
|
||||
filterChainDefinitionMap.put("/deApi**", ANON);
|
||||
filterChainDefinitionMap.put("/swagger-ui.html", ANON);
|
||||
|
@ -37,8 +37,7 @@ public class DataSetTableController {
|
||||
|
||||
@DePermissions(value = {
|
||||
@DePermission(type = DePermissionType.DATASET, value = "id"),
|
||||
@DePermission(type = DePermissionType.DATASET, value = "sceneId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE),
|
||||
@DePermission(type = DePermissionType.DATASOURCE, value = "dataSourceId", level = ResourceAuthLevel.DATASET_LEVEL_USE)
|
||||
@DePermission(type = DePermissionType.DATASET, value = "sceneId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
}, logical = Logical.AND)
|
||||
@ApiOperation("批量保存")
|
||||
@PostMapping("batchAdd")
|
||||
@ -48,8 +47,7 @@ public class DataSetTableController {
|
||||
|
||||
@DePermissions(value = {
|
||||
@DePermission(type = DePermissionType.DATASET, value = "id", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE),
|
||||
@DePermission(type = DePermissionType.DATASET, value = "sceneId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE),
|
||||
@DePermission(type = DePermissionType.DATASOURCE, value = "dataSourceId", level = ResourceAuthLevel.DATASET_LEVEL_USE)
|
||||
@DePermission(type = DePermissionType.DATASET, value = "sceneId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
}, logical = Logical.AND)
|
||||
@ApiOperation("更新")
|
||||
@PostMapping("update")
|
||||
@ -63,8 +61,7 @@ public class DataSetTableController {
|
||||
|
||||
@DePermissions(value = {
|
||||
@DePermission(type = DePermissionType.DATASET, value = "id", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE),
|
||||
@DePermission(type = DePermissionType.DATASET, value = "sceneId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE),
|
||||
@DePermission(type = DePermissionType.DATASOURCE, value = "dataSourceId", level = ResourceAuthLevel.DATASET_LEVEL_USE)
|
||||
@DePermission(type = DePermissionType.DATASET, value = "sceneId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
}, logical = Logical.AND)
|
||||
@ApiOperation("修改")
|
||||
@PostMapping("alter")
|
||||
@ -107,7 +104,6 @@ public class DataSetTableController {
|
||||
return dataSetTableService.getWithPermission(id, null);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASOURCE, level = ResourceAuthLevel.DATASOURCE_LEVEL_USE, value = "dataSourceId")
|
||||
@ApiOperation("查询原始字段")
|
||||
@PostMapping("getFields")
|
||||
public List<TableField> getFields(@RequestBody DatasetTable datasetTable) throws Exception {
|
||||
@ -128,14 +124,12 @@ public class DataSetTableController {
|
||||
return dataSetTableService.getPreviewData(dataSetTableRequest, page, pageSize, null);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASOURCE, level = ResourceAuthLevel.DATASOURCE_LEVEL_USE, value = "dataSourceId")
|
||||
@ApiOperation("根据sql查询预览数据")
|
||||
@PostMapping("sqlPreview")
|
||||
public Map<String, Object> getSQLPreview(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
return dataSetTableService.getSQLPreview(dataSetTableRequest);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASOURCE, level = ResourceAuthLevel.DATASOURCE_LEVEL_USE, value = "dataSourceId")
|
||||
@ApiOperation("预览自定义数据数据")
|
||||
@PostMapping("customPreview")
|
||||
public Map<String, Object> customPreview(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
|
@ -80,7 +80,7 @@ public class PanelGroupController {
|
||||
@DePermissionProxy(paramIndex = 1)
|
||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW)
|
||||
@PostMapping("/proxy/findOne/{id}")
|
||||
public PanelGroupWithBLOBs proxyFindOne(@PathVariable String id, @RequestBody PermissionProxy proxy)
|
||||
public PanelGroupDTO proxyFindOne(@PathVariable String id, @RequestBody PermissionProxy proxy)
|
||||
throws Exception {
|
||||
return panelGroupService.findOne(id);
|
||||
}
|
||||
|
@ -64,12 +64,12 @@ public class ColumnPermissionsController {
|
||||
return columnPermissionService.searchPermissions(request);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
@DePermission(type = DePermissionType.DATASET, value = "datasetId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("/delete/{id}")
|
||||
public void delete(@PathVariable String id) {
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody DatasetColumnPermissions datasetColumnPermissions) {
|
||||
ColumnPermissionService columnPermissionService = SpringContextUtil.getBean(ColumnPermissionService.class);
|
||||
columnPermissionService.delete(id);
|
||||
columnPermissionService.delete(datasetColumnPermissions.getId());
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
|
@ -62,12 +62,12 @@ public class RowPermissionsController {
|
||||
return rowPermissionService.searchRowPermissions(request);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
@DePermission(type = DePermissionType.DATASET, value = "datasetId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("/delete/{id}")
|
||||
public void dataSetRowPermissionInfo(@PathVariable String id) {
|
||||
@PostMapping("/delete")
|
||||
public void dataSetRowPermissionInfo(@RequestBody DatasetRowPermissions datasetRowPermissions) {
|
||||
RowPermissionService rowPermissionService = SpringContextUtil.getBean(RowPermissionService.class);
|
||||
rowPermissionService.delete(id);
|
||||
rowPermissionService.delete(datasetRowPermissions.getId());
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.DATASET, value = "datasetId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
@ -20,6 +19,8 @@ import io.dataease.plugins.xpack.auth.service.AuthXpackService;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping("/plugin/auth")
|
||||
@RestController
|
||||
@ -74,11 +75,31 @@ public class XAuthServer {
|
||||
}
|
||||
String authCacheKey = getAuthCacheKey(request);
|
||||
if (StringUtils.isNotBlank(authCacheKey)) {
|
||||
CacheUtils.remove(authCacheKey, request.getAuthTargetType() + request.getAuthTarget());
|
||||
if (StringUtils.equals("dept", request.getAuthTargetType())) {
|
||||
List<String> authTargets = getAuthModels(request.getAuthTarget(), request.getAuthTargetType(),
|
||||
user.getUserId(), user.getIsAdmin());
|
||||
if (CollectionUtils.isNotEmpty(authTargets)) {
|
||||
authTargets.forEach(deptId -> {
|
||||
CacheUtils.remove(authCacheKey, request.getAuthTargetType() + deptId);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
CacheUtils.remove(authCacheKey, request.getAuthTargetType() + request.getAuthTarget());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> getAuthModels(String id, String type, Long userId, Boolean isAdmin) {
|
||||
AuthXpackService sysAuthService = SpringContextUtil.getBean(AuthXpackService.class);
|
||||
List<XpackVAuthModelDTO> vAuthModelDTOS = sysAuthService
|
||||
.searchAuthModelTree(new XpackBaseTreeRequest(id, type, "children"), userId, isAdmin);
|
||||
List<String> authSources = Optional.ofNullable(vAuthModelDTOS).orElse(new ArrayList<>()).stream()
|
||||
.map(XpackVAuthModelDTO::getId)
|
||||
.collect(Collectors.toList());
|
||||
return authSources;
|
||||
}
|
||||
|
||||
private String getAuthCacheKey(XpackSysAuthRequest request) {
|
||||
if (CollectionUtils.isEmpty(cacheTypes)) {
|
||||
|
@ -606,7 +606,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
case mysql:
|
||||
case mariadb:
|
||||
JdbcConfiguration jdbcConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), JdbcConfiguration.class);
|
||||
return String.format("SELECT TABLE_NAME,TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = '%s' ;", jdbcConfiguration.getDataBase());
|
||||
return String.format("SELECT TABLE_NAME,TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '%s' ;", jdbcConfiguration.getDataBase());
|
||||
case de_doris:
|
||||
case ds_doris:
|
||||
case hive:
|
||||
|
@ -26,14 +26,12 @@ public class VAuthModelService {
|
||||
|
||||
public List<VAuthModelDTO> queryAuthModel(VAuthModelRequest request) {
|
||||
request.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
// 定时任务选数据集时,列表需去除空目录
|
||||
if (request.isClearEmptyDir()) {
|
||||
request.setMode(null);
|
||||
}
|
||||
List<VAuthModelDTO> result = extVAuthModelMapper.queryAuthModel(request);
|
||||
// 定时任务选数据集时,列表需去除空目录
|
||||
|
||||
if (request.getPrivileges() != null) {
|
||||
result = filterPrivileges(request, result);
|
||||
}
|
||||
if (request.isClearEmptyDir()) {
|
||||
result = filterData(request, result);
|
||||
List<VAuthModelDTO> vAuthModelDTOS = TreeUtils.mergeTree(result);
|
||||
setAllLeafs(vAuthModelDTOS);
|
||||
removeEmptyDir(vAuthModelDTOS);
|
||||
@ -42,16 +40,7 @@ public class VAuthModelService {
|
||||
return TreeUtils.mergeTree(result);
|
||||
}
|
||||
|
||||
private List<VAuthModelDTO> filterData(VAuthModelRequest request, List<VAuthModelDTO> result) {
|
||||
if (request.getDatasetMode() != null && request.getDatasetMode() == 1) {
|
||||
result = result.stream().filter(vAuthModelDTO -> {
|
||||
if (vAuthModelDTO.getNodeType().equalsIgnoreCase("spine") || (vAuthModelDTO.getNodeType().equalsIgnoreCase("leaf") && vAuthModelDTO.getMode().equals(1L)) && !vAuthModelDTO.getModelInnerType().equalsIgnoreCase("excel") && !vAuthModelDTO.getModelInnerType().equalsIgnoreCase("custom") && !vAuthModelDTO.getModelInnerType().equalsIgnoreCase("union")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
private List<VAuthModelDTO> filterPrivileges(VAuthModelRequest request, List<VAuthModelDTO> result) {
|
||||
if (request.getPrivileges() != null) {
|
||||
result = result.stream().filter(vAuthModelDTO -> {
|
||||
if (vAuthModelDTO.getNodeType().equalsIgnoreCase("spine") || (vAuthModelDTO.getNodeType().equalsIgnoreCase("leaf") && vAuthModelDTO.getPrivileges() != null && vAuthModelDTO.getPrivileges().contains(request.getPrivileges()))) {
|
||||
|
@ -283,7 +283,6 @@ public class PanelGroupService {
|
||||
panelData = panelData.replaceAll(panelView.getCopyFromView(), panelView.getChartViewId());
|
||||
}
|
||||
newPanel.setPanelData(panelData);
|
||||
panelGroupMapper.insertSelective(newPanel);
|
||||
//TODO 复制跳转信息 copy panel_link_jump panel_link_jump_info panel_link_jump_target_view_info
|
||||
extPanelLinkJumpMapper.copyLinkJump(copyId);
|
||||
extPanelLinkJumpMapper.copyLinkJumpInfo(copyId);
|
||||
@ -292,6 +291,7 @@ public class PanelGroupService {
|
||||
extPanelViewLinkageMapper.copyViewLinkage(copyId);
|
||||
extPanelViewLinkageMapper.copyViewLinkageField(copyId);
|
||||
}
|
||||
panelGroupMapper.insertSelective(newPanel);
|
||||
return newPanelId;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -170,8 +170,8 @@ export default {
|
||||
.full-height {
|
||||
height: 100vh !important;
|
||||
::-webkit-scrollbar {
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,7 +112,13 @@ export function getLabel(chart) {
|
||||
if (l.show) {
|
||||
if (chart.type === 'pie') {
|
||||
label = {
|
||||
type: l.position
|
||||
type: l.position,
|
||||
autoRotate: false
|
||||
}
|
||||
} else if (chart.type.includes('line')) {
|
||||
label = {
|
||||
position: l.position,
|
||||
offsetY: -8
|
||||
}
|
||||
} else {
|
||||
label = {
|
||||
|
@ -13,6 +13,9 @@
|
||||
<i slot="reference" class="el-icon-warning icon-class" style="margin-left: 4px;cursor: pointer;" />
|
||||
</el-popover>
|
||||
<span style="float: right;line-height: 40px;">
|
||||
<el-button size="mini" @click="close">
|
||||
{{ $t('chart.close') }}
|
||||
</el-button>
|
||||
<el-button size="mini" :disabled="!hasEdit" @click="reset">
|
||||
{{ $t('chart.recover') }}
|
||||
</el-button>
|
||||
@ -1246,7 +1249,8 @@ export default {
|
||||
this.table = response.data
|
||||
this.initTableField(id)
|
||||
}).catch(err => {
|
||||
this.resetView()
|
||||
this.table = null
|
||||
this.resetDatasetField()
|
||||
this.httpRequest.status = err.response.data.success
|
||||
this.httpRequest.msg = err.response.data.message
|
||||
return true
|
||||
@ -1525,6 +1529,14 @@ export default {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.closeChangeChart()
|
||||
// 从仪表板入口关闭
|
||||
if (this.$route.path.indexOf('panel') > -1) {
|
||||
this.$store.commit('recordSnapshot')
|
||||
bus.$emit('PanelSwitchComponent', { name: 'PanelEdit' })
|
||||
}
|
||||
},
|
||||
getData(id) {
|
||||
this.hasEdit = false
|
||||
if (id) {
|
||||
|
@ -60,7 +60,7 @@
|
||||
|
||||
<!--选择数据集-->
|
||||
<el-dialog v-if="selectDsDialog" v-dialogDrag :title="$t('chart.select_dataset')" :visible="selectDsDialog" :show-close="false" width="400px" class="dialog-css">
|
||||
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" @getTable="firstDs" />
|
||||
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" clear-empty-dir="true" @getTable="firstDs" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeSelectDs()">{{ $t('dataset.cancel') }}</el-button>
|
||||
<el-button :disabled="!tempDs.id" type="primary" size="mini" @click="confirmSelectDs()">{{ $t('dataset.confirm') }}</el-button>
|
||||
@ -139,7 +139,7 @@ export default {
|
||||
allChildCount: 0
|
||||
},
|
||||
name: '关联数据集',
|
||||
customType: ['db', 'sql', 'excel'],
|
||||
customType: ['db', 'sql', 'excel', 'api'],
|
||||
selectDsDialog: false,
|
||||
// 弹框临时选中的数据集
|
||||
tempDs: {},
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
<!--选择数据集-->
|
||||
<el-dialog v-if="selectDsDialog" v-dialogDrag :title="$t('chart.select_dataset')" :visible="selectDsDialog" :show-close="false" width="400px" class="dialog-css">
|
||||
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" :mode="currentNode.currentDs.mode" @getTable="firstDs" />
|
||||
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" clear-empty-dir="true" :mode="currentNode.currentDs.mode" @getTable="firstDs" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeSelectDs()">{{ $t('dataset.cancel') }}</el-button>
|
||||
<el-button :disabled="!tempDs.id" type="primary" size="mini" @click="confirmSelectDs()">{{ $t('dataset.confirm') }}</el-button>
|
||||
@ -79,7 +79,7 @@ export default {
|
||||
},
|
||||
allChildCount: 0
|
||||
},
|
||||
customType: ['db', 'sql', 'excel'],
|
||||
customType: ['db', 'sql', 'excel', 'api'],
|
||||
selectDsDialog: false,
|
||||
// 弹框临时选中的数据集
|
||||
tempDs: {},
|
||||
@ -129,7 +129,7 @@ export default {
|
||||
selectDs() {
|
||||
// 根据父级node,过滤不同的数据集
|
||||
if (this.currentNode.currentDs.mode === 1) {
|
||||
this.customType = ['db', 'sql', 'excel']
|
||||
this.customType = ['db', 'sql', 'excel', 'api']
|
||||
} else if (this.currentNode.currentDs.mode === 0) {
|
||||
if (this.currentNode.currentDs.modelInnerType === 'db') {
|
||||
this.customType = ['db']
|
||||
|
@ -340,7 +340,7 @@ export default {
|
||||
{ required: true, message: this.$t('dataset.required'), trigger: 'change' }
|
||||
]
|
||||
},
|
||||
customType: ['db', 'sql']
|
||||
customType: ['db', 'sql', 'api']
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import Config from '@/settings'
|
||||
import { getToken, setToken, setUserInfo } from '@/common/utils'
|
||||
import { getToken, setToken, setUserInfo, parseLanguage } from '@/common/utils'
|
||||
const TokenKey = Config.TokenKey
|
||||
const RefreshTokenKey = Config.RefreshTokenKey
|
||||
const white_list = Config.WHITE_LIST
|
||||
@ -15,6 +15,17 @@ let service = axios.create({
|
||||
// request interceptor
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
|
||||
let lang = parseLanguage() || uni.getLocale()
|
||||
if (lang === 'en') {
|
||||
config.headers['Accept-Language'] = 'en-US'
|
||||
}else if(lang === 'zh-Hant'){
|
||||
config.headers['Accept-Language'] = 'zh-TW'
|
||||
}else {
|
||||
config.headers['Accept-Language'] = 'zh-CN'
|
||||
}
|
||||
|
||||
|
||||
if (white_list.includes(config.url)) {
|
||||
return config
|
||||
}
|
||||
|
@ -21,13 +21,23 @@
|
||||
</block>
|
||||
|
||||
</uni-nav-bar>
|
||||
<view v-if="url">
|
||||
<web-view
|
||||
:webview-styles="webViewStyles"
|
||||
style="height: 100vh;"
|
||||
>
|
||||
</web-view>
|
||||
</view>
|
||||
|
||||
<scroll-view
|
||||
|
||||
:scroll-top="scrollTop"
|
||||
scroll-y="true"
|
||||
class="scroll-Y"
|
||||
@scrolltoupper="upper"
|
||||
@scrolltolower="lower"
|
||||
@scroll="scroll">
|
||||
|
||||
<!-- <web-view v-if="url" :style="{height: 'calc(100vh - ' + ktxStatusHeight +'px)'}" /> -->
|
||||
<!-- <web-view v-if="url" style="height: 100vh;" /> -->
|
||||
<web-view v-if="url" :style="{height: viewHeight}" />
|
||||
|
||||
</scroll-view>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -73,16 +83,16 @@
|
||||
title: '',
|
||||
banner: {},
|
||||
htmlNodes: [],
|
||||
webViewStyles: {
|
||||
|
||||
progress: {
|
||||
color: '#FF3333'
|
||||
},
|
||||
height: '700px'
|
||||
},
|
||||
|
||||
url: '',
|
||||
hasStar: false,
|
||||
refreshCount: 0
|
||||
refreshCount: 0,
|
||||
scrollTop: 0,
|
||||
old: {
|
||||
scrollTop: 0
|
||||
},
|
||||
viewHeight: null,
|
||||
ktxStatusHeight: null
|
||||
}
|
||||
},
|
||||
onLoad(event) {
|
||||
@ -101,12 +111,12 @@
|
||||
uni.setNavigationBarTitle({
|
||||
title: this.banner.title
|
||||
});
|
||||
// this.getDetail();
|
||||
this.addRecent()
|
||||
uni.$emit('loadHomeIndex', {
|
||||
index: 1
|
||||
})
|
||||
this.loadStarStatus()
|
||||
this.caclViewHeight()
|
||||
|
||||
|
||||
},
|
||||
@ -118,68 +128,10 @@
|
||||
uni.navigateBack()
|
||||
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: this.banner.title,
|
||||
path: DETAIL_PAGE_PATH + '?detailDate=' + JSON.stringify(this.banner)
|
||||
}
|
||||
},
|
||||
onNavigationBarButtonTap(event) {
|
||||
const buttonIndex = event.index;
|
||||
if (buttonIndex === 0) {
|
||||
// 分享 H5 的页面
|
||||
const shareProviders = [];
|
||||
uni.getProvider({
|
||||
service: 'share',
|
||||
success: (result) => {
|
||||
// 目前仅考虑分享到微信
|
||||
if (result.provider && result.provider.length && ~result.provider.indexOf('weixin')) {
|
||||
const channels = _handleShareChannels(result.provider);
|
||||
uni.showActionSheet({
|
||||
itemList: channels.map(channel => {
|
||||
return channel.text;
|
||||
}),
|
||||
success: (result) => {
|
||||
const tapIndex = result.tapIndex;
|
||||
uni.share({
|
||||
provider: 'weixin',
|
||||
type: 0,
|
||||
title: this.banner.title,
|
||||
scene: tapIndex === 0 ? 'WXSceneSession' : 'WXSenceTimeline',
|
||||
href: 'https://uniapp.dcloud.io/h5' + DETAIL_PAGE_PATH + '?detailDate=' + JSON.stringify(this.banner),
|
||||
imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b6304f00-5168-11eb-bd01-97bc1429a9ff.png'
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '未检测到可用的微信分享服务'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
uni.showToast({
|
||||
title: '获取分享服务失败'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
getDetail() {
|
||||
uni.request({
|
||||
url: 'https://unidemo.dcloud.net.cn/api/news/36kr/' + this.banner.post_id,
|
||||
success: (data) => {
|
||||
if (data.statusCode == 200) {
|
||||
var htmlString = data.data.content.replace(/\\/g, "").replace(/<img/g, "<img style=\"display:none;\"");
|
||||
//this.htmlNodes = htmlParser(htmlString);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
console.log('fail');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addRecent() {
|
||||
const item = {id: this.banner.id, title: this.banner.title, index: this.banner.index}
|
||||
addRecent(item)
|
||||
@ -215,18 +167,30 @@
|
||||
})
|
||||
},
|
||||
loadLinkUrl() {
|
||||
|
||||
|
||||
this.url = process.env.VUE_APP_BASE_API + 'tempMobileLink/' + this.banner.id + "/" + getToken()
|
||||
const url = this.url
|
||||
/* uni.hideLoading() */
|
||||
setTimeout(() => {
|
||||
const iframe = document.getElementsByTagName("iframe")[0]
|
||||
|
||||
// iframe.style.height = (ktxScreentHeight - ktxStatusHeight) + 'px'
|
||||
iframe.src = url
|
||||
iframe.onload = e => {
|
||||
uni.hideLoading()
|
||||
iframe.onload = e => {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
},
|
||||
caclViewHeight() {
|
||||
let systemInfo = uni.getSystemInfoSync()
|
||||
const h5Height = systemInfo.windowHeight - systemInfo.statusBarHeight
|
||||
if(systemInfo.navigationBarHeight) {
|
||||
h5Height = h5Height - systemInfo.navigationBarHeight
|
||||
}
|
||||
this.viewHeight = h5Height + 'px'
|
||||
|
||||
},
|
||||
back() {
|
||||
// #ifdef H5
|
||||
let canBack = true
|
||||
@ -245,7 +209,27 @@
|
||||
return
|
||||
// #endif
|
||||
uni.navigateBack(1)
|
||||
}
|
||||
},
|
||||
upper: function(e) {
|
||||
console.log(e)
|
||||
},
|
||||
lower: function(e) {
|
||||
console.log(e)
|
||||
},
|
||||
scroll: function(e) {
|
||||
console.log(e)
|
||||
this.old.scrollTop = e.detail.scrollTop
|
||||
},
|
||||
goTop: function(e) {
|
||||
this.scrollTop = this.old.scrollTop
|
||||
this.$nextTick(() => {
|
||||
this.scrollTop = 0
|
||||
});
|
||||
uni.showToast({
|
||||
icon:"none",
|
||||
title:"纵向滚动 scrollTop 值已被修改为 0"
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user