diff --git a/src/core/index.js b/src/core/index.js index e4c5b8bc..6de7cee9 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -29,6 +29,29 @@ export const app_info = { layout: platform.layout }; +export function queryIndexer(array, callback, params) { + if(!array) return false + + if (Array.isArray(array)) { + let opt = { + regex: /:id/gi + } + + if (params) { + opt = { ...opt, ...params } + } + + array.forEach((e) =>{ + if (e.match != null && e.to != null) { + const pathMatch = pathMatchRegexp(e.match, window.location.pathname) + if (pathMatch != null) { + return callback(e.to.replace(opt.regex, pathMatch[1])) + } + } + }) + } +} + export function createScreenshotFromElement(element){ if (!element) return false html2canvas(element, { @@ -341,7 +364,6 @@ export const time = { }; export function pathMatchRegexp(regexp, pathname) { - console.log('Regex => ', pathname) return pathToRegexp(regexp).exec(pathname) } diff --git a/src/core/libs/verbosity/index.js b/src/core/libs/verbosity/index.js index 242dad85..3f1ff60b 100644 --- a/src/core/libs/verbosity/index.js +++ b/src/core/libs/verbosity/index.js @@ -42,7 +42,6 @@ export function verbosity(data, params, stackTraceParams){ if (typeof(stackTraceParams) !== "undefined" || stackTraceParams != null) { objectToArray(stackTraceParams).forEach((e) => { if(typeof(e.value) !== "undefined"){ - console.log(e.key,e.value) optStackTrace[e.key] = e.value } }) @@ -83,6 +82,7 @@ export function verbosity(data, params, stackTraceParams){ if (Array.isArray(initData)) { return console[opt.type](...data) } + return console[opt.type](data) } diff --git a/src/models/app.js b/src/models/app.js index e94a6e1e..0b6af85a 100755 --- a/src/models/app.js +++ b/src/models/app.js @@ -5,6 +5,7 @@ import { user, session } from 'core/helpers' import { router, verbosity, appInterface } from 'core/libs' import settings from 'core/libs/settings' import { uri_resolver } from 'api/lib' +import { queryIndexer } from 'core' import jwt from 'jsonwebtoken' import cookie from 'cookie_js' @@ -93,6 +94,29 @@ export default { const sessionDataframe = yield select(state => state.app.session_data) window.PluginGlobals = [] + window.Internal = [] + + queryIndexer([ + { + match: '/s;:id', + to: `/settings?key=:id`, + }, + { + match: '/h;:id', + to: `/hashtag?key=:id`, + }, + { + match: '/p;:id', + to: `/post?key=:id`, + }, + { + match: '/@:id', + to: `/@/:id`, + } + ], (callback) => { + window.location = callback + }) + if (!service) { @@ -118,6 +142,10 @@ export default { const { user_id, access_token } = payload.authFrame yield put({ type: 'handleLogin', payload: { user_id, access_token, user_data: payload.dataFrame } }) }, + *initializeInternal({payload}, {select, put}){ + if(!payload) return false + yield put({ type: "handleInternal", payload }) + }, *initializeSocket({payload}, {select, put}){ if(!payload) return false const { type, address } = payload @@ -257,6 +285,14 @@ export default { ...payload, }; }, + handleInternal(state, { payload }){ + verbosity(payload) + if (Array.isArray(payload)) { + payload.forEach((e) => { + window.Internal[e.id] = e.payload + }) + } + }, handleUpdateResolvers(state, { payload }) { state.resolvers = payload }, diff --git a/src/pages/@/[user].js b/src/pages/@/[user].js new file mode 100644 index 00000000..504d32ee --- /dev/null +++ b/src/pages/@/[user].js @@ -0,0 +1,64 @@ +import React from 'react' +import { pathMatchRegexp } from 'core' +import { router } from 'core/libs/router' +import { Invalid } from 'components' +import styles from './index.less' + +import * as antd from 'antd' +import { connect } from 'umi' +const matchRegexp = pathMatchRegexp('/@/:id', location.pathname) + +const __Avatar = "https://comty.pw/upload/photos/2020/09/MEmX2WskbYdqxxIfG1Ci_12_bf9ae629707074e3dde5b6ff4ccb1caf_avatar.jpeg?cache=1599917094" +const __Cover = "https://comty.pw/upload/photos/2020/09/ontbBGwvDruPxxHxzd7K_12_b36cb70f20df86ea77cd04005786bad7_cover.png?cache=1599917132" + +@connect(({ app }) => ({ app })) +class UserLayout extends React.Component{ + state = { + styleComponent: "UserLayout", + userString: matchRegexp[1], + } + + componentDidMount(){ + + } + + render(){ + const { styleComponent } = this.state + const toStyles = e => styles[`${styleComponent}_${e}`] + + return( +