Commit f761025a authored by 郭志伟's avatar 郭志伟

fix(token): 重写xyqbNativeEvent

parent 31dd2581
......@@ -7,6 +7,7 @@ import { release } from '@/.sentryclirc';
import '@/service/qg.service';
import SaDirective from '@qg/citrus-ui/src/helper/directives/saTrack.directive.js';
import config from '@qg/citrus-ui/src/config/index.js';
import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus';
import { getParameterByName } from '../../../service/utils.service';
import lazyload from '@qg/cherry-ui/src/lazyload/index';
......@@ -39,6 +40,16 @@ if (EASY_ENV_IS_BROWSER) {
Vue.use(lazyload);
const saDirective = new SaDirective();
Vue.directive('track', saDirective.directive);
window.xyqbNativeEvent = function(res) {
const json = typeof res === 'string' ? JSON.parse(res) : res;
console.log('xyqbNativeEvent toggle');
if (json.event === 'loginAndLogoutNotification') {
EventBus.$emit('NATIVE_EVENT_LOGIN', json);
}
if (json.event === 'getTokenSuccess') {
EventBus.$emit('NATIVE_EVENT_GET_TOKEN', json);
}
};
}
@Component({
name: 'Layout'
......
......@@ -3,5 +3,6 @@ declare var EASY_ENV_IS_BROWSER: boolean;
type PlainObject<T = any> = { [key: string]: T };
interface Window {
__INITIAL_STATE__: string | any;
xyqbNativeEvent: any;
}
declare var apollo: any;
......@@ -7,13 +7,17 @@ import GridItem from '../../component/VueGridLayout/GridItem.vue';
import TransformStyleMixin from '@/page/mixins/transformStyle.mixin';
import SaMixin from '@/page/mixins/sa.mixin';
import { getStyle, debounce, isApp } from '@/service/utils.service';
import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus';
import { setAppTitleColor } from '@/service/color.service';
import localStorage from '@/service/localStorage.service';
@Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip }, name: 'Activity'})
export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
@Getter('pageData') pageData;
@State(state => state.activity.pageInfo.pageName) pageName;
@State(state => state.activity.pageInfo.appLoginState) appLoginState;
@State(state => state.activity.gridLayout.rowHeight) rowHeight;
@Mutation('SET_PAGE_ELEMENTS') setPageElement;
@Mutation('UPDATE_APP_LOGIN_STATE') updateAppLoginState;
@Provide() editor = this;
isEditor: boolean = false;
......@@ -55,8 +59,9 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
this.bottomInfo.y = this.bottomInfo.y + lastGridItemPoint.y + lastGridItemPoint.h;
}
if (isApp) {
// 当页面数据改变,并且渲染完成后改变app 标题栏颜色
this.$nextTick(() => {
setAppTitleColor(this.pageData.props.titleBgColor);
debounce(setAppTitleColor(this.pageData.props.titleBgColor), 300);
});
}
}
......@@ -84,6 +89,21 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
this.targetEle = document.querySelector('body');
this.showBackTop = true;
this.pageVisibilityChange();
if (EASY_ENV_IS_BROWSER) {
EventBus.$on('NATIVE_EVENT_LOGIN', json => {
console.log('xyqbNativeEvent got', json);
if (json.event === 'loginAndLogoutNotification') {
const appData = json.data || {};
if (appData && appData.login) {
localStorage.set('vccToken', appData.token);
this.updateAppLoginState(true);
} else {
this.updateAppLoginState(false);
localStorage.remove('vccToken');
}
}
});
}
}
fetchApi(options) {
const { store, route } = options;
......@@ -127,7 +147,7 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
this.showBackTop = state;
}
pageVisibilityChange() {
if (EASY_ENV_IS_NODE) return;
if (EASY_ENV_IS_NODE) { return; }
let hidden = 'hidden';
let visibilityChange = 'visibilitychange';
if (typeof document.hidden !== 'undefined') {
......
import api from '@/api/editor.api';
import { Module, GetterTree, ActionTree, MutationTree } from 'vuex';
import Vue from 'vue';
import { UPDATE_PAGE_INFO, SET_PAGE_INFO, SET_PAGE_DATA, SET_PAGE_ELEMENTS, SET_ELEMENT_POINT} from './type';
import { UPDATE_PAGE_INFO, SET_PAGE_INFO, SET_PAGE_DATA, SET_PAGE_ELEMENTS, SET_ELEMENT_POINT, UPDATE_APP_LOGIN_STATE } from './type';
import RootState from '../../state';
import EditorState, { PageInfo, defaultState, Page, PageElement } from './state';
......@@ -41,6 +41,9 @@ export default class EditorModule implements Module<EditorState, RootState> {
[SET_PAGE_DATA](state, data) {
state.pageInfo.page = data;
},
[UPDATE_APP_LOGIN_STATE](state, data) {
state.pageInfo.appLoginState = data;
},
[SET_PAGE_ELEMENTS](state, data) {
if (data) { (state.pageInfo.page as Page).elements = data; }
},
......
......@@ -47,6 +47,7 @@ export interface PageInfo {
coverImage?: string;
isTemplate?: number;
isPublish?: number | boolean;
appLoginState?: boolean;
}
export const defaultState = {
......
......@@ -13,4 +13,5 @@ export const UPDATE_COMMON_STYLE = 'UPDATE_COMMON_STYLE';
export const UPDATE_PAGE_STYLE = 'UPDATE_PAGE_STYLE';
export const UPDATE_PAGE_PROPS = 'UPDATE_PAGE_PROPS';
export const SET_PAGE_ELEMENTS = 'SET_PAGE_ELEMENTS';
export const SET_ELEMENT_POINT = 'SET_ELEMENT_POINT';
\ No newline at end of file
export const SET_ELEMENT_POINT = 'SET_ELEMENT_POINT';
export const UPDATE_APP_LOGIN_STATE = 'UPDATE_APP_LOGIN_STATE';
\ No newline at end of file
......@@ -5,6 +5,7 @@ declare var EASY_ENV_IS_NODE: boolean;
interface Window {
__INITIAL_STATE__: any;
xyqbNativeEvent: any;
}
declare module 'axios' {
......
......@@ -1658,13 +1658,13 @@
}
},
"@qg/citrus-ui": {
"version": "0.2.22",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.2.22.tgz",
"integrity": "sha512-KPUpR/mA9+Qz15IUarqB/Hb6e4FQWrOcx0OEjJehyrAhxPC42M3f9PpCgbiIjICaL0fUBx7/LQEt0+fowEEljg==",
"version": "0.2.23",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.2.23.tgz",
"integrity": "sha512-dscWXSQLMdDJU60+wbmmxtfn1S1bCzB4Hh+Ud1JybSl4me+0X/OeVBkSgXru1PNNVMGB1IqCiR1gq9JzprLBYQ==",
"requires": {
"@better-scroll/core": "^2.1.1",
"@qg/cherry-ui": "^2.21.1",
"@qg/js-bridge": "^1.1.11",
"@qg/js-bridge": "^1.1.12",
"axios": "^0.21.1",
"intersection-observer": "^0.12.0",
"js-cookie": "^2.2.1",
......@@ -1672,22 +1672,12 @@
"swiper": "^4.5.1",
"vuex": "^3.6.0",
"weixin-js-sdk": "^1.6.0"
},
"dependencies": {
"@qg/js-bridge": {
"version": "1.1.11",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fjs-bridge/-/js-bridge-1.1.11.tgz",
"integrity": "sha512-WVvkSUg2zcc2nblzYGxM/bVo+VDcANy/dw7vcbxLoW1Jega9Jm2d5FGSb7uS6m4746waghUUqcAWNJZ0Q5yeqA==",
"requires": {
"rollup": "^2.41.3"
}
}
}
},
"@qg/js-bridge": {
"version": "1.1.7",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fjs-bridge/-/js-bridge-1.1.7.tgz",
"integrity": "sha512-t9ucNc5OFntMxhz5E1UFWZJsIM2CGbmgiyjzoOtpJL1s32s2liPnLXrRfnbryYJEiLNzNyhXQUbA0Z1qZlqq3w=="
"version": "1.1.12",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fjs-bridge/-/js-bridge-1.1.12.tgz",
"integrity": "sha512-KhSbaGMJvGZ7CNrl6nIhD56vAKwDCx6kjwm26UeCBb8KAAb2JjgRe3pIAw/XHjC5WZXjlwfwx6hwrgslQiFyxA=="
},
"@tootallnate/once": {
"version": "1.1.2",
......@@ -20876,22 +20866,6 @@
"resolved": "http://npmprivate.quantgroups.com/rndm/-/rndm-1.2.0.tgz",
"integrity": "sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w="
},
"rollup": {
"version": "2.56.2",
"resolved": "http://npmprivate.quantgroups.com/rollup/-/rollup-2.56.2.tgz",
"integrity": "sha512-s8H00ZsRi29M2/lGdm1u8DJpJ9ML8SUOpVVBd33XNeEeL3NVaTiUcSBHzBdF3eAyR0l7VSpsuoVUGrRHq7aPwQ==",
"requires": {
"fsevents": "~2.3.2"
},
"dependencies": {
"fsevents": {
"version": "2.3.2",
"resolved": "http://npmprivate.quantgroups.com/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"optional": true
}
}
},
"run-async": {
"version": "2.4.1",
"resolved": "http://npmprivate.quantgroups.com/run-async/-/run-async-2.4.1.tgz",
......@@ -20956,9 +20930,9 @@
}
},
"sa-sdk-javascript": {
"version": "1.18.12",
"resolved": "http://npmprivate.quantgroups.com/sa-sdk-javascript/-/sa-sdk-javascript-1.18.12.tgz",
"integrity": "sha512-D4ov1/fwhYKdUoG2bvX1gjSgMY2/5oIyGH3g1dH8pTLfJB1L3dHXXTSz18u1mJ1TfbGIcgCtgVCH3kd8B7FF2Q=="
"version": "1.18.13",
"resolved": "http://npmprivate.quantgroups.com/sa-sdk-javascript/-/sa-sdk-javascript-1.18.13.tgz",
"integrity": "sha512-nS8OlmEnXeX/fAnjBrxjJTS6Dp3F2DfGm/XP+xpvcBXQ+GDXWL3saSCT66pRhhE2SSCZ+6WCDDLh03fMK7+PXg=="
},
"safe-buffer": {
"version": "5.2.1",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment