当前位置: 首页 > news >正文

php 网站配置丛台企业做网站推广

php 网站配置,丛台企业做网站推广,wordpress怎么seo好,福建百度推广开户HBuilderx 插件开发变量名称翻译 #xff0c;中文转#xff08;小驼峰#xff0c;大驼峰#xff0c;下划线#xff0c;常量#xff0c;CSS类名#xff09; 插件开发文档 工具HBuilderx #xff0c;创建项目 创建成功后目录 插件需求 开发时 用来将中文转为#xff0…HBuilderx 插件开发变量名称翻译 中文转小驼峰大驼峰下划线常量CSS类名 插件开发文档 工具HBuilderx 创建项目 创建成功后目录 插件需求 开发时 用来将中文转为小驼峰大驼峰下划线常量CSS类名 package.json 文件中配置插件菜单通过在插件package.json文件中contributes节点下定义的一些JSON格式的配置项。注意配置时一定要注意json格式 {id: plugin-fyi,name: fyi,description: plugin-fyi,displayName: plugin-fyi,version: 0.0.0,publisher: your name,engines: {HBuilderX: ^2.7.0},categories: [Other],main: ./extension,activationEvents: [*],contributes: {commands: [{command: fyi.smallHump,title: 小驼峰},{command: fyi.bigHump,title: 大驼峰},{command: fyi.underline,title: 下划线},{command: fyi.constant,title: 常量},{command: fyi.cssClassName,title: CSS类名}],menus: {editor/context: [{group: z_commands}, {title: 小驼峰,command: fyi.smallHump,group: z_commands},{title: 大驼峰,command: fyi.bigHump,group: z_commands},{title: 下划线,command: fyi.underline,group: z_commands},{title: 常量,command: fyi.constant,group: z_commands},{title: CSS类名,command: fyi.cssClassName,group: z_commands},{group: z_commands}]},extensionDependencies: [plugin-manager]},dependencies: {axios: ^1.7.9,js-md5: ^0.8.3} }运行插件 运行成功 会打开新的编辑器 打开一个项目 或者新建一个项目 我这里是打开一个项目然后右键查看 中文翻译需要用到 百度翻译 百度翻译开放平台 申请秘钥 APPID 和 密钥 开始添加逻辑处理 新建js文件夹 用来处理 翻译 转换的逻辑 extension.js 文件 该文件为主文件 需要与 package.json 中的 main 保持一致 const hx require(hbuilderx);const commands require(./js/index)//该方法将在插件激活的时候调用function activate(context) {for (const c of commands) {//订阅销毁钩子插件禁用的时候自动注销该command。context.subscriptions.push(c);}}//该方法将在插件禁用的时候调用目前是在插件卸载的时候触发function deactivate() {}module.exports {activate,deactivate}调用百度翻译需要用到 axios 和 MD5.js 安装 npm install axios npm install js-md5 util.js 调用百度api 翻译 *******请更换代码中的 appid 和密钥******** const axios require(axios); const hx require(hbuilderx); const md5 require(js-md5);// 封装百度翻译 API 请求函数 module.exports async function (text) {try {// 在状态栏显示正在转换的消息hx.window.setStatusBarMessage(正在转换...);// 百度翻译 API 的配置信息const appid 你上面申请的appid;const secretKey 你上面申请的密钥;// 生成随机数 saltconst salt Math.floor(Math.random() * (65536 - 32768 1)) 32768;// 拼接用于生成签名的字符串const signStr appid text salt secretKey;// 计算 MD5 哈希值作为签名const sign md5(signStr);// 发送请求到百度翻译 APIconst response await axios({method: post,url: http://api.fanyi.baidu.com/api/trans/vip/translate,data: {q: text,from: auto,to: en,appid: appid,salt: salt,sign: sign},headers: { Content-Type: application/x-www-form-urlencoded; charsetUTF-8 }});const data response.data;// 检查响应数据是否包含必要的字段if (data.from data.to data.trans_result) {// 解析出翻译结果return data.trans_result[0].dst;} else {// 处理识别失败的情况const errorMessage 识别失败错误码: ${data.error_code};hx.window.showErrorMessage(errorMessage);return {msg: 识别失败,code: data.error_code};}} catch (error) {// 处理请求过程中可能出现的错误const errorMessage 请求翻译 API 时发生错误: ${error.message};hx.window.showErrorMessage(errorMessage);console.error(errorMessage, error);return {msg: 请求翻译 API 时发生错误,code: -1};} finally {// 清除状态栏的消息hx.window.clearStatusBarMessage();} };index.js 转换方法文件 const hx require(hbuilderx); const util require(./util);// 定义字符串转换类型的映射对象 const conversionFunctions {1: toCamelCase,2: toPascalCase,3: toSnakeCase,4: toConstantCase,5: toCssClassName };// 注册命令的函数 function registerCommand(method, type) {return hx.commands.registerCommand(method, async () {try {// 获取当前活动的文本编辑器const activeEditor await hx.window.getActiveTextEditor();if (!activeEditor) {return;}const editor await activeEditor;const selections editor.selections;// 遍历每个选中区域for (const selection of selections) {const selectText editor.document.getText(selection);let text await util(selectText);// 根据类型获取对应的转换函数const convertFunction conversionFunctions[type] || toCamelCase;const str convertFunction(text);// 替换选中区域的文本editor.edit(editBuilder editBuilder.replace(selection, str));}} catch (error) {console.error(执行命令时发生错误:, error);}}); }// 小驼峰转换函数 function toCamelCase(str) {const words str.split( );return words.map((word, index) {if (index 0) {return word.toLowerCase();}return word.charAt(0).toUpperCase() word.slice(1).toLowerCase();}).join(); }// 大驼峰转换函数 function toPascalCase(str) {return str.split( ).map(word {return word.charAt(0).toUpperCase() word.slice(1).toLowerCase();}).join(); }// 下划线转换函数 function toSnakeCase(str) {return str.replace(/\s/g, _).toLowerCase(); }// 常量转换函数 function toConstantCase(str) {return str.replace(/\s/g, _).toUpperCase(); }// CSS类名转换函数 function toCssClassName(str) {return str.toLowerCase().replace(/\s/g, -); }// 注册各个命令 const smallHump registerCommand(fyi.smallHump, 1); const bigHump registerCommand(fyi.bigHump, 2); const underline registerCommand(fyi.underline, 3); const constant registerCommand(fyi.constant, 4); const cssClassName registerCommand(fyi.cssClassName, 5);// 导出注册的命令 module.exports [smallHump,bigHump,underline,constant,cssClassName ];至此 全部开发结束。重新运行插件 测试正常开发结束。 优化 菜单合并 package.json {id: plugin-fyi,name: fyi,description: plugin-fyi,displayName: plugin-fyi,version: 0.0.0,publisher: your name,engines: {HBuilderX: ^2.7.0},categories: [Other],main: ./extension,activationEvents: [*],contributes: {commands: [{command: fyi.smallHump,title: 小驼峰},{command: fyi.bigHump,title: 大驼峰},{command: fyi.underline,title: 下划线},{command: fyi.constant,title: 常量},{command: fyi.cssClassName,title: CSS类名}],menus: {editor/context: [{id: fyi,title: 來啊快樂啊,group: assist},{title: 小驼峰,command: fyi.smallHump,group: fyi1},{title: 大驼峰,command: fyi.bigHump,group: fyi2},{title: 下划线,command: fyi.underline,group: fyi3},{title: 常量,command: fyi.constant,group: fyi4},{title: CSS类名,command: fyi.cssClassName,group: fyi5}]},extensionDependencies: [plugin-manager]},dependencies: {axios: ^1.7.9,js-md5: ^0.8.3} }配置快捷键 点击工具 ----自定义快捷键 添加代码 保存 快捷键使用正常。 完结。
http://www.sczhlp.com/news/240761/

