添加到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 :部分,它解析并添加,但当然,构建失败。
我遇到了与插件方法相同的Visual Studio解析问题。我能够通过1)注释''块,2)安装插件,3)取消注释''块,4)删除并重新安装插件。诀窍是在整个过程中保持插件/自定义选项卡的显示。我还必须删除平台/ Windows文件夹并重建应用程序。 –