Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MingSnake_241120
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
MingSnake_241120
Commits
a7fd731e
Commit
a7fd731e
authored
Dec 30, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
886605a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
54 deletions
+78
-54
RulePanel.ts
assets/Scripts/Panels/RulePanel.ts
+64
-41
coop_frontVariable.query.json
preview-template/mock/coop_frontVariable.query.json
+14
-13
No files found.
assets/Scripts/Panels/RulePanel.ts
View file @
a7fd731e
import
Panel
from
"../../Module/Panel"
;
import
{
_decorator
,
Button
,
RichText
,
UITransform
,
Node
,
Sprite
,
Texture2D
,
ImageAsset
,
SpriteFram
e
}
from
"cc"
;
import
{
_decorator
,
Button
,
game
,
Nod
e
}
from
"cc"
;
import
store
from
"../store/store"
;
import
{
observer
,
render
}
from
"../store/decorators"
;
const
{
ccclass
,
property
}
=
_decorator
;
import
{
HTMLRichText
}
from
"../../Component/HTMLRichText/HTMLRichText"
;
import
{
WebNetName
,
sendWebNet
}
from
"../Utils/WebNet/WebNet"
;
@
observer
@
ccclass
(
'RulePanel'
)
@
ccclass
(
"RulePanel"
)
export
default
class
RulePanel
extends
Panel
{
static
bundle
=
"RulePanel"
;
static
skin
=
"RulePanel"
;
static
bundle
=
"RulePanel"
;
static
skin
=
"RulePanel"
;
@
property
(
Node
)
closeBtn
:
Node
=
null
;
@
property
(
Node
)
ruleNode
:
Node
=
null
;
@
property
(
Node
)
content
:
Node
=
null
;
dom
:
HTMLDivElement
;
async
onLoad
()
{
await
store
.
updateRule
();
this
.
closeBtn
.
on
(
Button
.
EventType
.
CLICK
,
this
.
clickClose
);
}
@
property
(
Node
)
closeBtn
:
Node
=
null
;
@
property
(
Node
)
ruleNode
:
Node
=
null
;
@
property
(
Node
)
content
:
Node
=
null
;
@
render
render
()
{
// const { success, data } = await sendWebNet(WebNetName.projectRule)
;
// if (!success) return
async
onLoad
()
{
await
store
.
updateRule
()
this
.
closeBtn
.
on
(
Button
.
EventType
.
CLICK
,
this
.
clickClose
);
}
this
.
setRuleTxt
(
store
.
ruleInfo
);
}
@
render
render
()
{
// const { success, data } = await sendWebNet(WebNetName.projectRule
);
// if (!success) return
clickClose
=
()
=>
{
this
.
hidePanel
();
this
.
dom
&&
this
.
dom
.
remove
(
);
};
this
.
setRuleTxt
(
store
.
ruleInfo
);
}
setRuleTxt
(
txt
:
string
)
{
clickClose
=
()
=>
{
this
.
hidePanel
(
);
}
if
(
!
this
.
dom
)
{
this
.
dom
=
document
.
createElement
(
"div"
);
}
setRuleTxt
(
txt
:
string
)
{
this
.
dom
.
innerHTML
=
`
<div
class="poster"
style="
width: 8.35rem;
height: 4.55rem;
position: absolute;
left: 3.995rem;
top: 2rem;
overflow: auto;
">
<img
src="
${
store
.
frontVariable
.
ruleImg
}
"
style="width: 100%;"
>
</div>
`
;
// const ruleNode = this.view['ScrollView/view/content/ruleTxt'];
const
ruleTxt
=
this
.
ruleNode
.
getComponent
(
RichText
);
// const content = this.view['ScrollView/view/content'];
ruleTxt
.
maxWidth
=
this
.
content
.
getComponent
(
UITransform
).
width
;
game
.
container
.
appendChild
(
this
.
dom
);
this
.
scheduleOnce
(()
=>
{
ruleTxt
.
string
=
txt
.
replace
(
/<p
\b
.*
?(?:\>
|
\/
>
)
/gi
,
""
).
replace
(
/<
\/
p
\>
/gi
,
"<br/>"
);
this
.
content
.
getComponent
(
UITransform
).
height
=
this
.
ruleNode
.
getComponent
(
UITransform
).
height
;
},
0.5
);
// const ruleNode = this.view['ScrollView/view/content/ruleTxt'];
// const ruleTxt = this.ruleNode.getComponent(RichText);
// // const content = this.view['ScrollView/view/content'];
// ruleTxt.maxWidth = this.content.getComponent(UITransform).width;
//
// this.scheduleOnce(() => {
// ruleTxt.string = txt.replace(/<p\b.*?(?:\>|\/>)/gi, "").replace(/<\/p\>/gi, "<br/>");
// this.content.getComponent(UITransform).height = this.ruleNode.getComponent(UITransform).height;
// }, 0.5);
// this.spNode.getComponent(HTMLRichText).html = txt;
// this.spNode.getComponent(HTMLRichText).html = txt;
// this.spNode.once(HTMLRichText.EventType.AFTER_RENDER, () => {
// this.spNode.once(HTMLRichText.EventType.AFTER_RENDER, () => {
// const { width: pw, height: ph } = this.spNode.getComponent(UITransform);
// const { width: pw, height: ph } = this.spNode.getComponent(UITransform);
// const width = this.spNode.parent.getComponent(UITransform).width;
// const width = this.spNode.parent.getComponent(UITransform).width;
// const height = ph * width / pw;
// const height = ph * width / pw;
// this.spNode.getComponent(UITransform).setContentSize(width, height);
// this.spNode.getComponent(UITransform).setContentSize(width, height);
// });
}
// });
}
}
preview-template/mock/coop_frontVariable.query.json
View file @
a7fd731e
{
"success"
:
true
,
"message"
:
null
,
"code"
:
null
,
"timeStamp"
:
1703644343317
,
"data"
:
{
"shareInfo"
:
{
"title"
:
"分享标题"
,
"content"
:
"分享描述"
,
"thumbnail"
:
"https://yun.duiba.com.cn/polaris/share.dbc0a949487ba41cacc4dca4fb6254238f223a61.png"
},
"loginUrl"
:
"https://activity.m.duiba.com.cn/customShare/share?id=Did1NTg5NTE"
,
"type"
:
"1"
}
"success"
:
true
,
"message"
:
null
,
"code"
:
null
,
"timeStamp"
:
1703644343317
,
"data"
:
{
"shareInfo"
:
{
"title"
:
"分享标题"
,
"content"
:
"分享描述"
,
"thumbnail"
:
"https://yun.duiba.com.cn/polaris/share.dbc0a949487ba41cacc4dca4fb6254238f223a61.png"
},
"loginUrl"
:
"https://activity.m.duiba.com.cn/customShare/share?id=Did1NTg5NTE"
,
"type"
:
"1"
,
"ruleImg"
:
"//yun.duiba.com.cn/polaris/%E6%B4%BB%E5%8A%A8%E8%A7%84%E5%88%99%E9%A1%B5-%E9%9B%B6%E9%A3%9F%E8%B4%AA%E5%90%83%E8%9B%87-%E5%BE%88%E5%BF%99%E7%89%88%E6%9C%AC@1x.dc2bdc490918f1fb831c6c28fab824e1ed192888.png"
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment