repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
vue-vapor
github_2023
vuejs
typescript
mockElementWithStyle
function mockElementWithStyle() { const store: any = {} return { style: { display: '', WebkitTransition: '', setProperty(key: string, val: string) { store[key] = val }, getPropertyValue(key: string) { return store[key] }, }, } ...
// JSDOM doesn't support custom properties on style object so we have to
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/__tests__/patchStyle.spec.ts#L123-L137
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._resolveDef
private _resolveDef() { if (this._pendingResolve) { return } // set initial attrs for (let i = 0; i < this.attributes.length; i++) { this._setAttr(this.attributes[i].name) } // watch future attr changes this._ob = new MutationObserver(mutations => { for (const m of mutati...
/** * resolve inner component definition (handle possible async component) */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L342-L412
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._getProp
protected _getProp(key: string): any { return this._props[key] }
/** * @internal */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L480-L482
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._setProp
_setProp( key: string, val: any, shouldReflect = true, shouldUpdate = false, ): void { if (val !== this._props[key]) { if (val === REMOVAL) { delete this._props[key] } else { this._props[key] = val // support set key on ceVNode if (key === 'key' && this....
/** * @internal */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L487-L520
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._parseSlots
private _parseSlots() { const slots: VueElement['_slots'] = (this._slots = {}) let n while ((n = this.firstChild)) { const slotName = (n.nodeType === 1 && (n as Element).getAttribute('slot')) || 'default' ;(slots[slotName] || (slots[slotName] = [])).push(n) this.removeChild(n) ...
/** * Only called when shadowRoot is false */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L617-L626
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._renderSlots
private _renderSlots() { const outlets = (this._teleportTarget || this).querySelectorAll('slot') const scopeId = this._instance!.type.__scopeId for (let i = 0; i < outlets.length; i++) { const o = outlets[i] as HTMLSlotElement const slotName = o.getAttribute('name') || 'default' const cont...
/** * Only called when shadowRoot is false */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L631-L658
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._injectChildStyle
_injectChildStyle(comp: ConcreteComponent & CustomElementOptions): void { this._applyStyles(comp.styles, comp) }
/** * @internal */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L663-L665
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
VueElement._removeChildStyle
_removeChildStyle(comp: ConcreteComponent): void { if (__DEV__) { this._styleChildren.delete(comp) if (this._childStyles && comp.__hmrId) { // clear old styles const oldStyles = this._childStyles.get(comp.__hmrId) if (oldStyles) { oldStyles.forEach(s => this._root.remov...
/** * @internal */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/apiCustomElement.ts#L670-L682
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
injectCompilerOptionsCheck
function injectCompilerOptionsCheck(app: App) { if (isRuntimeOnly()) { const isCustomElement = app.config.isCustomElement Object.defineProperty(app.config, 'isCustomElement', { get() { return isCustomElement }, set() { warn( `The \`isCustomElement\` config option is...
// dev only
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/index.ts#L191-L226
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
decorate
const decorate = (t: typeof Transition) => { t.displayName = 'Transition' t.props = TransitionPropsValidators if (__COMPAT__) { t.__isBuiltIn = true } return t }
/** * Wrap logic that attaches extra properties to Transition in a function * so that it can be annotated as pure */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/components/Transition.ts#L74-L81
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
callHook
const callHook = ( hook: Function | Function[] | undefined, args: any[] = [], ) => { if (isArray(hook)) { hook.forEach(h => h(...args)) } else if (hook) { hook(...args) } }
/** * #3227 Incoming hooks may be merged into arrays when wrapping Transition * with custom HOCs. */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/components/Transition.ts#L96-L105
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
hasExplicitCallback
const hasExplicitCallback = ( hook: Function | Function[] | undefined, ): boolean => { return hook ? isArray(hook) ? hook.some(h => h.length > 1) : hook.length > 1 : false }
/** * Check if a hook expects a callback (2nd arg), which means the user * intends to explicitly control the end of the transition. */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/components/Transition.ts#L111-L119
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
getStyleProperties
const getStyleProperties = (key: StylePropertiesKey) => (styles[key] || '').split(', ')
// JSDOM may return undefined for transition properties
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/components/Transition.ts#L410-L411
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
toMs
function toMs(s: string): number { // #8409 default value for CSS durations can be 'auto' if (s === 'auto') return 0 return Number(s.slice(0, -1).replace(',', '.')) * 1000 }
// Old versions of Chromium (below 61.0.3163.100) formats floating pointer
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/components/Transition.ts#L472-L476
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
decorate
const decorate = (t: typeof TransitionGroupImpl) => { // TransitionGroup does not support "mode" so we need to remove it from the // props declarations, but direct delete operation is considered a side effect delete t.props.mode if (__COMPAT__) { t.__isBuiltIn = true } return t }
/** * Wrap logic that modifies TransitionGroup properties in a function * so that it can be annotated as pure */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/components/TransitionGroup.ts#L46-L54
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
getValue
function getValue(el: HTMLOptionElement | HTMLInputElement) { return '_value' in el ? (el as any)._value : el.value }
// retrieve raw value set via :value bindings
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/directives/vModel.ts#L280-L282
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
getCheckboxValue
function getCheckboxValue( el: HTMLInputElement & { _trueValue?: any; _falseValue?: any }, checked: boolean, ) { const key = checked ? '_trueValue' : '_falseValue' return key in el ? el[key] : checked }
// retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-dom/src/directives/vModel.ts#L285-L291
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
mockElementWithStyle
function mockElementWithStyle() { const store: any = {} return { style: { display: '', WebkitTransition: '', setProperty(key: string, val: string) { store[key] = val }, getPropertyValue(key: string) { return store[key] ...
// JSDOM doesn't support custom properties on style object so we have to
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/__tests__/dom/prop.spec.ts#L156-L170
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
getSequence
function getSequence(arr: number[]): number[] { const p = arr.slice() const result = [0] let i, j, u, v, c const len = arr.length for (i = 0; i < len; i++) { const arrI = arr[i] if (arrI !== 0) { j = result[result.length - 1] if (arr[j] < arrI) { p[i] = j result.push(i) ...
// https://en.wikipedia.org/wiki/Longest_increasing_subsequence
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/apiCreateFor.ts#L392-L431
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
inferFromRegistry
const inferFromRegistry = (registry: Record<string, any> | undefined) => { for (const key in registry) { if (registry[key] === Component) { return key } } }
// try to infer the name based on reverse resolution
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/component.ts#L399-L405
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
validateProps
function validateProps( rawProps: NormalizedRawProps, props: Data, options: NormalizedProps, ) { const presentKeys: string[] = [] for (const props of rawProps) { presentKeys.push(...Object.keys(isFunction(props) ? props() : props)) } for (const key in options) { const opt = options[key] if (o...
/** * dev only */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/componentProps.ts#L336-L357
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
validateProp
function validateProp( name: string, value: unknown, option: PropOptions, props: Data, isAbsent: boolean, ) { const { required, validator } = option // required! if (required && isAbsent) { warn('Missing required prop: "' + name + '"') return } // missing but optional if (value == null && ...
/** * dev only */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/componentProps.ts#L362-L401
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
createDevtoolsComponentHook
function createDevtoolsComponentHook( hook: DevtoolsHooks, ): DevtoolsComponentHook { return (component: ComponentInternalInstance) => { emit( hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component, ) } }
/*! #__NO_SIDE_EFFECTS__ */
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/devtools.ts#L123-L135
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
flushJobs
function flushJobs() { if (__BENCHMARK__) performance.mark('flushJobs-start') isFlushPending = false isFlushing = true // Sort queue before flush. // This ensures that: // 1. Components are updated from parent to child. (because parent is always // created before the child so its render effect will ha...
// TODO: dev mode and checkRecursiveUpdates
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/scheduler.ts#L141-L175
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
findInsertionIndex
function findInsertionIndex(id: number) { // the start index should be `flushIndex + 1` let start = flushIndex + 1 let end = queue.length while (start < end) { const middle = (start + end) >>> 1 const middleJob = queue[middle] const middleJobId = getId(middleJob) if ( middleJobId < id || ...
// #2768
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/scheduler.ts#L189-L209
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
getValue
function getValue(el: HTMLOptionElement | HTMLInputElement) { const metadata = getMetadata(el) return (metadata && metadata[MetadataKind.prop].value) || el.value }
// retrieve raw value set via :value bindings
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/directives/vModel.ts#L216-L219
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
getCheckboxValue
function getCheckboxValue(el: HTMLInputElement, checked: boolean) { const metadata = getMetadata(el) const props = metadata && metadata[MetadataKind.prop] const key = checked ? 'true-value' : 'false-value' if (props && key in props) { return props[key] } if (el.hasAttribute(key)) { return el.getAttr...
// retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/directives/vModel.ts#L222-L233
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
shouldSetAsProp
function shouldSetAsProp( el: Element, key: string, value: unknown, isSVG: boolean, ) { if (isSVG) { // most keys must be set as attribute on svg elements to work // ...except innerHTML & textContent if (key === 'innerHTML' || key === 'textContent') { return true } // or native oncli...
// TODO copied from runtime-dom
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/dom/prop.ts#L219-L253
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
resolveAsset
function resolveAsset(type: AssetTypes, name: string, warnMissing = true) { const instance = currentInstance if (instance) { const Component = instance.type // explicit self name has highest priority if (type === COMPONENTS) { const selfName = getComponentName(Component) if ( selfNa...
// implementation
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/runtime-vapor/src/helpers/resolveAssets.ts#L35-L73
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
isRef
const isRef = (val: any): val is { value: unknown } => { return !!(val && val[ReactiveFlags.IS_REF] === true) }
// can't use isRef here since @vue/shared has no deps
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/shared/src/toDisplayString.ts#L16-L18
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
assertPolygon
async function assertPolygon(total: number) { expect( await page().evaluate( ([total]) => { const points = globalStats .map((stat, i) => { const point = valueToPoint(stat.value, i, total) return point.x + ',' + point.y }) .join(...
// assert the shape of the polygon is correct
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/vue/__tests__/e2e/svg.spec.ts#L22-L39
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
assertLabels
async function assertLabels(total: number) { const positions = await page().evaluate( ([total]) => { return globalStats.map((stat, i) => { const point = valueToPoint(+stat.value + 10, i, total) return [point.x, point.y] }) }, [total], ) for (let i = 0; i...
// assert the position of each label is correct
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/vue/__tests__/e2e/svg.spec.ts#L42-L59
da75dd9131958ff4fb0f9b592c99cd76c761e272
vue-vapor
github_2023
vuejs
typescript
assertStats
async function assertStats(expected: number[]) { const statsValue = await page().evaluate(() => { return globalStats.map(stat => +stat.value) }) expect(statsValue).toEqual(expected) }
// assert each value of stats is correct
https://github.com/vuejs/vue-vapor/blob/da75dd9131958ff4fb0f9b592c99cd76c761e272/packages/vue/__tests__/e2e/svg.spec.ts#L62-L67
da75dd9131958ff4fb0f9b592c99cd76c761e272
three-vue-tres
github_2023
hawk86104
typescript
echartsUpdateHandle
const echartsUpdateHandle = (dataset: any) => { if (chartFrame === ChartFrameEnum.ECHARTS) { if (vChartRef.value) { setOption(vChartRef.value, { dataset: dataset }) } } }
// eCharts 组件配合 vChart 库更新方式
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useChartDataFetch.hook.ts#L36-L42
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
newPondItemInterval
const newPondItemInterval = ( requestGlobalConfig: RequestGlobalConfigType, requestDataPondItem: ComputedRef<RequestDataPondItemType>, dataPondMapItem?: DataPondMapType[] ) => { if (!dataPondMapItem) return let fetchInterval: any = 0 clearInterval(fetchInterval) // 请求 const fetchFn = async () => { ...
// 创建单个数据项轮询接口
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useChartDataPondFetch.hook.ts#L21-L79
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
fetchFn
const fetchFn = async () => { try { const res = await customizeHttp(toRaw(requestDataPondItem.value.dataPondRequestConfig), toRaw(requestGlobalConfig)) if (res) { try { // 遍历更新回调函数 dataPondMapItem.forEach(item => { item.updateCallback(newFunctionHandle(res?.data, ...
// 请求
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useChartDataPondFetch.hook.ts#L32-L49
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
addGlobalDataInterface
const addGlobalDataInterface = ( targetComponent: CreateComponentType, useChartEditStore: ChartEditStoreType, updateCallback: (...args: any) => any ) => { const chartEditStore = useChartEditStore() const { requestDataPond } = chartEditStore.getRequestGlobalConfig // 组件对应的数据池 Id const requ...
// 新增全局接口
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useChartDataPondFetch.hook.ts#L86-L103
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
clearMittDataPondMap
const clearMittDataPondMap = () => { mittDataPondMap.clear() }
// 清除旧数据
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useChartDataPondFetch.hook.ts#L106-L108
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
initDataPond
const initDataPond = (useChartEditStore: ChartEditStoreType) => { const { requestGlobalConfig } = useChartEditStore() const chartEditStore = useChartEditStore() // 根据 mapId 查找对应的数据池配置 for (let pondKey of mittDataPondMap.keys()) { const requestDataPondItem = computed(() => { return requestG...
// 初始化数据池
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useChartDataPondFetch.hook.ts#L111-L123
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
generateFunc
function generateFunc(fnStr: string, e: any) { try { // npmPkgs 便于拷贝 echarts 示例时设置option 的formatter等相关内容 Function(` "use strict"; return ( async function(e, components, node_modules){ const {${Object.keys(npmPkgs).join()}} = node_modules; ${fnStr} } )`)()....
/** * 生成高级函数 * @param fnStr 用户方法体代码 * @param e 执行生命周期的动态组件实例 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/useLifeHandler.hook.ts#L65-L79
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
windowResize
const windowResize = () => { window.addEventListener('resize', resize) }
// * 改变窗口大小重新绘制
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/usePreviewScale.hook.ts#L53-L55
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
unWindowResize
const unWindowResize = () => { window.removeEventListener('resize', resize) }
// * 卸载监听
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/gHooks/usePreviewScale.hook.ts#L58-L60
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
windowResize
const windowResize = () => { window.addEventListener('resize', resize) }
// * 改变窗口大小重新绘制
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/hooks/usePreviewScale.hook.ts#L53-L55
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
unWindowResize
const unWindowResize = () => { window.removeEventListener('resize', resize) }
// * 卸载监听
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/hooks/usePreviewScale.hook.ts#L58-L60
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
useAddWheelHandle
const useAddWheelHandle = (removeEvent: Function) => { addEventListener( 'wheel', (e: any) => { if (window?.$KeyboardActive?.ctrl) { e.preventDefault() e.stopPropagation() removeEvent() const transform = previewRef.value?.style.transform const re...
// 监听鼠标滚轮 +ctrl 键
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/hooks/useScale.hook.ts#L17-L49
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
fetchComponent
const fetchComponent = (chartName: string, flag: FetchComFlagType) => { const module = flag === FetchComFlagType.VIEW ? indexModules : configModules for (const key in module) { const urlSplit = key.split('/') if (urlSplit[urlSplit.length - 2] === chartName) { return module[key] } } }
/** * * 获取组件 * @param {string} chartName 名称 * @param {FetchComFlagType} flag 标识 0为展示组件, 1为配置组件 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/index.ts#L60-L68
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
createFlyLine
function createFlyLine(radius, startAngle, endAngle, color) { const geometry = new BufferGeometry() //声明一个几何体对象BufferGeometry // ArcCurve创建圆弧曲线 const arc = new ArcCurve(0, 0, radius, startAngle, endAngle, false) //getSpacedPoints是基类Curve的方法,返回一个vector2对象作为元素组成的数组 const pointsArr = arc.getSpacedPoints(100) //...
/* * 绘制一条圆弧飞线 * 5个参数含义:( 飞线圆弧轨迹半径, 开始角度, 结束角度) */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L20-L74
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
flyArc
function flyArc(radius, lon1, lat1, lon2, lat2, options) { const sphereCoord1 = lon2xyz(radius, lon1, lat1) //经纬度坐标转球面坐标 // startSphereCoord:轨迹线起点球面坐标 const startSphereCoord = new Vector3(sphereCoord1.x, sphereCoord1.y, sphereCoord1.z) const sphereCoord2 = lon2xyz(radius, lon2, lat2) // startSphereCoord:轨迹线结束...
/**输入地球上任意两点的经纬度坐标,通过函数flyArc可以绘制一个飞线圆弧轨迹 * lon1,lat1:轨迹线起点经纬度坐标 * lon2,lat2:轨迹线结束点经纬度坐标 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L80-L94
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
_3Dto2D
function _3Dto2D(startSphere, endSphere) { /*计算第一次旋转的四元数:表示从一个平面如何旋转到另一个平面*/ const origin = new Vector3(0, 0, 0) //球心坐标 const startDir = startSphere.clone().sub(origin) //飞线起点与球心构成方向向量 const endDir = endSphere.clone().sub(origin) //飞线结束点与球心构成方向向量 // dir1和dir2构成一个三角形,.cross()叉乘计算该三角形法线normal const normal = s...
/* * 把3D球面上任意的两个飞线起点和结束点绕球心旋转到到XOY平面上, * 同时保持关于y轴对称,借助旋转得到的新起点和新结束点绘制 * 一个圆弧,最后把绘制的圆弧反向旋转到原来的起点和结束点即可 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L100-L141
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
arcXOY
function arcXOY(radius, startPoint, endPoint, options) { // 计算两点的中点 const middleV3 = new Vector3().addVectors(startPoint, endPoint).multiplyScalar(0.5) // 弦垂线的方向dir(弦的中点和圆心构成的向量) const dir = middleV3.clone().normalize() // 计算球面飞线的起点、结束点和球心构成夹角的弧度值 const earthRadianAngle = radianAOB(startPoint, endPoint, new...
/**通过函数arcXOY()可以在XOY平面上绘制一个关于y轴对称的圆弧曲线 * startPoint, endPoint:表示圆弧曲线的起点和结束点坐标值,起点和结束点关于y轴对称 * 同时在圆弧轨迹的基础上绘制一段飞线*/
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L145-L188
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
radianAOB
function radianAOB(A, B, O) { // dir1、dir2:球面上两个点和球心构成的方向向量 const dir1 = A.clone().sub(O).normalize() const dir2 = B.clone().sub(O).normalize() //点乘.dot()计算夹角余弦值 const cosAngle = dir1.clone().dot(dir2) const radianAngle = Math.acos(cosAngle) //余弦值转夹角弧度值,通过余弦值可以计算夹角范围是0~180度 return radianAngle }
/*计算球面上两点和球心构成夹角的弧度值 参数point1, point2:表示地球球面上两点坐标Vector3 计算A、B两点和顶点O构成的AOB夹角弧度值*/
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L192-L200
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
circleLine
function circleLine(x, y, r, startAngle, endAngle, color) { const geometry = new BufferGeometry() //声明一个几何体对象Geometry // ArcCurve创建圆弧曲线 const arc = new ArcCurve(x, y, r, startAngle, endAngle, false) //getSpacedPoints是基类Curve的方法,返回一个vector2对象作为元素组成的数组 const points = arc.getSpacedPoints(80) //分段数50,返回51个顶点 g...
/*绘制一条圆弧曲线模型Line 5个参数含义:(圆心横坐标, 圆心纵坐标, 飞线圆弧轨迹半径, 开始角度, 结束角度)*/
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L203-L215
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
threePointCenter
function threePointCenter(p1, p2, p3) { const L1 = p1.lengthSq() //p1到坐标原点距离的平方 const L2 = p2.lengthSq() const L3 = p3.lengthSq() const x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y, x3 = p3.x, y3 = p3.y const S = x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2 const x = (L2 * y3 ...
//求三个点的外接圆圆心,p1, p2, p3表示三个点的坐标Vector3。
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/Utils/arc.ts#L217-L233
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
Basic.initScenes
initScenes() { this.scene = new THREE.Scene() this.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 100000) this.camera.position.set(0, 30, -250) this.renderer = new THREE.WebGLRenderer({ // canvas: this.dom, alpha: true, // 透明 antialias: true, // 抗...
/** * 初始化场景 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Basic.ts#L25-L40
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
Basic.setControls
setControls() { // 鼠标控制 相机,渲染dom this.controls = new OrbitControls(this.camera, this.renderer.domElement) this.controls.autoRotateSpeed = 3 // 使动画循环使用时阻尼或自转 意思是否有惯性 this.controls.enableDamping = true // 动态阻尼系数 就是鼠标拖拽旋转灵敏度 this.controls.dampingFactor = 0.05 // 是否可以缩放 this.contro...
/** * 设置控制器 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Basic.ts#L45-L62
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
Resources.setLoadingManager
private setLoadingManager() { this.manager = new LoadingManager() // 开始加载 this.manager.onStart = () => { loadingStart() } // 加载完成 this.manager.onLoad = () => { this.callback() } // 正在进行中 this.manager.onProgress = url => { loadingFinish() } this.manager.onEr...
/** * 管理加载状态 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Resources.ts#L22-L41
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
Resources.loadResources
private loadResources(): void { this.textureLoader = new TextureLoader(this.manager) resources.textures?.forEach(item => { this.textureLoader.load(item.url, t => { this.textures[item.name] = t }) }) }
/** * 加载资源 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Resources.ts#L46-L53
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
World.render
public render() { requestAnimationFrame(this.render.bind(this)) this.renderer.render(this.scene, this.camera) this.controls && this.controls.update() this.earth && this.earth.render() }
/** * 渲染函数 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts#L77-L82
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
World.updateSize
public updateSize(width?: number, height?: number) { let w = width || this.option.width let h = height || this.option.height // 取小值 if (w < h) h = w else w = h this.renderer.setSize(w, h) this.camera.aspect = w / h this.camera.updateProjectionMatrix() }
// 更新
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts#L85-L95
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
World.updateData
public updateData(data?: any) { if (!this.earth.group) return // 先删除旧的 this.scene.remove(this.earth.group) // 递归遍历组对象group释放所有后代网格模型绑定几何体占用内存 this.earth.group.traverse((obj: any) => { if (obj.type === 'Mesh') { obj.geometry.dispose() obj.material.dispose() } }) //...
// 数据更新重新渲染
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/goView/lib/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts#L98-L111
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
Resource.constructor
constructor({ decoderPath = './draco/' } = {}) { this.decoderPath = decoderPath // this.setLoadingManager() this.items = {} }
// }
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/resourceManager/lib/Resource.ts#L39-L43
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
HeightCorrection.constructor
constructor(geometry?: BufferGeometry) { this.geometry = geometry; }
/** * @param geometry [BufferGeometry](https://threejs.org/docs/index.html?q=buffer#api/zh/core/BufferGeometry), * 在解码地形时会将地形顶点的高程匹配到几何体上。 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/HeightCorrection/HeightCorrection.ts#L18-L20
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
HeightCorrectionArea.constructor
constructor(path: number[][], height: number) { super(); console.log(path, height); }
/** * @param path GPS坐标点路径 * @param height 目标高程 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/HeightCorrection/HeightCorrectionArea.ts#L10-L13
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
HeightCrrectionPath.constructor
constructor(path: number[][], width: number) { super(); console.log(path, width); }
/** * @param path GPS坐标点路径 * @param width 路径扩展宽度 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/HeightCorrection/HeightCrrectionPath.ts#L11-L14
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
countElements
function countElements(ax: number, ay: number, bx: number, by: number, cx: number, cy: number) { const mx = (ax + bx) >> 1; const my = (ay + by) >> 1; if (Math.abs(ax - cx) + Math.abs(ay - cy) > 1 && errors[my * size + mx] > maxError) { countElements(cx, cy, ax, ay, ...
// retrieve mesh in two stages that both traverse the error map:
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/Martini.ts#L127-L140
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
MartiniTile.getMeshWithSkirts
getMeshWithSkirts(maxError = 0) { const { gridSize: size, indices } = this.martini; const { errors } = this; let numVertices = 0; let numTriangles = 0; const max = size - 1; let aIndex, bIndex, cIndex = 0; // Skirt indices let leftSkirtIndices: number[] = ...
// https://github.com/mapbox/martini/pull/12/commits/4677d0c5cfe446ccc96d3982ff4f442cddba5063
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/Martini.ts#L184-L357
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
countElements
function countElements(ax: number, ay: number, bx: number, by: number, cx: number, cy: number) { const mx = (ax + bx) >> 1; const my = (ay + by) >> 1; if (Math.abs(ax - cx) + Math.abs(ay - cy) > 1 && errors[my * size + mx] > maxError) { countElements(cx, cy, ax, ay, ...
// retrieve mesh in two stages that both traverse the error map:
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/Martini.ts#L202-L251
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
constructSkirt
function constructSkirt(skirt: number[]) { skirtLength = skirt.length; // Loop through indices in groups of two to generate triangles for (var i = 0; i < skirtLength - 1; i++) { currIndex = skirt[i]; nextIndex = skirt[i + 1]; currentSki...
// Add skirt vertices from index of last mesh vertex
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/Martini.ts#L326-L348
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
MartiniTileUtil.findAncestorTerrainData
static findAncestorTerrainData(tileNo: number[], maxZ: number) { const z = tileNo[2]; let terrain: Float32Array | undefined = undefined; let parentTileNo = tileNo; const maxClip = z >= maxZ ? z - maxZ : 5; for (let i = 0; i < maxClip; i++) { parentTileNo = getParent(p...
/** * 从缓存的地形里找到指定瓦片编号的祖先地形数据及其编号 * @param tileNo 瓦片编号 * @param maxZ 瓦片数据源所能提供的最大层级 * @returns 地形数据,及地形所对应的瓦片编号 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/MartiniTileUtil.ts#L30-L44
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
MartiniTileUtil.getTerrainData
static async getTerrainData(tileNo: number[], url: string, maxZ: number) { const id = tileNo.join('-'); const { baseSize } = this; const { terrain, tileNo: parentTileNo } = this.findAncestorTerrainData(tileNo, maxZ); if (terrain) { let clipTimes = tileNo[2] - parentTileNo[2]...
/** * 获取地形数据,根据情况从缓存读取祖先地形并切割,或直接从url获取地形图片并解码 * @param tileNo 瓦片编号 * @param url 瓦片下载地址 * @param maxZ 瓦片数据源所能提供的最大层级,大于此层级将从缓存切割瓦片而非下载 * @returns 地形数据,地形大小,及地形对应的bbox */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/MartiniTileUtil.ts#L53-L82
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
MartiniTileUtil.getTileGeometryAttributes
static async getTileGeometryAttributes(tileNo: number[], url: string, maxZ: number, coordType = MERC, utmZone?: number) { const { terrain, size, bbox } = await this.getTerrainData(tileNo, url, maxZ); const martini = this.getMartini(size); const martiniTile = martini.createTile(terrain); ...
/** * 根据瓦片编号获取模型数据 * @param tileNo 瓦片编号 * @param url 瓦片下载地址 * @param maxZ 瓦片数据源所能提供的最大层级 * @param coordType 坐标类型,默认 MERC * @param utmZone 当坐标类型为utm时的区号。 * @returns 几何体顶点、UV、顶点索引 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/MartiniTerrainProvider/MartiniTileUtil.ts#L93-L128
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
QuantizedMeshTerrainProvider.clip
clip(data: QuantizedMeshData, fromTileNo: number[], toTileNo: number[]): QuantizedMeshData { const fromBBox = tileToBBox(fromTileNo); const toBBox = tileToBBOX(toTileNo); const left = fromBBox[0] / toBBox[2] * vertexMaxPos; const right = fromBBox[2] / toBBox[2] * vertexMaxPos; co...
/** * 裁切地形数据 * @param data 量化网格地形数据 * @param fromTileNo 84瓦片坐标 * @param toTileNo 墨卡托瓦片坐标 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Providers/QuantizedMeshTerrainProvider/QuantizedMeshTerrainProvider.ts#L63-L81
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
TerrainUtil.getFromBitmap
static getFromBitmap(bitmap: ImageBitmap, size = 256) { if (!this.offscreencanvas) { this.offscreencanvas = new OffscreenCanvas(512, 512); } const ctx = this.offscreencanvas.getContext('2d'); if (!ctx) { throw new Error('Get context 2d error.'); } ...
/** * 从图片中解码地形数据 * @param bitmap 图像数据 * @param size 瓦片大小 * @returns 地形数据 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Utils/TerrainUtil.ts#L11-L40
918e54f5f6d262da3243a98b3dfc43430801bf1b
three-vue-tres
github_2023
hawk86104
typescript
TerrainUtil.clip
static clip(sourceTerrain: Float32Array, sourceSize: number, x: number, y: number, size: number) { if (x + size > sourceSize + 1 || y + size > sourceSize + 1) { console.log('clip: ', x, y, size); throw new RangeError('Clip terrain error'); } const gridSize = size...
/** * 从源地形数据中裁切出一部分 * @param sourceTerrain 源地形数据 * @param sourceSize 源地形大小 * @param x 裁切开始位置 x 坐标 * @param y 裁切开始位置 y 坐标 * @param size 裁切大小 * @returns 裁切后的地形数据 */
https://github.com/hawk86104/three-vue-tres/blob/918e54f5f6d262da3243a98b3dfc43430801bf1b/src/plugins/simpleGIS/lib/threeSatelliteMap/Utils/TerrainUtil.ts#L51-L66
918e54f5f6d262da3243a98b3dfc43430801bf1b
AiEditor
github_2023
aieditor-team
typescript
getCommandLineArgs
function getCommandLineArgs() { const args: Record<string, string | boolean> = {}; process.argv.slice(2).forEach((arg, index, array) => { if (arg.startsWith('--')) { const key = arg.slice(2); const value = array[index + 1] && !array[index + 1].startsWith('--') ? array[index + 1] ...
// 简单解析命令行参数 支持命令: npm run docs:dev -- --domain=http://localhost:3000
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/docs/.vitepress/config.ts#L24-L34
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
AbstractMenuButton.onClick
onClick(commands: ChainedCommands) { //do nothing }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/AbstractMenuButton.ts#L29-L31
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
AbstractMenuButton.onActive
onActive(editor: Editor): boolean { return false }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/AbstractMenuButton.ts#L49-L51
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Footer.onEditableChange
onEditableChange(editable: boolean) { }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/Footer.ts#L98-L99
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Attachment.onClick
onClick(commands) { if (this.options?.attachment?.customMenuInvoke) { this.options.attachment.customMenuInvoke((this.editor as InnerEditor).aiEditor); } else { this.fileInput?.click(); } }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Attachment.ts#L40-L46
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Bold.onClick
onClick(commands) { commands.toggleBold(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Bold.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Break.onClick
onClick(commands) { commands.setHardBreak(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Break.ts#L15-L17
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
BulletList.onClick
onClick(commands) { commands.toggleBulletList(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/BulletList.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Code.onClick
onClick(commands) { commands.toggleCode(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Code.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
CodeBlock.onClick
onClick(commands) { commands.toggleCodeBlock(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/CodeBlock.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Container.onClick
onClick(commands) { if (this.editor?.isActive("container")) { commands.unsetContainer() } else { commands.setContainer("") } commands.focus() }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Container.ts#L16-L23
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Eraser.onClick
onClick(commands) { commands.unsetAllMarks(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Eraser.ts#L15-L17
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Fullscreen.onClick
onClick(commands) { const container = this.closest(".aie-container") as HTMLDivElement; if (!this.isFullscreen) { container.style.height = "calc(100vh - 2px)"; container.style.width = "calc(100% - 2px)"; container.style.position = "fixed"; container.style....
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Fullscreen.ts#L21-L46
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Hr.onClick
onClick(commands) { commands.setHorizontalRule(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Hr.ts#L15-L17
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Image.onClick
onClick(commands) { if (this.options?.image?.customMenuInvoke) { setTimeout(() => { this.options!.image!.customMenuInvoke!((this.editor as InnerEditor).aiEditor); }) } else { this.fileInput?.click(); } }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Image.ts#L40-L48
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
IndentDecrease.onClick
onClick(commands) { commands.outdent(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/IndentDecrease.ts#L15-L17
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
IndentIncrease.onClick
onClick(commands) { commands.indent(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/IndentIncrease.ts#L15-L17
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Italic.onClick
onClick(commands) { commands.toggleItalic(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Italic.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
OrderedList.onClick
onClick(commands) { commands.toggleOrderedList(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/OrderedList.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Painter.onClick
onClick(commands) { commands.setPainter(this.editor?.state.selection.$head.marks()) }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Painter.ts#L12-L14
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Printer.onClick
onClick(commands) { let html = this.closest(".aie-container")!.querySelector(".aie-content")!.innerHTML; html = `<div class="aie-container" style="border: none;padding: 0;margin: 0"><div class="aie-content" style="border: none;height: auto;overflow: visible">${html}</div></div>` const style :s...
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Printer.ts#L15-L61
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Quote.onClick
onClick(commands) { commands.toggleBlockquote(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Quote.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Redo.onClick
onClick(commands) { commands.redo(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Redo.ts#L15-L17
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Strike.onClick
onClick(commands) { commands.toggleStrike(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Strike.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Subscript.onClick
onClick(commands) { commands.toggleSubscript(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Subscript.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0
AiEditor
github_2023
aieditor-team
typescript
Superscript.onClick
onClick(commands) { commands.toggleSuperscript(); }
// @ts-ignore
https://github.com/aieditor-team/AiEditor/blob/3ee22e6953a0dad22c3415c9f145f682aa354ef0/src/components/menus/Superscript.ts#L16-L18
3ee22e6953a0dad22c3415c9f145f682aa354ef0