mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
wtf
This commit is contained in:
parent
98e2db0b70
commit
f0c8b7af00
@ -29,6 +29,29 @@ export const app_info = {
|
|||||||
layout: platform.layout
|
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){
|
export function createScreenshotFromElement(element){
|
||||||
if (!element) return false
|
if (!element) return false
|
||||||
html2canvas(element, {
|
html2canvas(element, {
|
||||||
@ -341,7 +364,6 @@ export const time = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function pathMatchRegexp(regexp, pathname) {
|
export function pathMatchRegexp(regexp, pathname) {
|
||||||
console.log('Regex => ', pathname)
|
|
||||||
return pathToRegexp(regexp).exec(pathname)
|
return pathToRegexp(regexp).exec(pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ export function verbosity(data, params, stackTraceParams){
|
|||||||
if (typeof(stackTraceParams) !== "undefined" || stackTraceParams != null) {
|
if (typeof(stackTraceParams) !== "undefined" || stackTraceParams != null) {
|
||||||
objectToArray(stackTraceParams).forEach((e) => {
|
objectToArray(stackTraceParams).forEach((e) => {
|
||||||
if(typeof(e.value) !== "undefined"){
|
if(typeof(e.value) !== "undefined"){
|
||||||
console.log(e.key,e.value)
|
|
||||||
optStackTrace[e.key] = e.value
|
optStackTrace[e.key] = e.value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -83,6 +82,7 @@ export function verbosity(data, params, stackTraceParams){
|
|||||||
if (Array.isArray(initData)) {
|
if (Array.isArray(initData)) {
|
||||||
return console[opt.type](...data)
|
return console[opt.type](...data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return console[opt.type](data)
|
return console[opt.type](data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import { user, session } from 'core/helpers'
|
|||||||
import { router, verbosity, appInterface } from 'core/libs'
|
import { router, verbosity, appInterface } from 'core/libs'
|
||||||
import settings from 'core/libs/settings'
|
import settings from 'core/libs/settings'
|
||||||
import { uri_resolver } from 'api/lib'
|
import { uri_resolver } from 'api/lib'
|
||||||
|
import { queryIndexer } from 'core'
|
||||||
|
|
||||||
import jwt from 'jsonwebtoken'
|
import jwt from 'jsonwebtoken'
|
||||||
import cookie from 'cookie_js'
|
import cookie from 'cookie_js'
|
||||||
@ -93,6 +94,29 @@ export default {
|
|||||||
const sessionDataframe = yield select(state => state.app.session_data)
|
const sessionDataframe = yield select(state => state.app.session_data)
|
||||||
|
|
||||||
window.PluginGlobals = []
|
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) {
|
if (!service) {
|
||||||
|
|
||||||
@ -118,6 +142,10 @@ export default {
|
|||||||
const { user_id, access_token } = payload.authFrame
|
const { user_id, access_token } = payload.authFrame
|
||||||
yield put({ type: 'handleLogin', payload: { user_id, access_token, user_data: payload.dataFrame } })
|
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}){
|
*initializeSocket({payload}, {select, put}){
|
||||||
if(!payload) return false
|
if(!payload) return false
|
||||||
const { type, address } = payload
|
const { type, address } = payload
|
||||||
@ -257,6 +285,14 @@ export default {
|
|||||||
...payload,
|
...payload,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
handleInternal(state, { payload }){
|
||||||
|
verbosity(payload)
|
||||||
|
if (Array.isArray(payload)) {
|
||||||
|
payload.forEach((e) => {
|
||||||
|
window.Internal[e.id] = e.payload
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
handleUpdateResolvers(state, { payload }) {
|
handleUpdateResolvers(state, { payload }) {
|
||||||
state.resolvers = payload
|
state.resolvers = payload
|
||||||
},
|
},
|
||||||
|
64
src/pages/@/[user].js
Normal file
64
src/pages/@/[user].js
Normal file
@ -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(
|
||||||
|
<div className={toStyles("wrapper")} >
|
||||||
|
<div className={toStyles("cover")}>
|
||||||
|
<img src={__Cover} />
|
||||||
|
</div>
|
||||||
|
<div className={toStyles("header")}>
|
||||||
|
|
||||||
|
<div className={toStyles("avatar")}>
|
||||||
|
<antd.Avatar shape="square" src={__Avatar} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={toStyles("title")}>
|
||||||
|
<h1>{this.state.userString}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={toStyles("content")}>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default class UserIndexer extends React.Component {
|
||||||
|
render() {
|
||||||
|
const { location } = this.props
|
||||||
|
if (matchRegexp) {
|
||||||
|
return <UserLayout />
|
||||||
|
}
|
||||||
|
return <Invalid type="index" messageProp1={location.pathname} />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
90
src/pages/@/index.less
Normal file
90
src/pages/@/index.less
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
.UserLayout_wrapper{
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-content: center;
|
||||||
|
|
||||||
|
padding: 0 68px 15px 68px;
|
||||||
|
margin: auto;
|
||||||
|
border-radius: 0 0 20px 20px;
|
||||||
|
padding: 20px 0 3px 0;
|
||||||
|
|
||||||
|
padding-top: 0;
|
||||||
|
overflow: initial !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.UserLayout_header{
|
||||||
|
font-family: "Poppins", sans-serif;
|
||||||
|
color: #242424;
|
||||||
|
|
||||||
|
vertical-align: top;
|
||||||
|
display: flex;
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
height: 24vh;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.UserLayout_cover{
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
img {
|
||||||
|
height: min-content;
|
||||||
|
width: min-content;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.follow_wrapper {
|
||||||
|
margin: 0 7px 0 7px;
|
||||||
|
position: relative;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.UserLayout_title{
|
||||||
|
padding: 54px;
|
||||||
|
padding: 0 10px 10px 0;
|
||||||
|
color: #242424;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
transform: translate(-25px, -45px);
|
||||||
|
max-height: 200px;
|
||||||
|
max-width: 120px;
|
||||||
|
|
||||||
|
&>span {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.mobile{
|
||||||
|
transform: translate(0,-90px);
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.ant-avatar {
|
||||||
|
box-shadow: 13px 13px 17px 4px rgba(69, 69, 69, 0.151);
|
||||||
|
border-radius: 7px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 120px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.UserLayout_content{
|
||||||
|
|
||||||
|
}
|
@ -1,29 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { pathMatchRegexp } from 'core'
|
|
||||||
import Error404 from './404.js'
|
import Error404 from './404.js'
|
||||||
// <UserProfile {...this.props} regx={matchUser} />
|
|
||||||
import { Invalid } from 'components'
|
|
||||||
|
|
||||||
class PageIndexer extends React.Component {
|
export default class PageIndexer extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { location } = this.props
|
const { location } = this.props
|
||||||
const matchUser = pathMatchRegexp('/@:id', location.pathname)
|
|
||||||
const matchSetting = pathMatchRegexp('/~:id', location.pathname)
|
|
||||||
console.log(matchSetting)
|
|
||||||
if (matchUser) {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{matchUser}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (matchSetting) {
|
|
||||||
return(
|
|
||||||
<div>
|
|
||||||
<Invalid type="skeleton" />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// By default return Error 404
|
// By default return Error 404
|
||||||
return (
|
return (
|
||||||
@ -33,5 +13,3 @@ class PageIndexer extends React.Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PageIndexer
|
|
||||||
|
44
src/pages/debug/debuggers/internals.js
Normal file
44
src/pages/debug/debuggers/internals.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import * as antd from 'antd'
|
||||||
|
import { connect } from 'umi'
|
||||||
|
|
||||||
|
@connect(({ app }) => ({ app }))
|
||||||
|
export default class InternalDebug extends React.Component{
|
||||||
|
state = {
|
||||||
|
internals: window.Internal
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDispatch(){
|
||||||
|
this.props.dispatch({
|
||||||
|
type: "app/initializeInternal",
|
||||||
|
payload: [
|
||||||
|
{
|
||||||
|
id: "test",
|
||||||
|
payload: () => {
|
||||||
|
console.log("Hey i am alivee")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCallTest(){
|
||||||
|
if (window.Internal.test != null) {
|
||||||
|
window.Internal.test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render(){
|
||||||
|
return(
|
||||||
|
<div>
|
||||||
|
<antd.Card>
|
||||||
|
{JSON.stringify(this.state.internals) ?? "No internals to show"}
|
||||||
|
</antd.Card>
|
||||||
|
<div style={{ marginTop: "12px" }}>
|
||||||
|
<antd.Button onClick={() => this.handleDispatch()} > init example </antd.Button>
|
||||||
|
<antd.Button onClick={() => this.handleCallTest()} > Call test </antd.Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,8 @@ import CoreDebug from './debuggers/core'
|
|||||||
import ThemeDebug from './debuggers/theme'
|
import ThemeDebug from './debuggers/theme'
|
||||||
import SocketDebug from './debuggers/socket'
|
import SocketDebug from './debuggers/socket'
|
||||||
import VerbosityDebug from './debuggers/verbosity'
|
import VerbosityDebug from './debuggers/verbosity'
|
||||||
|
import InternalDebug from './debuggers/internals'
|
||||||
|
|
||||||
|
|
||||||
const Debuggers = {
|
const Debuggers = {
|
||||||
api: <ApiDebug />,
|
api: <ApiDebug />,
|
||||||
@ -15,7 +17,8 @@ const Debuggers = {
|
|||||||
core: <CoreDebug />,
|
core: <CoreDebug />,
|
||||||
theme: <ThemeDebug />,
|
theme: <ThemeDebug />,
|
||||||
socket: <SocketDebug />,
|
socket: <SocketDebug />,
|
||||||
verbosity: <VerbosityDebug />
|
verbosity: <VerbosityDebug />,
|
||||||
|
internals: <InternalDebug />
|
||||||
}
|
}
|
||||||
|
|
||||||
const menuList = [
|
const menuList = [
|
||||||
@ -49,6 +52,11 @@ const menuList = [
|
|||||||
key: "verbosity",
|
key: "verbosity",
|
||||||
title: "Verbosity",
|
title: "Verbosity",
|
||||||
icon: <Icons.Edit3 />
|
icon: <Icons.Edit3 />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "internals",
|
||||||
|
title: "Internals",
|
||||||
|
icon: <Icons.Box />
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user