2016-04-21 49 views
1

我创建从我的HTML/JS代码与此科尔多瓦,配置一个科尔多瓦应用程序平铺标题:科尔多瓦 - 如何获得在Windows Mobile

<?xml version='1.0' encoding='utf-8'?> 
<widget id="myapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name>My App</name> 
    <description> 
     A small demo app 
    </description> 
    <author email="[email protected]" href="http://anyth.ing"> 
     My App 
    </author> 
    <content src="index.html" /> 
    <plugin name="cordova-plugin-splashscreen" spec="3.2.0"/> 
    <access origin="*" /> 
    <preference name="Fullscreen" value="true"/> 
    <platform name="windows"> 
     <!-- splashs and icons --> 

    </platform> 
</widget> 

但是,当我的应用程序部署到我的手机devide (Windows 10移动版)启动屏幕上的图块不显示标题。应用程序列表中的应用程序本身有一个标题,但不包含图块。

如何在起始屏幕拼贴中获得拼贴图标题?

问候

Tenoda

回答

3

据我所看到的,科尔多瓦不提供添加Windows瓦称号的偏好。你会假设科尔多瓦只需要在config.xml中的名称名称元素中使用,并将其用于主屏幕拼贴。

为了获得起始画面拼贴中的标题,您需要编辑位于platform/windows目录下的package.windows10.appxmanifest。

添加UAP在以下:DefaultTile元素使得它为我工作:

<uap:ShowNameOnTiles> 
    <uap:ShowOn Tile="square310x310Logo" /> 
    <uap:ShowOn Tile="square150x150Logo" /> 
    <uap:ShowOn Tile="wide310x150Logo" /> 
</uap:DefaultTile> 

:添加所需的标题在SHORTNAME属性的元素UAP:DefaultTile

0

添加到Evertson的回答是:

为了避免继续编辑平台/ windows文件,你可以复制package.windows10.appxmanifest到RES /本地/ windows文件夹。该代码应该是这样的:

<uap:DefaultTile ShortName="..." Square310x310Logo="..." etc.> 
    <uap:ShowNameOnTiles> 
     <uap:ShowOn Tile="square310x310Logo" /> 
     <uap:ShowOn Tile="square150x150Logo" /> 
     <uap:ShowOn Tile="wide310x150Logo" /> 
    </uap:ShowNameOnTiles> 
</uap:DefaultTile> 

当然,这意味着你需要编辑清单您做出配置更改的任何时间。

有趣的是,默认情况下,旧的Windows 8.1清单(package.windows.appxmanifest)和Windows 8.1电话清单(package.phone.appxmanifestfile)确实已包含此信息。

:不知道为什么,这是针对Windows 10

编辑

您可以创建一个钩插入XML,所以你不必担心将更改应用到config.xml中移除添加以下内容:hooks/showNameOnTiles.js

module.exports = function (context) { 
    "use strict"; 
    var fs = require('fs'), 
     path = context.opts.projectRoot + '/platforms/windows/package.windows10.appxmanifest', 
     manifest = fs.readFileSync(path).toString(), 
     lines, i, lineNo; 
    if (!manifest.includes('uap:ShowNameOnTiles')) { 
     lines = manifest.split(/\r?\n/); 
     for (i = 0; i < lines.length; i++) { 
      if (lines[i].indexOf('uap:DefaultTile') !== -1) { 
       lineNo = i; 
       break; 
      } 
     } 
     if (lineNo) { 
      lines[lineNo] = lines[lineNo].replace('/>', '>').replace(' >', '>'); 
      lines.splice(lineNo + 1, 0, [ 
       '<uap:ShowNameOnTiles>', 
        '<uap:ShowOn Tile="square310x310Logo" />', 
        '<uap:ShowOn Tile="square150x150Logo" />', 
        '<uap:ShowOn Tile="wide310x150Logo" />', 
       '</uap:ShowNameOnTiles>' 
      ].join('\n')); 
      lines.splice(lineNo + 2, 0, '</uap:DefaultTile>'); 
      fs.writeFileSync(path, lines.join('\n')); 
     } 
    } 
}; 

In config。XML,添加:

<platform name="windows"> 
    <hook type="after_prepare" src="hooks/showNameOnTiles.js" /> 
</platform> 

更简单的方法

有一种简单的方法来做到这一点,但我无法得到它的工作;你可以创建自己的插件:

<?xml version="1.0" encoding="UTF-8"?> 
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" 
    id="com.blah.addtiletitleplugin" version="1.0.0"> 
    <name>Adds the title to windows 10 tiles</name> 
    <description>Adds the title to windows 10 tiles</description> 
    <platform name="windows"> 
    <config-file target="package.windows10.appxmanifest" parent="/Package/Applications/Application/uap:VisualElements/uap:DefaultTile/"> 
     <uap:ShowNameOnTiles> 
     <uap:ShowOn Tile="square310x310Logo" /> 
     <uap:ShowOn Tile="square150x150Logo" /> 
     <uap:ShowOn Tile="wide310x150Logo" /> 
     </uap:ShowNameOnTiles> 
    </config-file> 
    </platform> 
</plugin> 

然而,当我尝试添加插件,视觉工作室拒绝解析它即使我指定:

xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" 

如果我删除UAP :部分,它解析并添加,但当然,构建失败。

+1

我遇到了与插件方法相同的Visual Studio解析问题。我能够通过1)注释''块,2)安装插件,3)取消注释''块,4)删除并重新安装插件。诀窍是在整个过程中保持插件/自定义选项卡的显示。我还必须删除平台/ Windows文件夹并重建应用程序。 –