相关文章:

  • 建设银行查余额网站怎么用域名进网站
  • 建设外贸网站价格广州一共13个区
  • MATLAB实现直流电法和大地电磁法的一维正演计算
  • 2025年10月上海装修公司推荐榜:五家口碑排行深度解析
  • 记一次 Kubebuilder Operator 开发中的 CRD 注解超限问题
  • 2025年10月上海装修公司榜单:五家口碑对比排行
  • (三)从分层架构到数据湖仓架构系列:数据仓库分层之贴源层和数据仓库层设计
  • 网站快速收录教程我的个人主页怎么制作
  • 联系客户做网站网站建设合同印花税
  • 做标书要不要做网站网站备案 个人 单位
  • asp网站 seowordpress个人展示网站6
  • 做百度手机网站优化h5网站制作介绍
  • 传奇怎么做充值网站深圳专业o2o网站设计公司
  • 网站开发基于什么平台台江网站建设
  • 江阴网站制作南京市公共建设管理中心网站
  • 网站备案程序做网站app需多少钱
  • 娄底本地做寄生虫网站城市建设理论研究官方网站
  • 南京做网站优化的公司自已创建网站要怎么做
  • 网站制作公司茂名网站备案代理公司
  • 价目表海报app制作乐山网站seo
  • 网站内链代码网站开发接单
  • 2025 年地漏厂家最新推荐榜:涵盖铜 / 防臭 / 抗菌 / 磁悬浮 / 防溢水等类型,精选实力企业助力消费者精准选购
  • 2025年10月网上兼职赚钱正规平台推荐:知名平台榜单全收录
  • 2025年定制啤酒设备制造厂权威推荐:德国啤酒生产设备定制厂家/德国精酿设备厂家供应商/啤酒设备企业/啤酒厂设备优质厂家精选
  • 2025年10月网上兼职赚钱正规平台推荐:市场报告与对比列表
  • 网站模块化怎么制作网站模板
  • 校园网站建设目标哈尔滨刚刚发生的大事件
  • asp.net 网站截图建设工程施工合同法条
  • 门户网站标题居中加大企业推广平台排行榜
  • 百度云服务器挂网站在线文库网站建设